@@ -6,48 +6,79 @@ import { motion, AnimatePresence } from "framer-motion";
66import { LogOut , LayoutDashboard } from "lucide-react"
77import Page from "@/components/dashboard/page" ;
88import ChartAreaDefault from "@/components/dashboard/chart-area" ;
9+ import Link from "next/link" ;
910import { useState , useEffect } from "react" ;
11+
1012export default function Dashboard ( ) {
1113 const [ imgUrl , setImgUrl ] = useState ( null ) ;
1214
1315 useEffect ( ( ) => {
1416 const fetchImage = async ( ) => {
1517 try {
16- const res = await fetch ( '/api/profile-image' ) ; // API يولد الصورة
17- const blob = await res . blob ( ) ;
18- const url = URL . createObjectURL ( blob ) ;
19- setImgUrl ( url ) ;
18+ const res = await fetch ( '/api/profile-image' ) ;
19+ const arrayBuffer = await res . arrayBuffer ( ) ;
20+ const base64 = btoa (
21+ new Uint8Array ( arrayBuffer ) . reduce (
22+ ( data , byte ) => data + String . fromCharCode ( byte ) ,
23+ ''
24+ )
25+ ) ;
26+ setImgUrl ( `data:image/png;base64,${ base64 } ` ) ;
2027 } catch ( e ) {
2128 console . error ( e ) ;
2229 }
2330 } ;
24-
31+
2532 fetchImage ( ) ;
26- return ( ) => {
27- if ( imgUrl ) URL . revokeObjectURL ( imgUrl ) ;
28- } ;
2933 } , [ ] ) ;
34+
35+ const addCommas = ( num ) => {
36+ return num . toString ( ) . replace ( / \B (? = ( \d { 3 } ) + (? ! \d ) ) / g, "," ) ;
37+ } ;
38+
39+ const formatted = addCommas ( "1250000" )
40+
3041 return (
3142 < Page >
3243
3344 < div className = "flex flex-col md:flex-row md:items-center gap-1 md:gap-4 mb-4" >
45+ < motion . div
46+ initial = { { opacity : 0 , scale : 0.95 } }
47+ animate = { { opacity : 1 , scale : 1 } }
48+ transition = { { duration : 0.6 , delay : 1 * 0.1 } } >
3449 < h2 className = "text-white flex space-x-2 font-medium text-lg md:text-xl" >
3550 < LayoutDashboard className = "h-6 w-6" />
3651 < span > Overview</ span >
3752 </ h2 >
53+ </ motion . div >
54+ < motion . div
55+ initial = { { opacity : 0 , scale : 0.95 } }
56+ animate = { { opacity : 1 , scale : 1 } }
57+ transition = { { duration : 0.6 , delay : 2 * 0.1 } } >
3858 < span className = "hidden md:block w-px h-4 bg-[#5b5683]" > </ span >
39-
59+ </ motion . div >
60+ < motion . div
61+ initial = { { opacity : 0 , scale : 0.95 } }
62+ animate = { { opacity : 1 , scale : 1 } }
63+ transition = { { duration : 0.6 , delay : 3 * 0.1 } } >
4064 < span className = "text-md text-zinc-400" >
4165 The Overview page gives you a quick glance at your most important information and activities, all in one place. It’s designed to help you stay on top of your account without needing to jump between different sections.
4266 </ span >
67+ </ motion . div >
4368 </ div >
69+ < motion . div
70+ initial = { { opacity : 0 , scale : 0.95 } }
71+ animate = { { opacity : 1 , scale : 1 } }
72+ transition = { { duration : 0.6 , delay : 4 * 0.1 } }
73+ >
4474 < hr className = "border-[#373450] mb-4" />
75+ </ motion . div >
4576
4677 < div className = "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4" >
4778 < motion . div
4879 initial = { { opacity : 0 , scale : 0.95 } }
4980 animate = { { opacity : 1 , scale : 1 } }
50- transition = { { duration : 0.6 , delay : 1 * 0.2 } }
81+ transition = { { duration : 0.6 , delay : 5 * 0.1 } }
5182 className = "bg-[#1b1922]/50 backdrop-blur p-3 sm:p-4 sm:py-2 rounded-md border border-[#2e2b41]"
5283 >
5384 < div className = "flex items-center gap-2 justify-between sm:gap-3" >
@@ -63,15 +94,15 @@ export default function Dashboard() {
6394 </ div >
6495
6596 < p className = " text-xl sm:text-2xl font-semibold break-words" >
66- 0
97+ { formatted }
6798 </ p >
6899 </ motion . div >
69100
70101
71102 < motion . div
72103 initial = { { opacity : 0 , scale : 0.95 } }
73104 animate = { { opacity : 1 , scale : 1 } }
74- transition = { { duration : 0.6 , delay : 2 * 0.2 } }
105+ transition = { { duration : 0.6 , delay : 6 * 0.1 } }
75106 className = "bg-[#1b1922]/50 backdrop-blur p-3 sm:p-4 sm:py-2 rounded-md border border-[#2e2b41]"
76107 >
77108 < div className = "flex items-center gap-2 justify-between sm:gap-3" >
@@ -87,14 +118,14 @@ export default function Dashboard() {
87118 </ div >
88119
89120 < p className = " text-xl sm:text-2xl font-semibold break-words" >
90- 0
121+ 45
91122 </ p >
92123 </ motion . div >
93124
94125 < motion . div
95126 initial = { { opacity : 0 , scale : 0.95 } }
96127 animate = { { opacity : 1 , scale : 1 } }
97- transition = { { duration : 0.6 , delay : 3 * 0.2 } }
128+ transition = { { duration : 0.6 , delay : 7 * 0.1 } }
98129 className = "bg-[#1b1922]/50 backdrop-blur p-3 sm:p-4 sm:py-2 rounded-md border border-[#2e2b41]"
99130 >
100131 < div className = "flex items-center gap-2 justify-between sm:gap-3" >
@@ -110,14 +141,14 @@ export default function Dashboard() {
110141 </ div >
111142
112143 < p className = " text-xl sm:text-2xl font-semibold break-words" >
113- 0
144+ 99
114145 </ p >
115146 </ motion . div >
116147
117148 < motion . div
118149 initial = { { opacity : 0 , scale : 0.95 } }
119150 animate = { { opacity : 1 , scale : 1 } }
120- transition = { { duration : 0.6 , delay : 4 * 0.2 } }
151+ transition = { { duration : 0.6 , delay : 8 * 0.1 } }
121152 className = "bg-[#1b1922]/50 backdrop-blur p-3 sm:p-4 sm:py-2 rounded-md border border-[#2e2b41]"
122153 >
123154 < div className = "flex items-center gap-2 justify-between sm:gap-3" >
@@ -133,7 +164,7 @@ export default function Dashboard() {
133164 </ div >
134165
135166 < p className = " text-xl sm:text-2xl font-semibold break-words" >
136- 0
167+ #1
137168 </ p >
138169 </ motion . div >
139170 </ div >
@@ -142,7 +173,7 @@ export default function Dashboard() {
142173 < motion . div
143174 initial = { { opacity : 0 , scale : 0.95 } }
144175 animate = { { opacity : 1 , scale : 1 } }
145- transition = { { duration : 0.6 , delay : 0.4 } }
176+ transition = { { duration : 0.6 , delay : 9 * 0.1 } }
146177 className = "flex-1 min-w-0"
147178 >
148179 < ChartAreaDefault />
@@ -151,21 +182,32 @@ export default function Dashboard() {
151182 < motion . div
152183 initial = { { opacity : 0 , scale : 0.95 } }
153184 animate = { { opacity : 1 , scale : 1 } }
154- transition = { { duration : 0.6 , delay : 0.4 } }
185+ transition = { { duration : 0.6 , delay : 10 * 0.1 } }
155186 className = "flex-shrink-0 w-full lg:w-[420px] xl:w-[500px] h-full"
156187 >
157- < div className = "bg-[#1b1922]/50 border border-[#2e2b41] p-6 rounded-lg flex flex-col items-center md:h-[34.2rem]" >
158- < h3 className = "text-xl text-gray-200 font-semibold mb-6" > Profile</ h3 >
188+ < div className = "bg-[#1b1922]/50 border border-[#2e2b41] p-6 rounded-lg flex flex-col md:h-[34.5rem]" >
189+ < div className = "flex justify-between" >
190+ < h3 className = "text-xl text-gray-200 font-semibold mb-6" > Profile</ h3 >
191+ < div className = "group" >
192+ < Link href = "/dashboard/store/profile" className = " flex space-x-1 p-1.5 bg-[#4f39f65d] rounded-xl cursor-pointer -translate-y-2 border-2 border-indigo-600 group-hover:bg-indigo-600 transition-all duration-300 " >
193+ < svg xmlns = "http://www.w3.org/2000/svg" width = { 24 } height = { 24 } viewBox = "0 0 24 24" > < g fill = "currentColor" fillRule = "evenodd" clipRule = "evenodd" > < path d = "M11.32 6.176H5c-1.105 0-2 .949-2 2.118v10.588C3 20.052 3.895 21 5 21h11c1.105 0 2-.948 2-2.118v-7.75l-3.914 4.144A2.46 2.46 0 0 1 12.81 16l-2.681.568c-1.75.37-3.292-1.263-2.942-3.115l.536-2.839c.097-.512.335-.983.684-1.352z" > </ path > < path d = "M19.846 4.318a2.2 2.2 0 0 0-.437-.692a2 2 0 0 0-.654-.463a1.92 1.92 0 0 0-1.544 0a2 2 0 0 0-.654.463l-.546.578l2.852 3.02l.546-.579a2.1 2.1 0 0 0 .437-.692a2.24 2.24 0 0 0 0-1.635M17.45 8.721L14.597 5.7L9.82 10.76a.54.54 0 0 0-.137.27l-.536 2.84c-.07.37.239.696.588.622l2.682-.567a.5.5 0 0 0 .255-.145l4.778-5.06Z" > </ path > </ g > </ svg >
194+ < span className = "mt-1" > Edit Profile</ span >
195+ </ Link >
196+ </ div >
197+ </ div >
159198
160199 { imgUrl ? (
161200 < img
162201 src = { imgUrl }
163202 alt = "Profile Image"
164- className = "w-full h-full max-h-[550px] rounded-lg object-cover shadow-lg transition-transform hover:scale-[1.03] duration-300"
203+ draggable = { false }
204+ onContextMenu = { ( e ) => e . preventDefault ( ) }
205+ className = "w-full select-none h-full max-h-[550px] rounded-lg object-cover shadow-lg transition-transform hover:scale-[1.03] duration-300"
165206 />
166207 ) : (
167208 < div className = "w-full h-full max-h-[550px] bg-[#2a2835] rounded-lg animate-pulse" />
168209 ) }
210+
169211 </ div >
170212 </ motion . div >
171213 </ div >
0 commit comments