-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update hasAvatar state logic in auth context
- Loading branch information
1 parent
a59ae76
commit 02feae5
Showing
10 changed files
with
188 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,63 @@ | ||
import { Link as JoyLink, Stack, Typography } from "@mui/joy"; | ||
import { Link as ReactLink } from "react-router-dom"; | ||
import { useContext, useState } from "react"; | ||
import { MockAvatar } from "../api/mock-avatar"; | ||
import { ArrowRightOutlined } from "../assets/icons/arrow-right"; | ||
import { AvatarLoading } from "../components/layout/avatar-loading"; | ||
import { Layout } from "../components/shared/containers"; | ||
import { AuthContext } from "../contexts/auth.context"; | ||
|
||
export const AvatarCreatePage = () => { | ||
return ( | ||
<Stack alignItems="center"> | ||
<Stack minHeight="100vh" width={1120} justifyContent="space-between" py={10} gap={4}> | ||
<Stack maxWidth={720} alignItems="center" alignSelf="center" gap={4}> | ||
<Typography level="h1" textAlign="center" textColor="neutral.dark"> | ||
Your Strength-Based Avatar is Almost Ready! | ||
</Typography> | ||
const { handleHasAvatar } = useContext(AuthContext); | ||
const [isLoadingAvatar, setIsLoadingAvatar] = useState<boolean>(false); | ||
|
||
<Typography level="body-md" textColor="neutral.dark"> | ||
Now, let's customize the core features to bring your Avatar to life. | ||
</Typography> | ||
</Stack> | ||
const handleCreateAvatar = async () => { | ||
setIsLoadingAvatar(true); | ||
try { | ||
await handleHasAvatar(); | ||
} catch (error) { | ||
console.error("Failed to create avatar:", error); | ||
} finally { | ||
setIsLoadingAvatar(false); | ||
} | ||
}; | ||
|
||
return ( | ||
<Layout alignCenter> | ||
{isLoadingAvatar ? ( | ||
<AvatarLoading /> | ||
) : ( | ||
<Stack alignItems="center"> | ||
<MockAvatar sx={{ fontSize: 280 }} /> | ||
</Stack> | ||
<Stack width={1120} gap={4}> | ||
<Stack maxWidth={720} alignItems="center" alignSelf="center" gap={4}> | ||
<Typography level="h1" textAlign="center" textColor="neutral.dark"> | ||
Your Strength-Based Avatar is Almost Ready! | ||
</Typography> | ||
|
||
<Typography level="body-md" textColor="neutral.dark"> | ||
Now, let's customize the core features to bring your Avatar to life. | ||
</Typography> | ||
</Stack> | ||
|
||
<Stack alignItems="center"> | ||
<MockAvatar sx={{ fontSize: 280 }} /> | ||
</Stack> | ||
|
||
<Stack bgcolor="neutral.white" height={128} alignItems="center" borderRadius={8}></Stack> | ||
<Stack bgcolor="neutral.white" height={128} alignItems="center" borderRadius={8}></Stack> | ||
|
||
<Stack alignItems="end"> | ||
<JoyLink | ||
component={ReactLink} | ||
to="/avatar-results" | ||
underline="none" | ||
endDecorator={<ArrowRightOutlined sx={{ fontSize: 10 }} />} | ||
textColor="neutral.black" | ||
gap={0.5} | ||
> | ||
Next | ||
</JoyLink> | ||
<Stack alignItems="end"> | ||
<JoyLink | ||
onClick={handleCreateAvatar} | ||
underline="none" | ||
endDecorator={<ArrowRightOutlined sx={{ fontSize: 10 }} />} | ||
textColor="neutral.black" | ||
gap={0.5} | ||
> | ||
Next | ||
</JoyLink> | ||
</Stack> | ||
</Stack> | ||
</Stack> | ||
</Stack> | ||
</Stack> | ||
)} | ||
</Layout> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,40 @@ | ||
import { Button, IconButton, Stack, Typography } from "@mui/joy"; | ||
import { Link } from "react-router-dom"; | ||
import { MockAvatar } from "../api/mock-avatar"; | ||
import { mockUser } from "../api/mock-data"; | ||
import { ArrowRotateOutlined } from "../assets/icons/arrow-rotate"; | ||
import { AvatarLoading } from "../components/layout/avatar-loading"; | ||
import { CardTopStrengths } from "../components/layout/card-top-strengths"; | ||
import { Layout } from "../components/shared/containers"; | ||
|
||
export const AvatarResultsPage = () => { | ||
const loading = mockUser.isAvatarLoading; | ||
|
||
return ( | ||
<> | ||
{loading ? ( | ||
<AvatarLoading /> | ||
) : ( | ||
<Layout alignCenter> | ||
<Stack direction="row" justifyContent="center" gap={14}> | ||
<Stack maxWidth={480}> | ||
<Stack alignItems="center" gap={7}> | ||
<Stack alignItems="center" gap={3}> | ||
<Typography level="h1" fontFamily="Acta-Book"> | ||
Your <Typography textColor="subvisual.primary">Strengths</Typography>, brought to life. | ||
</Typography> | ||
|
||
<Typography level="body-lg"> | ||
Meet your personalized avatar—a reflection of your unique talents and abilities. | ||
</Typography> | ||
</Stack> | ||
<Layout alignCenter> | ||
<Stack direction="row" justifyContent="center" gap={14}> | ||
<Stack maxWidth={480}> | ||
<Stack alignItems="center" gap={7}> | ||
<Stack alignItems="center" gap={3}> | ||
<Typography level="h1" fontFamily="Acta-Book"> | ||
Your <Typography textColor="subvisual.primary">Strengths</Typography>, brought to life. | ||
</Typography> | ||
|
||
<Stack alignItems="center" gap={4}> | ||
<MockAvatar sx={{ fontSize: 280 }} /> | ||
<IconButton> | ||
<ArrowRotateOutlined sx={{ fontSize: 16 }} /> | ||
</IconButton> | ||
<Button component={Link} to="/personal"> | ||
Go to dashboard | ||
</Button> | ||
</Stack> | ||
</Stack> | ||
<Typography level="body-lg"> | ||
Meet your personalized avatar—a reflection of your unique talents and abilities. | ||
</Typography> | ||
</Stack> | ||
|
||
<CardTopStrengths /> | ||
<Stack alignItems="center" gap={4}> | ||
<MockAvatar sx={{ fontSize: 280 }} /> | ||
<IconButton> | ||
<ArrowRotateOutlined sx={{ fontSize: 16 }} /> | ||
</IconButton> | ||
<Button component={Link} to="/personal"> | ||
Go to dashboard | ||
</Button> | ||
</Stack> | ||
</Stack> | ||
</Layout> | ||
)} | ||
</> | ||
</Stack> | ||
|
||
<CardTopStrengths /> | ||
</Stack> | ||
</Layout> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { CircularProgress, Stack } from "@mui/joy"; | ||
import { SubvisualLogo } from "../assets/icons/subvisual-logo"; | ||
|
||
export const LoadingPage = () => ( | ||
<Stack height="100vh" alignItems="center" justifyContent="center"> | ||
<CircularProgress variant="plain" sx={{ "--CircularProgress-size": "200px" }}> | ||
<SubvisualLogo sx={{ fontSize: 80 }} /> | ||
</CircularProgress> | ||
</Stack> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import { AuthContext } from "../contexts/auth.context"; | |
|
||
export const SignupPage = () => { | ||
const { handleLogin } = useContext(AuthContext); | ||
const [email, setEmail] = useState<string>("[email protected]"); | ||
const [email, setEmail] = useState<string>(""); | ||
const [isLoadingSubmit, setIsLoadingSubmit] = useState<boolean>(false); | ||
|
||
const handleSubmit = async (e: FormEvent) => { | ||
|
Oops, something went wrong.