"use client"; import { Card, CardContent } from "@/components/ui/card"; import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useZodForm } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { Form } from "@/components/ui/form"; import { Button } from "@/components/ui/button"; import { useMutation } from "@tanstack/react-query"; import { TooltipProvider } from "@/components/ui/tooltip"; import { S3FormSchema, S3FormType } from "@/features/settings/storage-s3.schema"; import { useRouter } from "next/navigation"; import { toast } from "sonner"; import { updateS3SettingsAction } from "@/features/settings/storage-s3.action"; import {PasswordInput} from "@/components/ui/password-input"; export type S3FormProps = { defaultValues?: S3FormType; }; export const StorageS3Form = (props: S3FormProps) => { const form = useZodForm({ schema: S3FormSchema, defaultValues: props.defaultValues, }); const router = useRouter(); const mutation = useMutation({ mutationFn: async (values: S3FormType) => { const updateS3Settings = await updateS3SettingsAction({ name: "system", data: values }); const data = updateS3Settings?.data?.data; if (updateS3Settings?.serverError || !data) { toast.error(updateS3Settings?.serverError); return; } toast.success(`Success updating storage informations`); router.refresh(); }, }); return (
{ await mutation.mutateAsync(values); }} > ( Endpoint Url * {"Your s3 compatible url"} )} /> ( Access Key * {"Add your access key"} )} /> ( Secret Key * {"Add your secret key"} )} /> ( Bucket name * {"The bucket name where you want to store your data"} )} />
); };