diff --git a/src/App.css b/src/App.css index 4d1241e7f319735924ae0ff47d4594d5c6b3212f..401641e756a4c7075214e3f1d71c9ca1e2f445f0 100644 --- a/src/App.css +++ b/src/App.css @@ -13,4 +13,5 @@ body { align-items: flex-start; margin: 0 auto; text-align: center; + width: 100%; } diff --git a/src/App.tsx b/src/App.tsx index e6b9f6a911c7257e0b8baff6b65d153586446e6b..6d4c034f555e9d905983c5ec76848fca0264e638 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -6,7 +6,6 @@ import { RouterProvider, } from "react-router-dom"; import { QueryClient, QueryClientProvider } from "react-query"; -import Home from "@/pages/Home"; import Login from "@/pages/Login"; import ProtectedLayout from "@/components/ProtectedLayout"; import HomeLayout from "@/components/HomeLayout"; @@ -22,7 +21,6 @@ const router = createBrowserRouter( createRoutesFromElements( <> <Route path="" element={<ProtectedLayout />}> - <Route path="" element={<Home />} /> <Route path="/profile" element={<Profile />} /> <Route path="/applications" element={<Applications />} /> <Route path="/gyms" element={<Gym />}></Route> diff --git a/src/components/HomeLayout.tsx b/src/components/HomeLayout.tsx index 8662252c91c271d4a7d7e00e71bc37bb7d9123fc..4c115e796346b5f5c48d7e7998260f67a53f0de3 100644 --- a/src/components/HomeLayout.tsx +++ b/src/components/HomeLayout.tsx @@ -7,7 +7,7 @@ function HomeLayout() { const nav = useNavigate(); useEffect(() => { if (user && status === "success") { - nav("/"); + nav("/profile"); } }, [user, nav, status]); diff --git a/src/components/profile/Employer.tsx b/src/components/profile/Employer.tsx index c7e300aaae9ca18fba40b188022fa4137abfc7c7..ef9a1d6c780823353a7f105e518de1d3759cdba6 100644 --- a/src/components/profile/Employer.tsx +++ b/src/components/profile/Employer.tsx @@ -19,7 +19,7 @@ function Employer({ user }: { user: UserReturned }) { {status !== "success" ? ( <p>Loading...</p> ) : gym === undefined ? ( - <p>You're not currently employed</p> + <p className="self-start">You're not currently employed</p> ) : ( <GymCard horizontal={true} gym={gym} /> )} diff --git a/src/components/profile/ProfileForm.tsx b/src/components/profile/ProfileForm.tsx index 78476a9587278078d48579448d40fd2fb0f7f49d..d08f447f176cccccda0658de582e02265e02398b 100644 --- a/src/components/profile/ProfileForm.tsx +++ b/src/components/profile/ProfileForm.tsx @@ -14,6 +14,7 @@ import { useState } from "react"; import validate from "@/utils/validationSchema/validate"; function ProfileForm({ user }: { user: UserReturned }) { + console.log("User in profile form", user); const queryClient = useQueryClient(); const { field: username, diff --git a/src/components/profile/SkillManagement.tsx b/src/components/profile/SkillManagement.tsx index 13a73c7baf0ba4ed05423d40ad36f2b62b66c67b..51d1da8090a4c97236bca4bafac1e1d04fd3774a 100644 --- a/src/components/profile/SkillManagement.tsx +++ b/src/components/profile/SkillManagement.tsx @@ -212,7 +212,7 @@ function SkillManagement() { userSkills ? ( <p>Loading</p> ) : ( - <div className="w-full h-[18.75rem] bg-slate-600 px-3 py-3 lg:px-6 lg:py-6 flex flex-col rounded-lg overflow-y-scroll gap-2"> + <div className="w-full h-[18.75rem] bg-slate-600 px-3 py-3 lg:px-6 lg:py-6 flex flex-col rounded-lg overflow-y-scroll gap-2 box-border"> {allSkillsProcessor(allSkills ?? [], userSkills ?? []).map( ({ alreadyOwned, description, skillName }) => ( <AllSkillBit diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index ab63a09f963696d14c33f680a3c7178c4cccb128..d1d51f51922f0c26cfe02d875280ae96d30e5a6d 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -34,9 +34,10 @@ function Login() { setUsername(""); setPassword(""); setLoginError(""); - queryClient.setQueryData(["user"], { user: data, status: "success" }); - queryClient.invalidateQueries(["user"]); - navigate("/"); + queryClient.setQueryData(["user"], data); + console.log(queryClient.getQueryData(["user"])); + + navigate("/profile"); }, }); diff --git a/src/pages/Profile.tsx b/src/pages/Profile.tsx index a428eac5fbc1f99a0ca86440942a61ebb2a4e56e..320796c26d012d138f52d82c8c99df84a234dd00 100644 --- a/src/pages/Profile.tsx +++ b/src/pages/Profile.tsx @@ -13,11 +13,11 @@ function Profile() { const { mutateAsync: logoutMutation } = useMutation({ mutationFn: logout, onSuccess: () => { - queryClient.invalidateQueries(); - queryClient.setQueryData(["user"], { user: undefined, status: "idle" }); + queryClient.setQueryData(["user"], undefined); + queryClient.invalidateQueries({ queryKey: ["skills", "me"] }); + queryClient.invalidateQueries({ queryKey: ["applications"] }); }, }); - console.log(user); return ( <div className="flex flex-col w-full justify-center items-start box-border py-4 lg:py-8 px-4 lg:px-8 text-left gap-4"> diff --git a/src/pages/Register.tsx b/src/pages/Register.tsx index bd1c454c8d73f8b52d2d323edec0facfa8a8f677..f232c20239742a6569918ad6a06ac66a4824839b 100644 --- a/src/pages/Register.tsx +++ b/src/pages/Register.tsx @@ -55,15 +55,14 @@ function Register() { mutationFn: async () => await register({ username, password, description, email, name }), onSuccess(data: UserReturned) { - console.log(data); - queryClient.setQueryData(["user"], { user: data, status: "success" }); + queryClient.setQueryData(["user"], data); setUsername(""); setDescription(""); setEmail(""); setName(""); setPassword(""); setRegisterError(""); - navigate("/"); + navigate("/profile"); }, }); diff --git a/src/utils/api/auth.ts b/src/utils/api/auth.ts index 2d95971f59b54ce2171abc8f15a2fa7486f5faad..a955f886e5f03f24df6161f69f55beb61f2bd119 100644 --- a/src/utils/api/auth.ts +++ b/src/utils/api/auth.ts @@ -29,7 +29,9 @@ async function getMe(): Promise<UserReturned> { .user; } -async function editMe(payload: UserReturned): Promise<UserReturned> { +async function editMe( + payload: Omit<UserReturned, "gymId"> +): Promise<UserReturned> { return ( await axios.patch(`${config.NODE_JS_API}/api/auth/me`, payload, header) ).data.user; diff --git a/src/utils/context/SkillProvider.tsx b/src/utils/context/SkillProvider.tsx index 44faed575bb82de30c39b13502052281bc75dbc3..af6488900200ee9cf03d7445d5c34582d2dba7fd 100644 --- a/src/utils/context/SkillProvider.tsx +++ b/src/utils/context/SkillProvider.tsx @@ -3,7 +3,6 @@ import { QueryStatus, useQuery } from "react-query"; import { Skill } from "../validationSchema/skill"; import { getSkills, getUserSkills } from "../api/skill"; import { UserReturned } from "../validationSchema/trainer"; -import { useUser } from "./AuthProvider"; const AllSkillsContext = createContext<{ allSkills: Skill[] | undefined;