From 6e3061b9db7924f5392268f4a2b1d1cb9d7c02e8 Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Wed, 5 Jul 2023 04:39:39 +0100 Subject: [PATCH 1/2] cookie bug fix and family dash style changes made --- src/components/AuthPages/Login/index.jsx | 52 +++++++++---------- .../MyPendingJobs/ParentWaiting.jsx | 14 ++++- .../MyPendingJobs/ParentWaitingTable.jsx | 12 +++-- src/components/MyTasks/MyJobTable.jsx | 6 +-- src/components/MyTasks/index.jsx | 14 ++++- 5 files changed, 61 insertions(+), 37 deletions(-) diff --git a/src/components/AuthPages/Login/index.jsx b/src/components/AuthPages/Login/index.jsx index c1e266a..76ddfa2 100644 --- a/src/components/AuthPages/Login/index.jsx +++ b/src/components/AuthPages/Login/index.jsx @@ -17,10 +17,7 @@ import { updateUserDetails } from "../../../store/UserDetails"; export default function Login() { const dispatch = useDispatch(); - let [loginType, setLoginType] = useState({ full: true, family: false }); - const [selectedLoginType, setSelectedLoginType] = useState( - document.cookie.includes("loginType=family") ? "loginfamily" : "loginfull" - ); + let [loginType, setLoginType] = useState(document.cookie.includes("loginType=family")? 'family': document.cookie.includes("loginType=full") ? 'full' : 'full'); const [checked, setValue] = useState(false); const [loginLoading, setLoginLoading] = useState(false); @@ -36,11 +33,12 @@ export default function Login() { //FUNCTION TO DETERMINE/CHANGE LOGIN COMPONENT const handleLoginType = ({ target: { name } }) => { - if (name == "full") { - setLoginType({ [name]: true, family: false }); - } else if ((name = "family")) { - setLoginType({ [name]: false, family: true }); - } + setLoginType(name); + let currentDate = new Date(); + let expirationDate = new Date(currentDate.getTime() + (24 * 60 * 60 * 1000)); + // Convert the expiration date to the appropriate format + let expirationDateString = expirationDate.toUTCString(); + document.cookie = `loginType=${name}; expires=${expirationDateString}; path=/login;`; }; // email @@ -71,7 +69,7 @@ export default function Login() { return; } - if (name == "loginfull") { + if (name == "full") { // Post Data Info for normal Login postData = { username: email, @@ -80,11 +78,7 @@ export default function Login() { login_mode: 1100, action: 11025, }; - - // Clear the loginType cookie if the user switches to loginfull - document.cookie = - "loginType=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; - } else if (name == "loginfamily") { + } else if (name == "family") { // Post Data Info for family Login postData = { username: email, @@ -93,8 +87,6 @@ export default function Login() { login_mode: 1105, action: 11025, }; - // Set the loginType cookie to remember the user's selection - document.cookie = "loginType=family; expires=Session; path=/;"; } else { setLoginLoading(false); setMsgError("Invalid Login Type. Consider refreshing the page"); @@ -146,16 +138,20 @@ export default function Login() { }); // In order to update the selected login type whenever the component renders - useEffect(() => { - setSelectedLoginType( - document.cookie.includes("loginType=family") ? "loginfamily" : "loginfull" - ); - }, []); + // useEffect(() => { + // document.cookie.includes("loginType=family") ? "loginfamily" : "loginfull" + + // Set the loginType cookie to remember the user's selection + // document.cookie = "loginType=family; expires=Session; path=/;"; + + // Clear the loginType cookie if the user switches to loginfull + // document.cookie ="loginType=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; + // }, []); useEffect(() => { setMail(""); setPassword(""); - }, [loginType.full, loginType.family]); + }, [loginType]); return ( <> @@ -192,7 +188,7 @@ export default function Login() {
Date: Wed, 5 Jul 2023 08:50:56 +0100 Subject: [PATCH 2/2] suggest image position adjusted --- src/components/Cards/FamilyMarketCard.jsx | 3 ++- src/components/FamilyPopup/SuggestTask.jsx | 3 ++- src/components/MyPendingJobs/ParentWaiting.jsx | 6 +----- src/components/MyTasks/index.jsx | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/components/Cards/FamilyMarketCard.jsx b/src/components/Cards/FamilyMarketCard.jsx index e5482e6..f5cb15d 100644 --- a/src/components/Cards/FamilyMarketCard.jsx +++ b/src/components/Cards/FamilyMarketCard.jsx @@ -26,7 +26,8 @@ export default function FamilyMarketCard({ className, datas, hidden = false }) { className="w-full h-[236px] p-6 rounded-xl overflow-hidden" onClick={popUpHandler} style={{ - background: `url(${selectedImage}) 0% 0% / cover no-repeat`, + // background: `url(${selectedImage}) 0% 0% / cover no-repeat`, + background: `url(${selectedImage}) center / contain no-repeat`, }} >
diff --git a/src/components/FamilyPopup/SuggestTask.jsx b/src/components/FamilyPopup/SuggestTask.jsx index 0293804..f56225a 100644 --- a/src/components/FamilyPopup/SuggestTask.jsx +++ b/src/components/FamilyPopup/SuggestTask.jsx @@ -81,7 +81,8 @@ const SuggestTask = ({ details, onClose, situation }) => {
diff --git a/src/components/MyPendingJobs/ParentWaiting.jsx b/src/components/MyPendingJobs/ParentWaiting.jsx index 4fe6c0a..3fec455 100644 --- a/src/components/MyPendingJobs/ParentWaiting.jsx +++ b/src/components/MyPendingJobs/ParentWaiting.jsx @@ -23,11 +23,7 @@ export default function ParentWaiting({ className }) { Waiting for Parent to Get Started... { - // navigate("/resources"); - // }} - to='/resources' + to='/familymarket' className="px-4 h-10 flex justify-center items-center btn-gradient text-base rounded-full text-white" > More Task diff --git a/src/components/MyTasks/index.jsx b/src/components/MyTasks/index.jsx index 2893407..4d47341 100644 --- a/src/components/MyTasks/index.jsx +++ b/src/components/MyTasks/index.jsx @@ -48,7 +48,7 @@ export default function MyTasks({