From 6b8427b18ab3cb5bcc83bceaf43cc7b712a83fa6 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Tue, 5 Dec 2023 15:09:52 +0700 Subject: add page content di formulir --- src/lib/form/components/SuratDukungan.jsx | 339 +++++++++++++++++------------- 1 file changed, 191 insertions(+), 148 deletions(-) (limited to 'src/lib/form/components/SuratDukungan.jsx') diff --git a/src/lib/form/components/SuratDukungan.jsx b/src/lib/form/components/SuratDukungan.jsx index 360dd838..d73c3fab 100644 --- a/src/lib/form/components/SuratDukungan.jsx +++ b/src/lib/form/components/SuratDukungan.jsx @@ -1,12 +1,14 @@ -import HookFormSelect from '@/core/components/elements/Select/HookFormSelect' -import cityApi from '@/lib/address/api/cityApi' -import { yupResolver } from '@hookform/resolvers/yup' -import React, { useEffect, useRef, useState } from 'react' -import ReCAPTCHA from 'react-google-recaptcha' -import { Controller, useForm } from 'react-hook-form' -import { toast } from 'react-hot-toast' -import * as Yup from 'yup' -import createLeadsApi from '../api/createLeadApi' +import HookFormSelect from '@/core/components/elements/Select/HookFormSelect'; +import cityApi from '@/lib/address/api/cityApi'; +import { yupResolver } from '@hookform/resolvers/yup'; +import React, { useEffect, useRef, useState } from 'react'; +import ReCAPTCHA from 'react-google-recaptcha'; +import { Controller, useForm } from 'react-hook-form'; +import { toast } from 'react-hot-toast'; +import * as Yup from 'yup'; +import createLeadsApi from '../api/createLeadApi'; + +import PageContent from '@/lib/content/components/PageContent'; const CreateSuratDukungan = () => { const { @@ -14,30 +16,33 @@ const CreateSuratDukungan = () => { handleSubmit, formState: { errors }, control, - reset + reset, } = useForm({ resolver: yupResolver(validationSchema), - defaultValues - }) - const [cities, setCities] = useState([]) - const [company_unit, setCompany_unit] = useState([]) + defaultValues, + }); + const [cities, setCities] = useState([]); + const [company_unit, setCompany_unit] = useState([]); - const recaptchaRef = useRef(null) + const recaptchaRef = useRef(null); useEffect(() => { const loadCities = async () => { - let dataCities = await cityApi() - dataCities = dataCities.map((city) => ({ value: city.id, label: city.name })) - setCities(dataCities) - } - loadCities() - }, []) + let dataCities = await cityApi(); + dataCities = dataCities.map((city) => ({ + value: city.id, + label: city.name, + })); + setCities(dataCities); + }; + loadCities(); + }, []); const onSubmitHandler = async (values) => { - const recaptchaValue = recaptchaRef.current.getValue() + const recaptchaValue = recaptchaRef.current.getValue(); if (!recaptchaValue) { - toast.error('Catcha harus diisi') - return + toast.error('Catcha harus diisi'); + return; } const data = { ...values, @@ -61,19 +66,21 @@ const CreateSuratDukungan = () => { ' \r\n Alamat 2 : ' + values.address2 + 'Keterangan : ' + - values.description - } + values.description, + }; - const create_leads = await createLeadsApi({ data }) + const create_leads = await createLeadsApi({ data }); if (create_leads) { - toast.success('Berhasil menambahkan alamat') - reset() - recaptchaRef.current.reset() + toast.success('Berhasil menambahkan alamat'); + reset(); + recaptchaRef.current.reset(); } - } + }; return (
-

Form Surat Dukungan

+

+ Form Surat Dukungan +

{ >

Lengkapi form berikut untuk melakukan konfirmasi pembayaran.

-
-

Data Peserta

-
-
-
-
- - -
{errors.company?.message}
-
-
-
-
- - -
{errors.address?.message}
-
-
-
-
- - -
{errors.phone?.message}
-
-
-
-
- - -
{errors.npwp?.message}
-
-
-
-
- - -
{errors.email?.message}
+
+
+
+

Data Peserta

-
-
-

Data Peserta

-
-
-
- - -
{errors.pengadaan?.message}
-
-
-
-
- -