mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: wip default message to sales transactions.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
// @ts-nocheck
|
||||
import { PreferencesReceiptsBoot } from './PreferencesReceiptsFormBoot';
|
||||
import { PreferencesReceiptsFormPage } from './PreferencesReceiptsFormPage';
|
||||
|
||||
/**
|
||||
* Preferences - Receipts.
|
||||
*/
|
||||
export function PreferencesReceipts() {
|
||||
return (
|
||||
<PreferencesReceiptsBoot>
|
||||
<PreferencesReceiptsFormPage />
|
||||
</PreferencesReceiptsBoot>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// @ts-nocheck
|
||||
import * as Yup from 'yup';
|
||||
|
||||
const Schema = Yup.object().shape({
|
||||
termsConditions: Yup.string().optional(),
|
||||
customerNotes: Yup.string().optional(),
|
||||
});
|
||||
|
||||
export const PreferencesReceiptsFormSchema = Schema;
|
||||
@@ -0,0 +1,78 @@
|
||||
// @ts-nocheck
|
||||
import styled from 'styled-components';
|
||||
import { Form } from 'formik';
|
||||
import { Button, Intent } from '@blueprintjs/core';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import {
|
||||
FormattedMessage as T,
|
||||
FFormGroup,
|
||||
FTextArea,
|
||||
} from '@/components';
|
||||
|
||||
/**
|
||||
* Preferences general form.
|
||||
*/
|
||||
export function PreferencesReceiptsForm({ isSubmitting }) {
|
||||
const history = useHistory();
|
||||
|
||||
// Handle close click.
|
||||
const handleCloseClick = () => {
|
||||
history.go(-1);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form>
|
||||
{/* ---------- Terms & Conditions ---------- */}
|
||||
<FFormGroup
|
||||
name={'termsConditions'}
|
||||
label={<T id={'pref.receipts.termsConditions.field'} />}
|
||||
fastField={true}
|
||||
>
|
||||
<FTextArea
|
||||
medium={'true'}
|
||||
name={'termsConditions'}
|
||||
fastField={true}
|
||||
fill={true}
|
||||
/>
|
||||
</FFormGroup>
|
||||
|
||||
{/* ---------- Customer Notes ---------- */}
|
||||
<FFormGroup
|
||||
name={'customerNotes'}
|
||||
label={<T id={'pref.receipts.customerNotes.field'} />}
|
||||
fastField={true}
|
||||
>
|
||||
<FTextArea
|
||||
medium={'true'}
|
||||
name={'tax_number'}
|
||||
fastField={true}
|
||||
fill={true}
|
||||
/>
|
||||
</FFormGroup>
|
||||
|
||||
<CardFooterActions>
|
||||
<Button loading={isSubmitting} intent={Intent.PRIMARY} type="submit">
|
||||
<T id={'save'} />
|
||||
</Button>
|
||||
<Button onClick={handleCloseClick}>
|
||||
<T id={'close'} />
|
||||
</Button>
|
||||
</CardFooterActions>
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
|
||||
const CardFooterActions = styled.div`
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid #e0e7ea;
|
||||
margin-top: 30px;
|
||||
|
||||
.bp4-button {
|
||||
min-width: 70px;
|
||||
|
||||
+ .bp4-button {
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -0,0 +1,56 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import styled from 'styled-components';
|
||||
import { CLASSES } from '@/constants/classes';
|
||||
import { useSettings } from '@/hooks/query';
|
||||
import PreferencesPageLoader from '../PreferencesPageLoader';
|
||||
import { Card } from '@/components';
|
||||
|
||||
const PreferencesReceiptsFormContext = React.createContext();
|
||||
|
||||
function PreferencesReceiptsBoot({ ...props }) {
|
||||
// Fetches organization settings.
|
||||
const { isLoading: isSettingsLoading } = useSettings();
|
||||
|
||||
// Provider state.
|
||||
const provider = {
|
||||
organization: {},
|
||||
};
|
||||
|
||||
// Detarmines whether if any query is loading.
|
||||
const isLoading = isSettingsLoading;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classNames(
|
||||
CLASSES.PREFERENCES_PAGE_INSIDE_CONTENT,
|
||||
CLASSES.PREFERENCES_PAGE_INSIDE_CONTENT_ACCOUNTANT,
|
||||
)}
|
||||
>
|
||||
<PreferencesReceiptsCard>
|
||||
{isLoading ? (
|
||||
<PreferencesPageLoader />
|
||||
) : (
|
||||
<PreferencesReceiptsFormContext.Provider
|
||||
value={provider}
|
||||
{...props}
|
||||
/>
|
||||
)}
|
||||
</PreferencesReceiptsCard>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const PreferencesReceiptsCard = styled(Card)`
|
||||
padding: 25px;
|
||||
|
||||
.bp4-form-group {
|
||||
max-width: 600px;
|
||||
}
|
||||
`;
|
||||
|
||||
const usePreferencesReceiptsFormContext = () =>
|
||||
React.useContext(PreferencesReceiptsFormContext);
|
||||
|
||||
export { PreferencesReceiptsBoot, usePreferencesReceiptsFormContext };
|
||||
@@ -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 { PreferencesReceiptsFormSchema } from './PreferencesReceiptsForm.schema';
|
||||
import { usePreferencesReceiptsFormContext } from './PreferencesReceiptsFormBoot';
|
||||
import { PreferencesReceiptsForm } from './PreferencesReceiptsForm';
|
||||
import withDashboardActions from '@/containers/Dashboard/withDashboardActions';
|
||||
|
||||
import { compose, transformToForm } from '@/utils';
|
||||
|
||||
const defaultValues = {
|
||||
termsConditions: '',
|
||||
customerNotes: '',
|
||||
};
|
||||
|
||||
/**
|
||||
* Preferences - Receipts.
|
||||
*/
|
||||
function PreferencesReceiptsFormPageRoot({
|
||||
// #withDashboardActions
|
||||
changePreferencesPageTitle,
|
||||
}) {
|
||||
const { organization } = usePreferencesReceiptsFormContext();
|
||||
|
||||
useEffect(() => {
|
||||
changePreferencesPageTitle(intl.get('preferences.receipts'));
|
||||
}, [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.receipts.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={PreferencesReceiptsFormSchema}
|
||||
onSubmit={handleFormSubmit}
|
||||
component={PreferencesReceiptsForm}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export const PreferencesReceiptsFormPage = compose(withDashboardActions)(
|
||||
PreferencesReceiptsFormPageRoot,
|
||||
);
|
||||
Reference in New Issue
Block a user