Skip to content

Commit 75b62c7

Browse files
committed
fix new client from edit client page
1 parent 8114bea commit 75b62c7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

frontend/src/components/client/client-helpers.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ export const useClientState = (clientId: string) => {
7272
const [client, setSimpleClient] = useState(getNewClientState(storeClient));
7373
const clientAlreadyExists = useClientAlreadyExists(client);
7474

75-
useEffect(() => {
76-
if (storeClient) {
77-
setClient(getNewClientState(storeClient)!);
78-
}
79-
}, [storeClient]);
80-
8175
const setClient = (newClient: ClientModel): void => {
8276
if (newClient.country && client?.country !== newClient.country && !client?.defaultInvoiceLines.length && newClient.country !== 'BE') {
8377
let btwRemark: string;
@@ -96,6 +90,14 @@ export const useClientState = (clientId: string) => {
9690
setSimpleClient(newClient);
9791
};
9892

93+
useEffect(() => {
94+
if (storeClient) {
95+
setClient(getNewClientState(storeClient)!);
96+
} else {
97+
setSimpleClient(null);
98+
}
99+
}, [storeClient]);
100+
99101
return {
100102
client,
101103
setClient,

0 commit comments

Comments
 (0)