Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f286960bed | |||
| a8a090c671 | |||
| 24e2a905d2 | |||
| 19c2500263 | |||
| 909c74b734 | |||
| 0ea988fcea | |||
| db5eb85794 |
@@ -1,10 +1,19 @@
|
|||||||
import React from "react";
|
import React, { Suspense, lazy, useState } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
import VideoElement from '../../components/VideoCom/VideoElement'
|
||||||
|
import OfferJobPopout from '../../components/jobPopout/OfferJobPopout'
|
||||||
|
import { PriceFormatter } from "../Helpers/PriceFormatter";
|
||||||
|
import CountDown from '../Helpers/CountDown'
|
||||||
|
|
||||||
|
const AccountDashboard = ({ className, bannerList, offersList, imageServer }) => {
|
||||||
|
|
||||||
|
let [offerPopout, setOfferPopout] = useState({ show: false, data: {} }); // STATE TO HOLD THE VALUE OF THE ALERT DETAILS AND DETERMINE WHEN TO SHOW
|
||||||
|
|
||||||
|
let offersListLength = offersList?.length
|
||||||
|
|
||||||
const AccountDashboard = ({ className, bannerList }) => {
|
|
||||||
// getting the upper three banners for the home layout
|
// getting the upper three banners for the home layout
|
||||||
const getUpperBanner = bannerList?.filter((value, idx) => idx <= 2);
|
const getUpperBanner = bannerList?.filter((value, idx) => idx <= 2 - offersListLength);
|
||||||
const getLowerBanner = bannerList?.filter((value, idx) => idx > 2);
|
const getLowerBanner = bannerList?.filter((value, idx) => !getUpperBanner?.map(item => item?.title)?.includes(value.title));
|
||||||
|
|
||||||
let getImage = ({ banner_location, banner }) => {
|
let getImage = ({ banner_location, banner }) => {
|
||||||
if (banner_location == "LOCAL") {
|
if (banner_location == "LOCAL") {
|
||||||
@@ -15,54 +24,89 @@ const AccountDashboard = ({ className, bannerList }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<>
|
||||||
className={`w-full min-h-[450px] flex flex-col justify-between items-center gap-4 rounded-2xl overflow-hidden ${
|
<div
|
||||||
className || ""
|
className={`w-full min-h-[450px] flex flex-col justify-between items-center gap-4 rounded-2xl overflow-hidden ${
|
||||||
}`}
|
className || ""
|
||||||
>
|
}`}
|
||||||
<div className="w-full grid xxs:grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 items-center justify-center gap-2 md:gap-4">
|
>
|
||||||
{getUpperBanner?.map((props, idx) => {
|
|
||||||
let image = getImage(props);
|
|
||||||
|
|
||||||
let { short_title, short_description, short_button_text, link_path, card_type, blog_id } =
|
<div className="w-full grid xxs:grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 items-center justify-center gap-2 md:gap-4">
|
||||||
props;
|
|
||||||
|
|
||||||
return (
|
{/* OFFER LIST DISPLAY */}
|
||||||
<div key={idx}>
|
<>
|
||||||
<TopBanner
|
{(offersList && offersList?.length > 0) &&
|
||||||
btn={short_button_text}
|
offersList.map((item, index) => {
|
||||||
image={image}
|
let thePrice = PriceFormatter(
|
||||||
title={short_title}
|
item?.price * 0.01,
|
||||||
desc={short_description}
|
item?.currency_code,
|
||||||
link_path={card_type=='BLOG' ? `${link_path}?blog_id=${blog_id}` : link_path}
|
item?.currency
|
||||||
/>
|
);
|
||||||
</div>
|
|
||||||
);
|
let image = `${imageServer}${localStorage.getItem("session_token")}/job/${item.job_uid}`
|
||||||
})}
|
return (
|
||||||
|
<div key={item.id}>
|
||||||
|
<NewOfferCard datas={item} image={image} price={thePrice} setOfferPopout={setOfferPopout} />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
|
||||||
|
{getUpperBanner?.map((props, idx) => {
|
||||||
|
let image = getImage(props);
|
||||||
|
|
||||||
|
let { short_title, short_description, short_button_text, link_path, card_type, blog_id } =
|
||||||
|
props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div key={idx}>
|
||||||
|
<TopBanner
|
||||||
|
btn={short_button_text}
|
||||||
|
image={image}
|
||||||
|
title={short_title}
|
||||||
|
desc={short_description}
|
||||||
|
link_path={card_type=='BLOG' ? `${link_path}?blog_id=${blog_id}` : link_path}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
<div className="w-full grid-cols-1 md:grid-cols-2 2xl::grid-cols-3 grid items-center justify-center gap-2 md:gap-4">
|
||||||
|
{getLowerBanner?.map((props, idx) => {
|
||||||
|
let image = getImage(props);
|
||||||
|
|
||||||
|
let { short_title, short_description, short_button_text, link_path, card_type, blog_id } =
|
||||||
|
props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div key={idx}>
|
||||||
|
<LowerBanner
|
||||||
|
btn={short_button_text}
|
||||||
|
image={image}
|
||||||
|
title={short_title}
|
||||||
|
desc={short_description}
|
||||||
|
link_path={link_path}
|
||||||
|
card_type={card_type}
|
||||||
|
blog_id={blog_id}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full grid-cols-1 md:grid-cols-2 2xl::grid-cols-3 grid items-center justify-center gap-2 md:gap-4">
|
|
||||||
{getLowerBanner?.map((props, idx) => {
|
|
||||||
let image = getImage(props);
|
|
||||||
|
|
||||||
let { short_title, short_description, short_button_text, link_path, card_type, blog_id } =
|
{/* Offer Job Popout */}
|
||||||
props;
|
{offerPopout.show && (
|
||||||
|
<OfferJobPopout
|
||||||
return (
|
details={offerPopout.data}
|
||||||
<div key={idx}>
|
onClose={() => {
|
||||||
<LowerBanner
|
setOfferPopout({ show: false, data: {} });
|
||||||
btn={short_button_text}
|
}}
|
||||||
image={image}
|
situation={offerPopout.show}
|
||||||
title={short_title}
|
/>
|
||||||
desc={short_description}
|
)}
|
||||||
link_path={link_path}
|
{/* End of Offer Job Popout */}
|
||||||
card_type={card_type}
|
</>
|
||||||
blog_id={blog_id}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -103,6 +147,64 @@ const TopBanner = ({ image, title = "", desc = "", btn, link_path, key }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const NewOfferCard = ({ datas, hidden = false, price, setOfferPopout, image }) => {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col shadow-md bg-red-50 dark:bg-dark-white rounded-xl dark:border-[#5356fb29] overflow-hidden">
|
||||||
|
<div className="h-[12rem] bg-transparent">
|
||||||
|
{/* thumbnail image/video */}
|
||||||
|
{datas.job_type == "MEDIA" ?
|
||||||
|
<Suspense fallback={<p>Loading...</p>}>
|
||||||
|
<VideoElement videoId={datas?.media_uid} />
|
||||||
|
</Suspense>
|
||||||
|
:
|
||||||
|
<div
|
||||||
|
className="thumbnail w-full h-full rounded-xl overflow-hidden px-4 pt-4"
|
||||||
|
style={{
|
||||||
|
background: `url(${image}) center / contain no-repeat`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{hidden && <div className="flex justify-center"></div>}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div className="rounded-b-xl bg-transparent dark:bg-dark-transparent">
|
||||||
|
<div className="border-b border-slate-300 px-2 py-1 h-[5.4rem] flex flex-col gap-2 dark:text-white">
|
||||||
|
<h1 className="font-bold text-lg line-clamp-1 text-center">
|
||||||
|
{datas?.title}
|
||||||
|
</h1>
|
||||||
|
{/* <Link to={link_path} className="text-sm">
|
||||||
|
{desc}
|
||||||
|
</Link> */}
|
||||||
|
<div className="card-buttons flex justify-center items-center space-x-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() =>
|
||||||
|
setOfferPopout({ show: true, data: { ...datas, price, image } })
|
||||||
|
}
|
||||||
|
className="btn-shine w-2/3 h-[40px] text-white rounded-full text-sm bg-pink flex justify-center items-center"
|
||||||
|
>
|
||||||
|
Start Task
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex justify-between w-full p-1 items-center">
|
||||||
|
<div className="flex gap-1 items-center">
|
||||||
|
<p className="text-[12px] text-red-500 tracking-wide">Expires</p>
|
||||||
|
<p className="text-[12px] font-semibold tracking-wide text-dark-gray dark:text-white">
|
||||||
|
<CountDown lastDate={datas.expire} />
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<button className="flex items-center justify-center gap-2">
|
||||||
|
<div className="w-[4px] h-[4px] bg-slate-400 rounded-full"></div>
|
||||||
|
<div className="w-[4px] h-[4px] bg-slate-400 rounded-full"></div>
|
||||||
|
<div className="w-[4px] h-[4px] bg-slate-400 rounded-full"></div>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const LowerBanner = ({ image, title = "", desc = "", btn, link_path, card_type, blog_id, key }) => {
|
const LowerBanner = ({ image, title = "", desc = "", btn, link_path, card_type, blog_id, key }) => {
|
||||||
const newLinkPath = card_type == 'BLOG' ? `${link_path}?blog_id=${blog_id}` : link_path
|
const newLinkPath = card_type == 'BLOG' ? `${link_path}?blog_id=${blog_id}` : link_path
|
||||||
|
|
||||||
|
|||||||
@@ -62,16 +62,19 @@ export default function FullAccountDash(props) {
|
|||||||
<div className="home-page-wrapper">
|
<div className="home-page-wrapper">
|
||||||
{renderDashboard()}
|
{renderDashboard()}
|
||||||
{process.env.REACT_APP_SHOW_ACCOUNT_DASH == "1" && (
|
{process.env.REACT_APP_SHOW_ACCOUNT_DASH == "1" && (
|
||||||
<AccountDashboard className="mb-4" bannerList={props.bannerList} />
|
<AccountDashboard className="mb-4" bannerList={props.bannerList} offersList={props.offersList} imageServer={props.imageServer} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{props?.dashTypes !== "undefined" &&
|
{
|
||||||
props.offersList?.data?.result_list?.length ? (
|
// props?.dashTypes !== "undefined" &&
|
||||||
<MyOffersTable
|
// props.offersList?.data?.result_list?.length ? (
|
||||||
MyActiveOffersList={props.offersList?.data}
|
// <MyOffersTable
|
||||||
className="mb-10"
|
// MyActiveOffersList={props.offersList?.data}
|
||||||
/>
|
// className="mb-10"
|
||||||
) : props.MyActiveJobList?.data?.length ? (
|
// />
|
||||||
|
// )
|
||||||
|
// :
|
||||||
|
props.MyActiveJobList?.data?.length ? (
|
||||||
<>
|
<>
|
||||||
<div className="w-full mb-5 flex justify-between items-center gap-1">
|
<div className="w-full mb-5 flex justify-between items-center gap-1">
|
||||||
<h1 className="text-26 font-bold text-dark-gray dark:text-white">
|
<h1 className="text-26 font-bold text-dark-gray dark:text-white">
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import usersService from "../../services/UsersService";
|
|||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import FamilyDash from "./FamilyDash";
|
import FamilyDash from "./FamilyDash";
|
||||||
import FullAccountDash from "./FullAccountDash";
|
import FullAccountDash from "./FullAccountDash";
|
||||||
|
import LoadingSpinner from '../../components/Spinners/LoadingSpinner'
|
||||||
|
|
||||||
export default function Home(props) {
|
export default function Home(props) {
|
||||||
// console.log("PROPS IN HOME->", props);
|
// console.log("PROPS IN HOME->", props);
|
||||||
@@ -12,7 +13,8 @@ export default function Home(props) {
|
|||||||
const { commonHeadBanner } = useSelector((state) => state.commonHeadBanner);
|
const { commonHeadBanner } = useSelector((state) => state.commonHeadBanner);
|
||||||
|
|
||||||
let [nextDueTask, setNextDueTask] = useState({});
|
let [nextDueTask, setNextDueTask] = useState({});
|
||||||
const [MyOffersList, setMyOffersList] = useState({loading: true, data: []});
|
|
||||||
|
// const [MyOffersList, setMyOffersList] = useState({loading: true, data: []});
|
||||||
|
|
||||||
const { userDetails } = useSelector((state) => state?.userDetails);
|
const { userDetails } = useSelector((state) => state?.userDetails);
|
||||||
|
|
||||||
@@ -46,19 +48,19 @@ export default function Home(props) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const getMyOffersList = async () => {
|
// const getMyOffersList = async () => {
|
||||||
try {
|
// try {
|
||||||
const res = await userApi.getOffersList();
|
// const res = await userApi.getOffersList();
|
||||||
setMyOffersList({loading:false, data:res.data});
|
// setMyOffersList({loading:false, data:res.data});
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
setMyOffersList({loading:false, data:[]});
|
// setMyOffersList({loading:false, data:[]});
|
||||||
console.log("Error getting offers", error);
|
// console.log("Error getting offers", error);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
await Promise.all([getHomeDate(), getMyOffersList(), getMyActiveJobList()]);
|
await Promise.all([getHomeDate(), getMyActiveJobList()]);
|
||||||
};
|
};
|
||||||
if(userDetails?.account_type == 'FULL'){
|
if(userDetails?.account_type == 'FULL'){
|
||||||
fetchData();
|
fetchData();
|
||||||
@@ -67,6 +69,9 @@ export default function Home(props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
|
{Object.keys(commonHeadBanner).length < 1 ?
|
||||||
|
<LoadingSpinner height='h-48' size='16' />
|
||||||
|
:
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
{userDetails && userDetails?.account_type == "FAMILY" ? (
|
{userDetails && userDetails?.account_type == "FAMILY" ? (
|
||||||
<FamilyDash
|
<FamilyDash
|
||||||
@@ -81,8 +86,10 @@ export default function Home(props) {
|
|||||||
nextDueTask={nextDueTask}
|
nextDueTask={nextDueTask}
|
||||||
bannerList={props.bannerList}
|
bannerList={props.bannerList}
|
||||||
dashTypes={props.dashTypes}
|
dashTypes={props.dashTypes}
|
||||||
offersList={MyOffersList}
|
// offersList={MyOffersList}
|
||||||
MyActiveJobList={MyActiveJobList}
|
MyActiveJobList={MyActiveJobList}
|
||||||
|
offersList={props.offersList}
|
||||||
|
imageServer={props.imageServer}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div>
|
<div>
|
||||||
@@ -90,6 +97,7 @@ export default function Home(props) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</Layout>
|
</Layout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ export default function HomePages() {
|
|||||||
const bannerOptions = {
|
const bannerOptions = {
|
||||||
bannerList: commonHeadBanner?.result_list,
|
bannerList: commonHeadBanner?.result_list,
|
||||||
dashTypes: commonHeadBanner?.home_dash_type,
|
dashTypes: commonHeadBanner?.home_dash_type,
|
||||||
|
offersList: commonHeadBanner?.offers_list,
|
||||||
|
imageServer: commonHeadBanner?.session_image_server
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user