@accounter/client 0.0.8-alpha-20251023122652-765c7f951395441461726b3b4345eebd020632d7 → 0.0.8-alpha-20251023122900-7a815283add88dac9904c7a135ddeb225f89589c
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 +19 -16
- package/dist/assets/{Checkbox-CpANMiXr.js → Checkbox-Bu7lbyW3.js} +2 -2
- package/dist/assets/{Progress-BEKiyNRK.js → Progress-Cq1kNJW5.js} +1 -1
- package/dist/assets/{Typography-C0c5augK.js → Typography-qy9vYtPs.js} +1 -1
- package/dist/assets/{accordion-ZFVTCyDy.js → accordion-DOoNLp8s.js} +1 -1
- package/dist/assets/accountant-approvals-Be5zF2_c.js +1 -0
- package/dist/assets/{all-charges-BTyaAlp7.js → all-charges-CkXCeGgB.js} +1 -1
- package/dist/assets/{arrow-up-down-PQdrJdei.js → arrow-up-down-DvV6Dq8U.js} +1 -1
- package/dist/assets/building-2-B-rX_xIy.js +6 -0
- package/dist/assets/business-CNkwr3_Z.js +32 -0
- package/dist/assets/business-header-Drp6R3A0.js +1 -0
- package/dist/assets/{business-transactions-single-DJqvqlMO.js → business-transactions-single-BSpUxu3D.js} +1 -1
- package/dist/assets/{business-trip-BXAjI1mO.js → business-trip-Bv1KXZPV.js} +1 -1
- package/dist/assets/charges-filters-CpNNXLPU.js +1 -0
- package/dist/assets/{charges-ledger-validation-CFc_zJFO.js → charges-ledger-validation-BcO2gYIK.js} +1 -1
- package/dist/assets/{chart-C5LuxRSv.js → chart-Cg9PgOtK.js} +1 -1
- package/dist/assets/{data-table-pagination-g2cF8_uB.js → data-table-pagination-aFECnXu9.js} +1 -1
- package/dist/assets/{editable-business-trip-DyQsUJjl.js → editable-business-trip-qxr12Yt0.js} +2 -2
- package/dist/assets/index--C4Az49P.js +1 -0
- package/dist/assets/index-A1xHtOLI.js +1 -0
- package/dist/assets/{index-Bpef3vuz.js → index-B2_BlI07.js} +2 -2
- package/dist/assets/{index-C0OGGVXE.js → index-BDsbL_Kg.js} +2 -2
- package/dist/assets/{index-BSg8ocop.js → index-BFERto_M.js} +2 -2
- package/dist/assets/{index-gBZ-7Z07.js → index-BNXVR9UW.js} +1 -1
- package/dist/assets/{index-Is4LJW4y.js → index-BYyokQ1_.js} +2 -2
- package/dist/assets/index-BrsmDzry.js +1 -0
- package/dist/assets/index-C3AdAlvt.js +9 -0
- package/dist/assets/index-CD53YLxm.js +1 -0
- package/dist/assets/index-CY2CmEvR.js +1 -0
- package/dist/assets/index-Crn32InT.js +1 -0
- package/dist/assets/{index-6-J73JPC.js → index-CuIQrA5k.js} +1 -1
- package/dist/assets/index-CyI9xpFz.js +1 -0
- package/dist/assets/{index-CN2818Wt.js → index-DOrujuWI.js} +233 -223
- package/dist/assets/index-DStQk1jH.js +1 -0
- package/dist/assets/{index-C99l-a0m.js → index-Dh7go2PN.js} +1 -1
- package/dist/assets/index-DtE5Y1ZB.css +1 -0
- package/dist/assets/index-DwzG6-LK.js +1 -0
- package/dist/assets/{index-CJdrnxxy.js → index-GwuBtmZO.js} +2 -2
- package/dist/assets/{index-o_W5PWRq.js → index-M3bu66aM.js} +6 -6
- package/dist/assets/{index-S6eSocQH.js → index-aW2k8oov.js} +7 -7
- package/dist/assets/index-bPa4yB-5.js +1 -0
- package/dist/assets/index-vHwCjYSy.js +1 -0
- package/dist/assets/{index.es-DZgQ4YcV.js → index.es-Bg5AVQ7i.js} +1 -1
- package/dist/assets/{issue-document-D-JoFiMZ.js → issue-document-B4ZlDg1e.js} +1 -1
- package/dist/assets/login-page-v4kHU0le.js +1 -0
- package/dist/assets/{missing-info-charges-CPnjfjfW.js → missing-info-charges-Ck_n6s6i.js} +1 -1
- package/dist/assets/page-not-found-TWjTuISB.js +1 -0
- package/dist/assets/{pencil-BUwX_eHK.js → pencil-CpRI4b2y.js} +1 -1
- package/dist/assets/report-commentary-row-BNIW-6Qg.js +1 -0
- package/dist/assets/save-CjLvssI1.js +6 -0
- package/dist/assets/{sub-C2zifPY5.js → sub-Daf_8shG.js} +1 -1
- package/dist/assets/subMonths-DIZWyi5T.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/businesses/index.tsx +56 -39
- package/src/components/common/forms/index.ts +0 -1
- package/src/components/common/modals/insert-business.tsx +659 -51
- package/src/gql/gql.ts +6 -30
- package/src/gql/graphql.ts +7 -30
- package/src/providers/urql-client.ts +3 -2
- package/src/providers/urql.tsx +0 -5
- package/src/router/loaders/business-loader.ts +4 -2
- package/src/router/loaders/charge-loader.ts +4 -2
- package/dist/assets/accountant-approvals-CpzuSBgK.js +0 -1
- package/dist/assets/business-DiQFqEHI.js +0 -42
- package/dist/assets/charges-filters-r7FjeZLc.js +0 -1
- package/dist/assets/index-2g0J28D2.js +0 -1
- package/dist/assets/index-B5j8Fmt8.js +0 -1
- package/dist/assets/index-BSBV6pv2.js +0 -9
- package/dist/assets/index-BziuNiXZ.js +0 -1
- package/dist/assets/index-C7KKktQ5.js +0 -1
- package/dist/assets/index-CE3kLG2a.js +0 -1
- package/dist/assets/index-CjDRKTTf.js +0 -1
- package/dist/assets/index-CzzfC-dD.css +0 -1
- package/dist/assets/index-D2xdQJAx.js +0 -1
- package/dist/assets/index-DGvh10a7.js +0 -1
- package/dist/assets/index-DLI6Z9VU.js +0 -1
- package/dist/assets/index-DXL1qPt9.js +0 -1
- package/dist/assets/index-T-JiUNDA.js +0 -1
- package/dist/assets/login-page-DsHy5amR.js +0 -1
- package/dist/assets/page-not-found-CYmXF0n2.js +0 -1
- package/dist/assets/report-commentary-row-Bpvvtwpd.js +0 -1
- package/dist/assets/save-Ck68rh6u.js +0 -11
- package/dist/assets/similar-charges-by-business-modal-bUtiFfAw.js +0 -1
- package/dist/assets/subMonths-uUfFviD2.js +0 -1
- 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/forms/business-card.tsx +0 -234
- package/src/providers/urql-error-handler.ts +0 -27
|
@@ -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,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
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { toast } from 'sonner';
|
|
2
|
-
import type { OperationResult } from 'urql';
|
|
3
|
-
|
|
4
|
-
export function handleUrqlError(result: OperationResult) {
|
|
5
|
-
// Handle network errors
|
|
6
|
-
if (result.error?.networkError) {
|
|
7
|
-
console.error('Network Error:', result.error.networkError);
|
|
8
|
-
toast.error('Network Error', {
|
|
9
|
-
description: 'Failed to connect to the server. Please check your connection.',
|
|
10
|
-
duration: 5000,
|
|
11
|
-
});
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Handle common GraphQL errors with toast notifications
|
|
16
|
-
if (result.error?.graphQLErrors?.length) {
|
|
17
|
-
const graphqlError = result.error.graphQLErrors[0];
|
|
18
|
-
const { message } = graphqlError;
|
|
19
|
-
|
|
20
|
-
// Show toast for common GraphQL errors
|
|
21
|
-
console.error('GraphQL Error:', graphqlError);
|
|
22
|
-
toast.error('Operation Error', {
|
|
23
|
-
description: message || 'An error occurred while processing your request.',
|
|
24
|
-
duration: 5000,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|