diff --git a/public/assets/images/avatar.svg b/public/assets/images/avatar.svg new file mode 100644 index 0000000..92f5a04 --- /dev/null +++ b/public/assets/images/avatar.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/app/[name]/(Profile)/profile/hooks/userProfileData.ts b/src/app/[name]/(Profile)/profile/hooks/userProfileData.ts new file mode 100644 index 0000000..b3fe32e --- /dev/null +++ b/src/app/[name]/(Profile)/profile/hooks/userProfileData.ts @@ -0,0 +1,10 @@ +import { useQuery } from "@tanstack/react-query"; +import * as api from "../service/ProfileService"; + +export const useGetProfile = () => { + return useQuery({ + queryKey: ["profile"], + queryFn: api.getProfile, + retry: false, + }); +}; diff --git a/src/app/[name]/(Profile)/profile/service/ProfileService.ts b/src/app/[name]/(Profile)/profile/service/ProfileService.ts new file mode 100644 index 0000000..3d6c990 --- /dev/null +++ b/src/app/[name]/(Profile)/profile/service/ProfileService.ts @@ -0,0 +1,7 @@ +import { api } from "@/config/axios"; +import { GetProfileResponse } from "../types/Types"; + +export const getProfile = async (): Promise => { + const { data } = await api.get("/public/user/me"); + return data; +}; diff --git a/src/app/[name]/(Profile)/profile/types/Types.ts b/src/app/[name]/(Profile)/profile/types/Types.ts new file mode 100644 index 0000000..e8d88fa --- /dev/null +++ b/src/app/[name]/(Profile)/profile/types/Types.ts @@ -0,0 +1,23 @@ +export interface UserProfile { + id: string; + createdAt: string; + updatedAt: string; + deletedAt: string | null; + restaurant: string; + firstName: string; + lastName: string; + phone: string; + birthDate: string; + marriageDate: string; + referrer: string | null; + isActive: boolean; + gender: boolean; + wallet: number; + points: number; +} + +export interface GetProfileResponse { + statusCode: number; + success: boolean; + data: UserProfile; +} diff --git a/src/app/globals.css b/src/app/globals.css index c3d31c8..eba820c 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -9,7 +9,6 @@ box-sizing: border-box; } - html, body { @apply h-full bg-background font-irancell font-normal text-foreground; @@ -109,9 +108,10 @@ input:autofill { transition: background-color 10000s ease-in-out 0s; } - .box-shadow-normal { box-shadow: 0px 2px 16px 0px #00000014; + height: fit-content; + padding-bottom: 20px; } .gradient-border { @@ -128,16 +128,14 @@ input:autofill { /* border thickness */ border-radius: inherit; /* inherit border-radius from parent */ - background: linear-gradient(to bottom right, - var(--container) 6.25%, - rgba(255, 253, 253, 0) 52.01%, - var(--container) 96.87%); - mask: - linear-gradient(#fff 0 0) content-box, - linear-gradient(#fff 0 0); - -webkit-mask: - linear-gradient(#fff 0 0) content-box, - linear-gradient(#fff 0 0); + background: linear-gradient( + to bottom right, + var(--container) 6.25%, + rgba(255, 253, 253, 0) 52.01%, + var(--container) 96.87% + ); + mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); + -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; @@ -361,4 +359,4 @@ html[data-theme="dark"] { body { @apply bg-background text-foreground; } -} */ \ No newline at end of file +} */ diff --git a/src/components/topbar/TopBar.tsx b/src/components/topbar/TopBar.tsx index 531baa0..44d9348 100644 --- a/src/components/topbar/TopBar.tsx +++ b/src/components/topbar/TopBar.tsx @@ -10,6 +10,7 @@ import Link from 'next/link' import { useParams } from 'next/navigation' import useToggle from '@/hooks/helpers/useToggle' import LogoutPrompt from '@/features/general/LogoutPrompt' +import { useGetProfile } from '@/app/[name]/(Profile)/profile/hooks/userProfileData' type Props = { profileDropState: boolean, @@ -23,9 +24,13 @@ type Props = { } function TopBar({ profileDropState, toggleProfileDropState, toggleMenuState }: Props) { + const params = useParams(); const { name } = params; const { state: logoutModal, toggle: toggleLogoutModal } = useToggle(); + const { data: profile } = useGetProfile(); + const profileData = profile?.data; + const fullName = profileData ? `${profileData.firstName} ${profileData.lastName}`.trim() : 'کاربر داناک'; return (
@@ -76,9 +81,9 @@ function TopBar({ profileDropState, toggleProfileDropState, toggleMenuState }: P height={24} alt='Profile avatar' className='rounded-full' - src={'/assets/images/user-avatar.png'} /> + src={'/assets/images/avatar.svg'} />
-
مهرداد مظفری
+
{fullName}
{/* */}
@@ -91,14 +96,15 @@ function TopBar({ profileDropState, toggleProfileDropState, toggleMenuState }: P >
{'user -

mail@danakcorp.com

+

{profileData?.firstName + ' ' + profileData?.lastName}

+ {/*

{profileData?.phone}

*/}