forked from QuantumNous/new-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplete-step.tsx
More file actions
110 lines (94 loc) · 3.7 KB
/
Copy pathcomplete-step.tsx
File metadata and controls
110 lines (94 loc) · 3.7 KB
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
/*
Copyright (C) 2023-2026 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { CheckCircle2 } from 'lucide-react'
import { useTranslation } from 'react-i18next'
import { StatusBadge } from '@/components/status-badge'
import { Separator } from '@/components/ui/separator'
import type { SetupFormValues, SetupStatus } from '../types'
interface CompleteStepProps {
status?: SetupStatus
values: SetupFormValues
}
const USAGE_MODE_LABEL_KEYS: Record<SetupFormValues['usageMode'], string> = {
external: 'External operations mode',
self: 'Personal use mode',
demo: 'Demo site mode',
}
const DATABASE_VARIANT: Record<
string,
'info' | 'success' | 'warning' | 'neutral'
> = {
sqlite: 'warning',
mysql: 'success',
postgres: 'success',
}
export function CompleteStep({ status, values }: CompleteStepProps) {
const { t } = useTranslation()
const usageLabelKey = USAGE_MODE_LABEL_KEYS[values.usageMode]
const dbType = status?.database_type ?? 'Unknown'
const databaseVariant = DATABASE_VARIANT[dbType.toLowerCase()] ?? 'neutral'
return (
<div className='flex flex-col items-center gap-6 text-center'>
<div className='rounded-2xl bg-emerald-500/10 p-4 text-emerald-600 dark:bg-emerald-500/20 dark:text-emerald-300'>
<CheckCircle2 className='size-8' />
</div>
<div className='space-y-2'>
<h2 className='text-2xl font-semibold tracking-tight'>
{t('Ready to initialize')}
</h2>
<p className='text-muted-foreground max-w-lg text-sm sm:text-base'>
{t(
'Double check the configuration below. Your system will be locked until initialization is complete.'
)}
</p>
</div>
<div className='bg-card w-full rounded-xl border p-6 text-left shadow-sm sm:p-8'>
<dl className='grid gap-6'>
<div className='space-y-1.5'>
<dt className='text-muted-foreground text-xs font-medium tracking-wide uppercase'>
{t('Database')}
</dt>
<dd className='flex flex-wrap items-center gap-2'>
<span className='text-sm font-semibold'>{dbType}</span>
<StatusBadge
label={dbType}
variant={databaseVariant}
copyable={false}
/>
</dd>
</div>
<Separator />
<div className='space-y-1.5'>
<dt className='text-muted-foreground text-xs font-medium tracking-wide uppercase'>
{t('Administrator account')}
</dt>
<dd className='text-sm font-semibold'>
{status?.root_init
? t('Existing account will be reused')
: values.username || t('Not set yet')}
</dd>
</div>
<Separator />
<div className='space-y-1.5'>
<dt className='text-muted-foreground text-xs font-medium tracking-wide uppercase'>
{t('Usage mode')}
</dt>
<dd className='text-sm font-semibold'>{t(usageLabelKey)}</dd>
</div>
</dl>
</div>
</div>
)
}