add admin setup token i love admin setup token
This commit is contained in:
parent
660da70666
commit
ac13e77dc4
15 changed files with 136 additions and 21 deletions
|
@ -20,6 +20,7 @@ import { useToast } from '@/hooks/use-toast'
|
|||
const formSchema = z.object({
|
||||
email: z.string().email('Invalid email address'),
|
||||
password: z.string().min(6, 'Password must be at least 6 characters long'),
|
||||
adminToken: z.string(),
|
||||
})
|
||||
|
||||
type FormValues = z.infer<typeof formSchema>
|
||||
|
@ -34,6 +35,7 @@ export function AuthForms() {
|
|||
defaultValues: {
|
||||
email: '',
|
||||
password: '',
|
||||
adminToken: '',
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -42,14 +44,14 @@ export function AuthForms() {
|
|||
if (activeTab === 'login') {
|
||||
await login(values.email, values.password)
|
||||
} else {
|
||||
await register(values.email, values.password)
|
||||
await register(values.email, values.password, values.adminToken)
|
||||
}
|
||||
form.reset()
|
||||
} catch (err: any) {
|
||||
toast({
|
||||
variant: 'destructive',
|
||||
title: 'Error',
|
||||
description: err.response?.data?.error || 'An error occurred',
|
||||
description: err.response?.data || 'An error occurred',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -93,6 +95,22 @@ export function AuthForms() {
|
|||
)}
|
||||
/>
|
||||
|
||||
{activeTab === 'register' && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="adminToken"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Admin Setup Token</FormLabel>
|
||||
<FormControl>
|
||||
<Input type="text" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Button type="submit" className="w-full">
|
||||
{activeTab === 'login' ? 'Sign in' : 'Create account'}
|
||||
</Button>
|
||||
|
@ -102,4 +120,4 @@ export function AuthForms() {
|
|||
</Tabs>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,9 +81,11 @@ export function LinkList({ refresh = 0 }: LinkListProps) {
|
|||
}
|
||||
|
||||
const handleCopy = (shortCode: string) => {
|
||||
navigator.clipboard.writeText(`http://localhost:8080/${shortCode}`)
|
||||
// Use import.meta.env.VITE_BASE_URL or fall back to window.location.origin
|
||||
const baseUrl = import.meta.env.VITE_API_URL || window.location.origin
|
||||
navigator.clipboard.writeText(`${baseUrl}/${shortCode}`)
|
||||
toast({
|
||||
description: "Link copied to clipboard",
|
||||
description: "Link copied to clipboard",
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue