-
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.
Merge pull request #7 from Fingertips18/development
Add user info display on the root page for signed in users
- Loading branch information
Showing
24 changed files
with
188 additions
and
42 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,3 +1,5 @@ | ||
import wave from "@/assets/wave.gif"; | ||
import key from "@/assets/key.svg"; | ||
|
||
export const KEY = key; | ||
export const WAVE = wave; |
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,5 +1,5 @@ | ||
export type ResetDTO = { | ||
token: string; | ||
oldpassword: string; | ||
newpassword: string; | ||
old_password: string; | ||
new_password: string; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { createJSONStorage, devtools, persist } from "zustand/middleware"; | ||
import { create } from "zustand"; | ||
|
||
import { UserDTO } from "@/lib/DTO/user-dto"; | ||
|
||
interface UserStoreState { | ||
user?: UserDTO; | ||
setUser: (user?: UserDTO) => void; | ||
} | ||
|
||
export const useUserStore = create<UserStoreState>()( | ||
devtools( | ||
persist( | ||
(set) => ({ | ||
user: undefined, | ||
setUser: (user?: UserDTO) => set({ user }), | ||
}), | ||
{ | ||
name: "go-react-user", | ||
storage: createJSONStorage(() => sessionStorage), | ||
} | ||
) | ||
) | ||
); |
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,16 @@ | ||
export const formatDate = (dateString: string) => { | ||
const date = new Date(dateString); | ||
|
||
if (isNaN(date.getTime())) { | ||
return "Invalid Date"; | ||
} | ||
|
||
return date.toLocaleString("en-US", { | ||
year: "numeric", | ||
month: "short", | ||
day: "numeric", | ||
hour: "2-digit", | ||
minute: "2-digit", | ||
hour12: true, | ||
}); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useUserStore } from "@/lib/stores/user-store"; | ||
import { formatDate } from "@/lib/utils/date"; | ||
|
||
import { WelcomeUser } from "./welcome-user"; | ||
import { InfoPair } from "./info-pair"; | ||
|
||
const Content = () => { | ||
const { user } = useUserStore(); | ||
|
||
return ( | ||
<section className="h-[calc(100dvh_-_56px)] flex-center max-w-screen-lg mx-auto px-4 lg:px-0"> | ||
<div className="w-fit space-y-6"> | ||
<WelcomeUser name={user?.username} /> | ||
|
||
<div className="w-full rounded-md border border-secondary/50 bg-secondary/15 drop-shadow-2xl"> | ||
<InfoPair label="Email" value={user?.email_address} /> | ||
<InfoPair | ||
label="Last Visit" | ||
value={formatDate(new Date(user!.last_signed_in).toDateString())} | ||
/> | ||
<InfoPair | ||
label="Joined" | ||
value={new Date(user!.created_at).toLocaleDateString("en-US", { | ||
year: "numeric", | ||
month: "long", | ||
day: "numeric", | ||
})} | ||
/> | ||
<InfoPair label="Verified" value={user!.is_verified ? "Yes" : "No"} /> | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
}; | ||
|
||
export { Content }; |
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,14 @@ | ||
interface InfoPairProps { | ||
label: string; | ||
value?: string; | ||
} | ||
|
||
const InfoPair = ({ label, value }: InfoPairProps) => { | ||
return ( | ||
<p className="font-medium flex items-center gap-x-2 px-6 py-4 border-b border-secondary/50"> | ||
{label}:<span className="font-semibold text-secondary">{value}</span> | ||
</p> | ||
); | ||
}; | ||
|
||
export { InfoPair }; |
29 changes: 29 additions & 0 deletions
29
client/src/pages/root/_components/content/welcome-user.tsx
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,29 @@ | ||
import { WAVE } from "@/constants/assets"; | ||
|
||
interface WelcomeUserProps { | ||
name?: string; | ||
} | ||
|
||
const WelcomeUser = ({ name }: WelcomeUserProps) => { | ||
return ( | ||
<div className="w-full rounded-md border border-primary/50 bg-primary/15 drop-shadow-2xl"> | ||
<h2 | ||
className="text-lg lg:text-2xl font-extrabold flex-center uppercase | ||
text-primary drop-shadow-primary-glow animate-pulse p-4 gap-x-4" | ||
> | ||
<span className="text-foreground flex-center gap-x-4 relative"> | ||
Hi there{" "} | ||
<img src={WAVE} alt="wave" className="size-8 relative -top-[3px]" /> | ||
</span> | ||
{name} | ||
</h2> | ||
<div className="w-full bg-primary/25 p-2.5 flex-center border-t border-primary/50"> | ||
<p className="text-xs lg:text-base text-center lg:max-w-[324px] text-foreground/60 font-semibold"> | ||
Welcome to Go + React Auth | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export { WelcomeUser }; |
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,11 @@ | ||
const Footer = () => { | ||
return ( | ||
<footer className="bg-secondary/10 backdrop-blur-lg border-t border-secondary/25 p-4"> | ||
<p className="max-w-screen-lg mx-auto text-center text-sm font-medium text-foreground/60"> | ||
© {new Date().getUTCFullYear()} Fingertips. All rights reserved. | ||
</p> | ||
</footer> | ||
); | ||
}; | ||
|
||
export { Footer }; |
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
Oops, something went wrong.