File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { useEffect } from "react" ;
2
2
3
+ import type { OrganisationDetail } from "@squonk/account-server-client" ;
4
+ import { OrganisationDetailDefaultProductPrivacy } from "@squonk/account-server-client" ;
3
5
import { useGetDefaultOrganisation } from "@squonk/account-server-client/organisation" ;
4
6
import { useGetProduct } from "@squonk/account-server-client/product" ;
5
7
@@ -22,14 +24,20 @@ export const useSyncUnitAndOrgFromProduct = () => {
22
24
// First set the default org as the current org on first load
23
25
useEffect ( ( ) => {
24
26
// ensure the partial org is all there before "asserting" that it's an OrganisationDetail type
27
+ // TODO convert this check to use a zod schema
25
28
if (
26
29
typeof defaultOrg ?. id === "string" &&
27
- typeof defaultOrg . caller_is_member === "boolean" &&
30
+ defaultOrg . caller_is_member !== undefined &&
28
31
typeof defaultOrg . created === "string" &&
29
32
typeof defaultOrg . name === "string" &&
30
- typeof defaultOrg . private === "boolean"
33
+ defaultOrg . private !== undefined
31
34
) {
32
- setOrganisation ( defaultOrg as Required < typeof defaultOrg > ) ;
35
+ const defaultOrgCopy = {
36
+ ...defaultOrg ,
37
+ default_product_privacy : OrganisationDetailDefaultProductPrivacy . DEFAULT_PUBLIC ,
38
+ } as OrganisationDetail ;
39
+
40
+ setOrganisation ( defaultOrgCopy ) ;
33
41
}
34
42
} , [ defaultOrg , setOrganisation ] ) ;
35
43
You can’t perform that action at this time.
0 commit comments