diff --git a/dashboard/src/components/forms/client-form.tsx b/dashboard/src/components/forms/client-form.tsx index b4191d9..88a34b7 100644 --- a/dashboard/src/components/forms/client-form.tsx +++ b/dashboard/src/components/forms/client-form.tsx @@ -14,6 +14,7 @@ import { AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle } import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { useRouter } from 'next/navigation'; import { Checkbox } from '@/components/ui/checkbox'; +import { Minus } from 'lucide-react'; interface CreateClientFormProps { action: (data: z.infer) => Promise>; @@ -22,17 +23,19 @@ interface CreateClientFormProps { export function CreateClientForm({ action }: CreateClientFormProps) { const router = useRouter(); + const [redirectUris, setRedirectUris] = useState(['']); const form = useForm>({ resolver: zodResolver(clientFormSchema), defaultValues: { client_name: '', - owner: '', scope: '', + redirect_uris: [''], skip: false, logo_uri: '', policy_uri: '', tos_uri: '', + owner: '', }, }); @@ -53,6 +56,23 @@ export function CreateClientForm({ action }: CreateClientFormProps) { }); }; + const addRedirectUri = () => { + setRedirectUris([...redirectUris, '']); + }; + + const removeRedirectUri = (index) => { + const updatedRedirectUris = redirectUris.filter((_, i) => i !== index); + setRedirectUris(updatedRedirectUris); + form.setValue('redirect_uris', updatedRedirectUris); + }; + + const handleInputChange = (index, event) => { + const updatedRedirectUris = [...redirectUris]; + updatedRedirectUris[index] = event.target.value; + setRedirectUris(updatedRedirectUris); + form.setValue('redirect_uris', updatedRedirectUris); + }; + return ( <> { @@ -117,27 +137,44 @@ export function CreateClientForm({ action }: CreateClientFormProps) { )} /> - ( + {redirectUris.map((uri, index) => ( +
- Scopes + Redirect + URI {index + 1} - +
+ handleInputChange(index, event)} + /> + {redirectUris.length > 1 && ( + + )} +
- - Scope is a string containing a space-separated list of scope values (as - described in - Section 3.3 of OAuth 2.0 [RFC6749]) that the client can use when - requesting - access - tokens. - - + {form.errors?.redirect_uris && form.errors.redirect_uris[index] && ( + {form.errors.redirect_uris[index].message} + )}
- )} - /> +
+ ))} + + @@ -162,6 +199,7 @@ export function CreateClientForm({ action }: CreateClientFormProps) { + {/* TODO: change to switch */} + + + + Supported OAuth2 flows + + + Configure allowed grant types and response types for this OAuth2 Client. + + + + + + +