diff --git a/src/containers/Projects/components/ProjectBillableEntriesLink.tsx b/src/containers/Projects/components/ProjectBillableEntriesLink.tsx new file mode 100644 index 000000000..bf58e96d8 --- /dev/null +++ b/src/containers/Projects/components/ProjectBillableEntriesLink.tsx @@ -0,0 +1,37 @@ +// @ts-nocheck +import React from 'react'; +import styled from 'styled-components'; +import * as R from 'ramda'; + +import { ButtonLink } from '@/components'; +import withDialogActions from '@/containers/Dialog/withDialogActions'; + +function ProjectBillableEntriesLinkComponent({ + // #ownProps + children, + projectId, + className, + + // #withDialogAction + openDialog, +}) { + const handleBillableEntries = (event) => { + openDialog('project-billable-entries', { projectId }); + event.preventDefault(); + }; + + return ( + + {children} + + ); +} + +export const ProjectBillableEntriesLink = R.compose(withDialogActions)( + ProjectBillableEntriesLinkComponent, +); + +const BillableEntriesLink = styled(ButtonLink)` + font-size: 11px; + margin-top: 6px; +`; diff --git a/src/containers/Projects/components/index.ts b/src/containers/Projects/components/index.ts index b0dd663ed..663be17ce 100644 --- a/src/containers/Projects/components/index.ts +++ b/src/containers/Projects/components/index.ts @@ -1,9 +1,10 @@ // @ts-nocheck export * from './ExpenseSelect'; -export * from './ChangeTypesSelect'; -export * from './TaskSelect'; +export * from './ProjectTaskSelect'; +export * from './ProjectTaskChargeTypeSelect'; export * from './ProjectsSelect'; -export * from './ProjectMultiSelect' +export * from './ProjectMultiSelect'; export * from './FInputGroupComponent'; -export * from './ProjectSuggestField' -export * from './ProjectBillableTypeSuggestField' \ No newline at end of file +export * from './ProjectSuggestField'; +export * from './ProjectBillableTypeSuggestField'; +export * from './ProjectBillableEntriesLink'; diff --git a/src/containers/Projects/containers/ProjectBillableEntriesFormDialog/utils.tsx b/src/containers/Projects/containers/ProjectBillableEntriesFormDialog/utils.tsx index 986c0f27f..bae988c01 100644 --- a/src/containers/Projects/containers/ProjectBillableEntriesFormDialog/utils.tsx +++ b/src/containers/Projects/containers/ProjectBillableEntriesFormDialog/utils.tsx @@ -1,9 +1,24 @@ // @ts-nocheck +import React from 'react'; import moment from 'moment'; +import { Callout, Intent, Classes } from '@blueprintjs/core'; +import { CLASSES } from '@/constants/classes'; +import { FormattedMessage as T } from '@/components'; -export const getDefaultQuery = () => { - return { - billableType: '', - to_date: moment(new Date()).format('YYYY-MM-DD'), - }; -}; +/** + * Empty status callout. + * @returns {React.JSX} + */ +export function EmptyStatuCallout() { + return ( +
+ +

+ +

+
+
+ ); +} diff --git a/src/containers/Sales/Invoices/InvoiceForm/InvoiceFormHeaderFields.tsx b/src/containers/Sales/Invoices/InvoiceForm/InvoiceFormHeaderFields.tsx index 15bbc1053..f3c722dff 100644 --- a/src/containers/Sales/Invoices/InvoiceForm/InvoiceFormHeaderFields.tsx +++ b/src/containers/Sales/Invoices/InvoiceForm/InvoiceFormHeaderFields.tsx @@ -36,7 +36,10 @@ import { InvoiceExchangeRateInputField, InvoiceProjectSelectButton, } from './components'; -import { ProjectsSelect } from '@/containers/Projects/components'; +import { + ProjectsSelect, + ProjectBillableEntriesLink, +} from '@/containers/Projects/components'; import withSettings from '@/containers/Settings/withSettings'; import withDialogActions from '@/containers/Dialog/withDialogActions'; @@ -56,6 +59,7 @@ function InvoiceFormHeaderFields({ // Invoice form context. const { customers, projects } = useInvoiceFormContext(); + // Formik context. const { values } = useFormikContext(); // Handle invoice number changing. @@ -78,14 +82,6 @@ function InvoiceFormHeaderFields({ // Syncs invoice number settings with form. useObserveInvoiceNoSettings(invoiceNumberPrefix, invoiceNextNumber); - React.useEffect(() => { - if (values.project_id) { - openDialog('project-billable-entries', { - projectId: values.project_id, - }); - } - }, [values]); - return (
{/* ----------- Customer name ----------- */} @@ -254,6 +250,11 @@ function InvoiceFormHeaderFields({ input={InvoiceProjectSelectButton} popoverFill={true} /> + {values?.project_id && ( + + + + )}
);