File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
frontend/src/components/client Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -72,12 +72,6 @@ export const useClientState = (clientId: string) => {
72
72
const [ client , setSimpleClient ] = useState ( getNewClientState ( storeClient ) ) ;
73
73
const clientAlreadyExists = useClientAlreadyExists ( client ) ;
74
74
75
- useEffect ( ( ) => {
76
- if ( storeClient ) {
77
- setClient ( getNewClientState ( storeClient ) ! ) ;
78
- }
79
- } , [ storeClient ] ) ;
80
-
81
75
const setClient = ( newClient : ClientModel ) : void => {
82
76
if ( newClient . country && client ?. country !== newClient . country && ! client ?. defaultInvoiceLines . length && newClient . country !== 'BE' ) {
83
77
let btwRemark : string ;
@@ -96,6 +90,14 @@ export const useClientState = (clientId: string) => {
96
90
setSimpleClient ( newClient ) ;
97
91
} ;
98
92
93
+ useEffect ( ( ) => {
94
+ if ( storeClient ) {
95
+ setClient ( getNewClientState ( storeClient ) ! ) ;
96
+ } else {
97
+ setSimpleClient ( null ) ;
98
+ }
99
+ } , [ storeClient ] ) ;
100
+
99
101
return {
100
102
client,
101
103
setClient,
You can’t perform that action at this time.
0 commit comments