@asgardeo/react 0.5.6 → 0.5.7
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.
|
@@ -15,19 +15,23 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { AllOrganizationsApiResponse, Organization } from '@asgardeo/browser';
|
|
18
|
+
import { AllOrganizationsApiResponse, Organization, CreateOrganizationPayload } from '@asgardeo/browser';
|
|
19
19
|
import { Context } from 'react';
|
|
20
20
|
/**
|
|
21
21
|
* Props interface of {@link OrganizationContext}
|
|
22
22
|
*/
|
|
23
23
|
export type OrganizationContextProps = {
|
|
24
|
+
/**
|
|
25
|
+
* Function to create a new organization.
|
|
26
|
+
*/
|
|
27
|
+
createOrganization?: (payload: CreateOrganizationPayload, sessionId: string) => Promise<Organization>;
|
|
24
28
|
currentOrganization: Organization | null;
|
|
25
29
|
error: string | null;
|
|
30
|
+
getAllOrganizations: () => Promise<AllOrganizationsApiResponse>;
|
|
26
31
|
isLoading: boolean;
|
|
27
32
|
myOrganizations: Organization[];
|
|
28
|
-
switchOrganization: (organization: Organization) => Promise<void>;
|
|
29
33
|
revalidateMyOrganizations: () => Promise<Organization[]>;
|
|
30
|
-
|
|
34
|
+
switchOrganization: (organization: Organization) => Promise<void>;
|
|
31
35
|
};
|
|
32
36
|
/**
|
|
33
37
|
* Context object for managing organization data and related operations.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { Organization, AllOrganizationsApiResponse } from '@asgardeo/browser';
|
|
18
|
+
import { Organization, AllOrganizationsApiResponse, CreateOrganizationPayload } from '@asgardeo/browser';
|
|
19
19
|
import { FC, PropsWithChildren } from 'react';
|
|
20
20
|
/**
|
|
21
21
|
* Props interface of {@link OrganizationProvider}
|
|
@@ -25,10 +25,18 @@ export interface OrganizationProviderProps {
|
|
|
25
25
|
* Whether to automatically fetch organizations on mount
|
|
26
26
|
*/
|
|
27
27
|
autoFetch?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Function to create a new organization.
|
|
30
|
+
*/
|
|
31
|
+
createOrganization?: (payload: CreateOrganizationPayload, sessionId: string) => Promise<Organization>;
|
|
28
32
|
/**
|
|
29
33
|
* Initial current organization
|
|
30
34
|
*/
|
|
31
35
|
currentOrganization?: Organization | null;
|
|
36
|
+
/**
|
|
37
|
+
* Initial list of organizations
|
|
38
|
+
*/
|
|
39
|
+
getAllOrganizations?: () => Promise<AllOrganizationsApiResponse>;
|
|
32
40
|
/**
|
|
33
41
|
* List of organizations the signed-in user belongs to.
|
|
34
42
|
*/
|
|
@@ -41,10 +49,6 @@ export interface OrganizationProviderProps {
|
|
|
41
49
|
* Callback function called when switching organizations
|
|
42
50
|
*/
|
|
43
51
|
onOrganizationSwitch?: (organization: Organization) => Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Initial list of organizations
|
|
46
|
-
*/
|
|
47
|
-
getAllOrganizations?: () => Promise<AllOrganizationsApiResponse>;
|
|
48
52
|
/**
|
|
49
53
|
* Refetch the my organizations list.
|
|
50
54
|
* @returns
|
package/dist/index.js
CHANGED
|
@@ -968,22 +968,25 @@ var I18nProvider = ({
|
|
|
968
968
|
var I18nProvider_default = I18nProvider;
|
|
969
969
|
|
|
970
970
|
// src/contexts/Organization/OrganizationProvider.tsx
|
|
971
|
-
import {
|
|
971
|
+
import {
|
|
972
|
+
AsgardeoRuntimeError as AsgardeoRuntimeError2
|
|
973
|
+
} from "@asgardeo/browser";
|
|
972
974
|
import { useCallback as useCallback3, useMemo as useMemo3, useState as useState3 } from "react";
|
|
973
975
|
|
|
974
976
|
// src/contexts/Organization/OrganizationContext.ts
|
|
975
977
|
import { createContext as createContext4 } from "react";
|
|
976
978
|
var OrganizationContext = createContext4({
|
|
979
|
+
createOrganization: () => null,
|
|
977
980
|
currentOrganization: null,
|
|
978
981
|
error: null,
|
|
979
|
-
isLoading: false,
|
|
980
|
-
myOrganizations: null,
|
|
981
|
-
switchOrganization: () => Promise.resolve(),
|
|
982
|
-
revalidateMyOrganizations: () => Promise.resolve([]),
|
|
983
982
|
getAllOrganizations: () => Promise.resolve({
|
|
984
983
|
count: 0,
|
|
985
984
|
organizations: []
|
|
986
|
-
})
|
|
985
|
+
}),
|
|
986
|
+
isLoading: false,
|
|
987
|
+
myOrganizations: null,
|
|
988
|
+
revalidateMyOrganizations: () => Promise.resolve([]),
|
|
989
|
+
switchOrganization: () => Promise.resolve()
|
|
987
990
|
});
|
|
988
991
|
OrganizationContext.displayName = "OrganizationContext";
|
|
989
992
|
var OrganizationContext_default = OrganizationContext;
|
|
@@ -997,7 +1000,8 @@ var OrganizationProvider = ({
|
|
|
997
1000
|
myOrganizations,
|
|
998
1001
|
onOrganizationSwitch,
|
|
999
1002
|
revalidateMyOrganizations,
|
|
1000
|
-
getAllOrganizations: getAllOrganizations2
|
|
1003
|
+
getAllOrganizations: getAllOrganizations2,
|
|
1004
|
+
createOrganization: createOrganization2
|
|
1001
1005
|
}) => {
|
|
1002
1006
|
const [isLoading, setIsLoading] = useState3(false);
|
|
1003
1007
|
const [error, setError] = useState3(null);
|
|
@@ -1030,13 +1034,14 @@ var OrganizationProvider = ({
|
|
|
1030
1034
|
);
|
|
1031
1035
|
const contextValue = useMemo3(
|
|
1032
1036
|
() => ({
|
|
1037
|
+
createOrganization: createOrganization2,
|
|
1033
1038
|
currentOrganization,
|
|
1034
1039
|
error,
|
|
1040
|
+
getAllOrganizations: getAllOrganizations2,
|
|
1035
1041
|
isLoading,
|
|
1036
1042
|
myOrganizations,
|
|
1037
|
-
switchOrganization,
|
|
1038
1043
|
revalidateMyOrganizations,
|
|
1039
|
-
|
|
1044
|
+
switchOrganization
|
|
1040
1045
|
}),
|
|
1041
1046
|
[
|
|
1042
1047
|
currentOrganization,
|
|
@@ -1045,7 +1050,8 @@ var OrganizationProvider = ({
|
|
|
1045
1050
|
myOrganizations,
|
|
1046
1051
|
switchOrganization,
|
|
1047
1052
|
revalidateMyOrganizations,
|
|
1048
|
-
getAllOrganizations2
|
|
1053
|
+
getAllOrganizations2,
|
|
1054
|
+
createOrganization2
|
|
1049
1055
|
]
|
|
1050
1056
|
);
|
|
1051
1057
|
return /* @__PURE__ */ jsx3(OrganizationContext_default.Provider, { value: contextValue, children });
|