1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
import { useState } from 'react'
import { Head, useForm } from '@inertiajs/react'
import Layout from '../Layout'
import * as Form from '@radix-ui/react-form'
import * as Tabs from '@radix-ui/react-tabs'
export default function ProfileShow({ auth, user_stats, errors = {} }) {
const { data, setData, patch, processing, reset } = useForm({
name: auth.name || '',
email_address: auth.email_address || '',
current_password: '',
password: '',
password_confirmation: '',
})
const handleSubmit = (e) => {
e.preventDefault()
patch('/profile', {
onSuccess: () => {
reset('current_password', 'password', 'password_confirmation')
},
})
}
return (
<Layout user={auth}>
<Head title="My Profile" />
<Tabs.Root defaultValue="profile" className="bg-white shadow overflow-hidden sm:rounded-lg">
<Tabs.List className="flex border-b border-gray-200">
<Tabs.Trigger
value="profile"
className="px-4 py-2 text-sm font-medium text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none data-[state=active]:border-b-2 data-[state=active]:border-indigo-500 data-[state=active]:text-indigo-600"
>
Profile
</Tabs.Trigger>
<Tabs.Trigger
value="activity"
className="px-4 py-2 text-sm font-medium text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none data-[state=active]:border-b-2 data-[state=active]:border-indigo-500 data-[state=active]:text-indigo-600"
>
Activity
</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="profile" className="focus:outline-none">
<div className="px-4 py-5 sm:px-6">
<h1 className="text-2xl font-bold text-gray-900">My Profile</h1>
<p className="mt-1 max-w-2xl text-sm text-gray-500">
Update your account information
</p>
</div>
<div className="border-t border-gray-200 px-4 py-5 sm:px-6">
<Form.Root className="space-y-6" onSubmit={handleSubmit}>
<Form.Field name="name" className="space-y-2">
<Form.Label className="block text-sm font-medium text-gray-700">
Name
</Form.Label>
<Form.Control asChild>
<input
type="text"
name="name"
value={data.name}
onChange={(e) => setData('name', e.target.value)}
className="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md"
/>
</Form.Control>
{errors.name && (
<Form.Message className="text-sm text-red-600">
{errors.name}
</Form.Message>
)}
</Form.Field>
<Form.Field name="email_address" className="space-y-2">
<Form.Label className="block text-sm font-medium text-gray-700">
Email Address
</Form.Label>
<Form.Control asChild>
<input
type="email"
name="email_address"
value={data.email_address}
onChange={(e) => setData('email_address', e.target.value)}
className="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md"
/>
</Form.Control>
{errors.email_address && (
<Form.Message className="text-sm text-red-600">
{errors.email_address}
</Form.Message>
)}
</Form.Field>
<div className="pt-5 border-t border-gray-200">
<h3 className="text-lg font-medium text-gray-900">Change Password</h3>
<p className="mt-1 text-sm text-gray-500">
Leave these fields blank if you don't want to change your password
</p>
</div>
<Form.Field name="current_password" className="space-y-2">
<Form.Label className="block text-sm font-medium text-gray-700">
Current Password
</Form.Label>
<Form.Control asChild>
<input
type="password"
name="current_password"
value={data.current_password}
onChange={(e) => setData('current_password', e.target.value)}
className="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md"
/>
</Form.Control>
{errors.current_password && (
<Form.Message className="text-sm text-red-600">
{errors.current_password}
</Form.Message>
)}
</Form.Field>
<Form.Field name="password" className="space-y-2">
<Form.Label className="block text-sm font-medium text-gray-700">
New Password
</Form.Label>
<Form.Control asChild>
<input
type="password"
name="password"
value={data.password}
onChange={(e) => setData('password', e.target.value)}
className="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md"
/>
</Form.Control>
{errors.password && (
<Form.Message className="text-sm text-red-600">
{errors.password}
</Form.Message>
)}
</Form.Field>
<Form.Field name="password_confirmation" className="space-y-2">
<Form.Label className="block text-sm font-medium text-gray-700">
Confirm New Password
</Form.Label>
<Form.Control asChild>
<input
type="password"
name="password_confirmation"
value={data.password_confirmation}
onChange={(e) => setData('password_confirmation', e.target.value)}
className="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md"
/>
</Form.Control>
</Form.Field>
<div className="flex justify-end">
<Form.Submit asChild>
<button
type="submit"
disabled={processing}
className="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50"
>
{processing ? 'Saving...' : 'Save Changes'}
</button>
</Form.Submit>
</div>
</Form.Root>
</div>
</Tabs.Content>
<Tabs.Content value="activity" className="focus:outline-none">
<div className="px-4 py-5 sm:px-6">
<h1 className="text-2xl font-bold text-gray-900">My Activity</h1>
<p className="mt-1 max-w-2xl text-sm text-gray-500">
Your account statistics and recent activity
</p>
</div>
<div className="border-t border-gray-200">
<dl className="sm:divide-y sm:divide-gray-200">
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt className="text-sm font-medium text-gray-500">Account created</dt>
<dd className="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
{new Date(auth.created_at).toLocaleDateString()}
</dd>
</div>
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt className="text-sm font-medium text-gray-500">Total images</dt>
<dd className="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
{user_stats.total_images}
</dd>
</div>
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt className="text-sm font-medium text-gray-500">Pending review</dt>
<dd className="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
{user_stats.pending_images}
</dd>
</div>
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt className="text-sm font-medium text-gray-500">Approved images</dt>
<dd className="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
{user_stats.approved_images}
</dd>
</div>
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt className="text-sm font-medium text-gray-500">Rejected images</dt>
<dd className="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
{user_stats.rejected_images}
</dd>
</div>
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt className="text-sm font-medium text-gray-500">Most used tags</dt>
<dd className="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<div className="flex flex-wrap gap-1">
{user_stats.top_tags && user_stats.top_tags.length > 0 ? (
user_stats.top_tags.map((tag) => (
<span
key={tag.id}
className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-indigo-100 text-indigo-800"
>
{tag.name} ({tag.count})
</span>
))
) : (
<span className="text-gray-500">No tags used yet</span>
)}
</div>
</dd>
</div>
</dl>
</div>
{user_stats.recent_images && user_stats.recent_images.length > 0 && (
<div className="border-t border-gray-200 px-4 py-5 sm:px-6">
<h3 className="text-lg font-medium text-gray-900">Recent Images</h3>
<div className="mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
{user_stats.recent_images.map((image) => (
<div
key={image.id}
className="relative rounded-lg border border-gray-300 bg-white px-6 py-5 shadow-sm flex items-center space-x-3 hover:border-gray-400"
>
<div className="flex-shrink-0">
<img
className="h-10 w-10 rounded-full object-cover"
src={image.file_url}
alt=""
/>
</div>
<div className="flex-1 min-w-0">
<a href={`/images/${image.id}`} className="focus:outline-none">
<span className="absolute inset-0" aria-hidden="true" />
<p className="text-sm font-medium text-gray-900">{image.title}</p>
<p className="text-sm text-gray-500 truncate">
{new Date(image.created_at).toLocaleDateString()} - {image.status}
</p>
</a>
</div>
</div>
))}
</div>
</div>
)}
</Tabs.Content>
</Tabs.Root>
</Layout>
)
}