@payloadcms/plugin-multi-tenant 3.28.0-internal.c4e1bed → 3.28.1

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.
Files changed (29) hide show
  1. package/dist/components/TenantField/index.client.d.ts.map +1 -1
  2. package/dist/components/TenantField/index.client.js +2 -3
  3. package/dist/components/TenantField/index.client.js.map +1 -1
  4. package/dist/components/TenantSelector/index.d.ts.map +1 -1
  5. package/dist/components/TenantSelector/index.js +1 -2
  6. package/dist/components/TenantSelector/index.js.map +1 -1
  7. package/dist/list-filters/filterDocumentsBySelectedTenant.d.ts.map +1 -1
  8. package/dist/list-filters/filterDocumentsBySelectedTenant.js +7 -8
  9. package/dist/list-filters/filterDocumentsBySelectedTenant.js.map +1 -1
  10. package/dist/list-filters/filterTenantsBySelectedTenant.d.ts.map +1 -1
  11. package/dist/list-filters/filterTenantsBySelectedTenant.js +7 -8
  12. package/dist/list-filters/filterTenantsBySelectedTenant.js.map +1 -1
  13. package/dist/list-filters/filterUsersBySelectedTenant.d.ts.map +1 -1
  14. package/dist/list-filters/filterUsersBySelectedTenant.js +9 -10
  15. package/dist/list-filters/filterUsersBySelectedTenant.js.map +1 -1
  16. package/dist/providers/TenantSelectionProvider/index.client.d.ts.map +1 -1
  17. package/dist/providers/TenantSelectionProvider/index.client.js +15 -10
  18. package/dist/providers/TenantSelectionProvider/index.client.js.map +1 -1
  19. package/dist/providers/TenantSelectionProvider/index.d.ts.map +1 -1
  20. package/dist/providers/TenantSelectionProvider/index.js +9 -7
  21. package/dist/providers/TenantSelectionProvider/index.js.map +1 -1
  22. package/dist/utilities/getGlobalViewRedirect.d.ts.map +1 -1
  23. package/dist/utilities/getGlobalViewRedirect.js +1 -2
  24. package/dist/utilities/getGlobalViewRedirect.js.map +1 -1
  25. package/package.json +7 -7
  26. package/dist/constants.d.ts +0 -2
  27. package/dist/constants.d.ts.map +0 -1
  28. package/dist/constants.js +0 -4
  29. package/dist/constants.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../src/components/TenantField/index.client.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AAG3D,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,cAAc,CAAA;AAIrB,KAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,GAAG,4BAA4B,CAAA;AAEhC,eAAO,MAAM,WAAW,SAAU,KAAK,6BAgDtC,CAAA"}
1
+ {"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../src/components/TenantField/index.client.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AAG3D,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,cAAc,CAAA;AAIrB,KAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,GAAG,4BAA4B,CAAA;AAEhC,eAAO,MAAM,WAAW,SAAU,KAAK,6BA6CtC,CAAA"}
@@ -2,7 +2,6 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { RelationshipField, useField } from '@payloadcms/ui';
4
4
  import React from 'react';
5
- import { SELECT_ALL } from '../../constants.js';
6
5
  import { useTenantSelection } from '../../providers/TenantSelectionProvider/index.client.js';
7
6
  import './index.scss';
8
7
  const baseClass = 'tenantField';
@@ -23,14 +22,14 @@ export const TenantField = (args)=>{
23
22
  });
24
23
  } else {
25
24
  // in the document view, the tenant field should always have a value
26
- const defaultValue = !selectedTenantID || selectedTenantID === SELECT_ALL ? options[0]?.value : selectedTenantID;
25
+ const defaultValue = selectedTenantID || options[0]?.value;
27
26
  setTenant({
28
27
  id: defaultValue,
29
28
  refresh: unique
30
29
  });
31
30
  }
32
31
  hasSetValueRef.current = true;
33
- } else if ((!value || value !== selectedTenantID) && selectedTenantID !== SELECT_ALL) {
32
+ } else if (!value || value !== selectedTenantID) {
34
33
  // Update the field on the document value when the tenant is changed
35
34
  setValue(selectedTenantID);
36
35
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/TenantField/index.client.tsx"],"sourcesContent":["'use client'\n\nimport type { RelationshipFieldClientProps } from 'payload'\n\nimport { RelationshipField, useField } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { SELECT_ALL } from '../../constants.js'\nimport { useTenantSelection } from '../../providers/TenantSelectionProvider/index.client.js'\nimport './index.scss'\n\nconst baseClass = 'tenantField'\n\ntype Props = {\n debug?: boolean\n unique?: boolean\n} & RelationshipFieldClientProps\n\nexport const TenantField = (args: Props) => {\n const { debug, path, unique } = args\n const { setValue, value } = useField<number | string>({ path })\n const { options, selectedTenantID, setPreventRefreshOnChange, setTenant } = useTenantSelection()\n\n const hasSetValueRef = React.useRef(false)\n\n React.useEffect(() => {\n if (!hasSetValueRef.current) {\n // set value on load\n if (value && value !== selectedTenantID) {\n setTenant({ id: value, refresh: unique })\n } else {\n // in the document view, the tenant field should always have a value\n const defaultValue =\n !selectedTenantID || selectedTenantID === SELECT_ALL\n ? options[0]?.value\n : selectedTenantID\n setTenant({ id: defaultValue, refresh: unique })\n }\n hasSetValueRef.current = true\n } else if ((!value || value !== selectedTenantID) && selectedTenantID !== SELECT_ALL) {\n // Update the field on the document value when the tenant is changed\n setValue(selectedTenantID)\n }\n }, [value, selectedTenantID, setTenant, setValue, options, unique])\n\n React.useEffect(() => {\n if (!unique) {\n setPreventRefreshOnChange(true)\n }\n return () => {\n setPreventRefreshOnChange(false)\n }\n }, [unique, setPreventRefreshOnChange])\n\n if (debug) {\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrapper`}>\n <RelationshipField {...args} />\n </div>\n <div className={`${baseClass}__hr`} />\n </div>\n )\n }\n\n return null\n}\n"],"names":["RelationshipField","useField","React","SELECT_ALL","useTenantSelection","baseClass","TenantField","args","debug","path","unique","setValue","value","options","selectedTenantID","setPreventRefreshOnChange","setTenant","hasSetValueRef","useRef","useEffect","current","id","refresh","defaultValue","div","className"],"mappings":"AAAA;;AAIA,SAASA,iBAAiB,EAAEC,QAAQ,QAAQ,iBAAgB;AAC5D,OAAOC,WAAW,QAAO;AAEzB,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,kBAAkB,QAAQ,0DAAyD;AAC5F,OAAO,eAAc;AAErB,MAAMC,YAAY;AAOlB,OAAO,MAAMC,cAAc,CAACC;IAC1B,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGH;IAChC,MAAM,EAAEI,QAAQ,EAAEC,KAAK,EAAE,GAAGX,SAA0B;QAAEQ;IAAK;IAC7D,MAAM,EAAEI,OAAO,EAAEC,gBAAgB,EAAEC,yBAAyB,EAAEC,SAAS,EAAE,GAAGZ;IAE5E,MAAMa,iBAAiBf,MAAMgB,MAAM,CAAC;IAEpChB,MAAMiB,SAAS,CAAC;QACd,IAAI,CAACF,eAAeG,OAAO,EAAE;YAC3B,oBAAoB;YACpB,IAAIR,SAASA,UAAUE,kBAAkB;gBACvCE,UAAU;oBAAEK,IAAIT;oBAAOU,SAASZ;gBAAO;YACzC,OAAO;gBACL,oEAAoE;gBACpE,MAAMa,eACJ,CAACT,oBAAoBA,qBAAqBX,aACtCU,OAAO,CAAC,EAAE,EAAED,QACZE;gBACNE,UAAU;oBAAEK,IAAIE;oBAAcD,SAASZ;gBAAO;YAChD;YACAO,eAAeG,OAAO,GAAG;QAC3B,OAAO,IAAI,AAAC,CAAA,CAACR,SAASA,UAAUE,gBAAe,KAAMA,qBAAqBX,YAAY;YACpF,oEAAoE;YACpEQ,SAASG;QACX;IACF,GAAG;QAACF;QAAOE;QAAkBE;QAAWL;QAAUE;QAASH;KAAO;IAElER,MAAMiB,SAAS,CAAC;QACd,IAAI,CAACT,QAAQ;YACXK,0BAA0B;QAC5B;QACA,OAAO;YACLA,0BAA0B;QAC5B;IACF,GAAG;QAACL;QAAQK;KAA0B;IAEtC,IAAIP,OAAO;QACT,qBACE,MAACgB;YAAIC,WAAWpB;;8BACd,KAACmB;oBAAIC,WAAW,GAAGpB,UAAU,SAAS,CAAC;8BACrC,cAAA,KAACL;wBAAmB,GAAGO,IAAI;;;8BAE7B,KAACiB;oBAAIC,WAAW,GAAGpB,UAAU,IAAI,CAAC;;;;IAGxC;IAEA,OAAO;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/components/TenantField/index.client.tsx"],"sourcesContent":["'use client'\n\nimport type { RelationshipFieldClientProps } from 'payload'\n\nimport { RelationshipField, useField } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { useTenantSelection } from '../../providers/TenantSelectionProvider/index.client.js'\nimport './index.scss'\n\nconst baseClass = 'tenantField'\n\ntype Props = {\n debug?: boolean\n unique?: boolean\n} & RelationshipFieldClientProps\n\nexport const TenantField = (args: Props) => {\n const { debug, path, unique } = args\n const { setValue, value } = useField<number | string>({ path })\n const { options, selectedTenantID, setPreventRefreshOnChange, setTenant } = useTenantSelection()\n\n const hasSetValueRef = React.useRef(false)\n\n React.useEffect(() => {\n if (!hasSetValueRef.current) {\n // set value on load\n if (value && value !== selectedTenantID) {\n setTenant({ id: value, refresh: unique })\n } else {\n // in the document view, the tenant field should always have a value\n const defaultValue = selectedTenantID || options[0]?.value\n setTenant({ id: defaultValue, refresh: unique })\n }\n hasSetValueRef.current = true\n } else if (!value || value !== selectedTenantID) {\n // Update the field on the document value when the tenant is changed\n setValue(selectedTenantID)\n }\n }, [value, selectedTenantID, setTenant, setValue, options, unique])\n\n React.useEffect(() => {\n if (!unique) {\n setPreventRefreshOnChange(true)\n }\n return () => {\n setPreventRefreshOnChange(false)\n }\n }, [unique, setPreventRefreshOnChange])\n\n if (debug) {\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrapper`}>\n <RelationshipField {...args} />\n </div>\n <div className={`${baseClass}__hr`} />\n </div>\n )\n }\n\n return null\n}\n"],"names":["RelationshipField","useField","React","useTenantSelection","baseClass","TenantField","args","debug","path","unique","setValue","value","options","selectedTenantID","setPreventRefreshOnChange","setTenant","hasSetValueRef","useRef","useEffect","current","id","refresh","defaultValue","div","className"],"mappings":"AAAA;;AAIA,SAASA,iBAAiB,EAAEC,QAAQ,QAAQ,iBAAgB;AAC5D,OAAOC,WAAW,QAAO;AAEzB,SAASC,kBAAkB,QAAQ,0DAAyD;AAC5F,OAAO,eAAc;AAErB,MAAMC,YAAY;AAOlB,OAAO,MAAMC,cAAc,CAACC;IAC1B,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGH;IAChC,MAAM,EAAEI,QAAQ,EAAEC,KAAK,EAAE,GAAGV,SAA0B;QAAEO;IAAK;IAC7D,MAAM,EAAEI,OAAO,EAAEC,gBAAgB,EAAEC,yBAAyB,EAAEC,SAAS,EAAE,GAAGZ;IAE5E,MAAMa,iBAAiBd,MAAMe,MAAM,CAAC;IAEpCf,MAAMgB,SAAS,CAAC;QACd,IAAI,CAACF,eAAeG,OAAO,EAAE;YAC3B,oBAAoB;YACpB,IAAIR,SAASA,UAAUE,kBAAkB;gBACvCE,UAAU;oBAAEK,IAAIT;oBAAOU,SAASZ;gBAAO;YACzC,OAAO;gBACL,oEAAoE;gBACpE,MAAMa,eAAeT,oBAAoBD,OAAO,CAAC,EAAE,EAAED;gBACrDI,UAAU;oBAAEK,IAAIE;oBAAcD,SAASZ;gBAAO;YAChD;YACAO,eAAeG,OAAO,GAAG;QAC3B,OAAO,IAAI,CAACR,SAASA,UAAUE,kBAAkB;YAC/C,oEAAoE;YACpEH,SAASG;QACX;IACF,GAAG;QAACF;QAAOE;QAAkBE;QAAWL;QAAUE;QAASH;KAAO;IAElEP,MAAMgB,SAAS,CAAC;QACd,IAAI,CAACT,QAAQ;YACXK,0BAA0B;QAC5B;QACA,OAAO;YACLA,0BAA0B;QAC5B;IACF,GAAG;QAACL;QAAQK;KAA0B;IAEtC,IAAIP,OAAO;QACT,qBACE,MAACgB;YAAIC,WAAWpB;;8BACd,KAACmB;oBAAIC,WAAW,GAAGpB,UAAU,SAAS,CAAC;8BACrC,cAAA,KAACJ;wBAAmB,GAAGM,IAAI;;;8BAE7B,KAACiB;oBAAIC,WAAW,GAAGpB,UAAU,IAAI,CAAC;;;;IAGxC;IAEA,OAAO;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TenantSelector/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC,OAAO,cAAc,CAAA;AAGrB,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,eAAO,MAAM,cAAc,wBAAyB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,6BAsC1F,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TenantSelector/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC,OAAO,cAAc,CAAA;AAGrB,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,eAAO,MAAM,cAAc,wBAAyB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,6BAgC1F,CAAA"}
@@ -3,7 +3,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import './index.scss';
4
4
  import { SelectInput, useTranslation } from '@payloadcms/ui';
5
5
  import React from 'react';
6
- import { SELECT_ALL } from '../../constants.js';
7
6
  import { useTenantSelection } from '../../providers/TenantSelectionProvider/index.client.js';
8
7
  export const TenantSelector = ({ label, viewType })=>{
9
8
  const { options, selectedTenantID, setTenant } = useTenantSelection();
@@ -35,7 +34,7 @@ export const TenantSelector = ({ label, viewType })=>{
35
34
  onChange: handleChange,
36
35
  options: options,
37
36
  path: "setTenant",
38
- value: selectedTenantID ? selectedTenantID === SELECT_ALL ? undefined : selectedTenantID : undefined
37
+ value: selectedTenantID
39
38
  })
40
39
  });
41
40
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/TenantSelector/index.tsx"],"sourcesContent":["'use client'\nimport type { ReactSelectOption } from '@payloadcms/ui'\nimport type { ViewTypes } from 'payload'\n\nimport './index.scss'\n\nimport { SelectInput, useTranslation } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { SELECT_ALL } from '../../constants.js'\nimport { useTenantSelection } from '../../providers/TenantSelectionProvider/index.client.js'\n\nexport const TenantSelector = ({ label, viewType }: { label: string; viewType?: ViewTypes }) => {\n const { options, selectedTenantID, setTenant } = useTenantSelection()\n const { t } = useTranslation()\n\n const handleChange = React.useCallback(\n (option: ReactSelectOption | ReactSelectOption[]) => {\n if (option && 'value' in option) {\n setTenant({ id: option.value as string, refresh: true })\n } else {\n setTenant({ id: undefined, refresh: true })\n }\n },\n [setTenant],\n )\n\n if (options.length <= 1) {\n return null\n }\n\n return (\n <div className=\"tenant-selector\">\n <SelectInput\n isClearable={viewType === 'list'}\n label={t(label as any)}\n name=\"setTenant\"\n onChange={handleChange}\n options={options}\n path=\"setTenant\"\n value={\n selectedTenantID\n ? selectedTenantID === SELECT_ALL\n ? undefined\n : (selectedTenantID as string)\n : undefined\n }\n />\n </div>\n )\n}\n"],"names":["SelectInput","useTranslation","React","SELECT_ALL","useTenantSelection","TenantSelector","label","viewType","options","selectedTenantID","setTenant","t","handleChange","useCallback","option","id","value","refresh","undefined","length","div","className","isClearable","name","onChange","path"],"mappings":"AAAA;;AAIA,OAAO,eAAc;AAErB,SAASA,WAAW,EAAEC,cAAc,QAAQ,iBAAgB;AAC5D,OAAOC,WAAW,QAAO;AAEzB,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,kBAAkB,QAAQ,0DAAyD;AAE5F,OAAO,MAAMC,iBAAiB,CAAC,EAAEC,KAAK,EAAEC,QAAQ,EAA2C;IACzF,MAAM,EAAEC,OAAO,EAAEC,gBAAgB,EAAEC,SAAS,EAAE,GAAGN;IACjD,MAAM,EAAEO,CAAC,EAAE,GAAGV;IAEd,MAAMW,eAAeV,MAAMW,WAAW,CACpC,CAACC;QACC,IAAIA,UAAU,WAAWA,QAAQ;YAC/BJ,UAAU;gBAAEK,IAAID,OAAOE,KAAK;gBAAYC,SAAS;YAAK;QACxD,OAAO;YACLP,UAAU;gBAAEK,IAAIG;gBAAWD,SAAS;YAAK;QAC3C;IACF,GACA;QAACP;KAAU;IAGb,IAAIF,QAAQW,MAAM,IAAI,GAAG;QACvB,OAAO;IACT;IAEA,qBACE,KAACC;QAAIC,WAAU;kBACb,cAAA,KAACrB;YACCsB,aAAaf,aAAa;YAC1BD,OAAOK,EAAEL;YACTiB,MAAK;YACLC,UAAUZ;YACVJ,SAASA;YACTiB,MAAK;YACLT,OACEP,mBACIA,qBAAqBN,aACnBe,YACCT,mBACHS;;;AAKd,EAAC"}
1
+ {"version":3,"sources":["../../../src/components/TenantSelector/index.tsx"],"sourcesContent":["'use client'\nimport type { ReactSelectOption } from '@payloadcms/ui'\nimport type { ViewTypes } from 'payload'\n\nimport './index.scss'\n\nimport { SelectInput, useTranslation } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { useTenantSelection } from '../../providers/TenantSelectionProvider/index.client.js'\n\nexport const TenantSelector = ({ label, viewType }: { label: string; viewType?: ViewTypes }) => {\n const { options, selectedTenantID, setTenant } = useTenantSelection()\n const { t } = useTranslation()\n\n const handleChange = React.useCallback(\n (option: ReactSelectOption | ReactSelectOption[]) => {\n if (option && 'value' in option) {\n setTenant({ id: option.value as string, refresh: true })\n } else {\n setTenant({ id: undefined, refresh: true })\n }\n },\n [setTenant],\n )\n\n if (options.length <= 1) {\n return null\n }\n\n return (\n <div className=\"tenant-selector\">\n <SelectInput\n isClearable={viewType === 'list'}\n label={t(label as any)}\n name=\"setTenant\"\n onChange={handleChange}\n options={options}\n path=\"setTenant\"\n value={selectedTenantID as string | undefined}\n />\n </div>\n )\n}\n"],"names":["SelectInput","useTranslation","React","useTenantSelection","TenantSelector","label","viewType","options","selectedTenantID","setTenant","t","handleChange","useCallback","option","id","value","refresh","undefined","length","div","className","isClearable","name","onChange","path"],"mappings":"AAAA;;AAIA,OAAO,eAAc;AAErB,SAASA,WAAW,EAAEC,cAAc,QAAQ,iBAAgB;AAC5D,OAAOC,WAAW,QAAO;AAEzB,SAASC,kBAAkB,QAAQ,0DAAyD;AAE5F,OAAO,MAAMC,iBAAiB,CAAC,EAAEC,KAAK,EAAEC,QAAQ,EAA2C;IACzF,MAAM,EAAEC,OAAO,EAAEC,gBAAgB,EAAEC,SAAS,EAAE,GAAGN;IACjD,MAAM,EAAEO,CAAC,EAAE,GAAGT;IAEd,MAAMU,eAAeT,MAAMU,WAAW,CACpC,CAACC;QACC,IAAIA,UAAU,WAAWA,QAAQ;YAC/BJ,UAAU;gBAAEK,IAAID,OAAOE,KAAK;gBAAYC,SAAS;YAAK;QACxD,OAAO;YACLP,UAAU;gBAAEK,IAAIG;gBAAWD,SAAS;YAAK;QAC3C;IACF,GACA;QAACP;KAAU;IAGb,IAAIF,QAAQW,MAAM,IAAI,GAAG;QACvB,OAAO;IACT;IAEA,qBACE,KAACC;QAAIC,WAAU;kBACb,cAAA,KAACpB;YACCqB,aAAaf,aAAa;YAC1BD,OAAOK,EAAEL;YACTiB,MAAK;YACLC,UAAUZ;YACVJ,SAASA;YACTiB,MAAK;YACLT,OAAOP;;;AAIf,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"filterDocumentsBySelectedTenant.d.ts","sourceRoot":"","sources":["../../src/list-filters/filterDocumentsBySelectedTenant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAMpD,KAAK,IAAI,GAAG;IACV,GAAG,EAAE,cAAc,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,qBAAqB,EAAE,MAAM,CAAA;CAC9B,CAAA;AACD,eAAO,MAAM,+BAA+B,qDAIzC,IAAI,KAAG,IAAI,GAAG,KAgBhB,CAAA"}
1
+ {"version":3,"file":"filterDocumentsBySelectedTenant.d.ts","sourceRoot":"","sources":["../../src/list-filters/filterDocumentsBySelectedTenant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAKpD,KAAK,IAAI,GAAG;IACV,GAAG,EAAE,cAAc,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,qBAAqB,EAAE,MAAM,CAAA;CAC9B,CAAA;AACD,eAAO,MAAM,+BAA+B,qDAIzC,IAAI,KAAG,IAAI,GAAG,KAgBhB,CAAA"}
@@ -1,4 +1,3 @@
1
- import { SELECT_ALL } from '../constants.js';
2
1
  import { getCollectionIDType } from '../utilities/getCollectionIDType.js';
3
2
  import { getTenantFromCookie } from '../utilities/getTenantFromCookie.js';
4
3
  export const filterDocumentsBySelectedTenant = ({ req, tenantFieldName, tenantsCollectionSlug })=>{
@@ -7,14 +6,14 @@ export const filterDocumentsBySelectedTenant = ({ req, tenantFieldName, tenantsC
7
6
  payload: req.payload
8
7
  });
9
8
  const selectedTenant = getTenantFromCookie(req.headers, idType);
10
- if (selectedTenant === SELECT_ALL) {
11
- return {};
9
+ if (selectedTenant) {
10
+ return {
11
+ [tenantFieldName]: {
12
+ equals: selectedTenant
13
+ }
14
+ };
12
15
  }
13
- return {
14
- [tenantFieldName]: {
15
- equals: selectedTenant
16
- }
17
- };
16
+ return {};
18
17
  };
19
18
 
20
19
  //# sourceMappingURL=filterDocumentsBySelectedTenant.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/list-filters/filterDocumentsBySelectedTenant.ts"],"sourcesContent":["import type { PayloadRequest, Where } from 'payload'\n\nimport { SELECT_ALL } from '../constants.js'\nimport { getCollectionIDType } from '../utilities/getCollectionIDType.js'\nimport { getTenantFromCookie } from '../utilities/getTenantFromCookie.js'\n\ntype Args = {\n req: PayloadRequest\n tenantFieldName: string\n tenantsCollectionSlug: string\n}\nexport const filterDocumentsBySelectedTenant = ({\n req,\n tenantFieldName,\n tenantsCollectionSlug,\n}: Args): null | Where => {\n const idType = getCollectionIDType({\n collectionSlug: tenantsCollectionSlug,\n payload: req.payload,\n })\n const selectedTenant = getTenantFromCookie(req.headers, idType)\n\n if (selectedTenant === SELECT_ALL) {\n return {}\n }\n\n return {\n [tenantFieldName]: {\n equals: selectedTenant,\n },\n }\n}\n"],"names":["SELECT_ALL","getCollectionIDType","getTenantFromCookie","filterDocumentsBySelectedTenant","req","tenantFieldName","tenantsCollectionSlug","idType","collectionSlug","payload","selectedTenant","headers","equals"],"mappings":"AAEA,SAASA,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,mBAAmB,QAAQ,sCAAqC;AAOzE,OAAO,MAAMC,kCAAkC,CAAC,EAC9CC,GAAG,EACHC,eAAe,EACfC,qBAAqB,EAChB;IACL,MAAMC,SAASN,oBAAoB;QACjCO,gBAAgBF;QAChBG,SAASL,IAAIK,OAAO;IACtB;IACA,MAAMC,iBAAiBR,oBAAoBE,IAAIO,OAAO,EAAEJ;IAExD,IAAIG,mBAAmBV,YAAY;QACjC,OAAO,CAAC;IACV;IAEA,OAAO;QACL,CAACK,gBAAgB,EAAE;YACjBO,QAAQF;QACV;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/list-filters/filterDocumentsBySelectedTenant.ts"],"sourcesContent":["import type { PayloadRequest, Where } from 'payload'\n\nimport { getCollectionIDType } from '../utilities/getCollectionIDType.js'\nimport { getTenantFromCookie } from '../utilities/getTenantFromCookie.js'\n\ntype Args = {\n req: PayloadRequest\n tenantFieldName: string\n tenantsCollectionSlug: string\n}\nexport const filterDocumentsBySelectedTenant = ({\n req,\n tenantFieldName,\n tenantsCollectionSlug,\n}: Args): null | Where => {\n const idType = getCollectionIDType({\n collectionSlug: tenantsCollectionSlug,\n payload: req.payload,\n })\n const selectedTenant = getTenantFromCookie(req.headers, idType)\n\n if (selectedTenant) {\n return {\n [tenantFieldName]: {\n equals: selectedTenant,\n },\n }\n }\n\n return {}\n}\n"],"names":["getCollectionIDType","getTenantFromCookie","filterDocumentsBySelectedTenant","req","tenantFieldName","tenantsCollectionSlug","idType","collectionSlug","payload","selectedTenant","headers","equals"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,mBAAmB,QAAQ,sCAAqC;AAOzE,OAAO,MAAMC,kCAAkC,CAAC,EAC9CC,GAAG,EACHC,eAAe,EACfC,qBAAqB,EAChB;IACL,MAAMC,SAASN,oBAAoB;QACjCO,gBAAgBF;QAChBG,SAASL,IAAIK,OAAO;IACtB;IACA,MAAMC,iBAAiBR,oBAAoBE,IAAIO,OAAO,EAAEJ;IAExD,IAAIG,gBAAgB;QAClB,OAAO;YACL,CAACL,gBAAgB,EAAE;gBACjBO,QAAQF;YACV;QACF;IACF;IAEA,OAAO,CAAC;AACV,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"filterTenantsBySelectedTenant.d.ts","sourceRoot":"","sources":["../../src/list-filters/filterTenantsBySelectedTenant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAMpD,KAAK,IAAI,GAAG;IACV,GAAG,EAAE,cAAc,CAAA;IACnB,qBAAqB,EAAE,MAAM,CAAA;CAC9B,CAAA;AACD,eAAO,MAAM,6BAA6B,oCAGvC,IAAI,KAAG,IAAI,GAAG,KAgBhB,CAAA"}
1
+ {"version":3,"file":"filterTenantsBySelectedTenant.d.ts","sourceRoot":"","sources":["../../src/list-filters/filterTenantsBySelectedTenant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAKpD,KAAK,IAAI,GAAG;IACV,GAAG,EAAE,cAAc,CAAA;IACnB,qBAAqB,EAAE,MAAM,CAAA;CAC9B,CAAA;AACD,eAAO,MAAM,6BAA6B,oCAGvC,IAAI,KAAG,IAAI,GAAG,KAgBhB,CAAA"}
@@ -1,4 +1,3 @@
1
- import { SELECT_ALL } from '../constants.js';
2
1
  import { getCollectionIDType } from '../utilities/getCollectionIDType.js';
3
2
  import { getTenantFromCookie } from '../utilities/getTenantFromCookie.js';
4
3
  export const filterTenantsBySelectedTenant = ({ req, tenantsCollectionSlug })=>{
@@ -7,14 +6,14 @@ export const filterTenantsBySelectedTenant = ({ req, tenantsCollectionSlug })=>{
7
6
  payload: req.payload
8
7
  });
9
8
  const selectedTenant = getTenantFromCookie(req.headers, idType);
10
- if (selectedTenant === SELECT_ALL) {
11
- return {};
9
+ if (selectedTenant) {
10
+ return {
11
+ id: {
12
+ equals: selectedTenant
13
+ }
14
+ };
12
15
  }
13
- return {
14
- id: {
15
- equals: selectedTenant
16
- }
17
- };
16
+ return {};
18
17
  };
19
18
 
20
19
  //# sourceMappingURL=filterTenantsBySelectedTenant.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/list-filters/filterTenantsBySelectedTenant.ts"],"sourcesContent":["import type { PayloadRequest, Where } from 'payload'\n\nimport { SELECT_ALL } from '../constants.js'\nimport { getCollectionIDType } from '../utilities/getCollectionIDType.js'\nimport { getTenantFromCookie } from '../utilities/getTenantFromCookie.js'\n\ntype Args = {\n req: PayloadRequest\n tenantsCollectionSlug: string\n}\nexport const filterTenantsBySelectedTenant = ({\n req,\n tenantsCollectionSlug,\n}: Args): null | Where => {\n const idType = getCollectionIDType({\n collectionSlug: tenantsCollectionSlug,\n payload: req.payload,\n })\n const selectedTenant = getTenantFromCookie(req.headers, idType)\n\n if (selectedTenant === SELECT_ALL) {\n return {}\n }\n\n return {\n id: {\n equals: selectedTenant,\n },\n }\n}\n"],"names":["SELECT_ALL","getCollectionIDType","getTenantFromCookie","filterTenantsBySelectedTenant","req","tenantsCollectionSlug","idType","collectionSlug","payload","selectedTenant","headers","id","equals"],"mappings":"AAEA,SAASA,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,mBAAmB,QAAQ,sCAAqC;AAMzE,OAAO,MAAMC,gCAAgC,CAAC,EAC5CC,GAAG,EACHC,qBAAqB,EAChB;IACL,MAAMC,SAASL,oBAAoB;QACjCM,gBAAgBF;QAChBG,SAASJ,IAAII,OAAO;IACtB;IACA,MAAMC,iBAAiBP,oBAAoBE,IAAIM,OAAO,EAAEJ;IAExD,IAAIG,mBAAmBT,YAAY;QACjC,OAAO,CAAC;IACV;IAEA,OAAO;QACLW,IAAI;YACFC,QAAQH;QACV;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/list-filters/filterTenantsBySelectedTenant.ts"],"sourcesContent":["import type { PayloadRequest, Where } from 'payload'\n\nimport { getCollectionIDType } from '../utilities/getCollectionIDType.js'\nimport { getTenantFromCookie } from '../utilities/getTenantFromCookie.js'\n\ntype Args = {\n req: PayloadRequest\n tenantsCollectionSlug: string\n}\nexport const filterTenantsBySelectedTenant = ({\n req,\n tenantsCollectionSlug,\n}: Args): null | Where => {\n const idType = getCollectionIDType({\n collectionSlug: tenantsCollectionSlug,\n payload: req.payload,\n })\n const selectedTenant = getTenantFromCookie(req.headers, idType)\n\n if (selectedTenant) {\n return {\n id: {\n equals: selectedTenant,\n },\n }\n }\n\n return {}\n}\n"],"names":["getCollectionIDType","getTenantFromCookie","filterTenantsBySelectedTenant","req","tenantsCollectionSlug","idType","collectionSlug","payload","selectedTenant","headers","id","equals"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,mBAAmB,QAAQ,sCAAqC;AAMzE,OAAO,MAAMC,gCAAgC,CAAC,EAC5CC,GAAG,EACHC,qBAAqB,EAChB;IACL,MAAMC,SAASL,oBAAoB;QACjCM,gBAAgBF;QAChBG,SAASJ,IAAII,OAAO;IACtB;IACA,MAAMC,iBAAiBP,oBAAoBE,IAAIM,OAAO,EAAEJ;IAExD,IAAIG,gBAAgB;QAClB,OAAO;YACLE,IAAI;gBACFC,QAAQH;YACV;QACF;IACF;IAEA,OAAO,CAAC;AACV,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"filterUsersBySelectedTenant.d.ts","sourceRoot":"","sources":["../../src/list-filters/filterUsersBySelectedTenant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAMpD,KAAK,IAAI,GAAG;IACV,GAAG,EAAE,cAAc,CAAA;IACnB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,2BAA2B,EAAE,MAAM,CAAA;IACnC,qBAAqB,EAAE,MAAM,CAAA;CAC9B,CAAA;AACD;;GAEG;AACH,eAAO,MAAM,2BAA2B,wFAKrC,IAAI,KAAG,IAAI,GAAG,KAgBhB,CAAA"}
1
+ {"version":3,"file":"filterUsersBySelectedTenant.d.ts","sourceRoot":"","sources":["../../src/list-filters/filterUsersBySelectedTenant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAKpD,KAAK,IAAI,GAAG;IACV,GAAG,EAAE,cAAc,CAAA;IACnB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,2BAA2B,EAAE,MAAM,CAAA;IACnC,qBAAqB,EAAE,MAAM,CAAA;CAC9B,CAAA;AACD;;GAEG;AACH,eAAO,MAAM,2BAA2B,wFAKrC,IAAI,KAAG,IAAI,GAAG,KAgBhB,CAAA"}
@@ -1,4 +1,3 @@
1
- import { SELECT_ALL } from '../constants.js';
2
1
  import { getCollectionIDType } from '../utilities/getCollectionIDType.js';
3
2
  import { getTenantFromCookie } from '../utilities/getTenantFromCookie.js';
4
3
  /**
@@ -9,16 +8,16 @@ import { getTenantFromCookie } from '../utilities/getTenantFromCookie.js';
9
8
  payload: req.payload
10
9
  });
11
10
  const selectedTenant = getTenantFromCookie(req.headers, idType);
12
- if (selectedTenant === SELECT_ALL) {
13
- return {};
11
+ if (selectedTenant) {
12
+ return {
13
+ [`${tenantsArrayFieldName}.${tenantsArrayTenantFieldName}`]: {
14
+ in: [
15
+ selectedTenant
16
+ ]
17
+ }
18
+ };
14
19
  }
15
- return {
16
- [`${tenantsArrayFieldName}.${tenantsArrayTenantFieldName}`]: {
17
- in: [
18
- selectedTenant
19
- ]
20
- }
21
- };
20
+ return {};
22
21
  };
23
22
 
24
23
  //# sourceMappingURL=filterUsersBySelectedTenant.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/list-filters/filterUsersBySelectedTenant.ts"],"sourcesContent":["import type { PayloadRequest, Where } from 'payload'\n\nimport { SELECT_ALL } from '../constants.js'\nimport { getCollectionIDType } from '../utilities/getCollectionIDType.js'\nimport { getTenantFromCookie } from '../utilities/getTenantFromCookie.js'\n\ntype Args = {\n req: PayloadRequest\n tenantsArrayFieldName: string\n tenantsArrayTenantFieldName: string\n tenantsCollectionSlug: string\n}\n/**\n * Filter the list of users by the selected tenant\n */\nexport const filterUsersBySelectedTenant = ({\n req,\n tenantsArrayFieldName,\n tenantsArrayTenantFieldName,\n tenantsCollectionSlug,\n}: Args): null | Where => {\n const idType = getCollectionIDType({\n collectionSlug: tenantsCollectionSlug,\n payload: req.payload,\n })\n const selectedTenant = getTenantFromCookie(req.headers, idType)\n\n if (selectedTenant === SELECT_ALL) {\n return {}\n }\n\n return {\n [`${tenantsArrayFieldName}.${tenantsArrayTenantFieldName}`]: {\n in: [selectedTenant],\n },\n }\n}\n"],"names":["SELECT_ALL","getCollectionIDType","getTenantFromCookie","filterUsersBySelectedTenant","req","tenantsArrayFieldName","tenantsArrayTenantFieldName","tenantsCollectionSlug","idType","collectionSlug","payload","selectedTenant","headers","in"],"mappings":"AAEA,SAASA,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,mBAAmB,QAAQ,sCAAqC;AAQzE;;CAEC,GACD,OAAO,MAAMC,8BAA8B,CAAC,EAC1CC,GAAG,EACHC,qBAAqB,EACrBC,2BAA2B,EAC3BC,qBAAqB,EAChB;IACL,MAAMC,SAASP,oBAAoB;QACjCQ,gBAAgBF;QAChBG,SAASN,IAAIM,OAAO;IACtB;IACA,MAAMC,iBAAiBT,oBAAoBE,IAAIQ,OAAO,EAAEJ;IAExD,IAAIG,mBAAmBX,YAAY;QACjC,OAAO,CAAC;IACV;IAEA,OAAO;QACL,CAAC,GAAGK,sBAAsB,CAAC,EAAEC,6BAA6B,CAAC,EAAE;YAC3DO,IAAI;gBAACF;aAAe;QACtB;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/list-filters/filterUsersBySelectedTenant.ts"],"sourcesContent":["import type { PayloadRequest, Where } from 'payload'\n\nimport { getCollectionIDType } from '../utilities/getCollectionIDType.js'\nimport { getTenantFromCookie } from '../utilities/getTenantFromCookie.js'\n\ntype Args = {\n req: PayloadRequest\n tenantsArrayFieldName: string\n tenantsArrayTenantFieldName: string\n tenantsCollectionSlug: string\n}\n/**\n * Filter the list of users by the selected tenant\n */\nexport const filterUsersBySelectedTenant = ({\n req,\n tenantsArrayFieldName,\n tenantsArrayTenantFieldName,\n tenantsCollectionSlug,\n}: Args): null | Where => {\n const idType = getCollectionIDType({\n collectionSlug: tenantsCollectionSlug,\n payload: req.payload,\n })\n const selectedTenant = getTenantFromCookie(req.headers, idType)\n\n if (selectedTenant) {\n return {\n [`${tenantsArrayFieldName}.${tenantsArrayTenantFieldName}`]: {\n in: [selectedTenant],\n },\n }\n }\n\n return {}\n}\n"],"names":["getCollectionIDType","getTenantFromCookie","filterUsersBySelectedTenant","req","tenantsArrayFieldName","tenantsArrayTenantFieldName","tenantsCollectionSlug","idType","collectionSlug","payload","selectedTenant","headers","in"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,mBAAmB,QAAQ,sCAAqC;AAQzE;;CAEC,GACD,OAAO,MAAMC,8BAA8B,CAAC,EAC1CC,GAAG,EACHC,qBAAqB,EACrBC,2BAA2B,EAC3BC,qBAAqB,EAChB;IACL,MAAMC,SAASP,oBAAoB;QACjCQ,gBAAgBF;QAChBG,SAASN,IAAIM,OAAO;IACtB;IACA,MAAMC,iBAAiBT,oBAAoBE,IAAIQ,OAAO,EAAEJ;IAExD,IAAIG,gBAAgB;QAClB,OAAO;YACL,CAAC,GAAGN,sBAAsB,CAAC,EAAEC,6BAA6B,CAAC,EAAE;gBAC3DO,IAAI;oBAACF;iBAAe;YACtB;QACF;IACF;IAEA,OAAO,CAAC;AACV,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../src/providers/TenantSelectionProvider/index.client.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAI3C,OAAO,KAAwB,MAAM,OAAO,CAAA;AAI5C,KAAK,WAAW,GAAG;IACjB;;OAEG;IACH,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB;;OAEG;IACH,gBAAgB,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IAC7C;;;;OAIG;IACH,yBAAyB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;IACxE;;;;;OAKG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAA;CAClF,CAAA;AASD,eAAO,MAAM,6BAA6B,6DAKvC;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,YAAY,EAAE,CAAA;CAC9B,sBA8FA,CAAA;AAED,eAAO,MAAM,kBAAkB,mBAAkC,CAAA"}
1
+ {"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../src/providers/TenantSelectionProvider/index.client.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAI3C,OAAO,KAAwB,MAAM,OAAO,CAAA;AAE5C,KAAK,WAAW,GAAG;IACjB;;OAEG;IACH,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB;;OAEG;IACH,gBAAgB,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IAC7C;;;;OAIG;IACH,yBAAyB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;IACxE;;;;;OAKG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAA;CAClF,CAAA;AASD,eAAO,MAAM,6BAA6B,6DAKvC;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,YAAY,EAAE,CAAA;CAC9B,sBA8FA,CAAA;AAED,eAAO,MAAM,kBAAkB,mBAA2B,CAAA"}
@@ -3,7 +3,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useAuth } from '@payloadcms/ui';
4
4
  import { useRouter } from 'next/navigation.js';
5
5
  import React, { createContext } from 'react';
6
- import { SELECT_ALL } from '../../constants.js';
7
6
  const Context = /*#__PURE__*/ createContext({
8
7
  options: [],
9
8
  selectedTenantID: undefined,
@@ -32,8 +31,8 @@ export const TenantSelectionProviderClient = ({ children, initialValue, tenantCo
32
31
  const setTenant = React.useCallback(({ id, refresh })=>{
33
32
  if (id === undefined) {
34
33
  if (tenantOptions.length > 1) {
35
- setSelectedTenantID(SELECT_ALL);
36
- setCookie(SELECT_ALL);
34
+ setSelectedTenantID(undefined);
35
+ deleteCookie();
37
36
  } else {
38
37
  setSelectedTenantID(tenantOptions[0]?.value);
39
38
  setCookie(String(tenantOptions[0]?.value));
@@ -46,14 +45,15 @@ export const TenantSelectionProviderClient = ({ children, initialValue, tenantCo
46
45
  router.refresh();
47
46
  }
48
47
  }, [
49
- setSelectedTenantID,
50
- setCookie,
51
- router,
48
+ deleteCookie,
52
49
  preventRefreshOnChange,
50
+ router,
51
+ setCookie,
52
+ setSelectedTenantID,
53
53
  tenantOptions
54
54
  ]);
55
55
  React.useEffect(()=>{
56
- if (selectedTenantID && selectedTenantID !== SELECT_ALL && !tenantOptions.find((option)=>option.value === selectedTenantID)) {
56
+ if (selectedTenantID && !tenantOptions.find((option)=>option.value === selectedTenantID)) {
57
57
  if (tenantOptions?.[0]?.value) {
58
58
  setTenant({
59
59
  id: tenantOptions[0].value,
@@ -78,13 +78,18 @@ export const TenantSelectionProviderClient = ({ children, initialValue, tenantCo
78
78
  if (userID && !tenantCookie) {
79
79
  // User is logged in, but does not have a tenant cookie, set it
80
80
  setSelectedTenantID(initialValue);
81
- setCookie(String(initialValue));
81
+ if (initialValue) {
82
+ setCookie(String(initialValue));
83
+ } else {
84
+ deleteCookie();
85
+ }
82
86
  }
83
87
  }, [
84
88
  userID,
85
89
  tenantCookie,
86
90
  initialValue,
87
91
  setCookie,
92
+ deleteCookie,
88
93
  router
89
94
  ]);
90
95
  React.useEffect(()=>{
@@ -105,7 +110,7 @@ export const TenantSelectionProviderClient = ({ children, initialValue, tenantCo
105
110
  return /*#__PURE__*/ _jsx("span", {
106
111
  "data-selected-tenant-id": selectedTenantID,
107
112
  "data-selected-tenant-title": selectedTenantLabel,
108
- children: /*#__PURE__*/ _jsx(Context.Provider, {
113
+ children: /*#__PURE__*/ _jsx(Context, {
109
114
  value: {
110
115
  options: tenantOptions,
111
116
  selectedTenantID,
@@ -116,6 +121,6 @@ export const TenantSelectionProviderClient = ({ children, initialValue, tenantCo
116
121
  })
117
122
  });
118
123
  };
119
- export const useTenantSelection = ()=>React.useContext(Context);
124
+ export const useTenantSelection = ()=>React.use(Context);
120
125
 
121
126
  //# sourceMappingURL=index.client.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/providers/TenantSelectionProvider/index.client.tsx"],"sourcesContent":["'use client'\n\nimport type { OptionObject } from 'payload'\n\nimport { useAuth } from '@payloadcms/ui'\nimport { useRouter } from 'next/navigation.js'\nimport React, { createContext } from 'react'\n\nimport { SELECT_ALL } from '../../constants.js'\n\ntype ContextType = {\n /**\n * Array of options to select from\n */\n options: OptionObject[]\n /**\n * The currently selected tenant ID\n */\n selectedTenantID: number | string | undefined\n /**\n * Prevents a refresh when the tenant is changed\n *\n * If not switching tenants while viewing a \"global\", set to true\n */\n setPreventRefreshOnChange: React.Dispatch<React.SetStateAction<boolean>>\n /**\n * Sets the selected tenant ID\n *\n * @param args.id - The ID of the tenant to select\n * @param args.refresh - Whether to refresh the page after changing the tenant\n */\n setTenant: (args: { id: number | string | undefined; refresh?: boolean }) => void\n}\n\nconst Context = createContext<ContextType>({\n options: [],\n selectedTenantID: undefined,\n setPreventRefreshOnChange: () => null,\n setTenant: () => null,\n})\n\nexport const TenantSelectionProviderClient = ({\n children,\n initialValue,\n tenantCookie,\n tenantOptions,\n}: {\n children: React.ReactNode\n initialValue?: number | string\n tenantCookie?: string\n tenantOptions: OptionObject[]\n}) => {\n const [selectedTenantID, setSelectedTenantID] = React.useState<number | string | undefined>(\n initialValue,\n )\n const [preventRefreshOnChange, setPreventRefreshOnChange] = React.useState(false)\n const { user } = useAuth()\n const userID = React.useMemo(() => user?.id, [user?.id])\n const selectedTenantLabel = React.useMemo(\n () => tenantOptions.find((option) => option.value === selectedTenantID)?.label,\n [selectedTenantID, tenantOptions],\n )\n\n const router = useRouter()\n\n const setCookie = React.useCallback((value?: string) => {\n const expires = '; expires=Fri, 31 Dec 9999 23:59:59 GMT'\n document.cookie = 'payload-tenant=' + (value || '') + expires + '; path=/'\n }, [])\n\n const deleteCookie = React.useCallback(() => {\n document.cookie = 'payload-tenant=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'\n }, [])\n\n const setTenant = React.useCallback<ContextType['setTenant']>(\n ({ id, refresh }) => {\n if (id === undefined) {\n if (tenantOptions.length > 1) {\n setSelectedTenantID(SELECT_ALL)\n setCookie(SELECT_ALL)\n } else {\n setSelectedTenantID(tenantOptions[0]?.value)\n setCookie(String(tenantOptions[0]?.value))\n }\n } else {\n setSelectedTenantID(id)\n setCookie(String(id))\n }\n if (!preventRefreshOnChange && refresh) {\n router.refresh()\n }\n },\n [setSelectedTenantID, setCookie, router, preventRefreshOnChange, tenantOptions],\n )\n\n React.useEffect(() => {\n if (\n selectedTenantID &&\n selectedTenantID !== SELECT_ALL &&\n !tenantOptions.find((option) => option.value === selectedTenantID)\n ) {\n if (tenantOptions?.[0]?.value) {\n setTenant({ id: tenantOptions[0].value, refresh: true })\n } else {\n setTenant({ id: undefined, refresh: true })\n }\n }\n }, [tenantCookie, setTenant, selectedTenantID, tenantOptions, initialValue, setCookie])\n\n React.useEffect(() => {\n if (userID && !tenantCookie) {\n // User is logged in, but does not have a tenant cookie, set it\n setSelectedTenantID(initialValue)\n setCookie(String(initialValue))\n }\n }, [userID, tenantCookie, initialValue, setCookie, router])\n\n React.useEffect(() => {\n if (!userID && tenantCookie) {\n // User is not logged in, but has a tenant cookie, delete it\n deleteCookie()\n setSelectedTenantID(undefined)\n } else if (userID) {\n // User changed, refresh\n router.refresh()\n }\n }, [userID, tenantCookie, deleteCookie, router])\n\n return (\n <span\n data-selected-tenant-id={selectedTenantID}\n data-selected-tenant-title={selectedTenantLabel}\n >\n <Context.Provider\n value={{\n options: tenantOptions,\n selectedTenantID,\n setPreventRefreshOnChange,\n setTenant,\n }}\n >\n {children}\n </Context.Provider>\n </span>\n )\n}\n\nexport const useTenantSelection = () => React.useContext(Context)\n"],"names":["useAuth","useRouter","React","createContext","SELECT_ALL","Context","options","selectedTenantID","undefined","setPreventRefreshOnChange","setTenant","TenantSelectionProviderClient","children","initialValue","tenantCookie","tenantOptions","setSelectedTenantID","useState","preventRefreshOnChange","user","userID","useMemo","id","selectedTenantLabel","find","option","value","label","router","setCookie","useCallback","expires","document","cookie","deleteCookie","refresh","length","String","useEffect","span","data-selected-tenant-id","data-selected-tenant-title","Provider","useTenantSelection","useContext"],"mappings":"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"}
1
+ {"version":3,"sources":["../../../src/providers/TenantSelectionProvider/index.client.tsx"],"sourcesContent":["'use client'\n\nimport type { OptionObject } from 'payload'\n\nimport { useAuth } from '@payloadcms/ui'\nimport { useRouter } from 'next/navigation.js'\nimport React, { createContext } from 'react'\n\ntype ContextType = {\n /**\n * Array of options to select from\n */\n options: OptionObject[]\n /**\n * The currently selected tenant ID\n */\n selectedTenantID: number | string | undefined\n /**\n * Prevents a refresh when the tenant is changed\n *\n * If not switching tenants while viewing a \"global\", set to true\n */\n setPreventRefreshOnChange: React.Dispatch<React.SetStateAction<boolean>>\n /**\n * Sets the selected tenant ID\n *\n * @param args.id - The ID of the tenant to select\n * @param args.refresh - Whether to refresh the page after changing the tenant\n */\n setTenant: (args: { id: number | string | undefined; refresh?: boolean }) => void\n}\n\nconst Context = createContext<ContextType>({\n options: [],\n selectedTenantID: undefined,\n setPreventRefreshOnChange: () => null,\n setTenant: () => null,\n})\n\nexport const TenantSelectionProviderClient = ({\n children,\n initialValue,\n tenantCookie,\n tenantOptions,\n}: {\n children: React.ReactNode\n initialValue?: number | string\n tenantCookie?: string\n tenantOptions: OptionObject[]\n}) => {\n const [selectedTenantID, setSelectedTenantID] = React.useState<number | string | undefined>(\n initialValue,\n )\n const [preventRefreshOnChange, setPreventRefreshOnChange] = React.useState(false)\n const { user } = useAuth()\n const userID = React.useMemo(() => user?.id, [user?.id])\n const selectedTenantLabel = React.useMemo(\n () => tenantOptions.find((option) => option.value === selectedTenantID)?.label,\n [selectedTenantID, tenantOptions],\n )\n\n const router = useRouter()\n\n const setCookie = React.useCallback((value?: string) => {\n const expires = '; expires=Fri, 31 Dec 9999 23:59:59 GMT'\n document.cookie = 'payload-tenant=' + (value || '') + expires + '; path=/'\n }, [])\n\n const deleteCookie = React.useCallback(() => {\n document.cookie = 'payload-tenant=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'\n }, [])\n\n const setTenant = React.useCallback<ContextType['setTenant']>(\n ({ id, refresh }) => {\n if (id === undefined) {\n if (tenantOptions.length > 1) {\n setSelectedTenantID(undefined)\n deleteCookie()\n } else {\n setSelectedTenantID(tenantOptions[0]?.value)\n setCookie(String(tenantOptions[0]?.value))\n }\n } else {\n setSelectedTenantID(id)\n setCookie(String(id))\n }\n if (!preventRefreshOnChange && refresh) {\n router.refresh()\n }\n },\n [deleteCookie, preventRefreshOnChange, router, setCookie, setSelectedTenantID, tenantOptions],\n )\n\n React.useEffect(() => {\n if (selectedTenantID && !tenantOptions.find((option) => option.value === selectedTenantID)) {\n if (tenantOptions?.[0]?.value) {\n setTenant({ id: tenantOptions[0].value, refresh: true })\n } else {\n setTenant({ id: undefined, refresh: true })\n }\n }\n }, [tenantCookie, setTenant, selectedTenantID, tenantOptions, initialValue, setCookie])\n\n React.useEffect(() => {\n if (userID && !tenantCookie) {\n // User is logged in, but does not have a tenant cookie, set it\n setSelectedTenantID(initialValue)\n if (initialValue) {\n setCookie(String(initialValue))\n } else {\n deleteCookie()\n }\n }\n }, [userID, tenantCookie, initialValue, setCookie, deleteCookie, router])\n\n React.useEffect(() => {\n if (!userID && tenantCookie) {\n // User is not logged in, but has a tenant cookie, delete it\n deleteCookie()\n setSelectedTenantID(undefined)\n } else if (userID) {\n // User changed, refresh\n router.refresh()\n }\n }, [userID, tenantCookie, deleteCookie, router])\n\n return (\n <span\n data-selected-tenant-id={selectedTenantID}\n data-selected-tenant-title={selectedTenantLabel}\n >\n <Context\n value={{\n options: tenantOptions,\n selectedTenantID,\n setPreventRefreshOnChange,\n setTenant,\n }}\n >\n {children}\n </Context>\n </span>\n )\n}\n\nexport const useTenantSelection = () => React.use(Context)\n"],"names":["useAuth","useRouter","React","createContext","Context","options","selectedTenantID","undefined","setPreventRefreshOnChange","setTenant","TenantSelectionProviderClient","children","initialValue","tenantCookie","tenantOptions","setSelectedTenantID","useState","preventRefreshOnChange","user","userID","useMemo","id","selectedTenantLabel","find","option","value","label","router","setCookie","useCallback","expires","document","cookie","deleteCookie","refresh","length","String","useEffect","span","data-selected-tenant-id","data-selected-tenant-title","useTenantSelection","use"],"mappings":"AAAA;;AAIA,SAASA,OAAO,QAAQ,iBAAgB;AACxC,SAASC,SAAS,QAAQ,qBAAoB;AAC9C,OAAOC,SAASC,aAAa,QAAQ,QAAO;AA0B5C,MAAMC,wBAAUD,cAA2B;IACzCE,SAAS,EAAE;IACXC,kBAAkBC;IAClBC,2BAA2B,IAAM;IACjCC,WAAW,IAAM;AACnB;AAEA,OAAO,MAAMC,gCAAgC,CAAC,EAC5CC,QAAQ,EACRC,YAAY,EACZC,YAAY,EACZC,aAAa,EAMd;IACC,MAAM,CAACR,kBAAkBS,oBAAoB,GAAGb,MAAMc,QAAQ,CAC5DJ;IAEF,MAAM,CAACK,wBAAwBT,0BAA0B,GAAGN,MAAMc,QAAQ,CAAC;IAC3E,MAAM,EAAEE,IAAI,EAAE,GAAGlB;IACjB,MAAMmB,SAASjB,MAAMkB,OAAO,CAAC,IAAMF,MAAMG,IAAI;QAACH,MAAMG;KAAG;IACvD,MAAMC,sBAAsBpB,MAAMkB,OAAO,CACvC,IAAMN,cAAcS,IAAI,CAAC,CAACC,SAAWA,OAAOC,KAAK,KAAKnB,mBAAmBoB,OACzE;QAACpB;QAAkBQ;KAAc;IAGnC,MAAMa,SAAS1B;IAEf,MAAM2B,YAAY1B,MAAM2B,WAAW,CAAC,CAACJ;QACnC,MAAMK,UAAU;QAChBC,SAASC,MAAM,GAAG,oBAAqBP,CAAAA,SAAS,EAAC,IAAKK,UAAU;IAClE,GAAG,EAAE;IAEL,MAAMG,eAAe/B,MAAM2B,WAAW,CAAC;QACrCE,SAASC,MAAM,GAAG;IACpB,GAAG,EAAE;IAEL,MAAMvB,YAAYP,MAAM2B,WAAW,CACjC,CAAC,EAAER,EAAE,EAAEa,OAAO,EAAE;QACd,IAAIb,OAAOd,WAAW;YACpB,IAAIO,cAAcqB,MAAM,GAAG,GAAG;gBAC5BpB,oBAAoBR;gBACpB0B;YACF,OAAO;gBACLlB,oBAAoBD,aAAa,CAAC,EAAE,EAAEW;gBACtCG,UAAUQ,OAAOtB,aAAa,CAAC,EAAE,EAAEW;YACrC;QACF,OAAO;YACLV,oBAAoBM;YACpBO,UAAUQ,OAAOf;QACnB;QACA,IAAI,CAACJ,0BAA0BiB,SAAS;YACtCP,OAAOO,OAAO;QAChB;IACF,GACA;QAACD;QAAchB;QAAwBU;QAAQC;QAAWb;QAAqBD;KAAc;IAG/FZ,MAAMmC,SAAS,CAAC;QACd,IAAI/B,oBAAoB,CAACQ,cAAcS,IAAI,CAAC,CAACC,SAAWA,OAAOC,KAAK,KAAKnB,mBAAmB;YAC1F,IAAIQ,eAAe,CAAC,EAAE,EAAEW,OAAO;gBAC7BhB,UAAU;oBAAEY,IAAIP,aAAa,CAAC,EAAE,CAACW,KAAK;oBAAES,SAAS;gBAAK;YACxD,OAAO;gBACLzB,UAAU;oBAAEY,IAAId;oBAAW2B,SAAS;gBAAK;YAC3C;QACF;IACF,GAAG;QAACrB;QAAcJ;QAAWH;QAAkBQ;QAAeF;QAAcgB;KAAU;IAEtF1B,MAAMmC,SAAS,CAAC;QACd,IAAIlB,UAAU,CAACN,cAAc;YAC3B,+DAA+D;YAC/DE,oBAAoBH;YACpB,IAAIA,cAAc;gBAChBgB,UAAUQ,OAAOxB;YACnB,OAAO;gBACLqB;YACF;QACF;IACF,GAAG;QAACd;QAAQN;QAAcD;QAAcgB;QAAWK;QAAcN;KAAO;IAExEzB,MAAMmC,SAAS,CAAC;QACd,IAAI,CAAClB,UAAUN,cAAc;YAC3B,4DAA4D;YAC5DoB;YACAlB,oBAAoBR;QACtB,OAAO,IAAIY,QAAQ;YACjB,wBAAwB;YACxBQ,OAAOO,OAAO;QAChB;IACF,GAAG;QAACf;QAAQN;QAAcoB;QAAcN;KAAO;IAE/C,qBACE,KAACW;QACCC,2BAAyBjC;QACzBkC,8BAA4BlB;kBAE5B,cAAA,KAAClB;YACCqB,OAAO;gBACLpB,SAASS;gBACTR;gBACAE;gBACAC;YACF;sBAECE;;;AAIT,EAAC;AAED,OAAO,MAAM8B,qBAAqB,IAAMvC,MAAMwC,GAAG,CAACtC,SAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/TenantSelectionProvider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAQ1D,KAAK,IAAI,GAAG;IACV,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,OAAO,EAAE,OAAO,CAAA;IAChB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,eAAO,MAAM,uBAAuB,oEAMjC,IAAI,yCA4CN,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/TenantSelectionProvider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAO1D,KAAK,IAAI,GAAG;IACV,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,OAAO,EAAE,OAAO,CAAA;IAChB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,eAAO,MAAM,uBAAuB,oEAMjC,IAAI,yCAkDN,CAAA"}
@@ -1,6 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { cookies as getCookies } from 'next/headers.js';
3
- import { SELECT_ALL } from '../../constants.js';
4
3
  import { findTenantOptions } from '../../queries/findTenantOptions.js';
5
4
  import { TenantSelectionProviderClient } from './index.client.js';
6
5
  export const TenantSelectionProvider = async ({ children, payload, tenantsCollectionSlug, useAsTitle, user })=>{
@@ -23,17 +22,20 @@ export const TenantSelectionProvider = async ({ children, payload, tenantsCollec
23
22
  const cookies = await getCookies();
24
23
  let tenantCookie = cookies.get('payload-tenant')?.value;
25
24
  let initialValue = undefined;
26
- if (tenantOptions.length > 1 && tenantCookie === SELECT_ALL) {
27
- initialValue = SELECT_ALL;
28
- } else {
25
+ /**
26
+ * Ensure the cookie is a valid tenant
27
+ */ if (tenantCookie) {
29
28
  const matchingOption = tenantOptions.find((option)=>String(option.value) === tenantCookie);
30
29
  if (matchingOption) {
31
30
  initialValue = matchingOption.value;
32
- } else {
33
- tenantCookie = undefined;
34
- initialValue = tenantOptions.length > 1 ? SELECT_ALL : tenantOptions[0]?.value;
35
31
  }
36
32
  }
33
+ /**
34
+ * If the there was no cookie or the cookie was an invalid tenantID set intialValue
35
+ */ if (!initialValue) {
36
+ tenantCookie = undefined;
37
+ initialValue = tenantOptions.length > 1 ? undefined : tenantOptions[0]?.value;
38
+ }
37
39
  return /*#__PURE__*/ _jsx(TenantSelectionProviderClient, {
38
40
  initialValue: initialValue,
39
41
  tenantCookie: tenantCookie,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/providers/TenantSelectionProvider/index.tsx"],"sourcesContent":["import type { OptionObject, Payload, User } from 'payload'\n\nimport { cookies as getCookies } from 'next/headers.js'\n\nimport { SELECT_ALL } from '../../constants.js'\nimport { findTenantOptions } from '../../queries/findTenantOptions.js'\nimport { TenantSelectionProviderClient } from './index.client.js'\n\ntype Args = {\n children: React.ReactNode\n payload: Payload\n tenantsCollectionSlug: string\n useAsTitle: string\n user: User\n}\n\nexport const TenantSelectionProvider = async ({\n children,\n payload,\n tenantsCollectionSlug,\n useAsTitle,\n user,\n}: Args) => {\n let tenantOptions: OptionObject[] = []\n\n try {\n const { docs } = await findTenantOptions({\n limit: 0,\n payload,\n tenantsCollectionSlug,\n useAsTitle,\n user,\n })\n tenantOptions = docs.map((doc) => ({\n label: String(doc[useAsTitle]),\n value: doc.id,\n }))\n } catch (_) {\n // user likely does not have access\n }\n\n const cookies = await getCookies()\n let tenantCookie = cookies.get('payload-tenant')?.value\n let initialValue = undefined\n\n if (tenantOptions.length > 1 && tenantCookie === SELECT_ALL) {\n initialValue = SELECT_ALL\n } else {\n const matchingOption = tenantOptions.find((option) => String(option.value) === tenantCookie)\n if (matchingOption) {\n initialValue = matchingOption.value\n } else {\n tenantCookie = undefined\n initialValue = tenantOptions.length > 1 ? SELECT_ALL : tenantOptions[0]?.value\n }\n }\n\n return (\n <TenantSelectionProviderClient\n initialValue={initialValue}\n tenantCookie={tenantCookie}\n tenantOptions={tenantOptions}\n >\n {children}\n </TenantSelectionProviderClient>\n )\n}\n"],"names":["cookies","getCookies","SELECT_ALL","findTenantOptions","TenantSelectionProviderClient","TenantSelectionProvider","children","payload","tenantsCollectionSlug","useAsTitle","user","tenantOptions","docs","limit","map","doc","label","String","value","id","_","tenantCookie","get","initialValue","undefined","length","matchingOption","find","option"],"mappings":";AAEA,SAASA,WAAWC,UAAU,QAAQ,kBAAiB;AAEvD,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,iBAAiB,QAAQ,qCAAoC;AACtE,SAASC,6BAA6B,QAAQ,oBAAmB;AAUjE,OAAO,MAAMC,0BAA0B,OAAO,EAC5CC,QAAQ,EACRC,OAAO,EACPC,qBAAqB,EACrBC,UAAU,EACVC,IAAI,EACC;IACL,IAAIC,gBAAgC,EAAE;IAEtC,IAAI;QACF,MAAM,EAAEC,IAAI,EAAE,GAAG,MAAMT,kBAAkB;YACvCU,OAAO;YACPN;YACAC;YACAC;YACAC;QACF;QACAC,gBAAgBC,KAAKE,GAAG,CAAC,CAACC,MAAS,CAAA;gBACjCC,OAAOC,OAAOF,GAAG,CAACN,WAAW;gBAC7BS,OAAOH,IAAII,EAAE;YACf,CAAA;IACF,EAAE,OAAOC,GAAG;IACV,mCAAmC;IACrC;IAEA,MAAMpB,UAAU,MAAMC;IACtB,IAAIoB,eAAerB,QAAQsB,GAAG,CAAC,mBAAmBJ;IAClD,IAAIK,eAAeC;IAEnB,IAAIb,cAAcc,MAAM,GAAG,KAAKJ,iBAAiBnB,YAAY;QAC3DqB,eAAerB;IACjB,OAAO;QACL,MAAMwB,iBAAiBf,cAAcgB,IAAI,CAAC,CAACC,SAAWX,OAAOW,OAAOV,KAAK,MAAMG;QAC/E,IAAIK,gBAAgB;YAClBH,eAAeG,eAAeR,KAAK;QACrC,OAAO;YACLG,eAAeG;YACfD,eAAeZ,cAAcc,MAAM,GAAG,IAAIvB,aAAaS,aAAa,CAAC,EAAE,EAAEO;QAC3E;IACF;IAEA,qBACE,KAACd;QACCmB,cAAcA;QACdF,cAAcA;QACdV,eAAeA;kBAEdL;;AAGP,EAAC"}
1
+ {"version":3,"sources":["../../../src/providers/TenantSelectionProvider/index.tsx"],"sourcesContent":["import type { OptionObject, Payload, User } from 'payload'\n\nimport { cookies as getCookies } from 'next/headers.js'\n\nimport { findTenantOptions } from '../../queries/findTenantOptions.js'\nimport { TenantSelectionProviderClient } from './index.client.js'\n\ntype Args = {\n children: React.ReactNode\n payload: Payload\n tenantsCollectionSlug: string\n useAsTitle: string\n user: User\n}\n\nexport const TenantSelectionProvider = async ({\n children,\n payload,\n tenantsCollectionSlug,\n useAsTitle,\n user,\n}: Args) => {\n let tenantOptions: OptionObject[] = []\n\n try {\n const { docs } = await findTenantOptions({\n limit: 0,\n payload,\n tenantsCollectionSlug,\n useAsTitle,\n user,\n })\n tenantOptions = docs.map((doc) => ({\n label: String(doc[useAsTitle]),\n value: doc.id,\n }))\n } catch (_) {\n // user likely does not have access\n }\n\n const cookies = await getCookies()\n let tenantCookie = cookies.get('payload-tenant')?.value\n let initialValue = undefined\n\n /**\n * Ensure the cookie is a valid tenant\n */\n if (tenantCookie) {\n const matchingOption = tenantOptions.find((option) => String(option.value) === tenantCookie)\n if (matchingOption) {\n initialValue = matchingOption.value\n }\n }\n\n /**\n * If the there was no cookie or the cookie was an invalid tenantID set intialValue\n */\n if (!initialValue) {\n tenantCookie = undefined\n initialValue = tenantOptions.length > 1 ? undefined : tenantOptions[0]?.value\n }\n\n return (\n <TenantSelectionProviderClient\n initialValue={initialValue}\n tenantCookie={tenantCookie}\n tenantOptions={tenantOptions}\n >\n {children}\n </TenantSelectionProviderClient>\n )\n}\n"],"names":["cookies","getCookies","findTenantOptions","TenantSelectionProviderClient","TenantSelectionProvider","children","payload","tenantsCollectionSlug","useAsTitle","user","tenantOptions","docs","limit","map","doc","label","String","value","id","_","tenantCookie","get","initialValue","undefined","matchingOption","find","option","length"],"mappings":";AAEA,SAASA,WAAWC,UAAU,QAAQ,kBAAiB;AAEvD,SAASC,iBAAiB,QAAQ,qCAAoC;AACtE,SAASC,6BAA6B,QAAQ,oBAAmB;AAUjE,OAAO,MAAMC,0BAA0B,OAAO,EAC5CC,QAAQ,EACRC,OAAO,EACPC,qBAAqB,EACrBC,UAAU,EACVC,IAAI,EACC;IACL,IAAIC,gBAAgC,EAAE;IAEtC,IAAI;QACF,MAAM,EAAEC,IAAI,EAAE,GAAG,MAAMT,kBAAkB;YACvCU,OAAO;YACPN;YACAC;YACAC;YACAC;QACF;QACAC,gBAAgBC,KAAKE,GAAG,CAAC,CAACC,MAAS,CAAA;gBACjCC,OAAOC,OAAOF,GAAG,CAACN,WAAW;gBAC7BS,OAAOH,IAAII,EAAE;YACf,CAAA;IACF,EAAE,OAAOC,GAAG;IACV,mCAAmC;IACrC;IAEA,MAAMnB,UAAU,MAAMC;IACtB,IAAImB,eAAepB,QAAQqB,GAAG,CAAC,mBAAmBJ;IAClD,IAAIK,eAAeC;IAEnB;;GAEC,GACD,IAAIH,cAAc;QAChB,MAAMI,iBAAiBd,cAAce,IAAI,CAAC,CAACC,SAAWV,OAAOU,OAAOT,KAAK,MAAMG;QAC/E,IAAII,gBAAgB;YAClBF,eAAeE,eAAeP,KAAK;QACrC;IACF;IAEA;;GAEC,GACD,IAAI,CAACK,cAAc;QACjBF,eAAeG;QACfD,eAAeZ,cAAciB,MAAM,GAAG,IAAIJ,YAAYb,aAAa,CAAC,EAAE,EAAEO;IAC1E;IAEA,qBACE,KAACd;QACCmB,cAAcA;QACdF,cAAcA;QACdV,eAAeA;kBAEdL;;AAGP,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getGlobalViewRedirect.d.ts","sourceRoot":"","sources":["../../src/utilities/getGlobalViewRedirect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAOvD,KAAK,IAAI,GAAG;IACV,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,eAAe,EAAE,MAAM,CAAA;IACvB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,IAAI,EAAE,SAAS,CAAA;CAChB,CAAA;AACD,wBAAsB,qBAAqB,CAAC,EAC1C,IAAI,EACJ,KAAK,EACL,OAAO,EACP,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,IAAI,EACJ,IAAI,GACL,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA6D/B"}
1
+ {"version":3,"file":"getGlobalViewRedirect.d.ts","sourceRoot":"","sources":["../../src/utilities/getGlobalViewRedirect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAMvD,KAAK,IAAI,GAAG;IACV,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,eAAe,EAAE,MAAM,CAAA;IACvB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,IAAI,EAAE,SAAS,CAAA;CAChB,CAAA;AACD,wBAAsB,qBAAqB,CAAC,EAC1C,IAAI,EACJ,KAAK,EACL,OAAO,EACP,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,IAAI,EACJ,IAAI,GACL,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA6D/B"}
@@ -1,4 +1,3 @@
1
- import { SELECT_ALL } from '../constants.js';
2
1
  import { findTenantOptions } from '../queries/findTenantOptions.js';
3
2
  import { getCollectionIDType } from './getCollectionIDType.js';
4
3
  import { getTenantFromCookie } from './getTenantFromCookie.js';
@@ -9,7 +8,7 @@ export async function getGlobalViewRedirect({ slug, docID, headers, payload, ten
9
8
  });
10
9
  let tenant = getTenantFromCookie(headers, idType);
11
10
  let redirectRoute;
12
- if (!tenant || tenant === SELECT_ALL) {
11
+ if (!tenant) {
13
12
  const tenantsQuery = await findTenantOptions({
14
13
  limit: 1,
15
14
  payload,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getGlobalViewRedirect.ts"],"sourcesContent":["import type { Payload, User, ViewTypes } from 'payload'\n\nimport { SELECT_ALL } from '../constants.js'\nimport { findTenantOptions } from '../queries/findTenantOptions.js'\nimport { getCollectionIDType } from './getCollectionIDType.js'\nimport { getTenantFromCookie } from './getTenantFromCookie.js'\n\ntype Args = {\n docID?: number | string\n headers: Headers\n payload: Payload\n slug: string\n tenantFieldName: string\n tenantsCollectionSlug: string\n useAsTitle: string\n user?: User\n view: ViewTypes\n}\nexport async function getGlobalViewRedirect({\n slug,\n docID,\n headers,\n payload,\n tenantFieldName,\n tenantsCollectionSlug,\n useAsTitle,\n user,\n view,\n}: Args): Promise<string | void> {\n const idType = getCollectionIDType({\n collectionSlug: tenantsCollectionSlug,\n payload,\n })\n let tenant = getTenantFromCookie(headers, idType)\n let redirectRoute\n\n if (!tenant || tenant === SELECT_ALL) {\n const tenantsQuery = await findTenantOptions({\n limit: 1,\n payload,\n tenantsCollectionSlug,\n useAsTitle,\n user,\n })\n\n tenant = tenantsQuery.docs[0]?.id || null\n }\n\n try {\n const { docs } = await payload.find({\n collection: slug,\n depth: 0,\n limit: 1,\n overrideAccess: false,\n pagination: false,\n user,\n where: {\n [tenantFieldName]: {\n equals: tenant,\n },\n },\n })\n\n const tenantDocID = docs?.[0]?.id\n\n if (view === 'document') {\n if (docID && !tenantDocID) {\n // viewing a document with an id but does not match the selected tenant, redirect to create route\n redirectRoute = `${payload.config.routes.admin}/collections/${slug}/create`\n } else if (tenantDocID && docID !== tenantDocID) {\n // tenant document already exists but does not match current route doc ID, redirect to matching tenant doc\n redirectRoute = `${payload.config.routes.admin}/collections/${slug}/${tenantDocID}`\n }\n } else if (view === 'list') {\n if (tenantDocID) {\n // tenant document exists, redirect to edit view\n redirectRoute = `${payload.config.routes.admin}/collections/${slug}/${tenantDocID}`\n } else {\n // tenant document does not exist, redirect to create route\n redirectRoute = `${payload.config.routes.admin}/collections/${slug}/create`\n }\n }\n } catch (e: unknown) {\n payload.logger.error(\n e,\n `${typeof e === 'object' && e && 'message' in e ? `e?.message - ` : ''}Multi Tenant Redirect Error`,\n )\n }\n return redirectRoute\n}\n"],"names":["SELECT_ALL","findTenantOptions","getCollectionIDType","getTenantFromCookie","getGlobalViewRedirect","slug","docID","headers","payload","tenantFieldName","tenantsCollectionSlug","useAsTitle","user","view","idType","collectionSlug","tenant","redirectRoute","tenantsQuery","limit","docs","id","find","collection","depth","overrideAccess","pagination","where","equals","tenantDocID","config","routes","admin","e","logger","error"],"mappings":"AAEA,SAASA,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,iBAAiB,QAAQ,kCAAiC;AACnE,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,mBAAmB,QAAQ,2BAA0B;AAa9D,OAAO,eAAeC,sBAAsB,EAC1CC,IAAI,EACJC,KAAK,EACLC,OAAO,EACPC,OAAO,EACPC,eAAe,EACfC,qBAAqB,EACrBC,UAAU,EACVC,IAAI,EACJC,IAAI,EACC;IACL,MAAMC,SAASZ,oBAAoB;QACjCa,gBAAgBL;QAChBF;IACF;IACA,IAAIQ,SAASb,oBAAoBI,SAASO;IAC1C,IAAIG;IAEJ,IAAI,CAACD,UAAUA,WAAWhB,YAAY;QACpC,MAAMkB,eAAe,MAAMjB,kBAAkB;YAC3CkB,OAAO;YACPX;YACAE;YACAC;YACAC;QACF;QAEAI,SAASE,aAAaE,IAAI,CAAC,EAAE,EAAEC,MAAM;IACvC;IAEA,IAAI;QACF,MAAM,EAAED,IAAI,EAAE,GAAG,MAAMZ,QAAQc,IAAI,CAAC;YAClCC,YAAYlB;YACZmB,OAAO;YACPL,OAAO;YACPM,gBAAgB;YAChBC,YAAY;YACZd;YACAe,OAAO;gBACL,CAAClB,gBAAgB,EAAE;oBACjBmB,QAAQZ;gBACV;YACF;QACF;QAEA,MAAMa,cAAcT,MAAM,CAAC,EAAE,EAAEC;QAE/B,IAAIR,SAAS,YAAY;YACvB,IAAIP,SAAS,CAACuB,aAAa;gBACzB,iGAAiG;gBACjGZ,gBAAgB,GAAGT,QAAQsB,MAAM,CAACC,MAAM,CAACC,KAAK,CAAC,aAAa,EAAE3B,KAAK,OAAO,CAAC;YAC7E,OAAO,IAAIwB,eAAevB,UAAUuB,aAAa;gBAC/C,0GAA0G;gBAC1GZ,gBAAgB,GAAGT,QAAQsB,MAAM,CAACC,MAAM,CAACC,KAAK,CAAC,aAAa,EAAE3B,KAAK,CAAC,EAAEwB,aAAa;YACrF;QACF,OAAO,IAAIhB,SAAS,QAAQ;YAC1B,IAAIgB,aAAa;gBACf,gDAAgD;gBAChDZ,gBAAgB,GAAGT,QAAQsB,MAAM,CAACC,MAAM,CAACC,KAAK,CAAC,aAAa,EAAE3B,KAAK,CAAC,EAAEwB,aAAa;YACrF,OAAO;gBACL,2DAA2D;gBAC3DZ,gBAAgB,GAAGT,QAAQsB,MAAM,CAACC,MAAM,CAACC,KAAK,CAAC,aAAa,EAAE3B,KAAK,OAAO,CAAC;YAC7E;QACF;IACF,EAAE,OAAO4B,GAAY;QACnBzB,QAAQ0B,MAAM,CAACC,KAAK,CAClBF,GACA,GAAG,OAAOA,MAAM,YAAYA,KAAK,aAAaA,IAAI,CAAC,aAAa,CAAC,GAAG,GAAG,2BAA2B,CAAC;IAEvG;IACA,OAAOhB;AACT"}
1
+ {"version":3,"sources":["../../src/utilities/getGlobalViewRedirect.ts"],"sourcesContent":["import type { Payload, User, ViewTypes } from 'payload'\n\nimport { findTenantOptions } from '../queries/findTenantOptions.js'\nimport { getCollectionIDType } from './getCollectionIDType.js'\nimport { getTenantFromCookie } from './getTenantFromCookie.js'\n\ntype Args = {\n docID?: number | string\n headers: Headers\n payload: Payload\n slug: string\n tenantFieldName: string\n tenantsCollectionSlug: string\n useAsTitle: string\n user?: User\n view: ViewTypes\n}\nexport async function getGlobalViewRedirect({\n slug,\n docID,\n headers,\n payload,\n tenantFieldName,\n tenantsCollectionSlug,\n useAsTitle,\n user,\n view,\n}: Args): Promise<string | void> {\n const idType = getCollectionIDType({\n collectionSlug: tenantsCollectionSlug,\n payload,\n })\n let tenant = getTenantFromCookie(headers, idType)\n let redirectRoute\n\n if (!tenant) {\n const tenantsQuery = await findTenantOptions({\n limit: 1,\n payload,\n tenantsCollectionSlug,\n useAsTitle,\n user,\n })\n\n tenant = tenantsQuery.docs[0]?.id || null\n }\n\n try {\n const { docs } = await payload.find({\n collection: slug,\n depth: 0,\n limit: 1,\n overrideAccess: false,\n pagination: false,\n user,\n where: {\n [tenantFieldName]: {\n equals: tenant,\n },\n },\n })\n\n const tenantDocID = docs?.[0]?.id\n\n if (view === 'document') {\n if (docID && !tenantDocID) {\n // viewing a document with an id but does not match the selected tenant, redirect to create route\n redirectRoute = `${payload.config.routes.admin}/collections/${slug}/create`\n } else if (tenantDocID && docID !== tenantDocID) {\n // tenant document already exists but does not match current route doc ID, redirect to matching tenant doc\n redirectRoute = `${payload.config.routes.admin}/collections/${slug}/${tenantDocID}`\n }\n } else if (view === 'list') {\n if (tenantDocID) {\n // tenant document exists, redirect to edit view\n redirectRoute = `${payload.config.routes.admin}/collections/${slug}/${tenantDocID}`\n } else {\n // tenant document does not exist, redirect to create route\n redirectRoute = `${payload.config.routes.admin}/collections/${slug}/create`\n }\n }\n } catch (e: unknown) {\n payload.logger.error(\n e,\n `${typeof e === 'object' && e && 'message' in e ? `e?.message - ` : ''}Multi Tenant Redirect Error`,\n )\n }\n return redirectRoute\n}\n"],"names":["findTenantOptions","getCollectionIDType","getTenantFromCookie","getGlobalViewRedirect","slug","docID","headers","payload","tenantFieldName","tenantsCollectionSlug","useAsTitle","user","view","idType","collectionSlug","tenant","redirectRoute","tenantsQuery","limit","docs","id","find","collection","depth","overrideAccess","pagination","where","equals","tenantDocID","config","routes","admin","e","logger","error"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,kCAAiC;AACnE,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,mBAAmB,QAAQ,2BAA0B;AAa9D,OAAO,eAAeC,sBAAsB,EAC1CC,IAAI,EACJC,KAAK,EACLC,OAAO,EACPC,OAAO,EACPC,eAAe,EACfC,qBAAqB,EACrBC,UAAU,EACVC,IAAI,EACJC,IAAI,EACC;IACL,MAAMC,SAASZ,oBAAoB;QACjCa,gBAAgBL;QAChBF;IACF;IACA,IAAIQ,SAASb,oBAAoBI,SAASO;IAC1C,IAAIG;IAEJ,IAAI,CAACD,QAAQ;QACX,MAAME,eAAe,MAAMjB,kBAAkB;YAC3CkB,OAAO;YACPX;YACAE;YACAC;YACAC;QACF;QAEAI,SAASE,aAAaE,IAAI,CAAC,EAAE,EAAEC,MAAM;IACvC;IAEA,IAAI;QACF,MAAM,EAAED,IAAI,EAAE,GAAG,MAAMZ,QAAQc,IAAI,CAAC;YAClCC,YAAYlB;YACZmB,OAAO;YACPL,OAAO;YACPM,gBAAgB;YAChBC,YAAY;YACZd;YACAe,OAAO;gBACL,CAAClB,gBAAgB,EAAE;oBACjBmB,QAAQZ;gBACV;YACF;QACF;QAEA,MAAMa,cAAcT,MAAM,CAAC,EAAE,EAAEC;QAE/B,IAAIR,SAAS,YAAY;YACvB,IAAIP,SAAS,CAACuB,aAAa;gBACzB,iGAAiG;gBACjGZ,gBAAgB,GAAGT,QAAQsB,MAAM,CAACC,MAAM,CAACC,KAAK,CAAC,aAAa,EAAE3B,KAAK,OAAO,CAAC;YAC7E,OAAO,IAAIwB,eAAevB,UAAUuB,aAAa;gBAC/C,0GAA0G;gBAC1GZ,gBAAgB,GAAGT,QAAQsB,MAAM,CAACC,MAAM,CAACC,KAAK,CAAC,aAAa,EAAE3B,KAAK,CAAC,EAAEwB,aAAa;YACrF;QACF,OAAO,IAAIhB,SAAS,QAAQ;YAC1B,IAAIgB,aAAa;gBACf,gDAAgD;gBAChDZ,gBAAgB,GAAGT,QAAQsB,MAAM,CAACC,MAAM,CAACC,KAAK,CAAC,aAAa,EAAE3B,KAAK,CAAC,EAAEwB,aAAa;YACrF,OAAO;gBACL,2DAA2D;gBAC3DZ,gBAAgB,GAAGT,QAAQsB,MAAM,CAACC,MAAM,CAACC,KAAK,CAAC,aAAa,EAAE3B,KAAK,OAAO,CAAC;YAC7E;QACF;IACF,EAAE,OAAO4B,GAAY;QACnBzB,QAAQ0B,MAAM,CAACC,KAAK,CAClBF,GACA,GAAG,OAAOA,MAAM,YAAYA,KAAK,aAAaA,IAAI,CAAC,aAAa,CAAC,GAAG,GAAG,2BAA2B,CAAC;IAEvG;IACA,OAAOhB;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-multi-tenant",
3
- "version": "3.28.0-internal.c4e1bed",
3
+ "version": "3.28.1",
4
4
  "description": "Multi Tenant plugin for Payload",
5
5
  "keywords": [
6
6
  "payload",
@@ -66,15 +66,15 @@
66
66
  "types.d.ts"
67
67
  ],
68
68
  "devDependencies": {
69
- "@payloadcms/eslint-config": "3.9.0",
70
- "@payloadcms/translations": "3.28.0-internal.c4e1bed",
71
- "@payloadcms/ui": "3.28.0-internal.c4e1bed",
72
- "payload": "3.28.0-internal.c4e1bed"
69
+ "@payloadcms/eslint-config": "3.28.0",
70
+ "@payloadcms/translations": "3.28.1",
71
+ "@payloadcms/ui": "3.28.1",
72
+ "payload": "3.28.1"
73
73
  },
74
74
  "peerDependencies": {
75
75
  "next": "^15.0.3",
76
- "@payloadcms/ui": "3.28.0-internal.c4e1bed",
77
- "payload": "3.28.0-internal.c4e1bed"
76
+ "@payloadcms/ui": "3.28.1",
77
+ "payload": "3.28.1"
78
78
  },
79
79
  "homepage:": "https://payloadcms.com",
80
80
  "scripts": {
@@ -1,2 +0,0 @@
1
- export declare const SELECT_ALL = "_ALL_";
2
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,UAAU,UAAU,CAAA"}
package/dist/constants.js DELETED
@@ -1,4 +0,0 @@
1
- // The tenant cookie can be set to _ALL_ to allow users to see all results for tenants they are a member of.
2
- export const SELECT_ALL = '_ALL_';
3
-
4
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["// The tenant cookie can be set to _ALL_ to allow users to see all results for tenants they are a member of.\nexport const SELECT_ALL = '_ALL_'\n"],"names":["SELECT_ALL"],"mappings":"AAAA,4GAA4G;AAC5G,OAAO,MAAMA,aAAa,QAAO"}