@accounter/client 0.0.8-alpha-20251022162652-6facbcde08fdda0fb354ba7105432df320367509 → 0.0.8-alpha-20251023065832-9a9f37786b0e29dc8e6ea58ec9856bc043cc0e8a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -2
- package/dist/assets/Checkbox-lfqFDKZM.js +6 -0
- package/dist/assets/Progress-DvGsu87E.js +1 -0
- package/dist/assets/Typography-BX4mj53o.js +1 -0
- package/dist/assets/accordion-lOk81yKP.js +1 -0
- package/dist/assets/accountant-approvals-DWLEu1Um.js +1 -0
- package/dist/assets/all-charges-DhPxcK73.js +1 -0
- package/dist/assets/arrow-up-down-CFrneqND.js +6 -0
- package/dist/assets/building-2-Bqvbwz7Q.js +6 -0
- package/dist/assets/business--eNnF4xF.js +42 -0
- package/dist/assets/business-header-DjutqTRC.js +1 -0
- package/dist/assets/business-transactions-single-CJ5pLN-D.js +1 -0
- package/dist/assets/business-trip-Jlc0bfXC.js +1 -0
- package/dist/assets/charges-filters-C-H07qp1.js +1 -0
- package/dist/assets/charges-ledger-validation-Bln73m_U.js +1 -0
- package/dist/assets/chart-Wut6cPCx.js +74 -0
- package/dist/assets/data-table-pagination-BnQGVnmE.js +11 -0
- package/dist/assets/editable-business-trip-CjJg13b0.js +16 -0
- package/dist/assets/graphql-document-dedupe-fragments-ByT8-wlV.js +1 -0
- package/dist/assets/index-BE5nnZYY.js +9 -0
- package/dist/assets/index-BQrSA2Kk.js +1 -0
- package/dist/assets/index-BX3VSsge.js +1 -0
- package/dist/assets/index-BagyRbeI.js +2 -0
- package/dist/assets/index-BkeJsHyM.js +1 -0
- package/dist/assets/index-BoSqeUi7.js +24 -0
- package/dist/assets/index-BtAgm6J8.js +1 -0
- package/dist/assets/index-BwIQ8ifH.js +1 -0
- package/dist/assets/index-Bxlzprxi.js +1 -0
- package/dist/assets/index-C--YkrHw.js +1 -0
- package/dist/assets/index-C2INIVq3.js +137 -0
- package/dist/assets/index-CN7VPpiB.js +876 -0
- package/dist/assets/index-CQXFj3Uj.css +1 -0
- package/dist/assets/index-CVz9TqoS.js +6 -0
- package/dist/assets/index-CalcGztb.js +1 -0
- package/dist/assets/index-Csqyxwgx.js +11 -0
- package/dist/assets/index-DjSJrgv5.js +2 -0
- package/dist/assets/index-DquDHLbE.js +17 -0
- package/dist/assets/index-Dr2UkUOm.js +1 -0
- package/dist/assets/index-E2rO9Bsf.js +1 -0
- package/dist/assets/index-Ggixi4PP.js +1 -0
- package/dist/assets/index-WCosiqtQ.js +1 -0
- package/dist/assets/index-vsZbkVMv.js +1 -0
- package/dist/assets/index-y8Z-aJKc.js +6 -0
- package/dist/assets/{index.es-Bh5tff8R.js → index.es-D8leRAY2.js} +5 -5
- package/dist/assets/issue-document-DKE0dzdE.js +1 -0
- package/dist/assets/login-page-BYwtRBMd.js +1 -0
- package/dist/assets/missing-info-charges-CgMJ4Bu3.js +1 -0
- package/dist/assets/page-not-found-Cfte6bjZ.js +1 -0
- package/dist/assets/pencil-CUSCcyVn.js +6 -0
- package/dist/assets/report-commentary-row-B-uxVnyO.js +1 -0
- package/dist/assets/save-qyt28nOG.js +6 -0
- package/dist/assets/sequential-CAnleQny.js +1 -0
- package/dist/assets/sub-LLu8afpC.js +1 -0
- package/dist/assets/subMonths-C1UIPrOU.js +1 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/components/business/business-header.tsx +21 -2
- package/src/components/business-transactions/business-extended-info.tsx +13 -15
- package/src/components/business-transactions/business-transactions-single.tsx +3 -3
- package/src/components/business-transactions/index.tsx +12 -1
- package/src/components/business-trips/business-trip.tsx +3 -3
- package/src/components/businesses/index.tsx +45 -36
- package/src/components/charges/cells/business-trip.tsx +6 -8
- package/src/components/charges/cells/counterparty.tsx +7 -5
- package/src/components/common/accounter-table.tsx +6 -5
- package/src/components/common/business-trip-report/parts/core-expense-row.tsx +11 -9
- package/src/components/common/business-trip-report/parts/uncategorized-transactions.tsx +11 -13
- package/src/components/common/buttons/index.ts +0 -2
- package/src/components/common/buttons/logout-button.tsx +7 -6
- package/src/components/common/documents-to-charge-matcher/selection-handler/index.tsx +4 -2
- package/src/components/common/documents-to-charge-matcher/selection-handler/wide-filtered-selection.tsx +5 -7
- package/src/components/common/forms/edit-document.tsx +21 -10
- package/src/components/common/forms/index.ts +0 -1
- package/src/components/common/new-documents-list.tsx +10 -8
- package/src/components/documents-table/cells/creditor.tsx +11 -4
- package/src/components/documents-table/cells/debtor.tsx +11 -4
- package/src/components/error-boundary.tsx +189 -0
- package/src/components/layout/breadcrumbs.tsx +72 -0
- package/src/components/layout/dashboard-layout.tsx +4 -0
- package/src/components/layout/document-title.tsx +26 -0
- package/src/components/layout/navigation-progress.tsx +52 -0
- package/src/components/layout/page-skeleton.tsx +49 -0
- package/src/components/layout/sidelinks.tsx +28 -27
- package/src/components/ledger-table/counterparty-cell.tsx +19 -13
- package/src/components/login-page.tsx +2 -1
- package/src/components/reports/corporate-tax-ruling-compliance-report/index.tsx +3 -3
- package/src/components/reports/profit-and-loss-report/index.tsx +3 -3
- package/src/components/reports/tax-report/index.tsx +3 -3
- package/src/components/screens/businesses/business.tsx +21 -9
- package/src/components/screens/charges/charge.tsx +22 -9
- package/src/components/transactions-table/cells/counterparty.tsx +9 -2
- package/src/components/transactions-table/cells-legacy/counterparty.tsx +9 -2
- package/src/gql/gql.ts +6 -30
- package/src/gql/graphql.ts +7 -30
- package/src/index.tsx +4 -22
- package/src/providers/auth-guard.tsx +14 -23
- package/src/providers/index.tsx +7 -2
- package/src/providers/urql-client.ts +86 -0
- package/src/providers/urql.tsx +7 -12
- package/src/providers/user-provider.tsx +3 -2
- package/src/router/config.tsx +534 -0
- package/src/router/layouts/dashboard-layout.tsx +20 -0
- package/src/router/layouts/root-layout.tsx +69 -0
- package/src/router/loaders/auth-loader.ts +32 -0
- package/src/router/loaders/business-loader.ts +25 -0
- package/src/router/loaders/charge-loader.ts +25 -0
- package/src/router/loaders/index.ts +17 -0
- package/src/router/routes.ts +88 -0
- package/src/router/types.ts +68 -0
- package/dist/assets/index-B2UYAO1O.css +0 -1
- package/dist/assets/index-D312yRtG.js +0 -1229
- package/src/components/businesses/all-businesses-row.tsx +0 -87
- package/src/components/businesses/cells/hebrew-name.tsx +0 -31
- package/src/components/businesses/cells/index.ts +0 -2
- package/src/components/businesses/cells/name.tsx +0 -31
- package/src/components/common/buttons/button-with-label.tsx +0 -41
- package/src/components/common/buttons/button.tsx +0 -44
- package/src/components/common/forms/business-card.tsx +0 -234
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { useState, type ReactElement } from 'react';
|
|
2
|
-
import { PanelTopClose, PanelTopOpen } from 'lucide-react';
|
|
3
|
-
import { Paper } from '@mantine/core';
|
|
4
|
-
import {
|
|
5
|
-
AllBusinessesRowFieldsFragmentDoc,
|
|
6
|
-
type AllBusinessesForScreenQuery,
|
|
7
|
-
type AllBusinessesRowFieldsFragment,
|
|
8
|
-
} from '../../gql/graphql.js';
|
|
9
|
-
import { getFragmentData } from '../../gql/index.js';
|
|
10
|
-
import { BusinessCard, ToggleMergeSelected } from '../common/index.js';
|
|
11
|
-
import { Button } from '../ui/button.js';
|
|
12
|
-
import { HebrewName } from './cells/hebrew-name.js';
|
|
13
|
-
import { Name } from './cells/name.js';
|
|
14
|
-
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- used by codegen
|
|
16
|
-
/* GraphQL */ `
|
|
17
|
-
fragment AllBusinessesRowFields on LtdFinancialEntity {
|
|
18
|
-
id
|
|
19
|
-
...AllBusinessesNameFields
|
|
20
|
-
...AllBusinessesHebrewNameFields
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
interface Props {
|
|
25
|
-
data: Extract<
|
|
26
|
-
NonNullable<AllBusinessesForScreenQuery['allBusinesses']>['nodes'][number],
|
|
27
|
-
{ __typename: 'LtdFinancialEntity' }
|
|
28
|
-
>;
|
|
29
|
-
isAllOpened: boolean;
|
|
30
|
-
toggleMergeBusiness?: (onChange: () => void) => void;
|
|
31
|
-
isSelectedForMerge: boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const AllBusinessesRow = ({
|
|
35
|
-
data,
|
|
36
|
-
isAllOpened,
|
|
37
|
-
toggleMergeBusiness,
|
|
38
|
-
isSelectedForMerge,
|
|
39
|
-
}: Props): ReactElement => {
|
|
40
|
-
const [opened, setOpened] = useState(false);
|
|
41
|
-
const [business, setBusiness] = useState<AllBusinessesRowFieldsFragment>(
|
|
42
|
-
getFragmentData(AllBusinessesRowFieldsFragmentDoc, data),
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<>
|
|
47
|
-
<tr>
|
|
48
|
-
<Name data={business} />
|
|
49
|
-
<HebrewName data={business} />
|
|
50
|
-
<td>
|
|
51
|
-
<div className="flex flex-col gap-2">
|
|
52
|
-
<Button
|
|
53
|
-
variant="outline"
|
|
54
|
-
size="icon"
|
|
55
|
-
className="size-7.5"
|
|
56
|
-
onClick={(): void => {
|
|
57
|
-
setOpened(i => !i);
|
|
58
|
-
}}
|
|
59
|
-
>
|
|
60
|
-
{isAllOpened || opened ? (
|
|
61
|
-
<PanelTopClose className="size-5" />
|
|
62
|
-
) : (
|
|
63
|
-
<PanelTopOpen className="size-5" />
|
|
64
|
-
)}
|
|
65
|
-
</Button>
|
|
66
|
-
|
|
67
|
-
{toggleMergeBusiness && (
|
|
68
|
-
<ToggleMergeSelected
|
|
69
|
-
toggleMergeSelected={(): void => toggleMergeBusiness(() => {})}
|
|
70
|
-
mergeSelected={isSelectedForMerge}
|
|
71
|
-
/>
|
|
72
|
-
)}
|
|
73
|
-
</div>
|
|
74
|
-
</td>
|
|
75
|
-
</tr>
|
|
76
|
-
{(isAllOpened || opened) && (
|
|
77
|
-
<tr>
|
|
78
|
-
<td colSpan={12}>
|
|
79
|
-
<Paper style={{ width: '100%' }} withBorder shadow="lg">
|
|
80
|
-
<BusinessCard businessID={business.id} updateBusiness={setBusiness} />
|
|
81
|
-
</Paper>
|
|
82
|
-
</td>
|
|
83
|
-
</tr>
|
|
84
|
-
)}
|
|
85
|
-
</>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { ReactElement } from 'react';
|
|
2
|
-
import { AllBusinessesHebrewNameFieldsFragmentDoc } from '../../../gql/graphql.js';
|
|
3
|
-
import { getFragmentData, type FragmentType } from '../../../gql/index.js';
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- used by codegen
|
|
6
|
-
/* GraphQL */ `
|
|
7
|
-
fragment AllBusinessesHebrewNameFields on LtdFinancialEntity {
|
|
8
|
-
id
|
|
9
|
-
hebrewName
|
|
10
|
-
}
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
data: FragmentType<typeof AllBusinessesHebrewNameFieldsFragmentDoc>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const HebrewName = ({ data }: Props): ReactElement => {
|
|
18
|
-
const business = getFragmentData(AllBusinessesHebrewNameFieldsFragmentDoc, data);
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<td>
|
|
22
|
-
<div
|
|
23
|
-
style={{
|
|
24
|
-
whiteSpace: 'nowrap',
|
|
25
|
-
}}
|
|
26
|
-
>
|
|
27
|
-
{business.hebrewName}
|
|
28
|
-
</div>
|
|
29
|
-
</td>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type ReactElement } from 'react';
|
|
2
|
-
import { AllBusinessesNameFieldsFragmentDoc } from '../../../gql/graphql.js';
|
|
3
|
-
import { getFragmentData, type FragmentType } from '../../../gql/index.js';
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- used by codegen
|
|
6
|
-
/* GraphQL */ `
|
|
7
|
-
fragment AllBusinessesNameFields on LtdFinancialEntity {
|
|
8
|
-
id
|
|
9
|
-
name
|
|
10
|
-
}
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
data: FragmentType<typeof AllBusinessesNameFieldsFragmentDoc>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const Name = ({ data }: Props): ReactElement => {
|
|
18
|
-
const business = getFragmentData(AllBusinessesNameFieldsFragmentDoc, data);
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<td>
|
|
22
|
-
<div
|
|
23
|
-
style={{
|
|
24
|
-
whiteSpace: 'nowrap',
|
|
25
|
-
}}
|
|
26
|
-
>
|
|
27
|
-
{business.name}
|
|
28
|
-
</div>
|
|
29
|
-
</td>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { CSSProperties, MouseEventHandler, ReactElement } from 'react';
|
|
2
|
-
|
|
3
|
-
export interface ButtonWithLabelProps {
|
|
4
|
-
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
5
|
-
type?: 'submit' | 'button';
|
|
6
|
-
style?: CSSProperties;
|
|
7
|
-
target?: string;
|
|
8
|
-
rel?: string;
|
|
9
|
-
title?: string;
|
|
10
|
-
url?: string;
|
|
11
|
-
textLabel?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const ButtonWithLabel = ({
|
|
15
|
-
title,
|
|
16
|
-
url,
|
|
17
|
-
style,
|
|
18
|
-
target,
|
|
19
|
-
textLabel,
|
|
20
|
-
rel,
|
|
21
|
-
type = 'button',
|
|
22
|
-
onClick,
|
|
23
|
-
}: ButtonWithLabelProps): ReactElement => {
|
|
24
|
-
return (
|
|
25
|
-
<div>
|
|
26
|
-
<label className="text-sm font-medium text-gray-700">{textLabel}</label>
|
|
27
|
-
<div>
|
|
28
|
-
<button
|
|
29
|
-
style={style}
|
|
30
|
-
type={type}
|
|
31
|
-
onClick={onClick}
|
|
32
|
-
className="bg-gray-100 border focus:ring-2 focus:ring-indigo-200 focus:bg-transparent hover:bg-indigo-500 hover:text-white text-base outline-hidden text-gray-700 py-1 px-3 leading-8 transition-colors duration-200 ease-in-out sm:text-sm rounded-md"
|
|
33
|
-
>
|
|
34
|
-
<a rel={rel} target={target} href={url} type={type}>
|
|
35
|
-
{title}
|
|
36
|
-
</a>
|
|
37
|
-
</button>
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ButtonHTMLAttributes,
|
|
3
|
-
CSSProperties,
|
|
4
|
-
DetailedHTMLProps,
|
|
5
|
-
MouseEventHandler,
|
|
6
|
-
ReactElement,
|
|
7
|
-
} from 'react';
|
|
8
|
-
|
|
9
|
-
export interface Props
|
|
10
|
-
extends DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
|
|
11
|
-
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
12
|
-
herf?: string;
|
|
13
|
-
type?: 'submit' | 'button';
|
|
14
|
-
style?: CSSProperties;
|
|
15
|
-
target?: string;
|
|
16
|
-
rel?: string;
|
|
17
|
-
title?: string;
|
|
18
|
-
url?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const Button = ({
|
|
22
|
-
title,
|
|
23
|
-
herf,
|
|
24
|
-
style,
|
|
25
|
-
target,
|
|
26
|
-
rel,
|
|
27
|
-
type = 'button',
|
|
28
|
-
onClick,
|
|
29
|
-
...props
|
|
30
|
-
}: Props): ReactElement => {
|
|
31
|
-
return (
|
|
32
|
-
<button
|
|
33
|
-
style={style}
|
|
34
|
-
type={type}
|
|
35
|
-
onClick={onClick}
|
|
36
|
-
className="cursor: pointer text-align: center flex ml-auto text-white bg-indigo-500 border-0 py-1.5 px-3 focus:outline-hidden hover:bg-indigo-600 rounded-sm;"
|
|
37
|
-
{...props}
|
|
38
|
-
>
|
|
39
|
-
<a rel={rel} target={target} href={herf} type={type}>
|
|
40
|
-
{title}
|
|
41
|
-
</a>
|
|
42
|
-
</button>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect, useState, type ReactElement } from 'react';
|
|
2
|
-
import { useForm, type SubmitHandler } from 'react-hook-form';
|
|
3
|
-
import { useQuery, type UseQueryExecute } from 'urql';
|
|
4
|
-
import { Loader } from '@mantine/core';
|
|
5
|
-
import {
|
|
6
|
-
FetchBusinessDocument,
|
|
7
|
-
type AllBusinessesRowFieldsFragment,
|
|
8
|
-
type FetchBusinessQuery,
|
|
9
|
-
type UpdateBusinessInput,
|
|
10
|
-
} from '../../../gql/graphql.js';
|
|
11
|
-
import { relevantDataPicker, type MakeBoolean } from '../../../helpers/index.js';
|
|
12
|
-
import { useUpdateBusiness } from '../../../hooks/use-update-business.js';
|
|
13
|
-
import { UserContext } from '../../../providers/user-provider.js';
|
|
14
|
-
import { Form } from '../../ui/form.js';
|
|
15
|
-
import { CopyToClipboardButton, SimilarChargesByBusinessModal } from '../index.js';
|
|
16
|
-
import { ModifyBusinessFields } from './modify-business-fields.js';
|
|
17
|
-
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- used by codegen
|
|
19
|
-
/* GraphQL */ `
|
|
20
|
-
query FetchBusiness($id: UUID!) {
|
|
21
|
-
business(id: $id) {
|
|
22
|
-
__typename
|
|
23
|
-
id
|
|
24
|
-
... on LtdFinancialEntity {
|
|
25
|
-
country
|
|
26
|
-
address
|
|
27
|
-
email
|
|
28
|
-
exemptDealer
|
|
29
|
-
governmentId
|
|
30
|
-
hebrewName
|
|
31
|
-
name
|
|
32
|
-
phoneNumber
|
|
33
|
-
sortCode {
|
|
34
|
-
id
|
|
35
|
-
key
|
|
36
|
-
name
|
|
37
|
-
}
|
|
38
|
-
taxCategory {
|
|
39
|
-
id
|
|
40
|
-
name
|
|
41
|
-
}
|
|
42
|
-
website
|
|
43
|
-
suggestions {
|
|
44
|
-
phrases
|
|
45
|
-
tags {
|
|
46
|
-
id
|
|
47
|
-
name
|
|
48
|
-
}
|
|
49
|
-
description
|
|
50
|
-
emails
|
|
51
|
-
emailListener {
|
|
52
|
-
internalEmailLinks
|
|
53
|
-
emailBody
|
|
54
|
-
attachments
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
optionalVAT
|
|
58
|
-
irsCode
|
|
59
|
-
pcn874RecordType
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
|
-
interface Props {
|
|
66
|
-
businessID: string;
|
|
67
|
-
updateBusiness: React.Dispatch<React.SetStateAction<AllBusinessesRowFieldsFragment>>;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function BusinessCard({ businessID, updateBusiness }: Props): ReactElement {
|
|
71
|
-
const [business, setBusiness] = useState<
|
|
72
|
-
Extract<FetchBusinessQuery['business'], { __typename: 'LtdFinancialEntity' }> | undefined
|
|
73
|
-
>(undefined);
|
|
74
|
-
|
|
75
|
-
// Form business data handle
|
|
76
|
-
const [{ data, fetching: businessFetching }, refetchBusiness] = useQuery({
|
|
77
|
-
query: FetchBusinessDocument,
|
|
78
|
-
variables: {
|
|
79
|
-
id: businessID,
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
if (businessFetching) {
|
|
85
|
-
setBusiness(undefined);
|
|
86
|
-
} else if (data && data.business.__typename === 'LtdFinancialEntity') {
|
|
87
|
-
setBusiness(data.business);
|
|
88
|
-
}
|
|
89
|
-
}, [data, businessFetching]);
|
|
90
|
-
|
|
91
|
-
// on every business successful fetch, update the business in the parent component
|
|
92
|
-
useEffect(() => {
|
|
93
|
-
if (business) {
|
|
94
|
-
updateBusiness(business);
|
|
95
|
-
}
|
|
96
|
-
}, [business, updateBusiness]);
|
|
97
|
-
|
|
98
|
-
return (
|
|
99
|
-
<div className="flex flex-col gap-5">
|
|
100
|
-
{business ? (
|
|
101
|
-
<BusinessCardContent business={business} refetchBusiness={refetchBusiness} />
|
|
102
|
-
) : businessFetching ? (
|
|
103
|
-
<Loader className="flex self-center my-5" color="dark" size="xl" variant="dots" />
|
|
104
|
-
) : (
|
|
105
|
-
<p>Error fetching extended information for this business</p>
|
|
106
|
-
)}
|
|
107
|
-
</div>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
interface ContentProps {
|
|
112
|
-
business: Extract<FetchBusinessQuery['business'], { __typename: 'LtdFinancialEntity' }>;
|
|
113
|
-
refetchBusiness: UseQueryExecute;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function BusinessCardContent({ business, refetchBusiness }: ContentProps): ReactElement {
|
|
117
|
-
const [fetching, setFetching] = useState<boolean>(false);
|
|
118
|
-
const [similarChargesOpen, setSimilarChargesOpen] = useState(false);
|
|
119
|
-
const [similarChargesData, setSimilarChargesData] = useState<
|
|
120
|
-
| {
|
|
121
|
-
tagIds?: { id: string }[];
|
|
122
|
-
description?: string;
|
|
123
|
-
}
|
|
124
|
-
| undefined
|
|
125
|
-
>(undefined);
|
|
126
|
-
const { userContext } = useContext(UserContext);
|
|
127
|
-
|
|
128
|
-
const { updateBusiness: updateDbBusiness, fetching: isBusinessLoading } = useUpdateBusiness();
|
|
129
|
-
|
|
130
|
-
// form management
|
|
131
|
-
const formManager = useForm<UpdateBusinessInput>({
|
|
132
|
-
defaultValues: {
|
|
133
|
-
...business,
|
|
134
|
-
taxCategory: business.taxCategory?.id,
|
|
135
|
-
sortCode: business?.sortCode?.key,
|
|
136
|
-
irsCode: business?.irsCode,
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
const {
|
|
141
|
-
handleSubmit: handleBusinessSubmit,
|
|
142
|
-
formState: { dirtyFields: dirtyBusinessFields },
|
|
143
|
-
} = formManager;
|
|
144
|
-
|
|
145
|
-
const onBusinessSubmit: SubmitHandler<UpdateBusinessInput> = async data => {
|
|
146
|
-
if (!business || !userContext?.context.adminBusinessId) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const dataToUpdate = relevantDataPicker(data, dirtyBusinessFields as MakeBoolean<typeof data>);
|
|
151
|
-
if (dataToUpdate && Object.keys(dataToUpdate).length > 0) {
|
|
152
|
-
dataToUpdate.sortCode &&= parseInt(dataToUpdate.sortCode.toString());
|
|
153
|
-
|
|
154
|
-
if (dataToUpdate.suggestions?.tags) {
|
|
155
|
-
dataToUpdate.suggestions.tags = dataToUpdate.suggestions.tags.map(tag => ({ id: tag.id }));
|
|
156
|
-
}
|
|
157
|
-
if (dataToUpdate.suggestions?.phrases) {
|
|
158
|
-
dataToUpdate.suggestions.phrases = data.suggestions!.phrases!.map(phrase => phrase);
|
|
159
|
-
}
|
|
160
|
-
if (dataToUpdate.suggestions?.emails) {
|
|
161
|
-
dataToUpdate.suggestions.emails = data.suggestions!.emails!.map(email => email);
|
|
162
|
-
}
|
|
163
|
-
if (dataToUpdate.suggestions?.emailListener) {
|
|
164
|
-
dataToUpdate.suggestions.emailListener.attachments &&=
|
|
165
|
-
data.suggestions!.emailListener!.attachments!.map(type => type);
|
|
166
|
-
dataToUpdate.suggestions.emailListener.internalEmailLinks &&=
|
|
167
|
-
data.suggestions!.emailListener!.internalEmailLinks!.map(link => link);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
await updateDbBusiness({
|
|
171
|
-
businessId: business.id,
|
|
172
|
-
ownerId: userContext.context.adminBusinessId,
|
|
173
|
-
fields: dataToUpdate,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
if (dataToUpdate.suggestions?.tags?.length || dataToUpdate.suggestions?.description) {
|
|
177
|
-
setSimilarChargesData({
|
|
178
|
-
tagIds: dataToUpdate.suggestions?.tags?.map(t => ({ id: t.id })),
|
|
179
|
-
description: dataToUpdate.suggestions?.description ?? undefined,
|
|
180
|
-
});
|
|
181
|
-
setSimilarChargesOpen(true);
|
|
182
|
-
} else {
|
|
183
|
-
refetchBusiness();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
return (
|
|
189
|
-
<>
|
|
190
|
-
{fetching && (
|
|
191
|
-
<Loader className="flex self-center my-5" color="dark" size="xl" variant="dots" />
|
|
192
|
-
)}
|
|
193
|
-
<div className="flex flex-row gap-5">
|
|
194
|
-
<Form {...formManager}>
|
|
195
|
-
<form onSubmit={handleBusinessSubmit(onBusinessSubmit)}>
|
|
196
|
-
<div className="flex flex-row mx-3 pt-3 sm:text-1xl gap-10">
|
|
197
|
-
<h1 className="sm:text-2xl font-small text-gray-900">Edit Business:</h1>
|
|
198
|
-
<div className="flex flex-row gap-2">
|
|
199
|
-
ID: {business.id}
|
|
200
|
-
<CopyToClipboardButton content={business.id} />
|
|
201
|
-
</div>
|
|
202
|
-
</div>
|
|
203
|
-
<div className="flex-row px-10 h-max justify-start block">
|
|
204
|
-
<ModifyBusinessFields
|
|
205
|
-
isInsert={false}
|
|
206
|
-
formManager={formManager}
|
|
207
|
-
setFetching={setFetching}
|
|
208
|
-
/>
|
|
209
|
-
</div>
|
|
210
|
-
<div className="mt-10 mb-5 flex justify-center gap-5">
|
|
211
|
-
<button
|
|
212
|
-
type="submit"
|
|
213
|
-
onClick={(): (() => Promise<void>) => handleBusinessSubmit(onBusinessSubmit)}
|
|
214
|
-
className="mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg"
|
|
215
|
-
disabled={isBusinessLoading || Object.keys(dirtyBusinessFields).length === 0}
|
|
216
|
-
>
|
|
217
|
-
Update
|
|
218
|
-
</button>
|
|
219
|
-
</div>
|
|
220
|
-
</form>
|
|
221
|
-
</Form>
|
|
222
|
-
</div>
|
|
223
|
-
|
|
224
|
-
<SimilarChargesByBusinessModal
|
|
225
|
-
businessId={business.id}
|
|
226
|
-
tagIds={similarChargesData?.tagIds}
|
|
227
|
-
description={similarChargesData?.description}
|
|
228
|
-
open={similarChargesOpen}
|
|
229
|
-
onOpenChange={setSimilarChargesOpen}
|
|
230
|
-
onClose={refetchBusiness}
|
|
231
|
-
/>
|
|
232
|
-
</>
|
|
233
|
-
);
|
|
234
|
-
}
|