Compare commits

..

11 Commits

7 changed files with 246 additions and 61 deletions
+109 -9
View File
@@ -1,15 +1,115 @@
import React from 'react'
import React from "react";
import { Link } from "react-router-dom";
const AccountDashboard = ({className}) => {
const AccountDashboard = ({ className, bannerList }) => {
const getUpperBanner = bannerList?.slice(0, 3);
let getImage = ({banner_location, banner}) => {
if (banner_location == "LOCAL") {
return require(`../../assets/images/${banner}`);
} else {
return banner;
}
};
console.log(getUpperBanner);
return (
<div className={`w-full min-h-[400px] md:grid grid-cols-2 lg:p-8 p-4 justify-between items-center gap-2 rounded-2xl overflow-hidden bg-[#ffed00] ${
<div
className={`w-full min-h-[450px] flex flex-col justify-between items-center gap-4 rounded-2xl overflow-hidden ${
className || ""
}`}>
<div className="w-full h-full flex items-center justify-center text-5xl text-center">
Account Dashboard
}`}
>
<div className="w-full h-[300px] md:grid grid-cols-3 items-center justify-center gap-2">
{getUpperBanner?.map((props, idx) => {
let image = getImage(props);
let { short_title, short_description, button_text, link_path } =
props;
return (
<TopBanner
btn={button_text}
image={image}
title={short_title}
desc={short_description}
link_path={link_path}
key={idx}
/>
);
})}
</div>
<div className="w-full h-[150px] md:grid grid-cols-2 items-center justify-center gap-4 ">
<LowerBanner />
<LowerBanner />
</div>
</div>
)
}
);
};
export default AccountDashboard
export default AccountDashboard;
const TopBanner = ({ image, title = "", desc = "", btn, link_path, key }) => {
return (
<div className="flex flex-col shadow-md rounded-xl">
<Link to={link_path} key={key} className="h-[12rem] rounded-t-xl">
<img
src={image}
alt="banner-img"
className="w-full h-full rounded-t-xl object-cover"
/>
</Link>
<div className="h-[7rem] rounded-b-xl bg-white">
<div className="border-b border-slate-300 px-2 py-1 h-[5.4rem]">
<Link to={link_path} className="font-bold text-lg">
{title}
</Link>
<Link to={link_path} className="text-sm">
{desc}
</Link>
</div>
<div className="flex justify-between w-full px-2 items-center">
<Link to={link_path} className="text-slate-300 font-semibold">
{btn}
</Link>
<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, key }) => {
let Image = require(`../../assets/images/offer.jpg`);
return (
<div className="flex flex-col bg-white shadow-md h-full rounded-xl">
<div className="w-full flex justify-between border-b border-slate-300 p-2">
<div className="h-[130px] flex justify-between items-center">
<div className="px-2">
<h3 className="text-lg font-bold">Banner Title</h3>
<p className="text-sm">Banner description text will come follow</p>
</div>
</div>
<div className="w-[150px] h-[100px]">
<img
src={Image}
alt="banner-img"
className="w-full h-full rounded-xl"
/>
</div>
</div>
<div className="flex justify-between w-full px-2 items-center">
<span className="text-slate-300 font-semibold">follow up text</span>
<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>
);
};
+89 -47
View File
@@ -4,64 +4,104 @@ import usersService from "../../services/UsersService";
import ParentWaiting from "../MyOffers/ParentWaiting";
import MyOffersFamilyTable from "../MyTasks/MyOffersFamilyTable";
import FamilyActiveLSlde from "./FamilyActiveLSlde";
import { useDispatch, useSelector } from "react-redux";
import { tableReload } from "../../store/TableReloads";
export default function FamilyDash({ familyOffers, MyActiveJobList }) {
// console.log("PROPS IN FAMILY DASH->", familyOffers?.result_list);
const dispatch = useDispatch();
const userApi = new usersService();
const trending = MyActiveJobList;
const { familyBannersList } = useSelector((state) => state.familyBannersList);
let [familyBannersList, setFamilyBannersList] = useState({loading:false, result:{}})
const { userDetails } = useSelector((state) => state?.userDetails);
const getFamilyBanners = async () => { // FUNCTION TO GET FAMILY BANNERS
setFamilyBannersList({loading:true, result:[]});
try {
const res = await userApi.getFamilyBannersList();
setFamilyBannersList({loading:false, result:res.data});
// console.log('TEST RESPONSE', res.data)
} catch (error) {
setFamilyBannersList({loading:false, result:[]});
console.log("Error getting tasks");
}
};
let [reloadBanner, setReloadBanner] = useState(0)
// DO NOT UNCOMMENT THE CODE BELOW
// let [familyBannersList, setFamilyBannersList] = useState({loading:false, result:{}})
// const getFamilyBanners = async () => { // FUNCTION TO GET FAMILY BANNERS
// setFamilyBannersList({loading:true, result:[]});
// try {
// const res = await userApi.getFamilyBannersList();
// setFamilyBannersList({loading:false, result:res.data});
// console.log('TEST RESPONSE', res.data)
// } catch (error) {
// setFamilyBannersList({loading:false, result:[]});
// console.log("Error getting tasks");
// }
// };
// useEffect(()=>{
// getFamilyBanners()
// },[])
useEffect(()=>{
getFamilyBanners()
},[])
if(reloadBanner >= 2){
dispatch(tableReload({ type: "FAMILYBANNERSLIST" })); // RELOAD FAMILY BANNERS LIST EVERY 10 MINS
setReloadBanner(0)
}
const timer = setInterval(()=>{
setReloadBanner(prev => prev+1)
},300000)
return ()=>{
clearInterval(timer)
}
},[reloadBanner])
return (
<div>
<div className="home-page-wrapper">
{/* <CommonHead commonHeadData={props.commonHeadData} /> */}
{/* Header */}
<div className="text-white mb-4 p-2 w-full rounded-lg grid grid-cols-1 sm:grid-cols-2 bg-sky-blue place-content-center">
<div className="w-full flex gap-4">
<p className="text-lg font-normal">Welcome</p>
<div className="self-center">
<h1 className="m-0 text-lg font-normal">{`${userDetails?.firstname} ${userDetails?.lastname}`}</h1>
<p className="-mt-1 text-sm">Email</p>
</div>
</div>
<div className="w-full text-sm flex justify-end items-end">
<p>Last Login: {`${userDetails?.last_login.split(' ')[0]}`}</p>
</div>
</div>
{process.env.REACT_APP_SHOW_NEW_FAMILY_DASH == '1' &&
<>
{!familyBannersList.loading && familyBannersList?.result?.result_list && Object.keys(familyBannersList?.result?.result_list).length > 0 &&
{familyBannersList?.result_list && Object.keys(familyBannersList?.result_list).length > 0 &&
// Loop for Family Banners
<div className="w-full mb-4 grid grid-cols-2 md:grid-cols-3 gap-2 md:gap-4">
{Object.keys(familyBannersList?.result?.result_list).map((item, index) => {
let content = familyBannersList?.result?.result_list[item]
{Object.keys(familyBannersList?.result_list).map((item, index) => {
let content = familyBannersList?.result_list[item]
let action = item == 'recommend' ? 'familymarket' : 'mytask'
return (
<Link key={item} to={`/${action}`} className={`h-44 rounded-lg bg-white dark:bg-dark-white shadow-md flex justify-center items-center transition-all duration-300 hover:shadow-sm`}>
<Link key={item} to={`/${action}`} className={`h-[300px] rounded-lg bg-white dark:bg-dark-white shadow-md flex justify-center items-center transition-all duration-300 hover:shadow-sm`}>
<div className="h-full w-full">
<img className="w-full h-1/2 object-cover rounded-t-lg" src={content.banner.image} alt='banner image' />
<div className="px-2 py-1">
<h1 className="text-lg text-black dark:text-white font-medium tracking-wide">{content.banner.text}</h1>
<p className="text-sm text-black dark:text-white">{content.banner.description}</p>
</div>
{/* Horizontal Line */}
<div className="w-full h-[1px] bg-slate-300"></div>
<img className="w-full h-2/3 object-cover object-left rounded-t-lg" src={content.banner.image} alt='banner image' />
<div className="h-1/3 flex flex-col justify-between">
<div className="px-2 py-1">
<h1 className="text-lg text-[#083e21] dark:text-white font-normal tracking-wide">{content.banner.text}</h1>
<p className="text-sm text-black dark:text-white">{content.banner.description}</p>
</div>
{/* Horizontal Line */}
<div className="w-full h-[1px] bg-slate-300"></div>
<div className="px-2 py-1 flex justify-between items-center">
<span className="text-slate-400 dark:text-slate-200 text-sm">6w ago</span>
{/* Dots */}
<div className="flex justify-center gap-1">
<div className="w-1 h-1 bg-slate-400 rounded-full"></div>
<div className="w-1 h-1 bg-slate-400 rounded-full"></div>
<div className="w-1 h-1 bg-slate-400 rounded-full"></div>
<div className="px-2 py-1 flex justify-between items-center">
<span className="text-slate-400 dark:text-slate-200 text-sm">6w ago</span>
{/* Dots */}
<div className="flex justify-center gap-1">
<div className="w-1 h-1 bg-slate-400 rounded-full"></div>
<div className="w-1 h-1 bg-slate-400 rounded-full"></div>
<div className="w-1 h-1 bg-slate-400 rounded-full"></div>
</div>
</div>
</div>
</div>
@@ -75,23 +115,25 @@ export default function FamilyDash({ familyOffers, MyActiveJobList }) {
<h1 className="my-4 text-26 font-bold text-dark-gray dark:text-white tracking-wide">Resources</h1>
<div className="w-full grid grid-cols-2 md:grid-cols-3 gap-2 md:gap-4">
{[1,2,3,4,5].map((item, index) => (
<Link key={item} to={`/`} className={`h-44 rounded-lg bg-white dark:bg-dark-white shadow-md flex justify-center items-center transition-all duration-300 hover:shadow-sm`}>
<Link key={item} to={`/`} className={`h-[300px] rounded-lg bg-white dark:bg-dark-white shadow-md flex justify-center items-center transition-all duration-300 hover:shadow-sm`}>
<div className="h-full w-full">
<img className="w-full h-1/2 object-cover rounded-t-lg" src={''} alt='banner image' />
<div className="px-2 py-1">
<h1 className="text-lg text-black dark:text-white font-medium tracking-wide">{'Heading'}</h1>
<p className="text-sm text-black dark:text-white">{'Description'}</p>
</div>
{/* Horizontal Line */}
<div className="w-full h-[1px] bg-slate-300"></div>
<img className="w-full h-2/3 object-cover object-left rounded-t-lg" src={''} alt='banner image' />
<div className="h-1/3 flex flex-col justify-between">
<div className="px-2 py-1">
<h1 className="text-lg text-[#083e21] dark:text-white font-medium tracking-wide">{'Heading'}</h1>
<p className="text-sm text-black dark:text-white">{'Description'}</p>
</div>
{/* Horizontal Line */}
<div className="w-full h-[1px] bg-slate-300"></div>
<div className="px-2 py-1 flex justify-between items-center">
<span className="text-slate-400 dark:text-slate-200 text-sm">6w ago</span>
{/* Dots */}
<div className="flex justify-center gap-1">
<div className="w-1 h-1 bg-slate-400 rounded-full"></div>
<div className="w-1 h-1 bg-slate-400 rounded-full"></div>
<div className="w-1 h-1 bg-slate-400 rounded-full"></div>
<div className="px-2 py-1 flex justify-between items-center">
<span className="text-slate-400 dark:text-slate-200 text-sm">6w ago</span>
{/* Dots */}
<div className="flex justify-center gap-1">
<div className="w-1 h-1 bg-slate-400 rounded-full"></div>
<div className="w-1 h-1 bg-slate-400 rounded-full"></div>
<div className="w-1 h-1 bg-slate-400 rounded-full"></div>
</div>
</div>
</div>
</div>
+1 -3
View File
@@ -59,13 +59,11 @@ export default function FullAccountDash(props) {
}
};
console.log(process.env.REACT_APP_SHOW_ACCOUNT_DASH)
return (
<>
<div className="home-page-wrapper">
{process.env.REACT_APP_SHOW_ACCOUNT_DASH == "1" && (
<AccountDashboard className="mb-4" />
<AccountDashboard className="mb-4" bannerList={props.bannerList} />
)}
{renderDashboard()}
+20 -1
View File
@@ -11,6 +11,7 @@ import { updateJobs } from "../store/jobLists";
import { updateNotifications } from "../store/notifications";
import { updateUserJobList } from "../store/userJobList";
import { updateWalletDetails } from "../store/walletDetails";
import { familyBannersList } from "../store/FamilyBannerList";
const AuthRoute = ({ redirectPath = "/login", children }) => {
const apiCall = useMemo(() => new usersService(), []);
@@ -20,7 +21,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
const [loadProfileDetails, setLoadProfileDetails] = useState([]);
const navigate = useNavigate();
const { jobListTable, walletTable } = useSelector(
const { jobListTable, walletTable, familyBannersListTable } = useSelector(
(state) => state.tableReload
);
@@ -252,6 +253,24 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
});
}, []);
//FUNCTION TO GET FAMILY BANNERS
useEffect(() => {
if((!loggedIn && !isLogin.status) || account_type == 'FULL'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FULL
return
}
const getFamilyBanners = async () => { // FUNCTION TO GET FAMILY BANNERS
// setFamilyBannersList({loading:true, result:[]});
try {
const res = await apiCall.getFamilyBannersList();
dispatch(familyBannersList(res.data))
} catch (error) {
console.log("Error getting tasks");
}
};
getFamilyBanners()
}, [isLogin.status, familyBannersListTable]);
// useEffect(() => {
// apiCall
// .getHeroJBanners()
+20
View File
@@ -0,0 +1,20 @@
import { createSlice } from "@reduxjs/toolkit";
const initialState = {
familyBannersList: {}
};
export const familyBannersListSlice = createSlice({
name: "familyBannersList",
initialState,
reducers: {
familyBannersList: (state,action) => {
state.familyBannersList = {...action.payload}
},
},
});
// Action creators are generated for each case reducer function
export const { familyBannersList } = familyBannersListSlice.actions;
export default familyBannersListSlice.reducer;
+4
View File
@@ -8,6 +8,7 @@ const initialState = {
couponTable: false,
walletTable: false,
uploadsTable: false,
familyBannersListTable: false,
};
export const tableReloadSlice = createSlice({
@@ -37,6 +38,9 @@ export const tableReloadSlice = createSlice({
case "UPLOADSTABLE":
state.uploadsTable = !state.uploadsTable;
return;
case "FAMILYBANNERSLIST":
state.familyBannersListTable = !state.familyBannersListTable;
return;
default:
return state;
}
+3 -1
View File
@@ -8,6 +8,7 @@ import jobReducer from "./jobLists";
import notificationsReducer from "./notifications";
import userJobListReducer from "./userJobList";
import walletDetails from "./walletDetails";
import familyBannerListReducer from "./FamilyBannerList"
export default configureStore({
reducer: {
@@ -18,6 +19,7 @@ export default configureStore({
userJobList: userJobListReducer,
commonHeadBanner: commonHeadBannerReducer,
notifications: notificationsReducer,
walletDetails: walletDetails
walletDetails: walletDetails,
familyBannersList: familyBannerListReducer
},
});