diff --git a/src/apis/SenderIdentity.ts b/src/apis/SenderIdentity.ts index f9c1e9f..add844b 100644 --- a/src/apis/SenderIdentity.ts +++ b/src/apis/SenderIdentity.ts @@ -3,8 +3,15 @@ import api from '@/utils/api'; export const getSenderIdentities = async () => { const response = await api.get('/api/sender-identity'); const data = await response.data; - { - console.log(data, '-->checking sender-identity data'); - } return data; }; + +export const createSenderIndentity = async (data: any) => { + try { + const response = await api.post('/api/sender-identity', data); + const dataResponse = await response.data; + return dataResponse; + } catch (error: any) { + throw error; + } +}; diff --git a/src/app/(auth)/sender-identity/create/page.tsx b/src/app/(auth)/sender-identity/create/page.tsx new file mode 100644 index 0000000..89a5d38 --- /dev/null +++ b/src/app/(auth)/sender-identity/create/page.tsx @@ -0,0 +1,43 @@ +'use client'; + +import { AtSymbolIcon } from '@heroicons/react/24/outline'; +import { useFormik } from 'formik'; +import { createSenderIndentity } from '@/apis/SenderIdentity'; +import { toast } from 'react-toastify'; +import { useRouter } from 'next/navigation'; +import { senderIdentityValidation } from '@/validations/senderIdentity'; +import SenderIdentity from '@/components/Forms/SenderIdentity'; + +const Page = () => { + const router = useRouter(); + const onSubmit = async (values: any) => { + try { + await createSenderIndentity(values); + toast.success('Sender Identity created successfully'); + router.back(); + } catch (error: any) { + toast.error(error.response.data.message); + } + }; + const formik = useFormik({ + initialValues: { + email: '', + name: '', + }, + onSubmit: onSubmit, + validationSchema: senderIdentityValidation, + }); + return ( +