$93 GRAYBYTE WORDPRESS FILE MANAGER $29

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.162.162 | ADMIN IP 216.73.216.51
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/home/bravetechrwanda/itiministry.org/plugins/give/src/DonationForms/resources/app/form/

HOME
Current File : /home/bravetechrwanda/itiministry.org/plugins/give/src/DonationForms/resources/app/form//Form.tsx
import {FormProvider, useForm, useFormState} from 'react-hook-form';
import {joiResolver} from '@hookform/resolvers/joi';

import getWindowData from '../utilities/getWindowData';
import {useDonationFormState} from '../store';
import {Section} from '@givewp/forms/types';
import {withTemplateWrapper} from '../templates';
import {useCallback} from 'react';
import FormSection from './Section';

import {ObjectSchema} from 'joi';
import DonationFormErrorBoundary from '@givewp/forms/app/errors/boundaries/DonationFormErrorBoundary';
import handleSubmitRequest from '@givewp/forms/app/utilities/handleFormSubmitRequest';
import {DonationSummaryProvider} from '@givewp/forms/app/store/donation-summary';

const {donateUrl, inlineRedirectRoutes} = getWindowData();
const formTemplates = window.givewp.form.templates;

const FormTemplate = withTemplateWrapper(formTemplates.layouts.form);

export default function Form({defaultValues, sections, validationSchema}: PropTypes) {
    const {gateways} = useDonationFormState();

    const getGateway = useCallback((gatewayId) => gateways.find(({id}) => id === gatewayId), []);

    const methods = useForm<FormInputs>({
        defaultValues,
        resolver: joiResolver(validationSchema),
        reValidateMode: 'onBlur',
    });

    const {handleSubmit, setError, control} = methods;

    const {errors, isSubmitting, isSubmitSuccessful} = useFormState({control});

    const formError = errors.hasOwnProperty('FORM_ERROR') ? errors.FORM_ERROR.message : null;

    return (
        <FormProvider {...methods}>
            <DonationFormErrorBoundary>
                <DonationSummaryProvider>
                    <FormTemplate
                        formProps={{
                            id: 'give-next-gen',
                            onSubmit: handleSubmit((values: any) =>
                                handleSubmitRequest(
                                    values,
                                    setError,
                                    getGateway(values.gatewayId),
                                    donateUrl,
                                    inlineRedirectRoutes
                                )
                            ),
                        }}
                        isSubmitting={isSubmitting || isSubmitSuccessful}
                        formError={formError}
                    >
                        <>
                            {sections.map((section) => {
                                return (
                                    <DonationFormErrorBoundary key={section.name}>
                                        <FormSection key={section.name} section={section} />
                                    </DonationFormErrorBoundary>
                                );
                            })}
                        </>
                    </FormTemplate>
                </DonationSummaryProvider>
            </DonationFormErrorBoundary>
        </FormProvider>
    );
}

type PropTypes = {
    sections: Section[];
    defaultValues: object;
    validationSchema: ObjectSchema;
};

type FormInputs = {
    FORM_ERROR: string;
    amount: number;
    firstName: string;
    lastName: string;
    email: string;
    gatewayId: string;
};


Current_dir [ WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
25 May 2026 4.20 PM
bravetechrwanda / bravetechrwanda
0755
MultiStepForm
--
25 May 2026 4.20 PM
bravetechrwanda / bravetechrwanda
0755
Form.tsx
3.177 KB
16 Oct 2023 9.55 PM
bravetechrwanda / bravetechrwanda
0644
Header.tsx
4.481 KB
28 Jan 2026 8.00 PM
bravetechrwanda / bravetechrwanda
0644
Section.tsx
1.328 KB
16 Oct 2023 9.55 PM
bravetechrwanda / bravetechrwanda
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF Static GIF