Skip to content

Commit 91161f2

Browse files
chore: format frontend code
1 parent b283c21 commit 91161f2

File tree

126 files changed

+7519
-8564
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+7519
-8564
lines changed

dashboard/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Copy `example.env` to `.env` then set the backend api address:
2525

2626
#### Environment variables
2727

28-
| Name | Description |
29-
| ------------- | ------------------------------------------------------------------------------------ |
28+
| Name | Description |
29+
| ------------- | ------------------------------------------------------------------------------------------- |
3030
| VITE_BASE_API | The api url of the deployed backend ([PasarGuard](https://github.com/PasarGuard/panel.git)) |
3131

3232
## Start development server

dashboard/public/statics/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1505,4 +1505,4 @@
15051505
"donate": "Donate Now",
15061506
"starOnGitHub": "Star on GitHub"
15071507
}
1508-
}
1508+
}

dashboard/public/statics/locales/fa.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@
11811181
"radiusMedium": "متوسط",
11821182
"radiusLarge": "بزرگ"
11831183
},
1184-
"coreConfigModal": {
1184+
"coreConfigModal": {
11851185
"addConfig": "افزودن پیکربندی هسته",
11861186
"createNewConfig": "ایجاد پیکربندی جدید هسته",
11871187
"editCore": "ویرایش پیکربندی هسته",
@@ -1485,4 +1485,4 @@
14851485
"donate": "حمایت مالی",
14861486
"starOnGitHub": "ستاره در GitHub"
14871487
}
1488-
}
1488+
}

dashboard/public/statics/locales/ru.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,4 +1494,4 @@
14941494
"donate": "Поддержать проект",
14951495
"starOnGitHub": "Поставить звезду на GitHub"
14961496
}
1497-
}
1497+
}

dashboard/public/statics/locales/zh.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,4 +1537,4 @@
15371537
"donate": "立即捐赠",
15381538
"starOnGitHub": "在 GitHub 上加星"
15391539
}
1540-
}
1540+
}

dashboard/src/App.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import { queryClient } from './utils/query-client'
1010
export default function App() {
1111
return (
1212
<ThemeProvider defaultTheme="system" storageKey="theme">
13-
<QueryClientProvider client={queryClient}>
14-
<main>
15-
<Toaster />
16-
<DonationPopup />
17-
<RouterProvider router={router} />
18-
</main>
19-
</QueryClientProvider>
13+
<QueryClientProvider client={queryClient}>
14+
<main>
15+
<Toaster />
16+
<DonationPopup />
17+
<RouterProvider router={router} />
18+
</main>
19+
</QueryClientProvider>
2020
</ThemeProvider>
2121
)
2222
}

dashboard/src/components/ActionButtons.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const ActionButtons: FC<ActionButtonsProps> = ({ user }) => {
6666
const userForm = useForm<UseEditFormValues>({
6767
defaultValues: {
6868
username: user.username,
69-
status: user.status === "expired" || user.status === "limited" ? "active" : user.status,
69+
status: user.status === 'expired' || user.status === 'limited' ? 'active' : user.status,
7070
data_limit: user.data_limit ? Math.round((Number(user.data_limit) / (1024 * 1024 * 1024)) * 100) / 100 : undefined, // Convert bytes to GB
7171
expire: user.expire,
7272
note: user.note || '',
@@ -88,7 +88,7 @@ const ActionButtons: FC<ActionButtonsProps> = ({ user }) => {
8888
useEffect(() => {
8989
const values: UseFormValues = {
9090
username: user.username,
91-
status: user.status === 'active' || user.status === 'on_hold' || user.status === 'disabled' ? user.status as any : 'active',
91+
status: user.status === 'active' || user.status === 'on_hold' || user.status === 'disabled' ? (user.status as any) : 'active',
9292
data_limit: user.data_limit ? Math.round((Number(user.data_limit) / (1024 * 1024 * 1024)) * 100) / 100 : 0,
9393
expire: user.expire, // Pass raw expire value (timestamp)
9494
note: user.note || '',

dashboard/src/components/AdminStatistics.tsx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,48 +23,50 @@ export default function AdminStatisticsSection({ data }: AdminsStatisticsProps)
2323
icon: User,
2424
label: t('admins.total'),
2525
value: total,
26-
color: ''
26+
color: '',
2727
},
2828
{
2929
icon: UserCheck,
3030
label: t('admins.active'),
3131
value: active,
32-
color: ''
32+
color: '',
3333
},
3434
{
3535
icon: UserX,
3636
label: t('admins.disable'),
3737
value: disabled,
38-
color: ''
39-
}
38+
color: '',
39+
},
4040
]
4141

4242
return (
43-
<div className={cn('flex flex-col lg:flex-row items-center justify-between gap-x-4 gap-y-4', dir === 'rtl' && 'lg:flex-row-reverse')}>
43+
<div className={cn('flex flex-col items-center justify-between gap-x-4 gap-y-4 lg:flex-row', dir === 'rtl' && 'lg:flex-row-reverse')}>
4444
{stats.map((stat, idx) => (
4545
<Card
4646
key={stat.label}
4747
dir={dir}
48-
className={cn(
49-
"group relative w-full animate-fade-in rounded-md transition-all duration-300 hover:shadow-lg",
50-
)}
48+
className={cn('group relative w-full animate-fade-in rounded-md transition-all duration-300 hover:shadow-lg')}
5149
style={{
5250
animationDuration: '600ms',
5351
animationDelay: `${(idx + 1) * 100}ms`,
54-
animationFillMode: 'both'
52+
animationFillMode: 'both',
5553
}}
5654
>
57-
<div className={cn(
58-
'absolute inset-0 bg-gradient-to-r from-primary/10 to-transparent opacity-0 transition-opacity duration-500',
59-
'dark:from-primary/5 dark:to-transparent',
60-
'group-hover:opacity-100'
61-
)} />
62-
<CardTitle className="flex items-center justify-between gap-x-4 relative z-10 p-5">
55+
<div
56+
className={cn(
57+
'absolute inset-0 bg-gradient-to-r from-primary/10 to-transparent opacity-0 transition-opacity duration-500',
58+
'dark:from-primary/5 dark:to-transparent',
59+
'group-hover:opacity-100',
60+
)}
61+
/>
62+
<CardTitle className="relative z-10 flex items-center justify-between gap-x-4 p-5">
6363
<div className="flex items-center gap-x-4">
64-
{React.createElement(stat.icon, { className: "h-6 w-6" })}
64+
{React.createElement(stat.icon, { className: 'h-6 w-6' })}
6565
<span>{stat.label}</span>
6666
</div>
67-
<span className="text-3xl font-bold" dir="ltr">{numberWithCommas(stat.value)}</span>
67+
<span className="text-3xl font-bold" dir="ltr">
68+
{numberWithCommas(stat.value)}
69+
</span>
6870
</CardTitle>
6971
</Card>
7072
))}

dashboard/src/components/AdminStatusBadge.tsx

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,34 @@ export const AdminStatusBadge: FC<AdminStatusProps> = ({ isSudo, isDisabled }) =
1818
return {
1919
color: statusColors['disabled']?.statusColor || 'bg-gray-400 text-white',
2020
icon: null,
21-
text: t('disabled')
21+
text: t('disabled'),
2222
}
2323
}
24-
24+
2525
if (isSudo) {
2626
return {
2727
color: 'bg-violet-500 text-white',
2828
icon: Shield,
29-
text: t('sudo')
29+
text: t('sudo'),
3030
}
3131
}
32-
32+
3333
return {
3434
color: statusColors['active']?.statusColor || 'bg-green-500 text-white',
3535
icon: UserRound,
36-
text: t('admin')
36+
text: t('admin'),
3737
}
3838
}
3939

4040
const statusInfo = getStatusInfo()
4141
const StatusIcon = statusInfo.icon
4242

4343
return (
44-
<Badge
45-
className={cn(
46-
'flex items-center justify-center rounded-full px-2 py-1 w-fit gap-x-2 pointer-events-none',
47-
statusInfo.color,
48-
'py-2.5 h-6 px-1.5 sm:py-0.5 sm:h-auto sm:px-1'
49-
)}
50-
>
44+
<Badge className={cn('pointer-events-none flex w-fit items-center justify-center gap-x-2 rounded-full px-2 py-1', statusInfo.color, 'h-6 px-1.5 py-2.5 sm:h-auto sm:px-1 sm:py-0.5')}>
5145
<div className="flex items-center gap-1 sm:px-1">
52-
{StatusIcon && <StatusIcon className="w-4 h-4 sm:w-3 sm:h-3" />}
53-
<span className="capitalize text-nowrap font-medium text-xs">
54-
{statusInfo.text}
55-
</span>
46+
{StatusIcon && <StatusIcon className="h-4 w-4 sm:h-3 sm:w-3" />}
47+
<span className="text-nowrap text-xs font-medium capitalize">{statusInfo.text}</span>
5648
</div>
5749
</Badge>
5850
)
59-
}
51+
}

dashboard/src/components/DonationPopup.tsx

Lines changed: 35 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const generateChecksum = (lastShown: string | null, nextShowTime: string): strin
2222
let hash = 0
2323
for (let i = 0; i < data.length; i++) {
2424
const char = data.charCodeAt(i)
25-
hash = ((hash << 5) - hash) + char
25+
hash = (hash << 5) - hash + char
2626
hash = hash & hash // Convert to 32-bit integer
2727
}
2828
return Math.abs(hash).toString(36)
@@ -58,7 +58,7 @@ const validateData = (data: DonationData): boolean => {
5858
}
5959

6060
// Validate: nextShowTime shouldn't be more than 4 days after lastShown (max 3 days + 1 day buffer)
61-
const maxExpectedNext = lastShownTimestamp + (4 * 24 * 60 * 60 * 1000)
61+
const maxExpectedNext = lastShownTimestamp + 4 * 24 * 60 * 60 * 1000
6262
if (nextShowTimestamp > maxExpectedNext) {
6363
console.warn('Donation popup: nextShowTime too far in future')
6464
return false
@@ -67,9 +67,9 @@ const validateData = (data: DonationData): boolean => {
6767

6868
// Validate: nextShowTime shouldn't be more than 1 year in the past or future from now
6969
const now = Date.now()
70-
const oneYearAgo = now - (365 * 24 * 60 * 60 * 1000)
71-
const oneYearLater = now + (365 * 24 * 60 * 60 * 1000)
72-
70+
const oneYearAgo = now - 365 * 24 * 60 * 60 * 1000
71+
const oneYearLater = now + 365 * 24 * 60 * 60 * 1000
72+
7373
if (nextShowTimestamp < oneYearAgo || nextShowTimestamp > oneYearLater) {
7474
console.warn('Donation popup: nextShowTime outside reasonable range')
7575
return false
@@ -111,7 +111,7 @@ export default function DonationPopup() {
111111
const checkShouldShow = () => {
112112
const data = getStorageData()
113113
const now = Date.now()
114-
114+
115115
if (!data) {
116116
// First time - schedule for 1 hour from now and store it
117117
const nextShowTime = new Date(now + FIRST_SHOW_DELAY).toISOString()
@@ -139,15 +139,15 @@ export default function DonationPopup() {
139139
const showPopup = () => {
140140
const now = Date.now()
141141
// Update storage: set lastShown to now and nextShowTime to 3 days from now
142-
const nextShowTime = new Date(now + (DAYS_BETWEEN_SHOWS * 24 * 60 * 60 * 1000)).toISOString()
143-
setStorageData({
144-
lastShown: new Date(now).toISOString(),
145-
nextShowTime
142+
const nextShowTime = new Date(now + DAYS_BETWEEN_SHOWS * 24 * 60 * 60 * 1000).toISOString()
143+
setStorageData({
144+
lastShown: new Date(now).toISOString(),
145+
nextShowTime,
146146
})
147-
147+
148148
// Make visible immediately
149149
setIsVisible(true)
150-
150+
151151
// Start animation after a frame for smooth CSS transition
152152
requestAnimationFrame(() => {
153153
requestAnimationFrame(() => {
@@ -174,63 +174,57 @@ export default function DonationPopup() {
174174
if (!isVisible) return null
175175

176176
return (
177-
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4 pointer-events-none">
177+
<div className="pointer-events-none fixed inset-0 z-[100] flex items-center justify-center p-4">
178178
{/* Backdrop */}
179179
<div
180180
className={cn(
181-
'absolute inset-0 bg-black/40 backdrop-blur-sm pointer-events-auto',
182-
'transition-opacity duration-700 ease-in-out will-change-opacity',
183-
isAnimating ? 'opacity-100' : 'opacity-0'
181+
'pointer-events-auto absolute inset-0 bg-black/40 backdrop-blur-sm',
182+
'will-change-opacity transition-opacity duration-700 ease-in-out',
183+
isAnimating ? 'opacity-100' : 'opacity-0',
184184
)}
185185
onClick={handleClose}
186186
/>
187187

188188
{/* Popup */}
189189
<div
190190
className={cn(
191-
'relative w-full max-w-md pointer-events-auto',
191+
'pointer-events-auto relative w-full max-w-md',
192192
'transform transition-all duration-700 ease-out will-change-transform',
193-
isAnimating
194-
? 'translate-y-0 opacity-100 scale-100'
195-
: '-translate-y-8 opacity-0 scale-95'
193+
isAnimating ? 'translate-y-0 scale-100 opacity-100' : '-translate-y-8 scale-95 opacity-0',
196194
)}
197195
>
198-
<div className="relative bg-gradient-to-br from-card via-card to-card/95 border-2 border-primary/20 rounded-2xl shadow-2xl overflow-hidden">
196+
<div className="relative overflow-hidden rounded-2xl border-2 border-primary/20 bg-gradient-to-br from-card via-card to-card/95 shadow-2xl">
199197
{/* Animated gradient background */}
200198
<div className="absolute inset-0 bg-gradient-to-br from-primary/5 via-transparent to-primary/10" />
201199
<div className="absolute inset-0 bg-gradient-to-tr from-primary/0 via-primary/5 to-primary/0" />
202-
200+
203201
{/* Close button */}
204-
<button
205-
onClick={handleClose}
206-
className="absolute top-4 right-4 z-10 p-2 rounded-full bg-background/80 hover:bg-background transition-all duration-200 hover:scale-110"
207-
aria-label="Close"
208-
>
209-
<X className="w-4 h-4" />
202+
<button onClick={handleClose} className="absolute right-4 top-4 z-10 rounded-full bg-background/80 p-2 transition-all duration-200 hover:scale-110 hover:bg-background" aria-label="Close">
203+
<X className="h-4 w-4" />
210204
</button>
211205

212206
{/* Content */}
213207
<div className="relative p-8">
214208
{/* Heart icon with enhanced animation */}
215-
<div className="flex justify-center mb-6">
209+
<div className="mb-6 flex justify-center">
216210
<div className="relative">
217-
<div className="absolute inset-0 bg-primary/30 rounded-full blur-xl" />
218-
<div className="absolute -inset-2 bg-primary/20 rounded-full animate-ping" style={{ animationDuration: '2s' }} />
219-
<div className="relative bg-gradient-to-br from-primary/20 to-primary/10 p-4 rounded-full backdrop-blur-sm border border-primary/20">
220-
<Heart className="w-10 h-10 text-primary fill-primary" />
211+
<div className="absolute inset-0 rounded-full bg-primary/30 blur-xl" />
212+
<div className="absolute -inset-2 animate-ping rounded-full bg-primary/20" style={{ animationDuration: '2s' }} />
213+
<div className="relative rounded-full border border-primary/20 bg-gradient-to-br from-primary/20 to-primary/10 p-4 backdrop-blur-sm">
214+
<Heart className="h-10 w-10 fill-primary text-primary" />
221215
</div>
222216
</div>
223217
</div>
224218

225219
{/* Title */}
226-
<h3 className="text-2xl font-bold text-center mb-3 bg-gradient-to-r from-primary via-primary to-primary/80 bg-clip-text text-transparent">
220+
<h3 className="mb-3 bg-gradient-to-r from-primary via-primary to-primary/80 bg-clip-text text-center text-2xl font-bold text-transparent">
227221
{t('donation.title', { defaultValue: 'Support PasarGuard' })}
228222
</h3>
229223

230224
{/* Message */}
231-
<p className="text-sm text-muted-foreground text-center mb-6 leading-relaxed px-2">
232-
{t('donation.message', {
233-
defaultValue: 'Your support helps us improve PasarGuard and build better features for everyone!'
225+
<p className="mb-6 px-2 text-center text-sm leading-relaxed text-muted-foreground">
226+
{t('donation.message', {
227+
defaultValue: 'Your support helps us improve PasarGuard and build better features for everyone!',
234228
})}
235229
</p>
236230

@@ -239,24 +233,19 @@ export default function DonationPopup() {
239233
<Button
240234
onClick={handleDonate}
241235
size="lg"
242-
className="w-full bg-gradient-to-r from-primary to-primary/90 hover:from-primary/90 hover:to-primary text-primary-foreground font-semibold shadow-lg hover:shadow-xl transition-all duration-300 hover:scale-[1.03] active:scale-[0.98]"
236+
className="w-full bg-gradient-to-r from-primary to-primary/90 font-semibold text-primary-foreground shadow-lg transition-all duration-300 hover:scale-[1.03] hover:from-primary/90 hover:to-primary hover:shadow-xl active:scale-[0.98]"
243237
>
244-
<Heart className="w-5 h-5 mr-2 fill-current" />
238+
<Heart className="mr-2 h-5 w-5 fill-current" />
245239
{t('donation.donate', { defaultValue: 'Donate Now' })}
246240
</Button>
247241

248242
<Button
249243
onClick={handleGitHub}
250244
variant="outline"
251245
size="lg"
252-
className="w-full border-primary/30 hover:bg-primary/5 hover:border-primary/50 transition-all duration-300 hover:scale-[1.03] active:scale-[0.98]"
246+
className="w-full border-primary/30 transition-all duration-300 hover:scale-[1.03] hover:border-primary/50 hover:bg-primary/5 active:scale-[0.98]"
253247
>
254-
<svg
255-
className="w-5 h-5 mr-2"
256-
fill="currentColor"
257-
viewBox="0 0 24 24"
258-
xmlns="http://www.w3.org/2000/svg"
259-
>
248+
<svg className="mr-2 h-5 w-5" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
260249
<path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z" />
261250
</svg>
262251
{t('donation.starOnGitHub', { defaultValue: 'Star on GitHub' })}
@@ -268,4 +257,3 @@ export default function DonationPopup() {
268257
</div>
269258
)
270259
}
271-

0 commit comments

Comments
 (0)