feat: Add default customer message and terms and conditions to the transactions.

This commit is contained in:
Ahmed Bouhuolia
2023-12-14 11:01:25 +02:00
parent e5bcb1c19a
commit 33e5d1a979
18 changed files with 658 additions and 1 deletions

View File

@@ -0,0 +1,69 @@
// @ts-nocheck
import React, { useEffect } from 'react';
import intl from 'react-intl-universal';
import { Formik } from 'formik';
import { Intent } from '@blueprintjs/core';
import { AppToaster } from '@/components';
import { PreferencesEstimatesFormSchema } from './PreferencesEstimatesForm.schema';
import { usePreferencesInvoiceFormContext } from './PreferencesEstimatesFormBoot';
import { PreferencesEstimatesForm } from './PreferencesEstimatesForm';
import withDashboardActions from '@/containers/Dashboard/withDashboardActions';
import { compose, transformToForm } from '@/utils';
const defaultValues = {
termsConditions: '',
customerNotes: '',
};
/**
* Preferences - .
*/
function PreferencesEstimatesFormPageRoot({
// #withDashboardActions
changePreferencesPageTitle,
}) {
const { organization } = usePreferencesInvoiceFormContext();
useEffect(() => {
changePreferencesPageTitle(intl.get('preferences.estimates'));
}, [changePreferencesPageTitle]);
// Initial values.
const initialValues = {
...defaultValues,
...transformToForm(organization.metadata, defaultValues),
};
// Handle the form submit.
const handleFormSubmit = (values, { setSubmitting }) => {
// Handle request success.
const onSuccess = (response) => {
AppToaster.show({
message: intl.get('preferences.estimates.success_message'),
intent: Intent.SUCCESS,
});
setSubmitting(false);
};
// Handle request error.
const onError = () => {
setSubmitting(false);
};
// updateOrganization({ ...values })
// .then(onSuccess)
// .catch(onError);
};
return (
<Formik
initialValues={initialValues}
validationSchema={PreferencesEstimatesFormSchema}
onSubmit={handleFormSubmit}
component={PreferencesEstimatesForm}
/>
);
}
export const PreferencesEstimatesFormPage = compose(withDashboardActions)(
PreferencesEstimatesFormPageRoot,
);