@tumaet/prompt-shared-state 0.0.5 → 0.0.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.
- package/dist/types/interfaces/application/exportedApplicationAnswer.d.ts +1 -1
- package/dist/types/interfaces/coursePhase/createCoursePhase.d.ts +1 -1
- package/dist/types/zustand/useAuthStore.d.ts +13 -0
- package/dist/types/zustand/useCourseStore.d.ts +11 -0
- package/dist/zustand/useAuthStore.js +17 -0
- package/dist/zustand/useAuthStore.js.map +1 -0
- package/dist/zustand/useCourseStore.js +15 -0
- package/dist/zustand/useCourseStore.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { User } from '../interfaces/user/user';
|
|
2
|
+
interface AuthStoreState {
|
|
3
|
+
user?: User;
|
|
4
|
+
permissions: string[];
|
|
5
|
+
setUser: (user: User) => void;
|
|
6
|
+
clearUser: () => void;
|
|
7
|
+
setPermissions: (permissions: string[]) => void;
|
|
8
|
+
clearPermissions: () => void;
|
|
9
|
+
logout: (redirectUri?: string) => void;
|
|
10
|
+
setLogoutFunction: (logoutFunction: (redirectUri?: string) => void) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const useAuthStore: import("zustand").UseBoundStore<import("zustand").StoreApi<AuthStoreState>>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Course } from '../interfaces/course/course';
|
|
2
|
+
interface CourseStoreState {
|
|
3
|
+
selectedCourse?: Course;
|
|
4
|
+
courses: Course[];
|
|
5
|
+
}
|
|
6
|
+
interface CourseStoreAction {
|
|
7
|
+
setSelectedCourse: (selectedCourse?: Course) => void;
|
|
8
|
+
setCourses: (courses: Course[]) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const useCourseStore: import("zustand").UseBoundStore<import("zustand").StoreApi<CourseStoreState & CourseStoreAction>>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
export const useAuthStore = create((set) => ({
|
|
3
|
+
user: undefined,
|
|
4
|
+
permissions: [],
|
|
5
|
+
setUser: (user) => set({ user }),
|
|
6
|
+
clearUser: () => set({ user: undefined }),
|
|
7
|
+
setPermissions: (permissions) => set({ permissions }),
|
|
8
|
+
clearPermissions: () => set({ permissions: [] }),
|
|
9
|
+
logout: (redirectUri) => {
|
|
10
|
+
console.warn('Logout function not initialized'); // Default fallback -> once the setLogout is set, this will be overwritten
|
|
11
|
+
if (redirectUri) {
|
|
12
|
+
window.location.href = redirectUri; // Default fallback for redirection
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
setLogoutFunction: (logoutFunction) => set({ logout: logoutFunction }),
|
|
16
|
+
}));
|
|
17
|
+
//# sourceMappingURL=useAuthStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAuthStore.js","sourceRoot":"","sources":["../../src/zustand/useAuthStore.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAchC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAiB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC3D,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IAChC,SAAS,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IACzC,cAAc,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,CAAC;IACrD,gBAAgB,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IAChD,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE;QACtB,OAAO,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA,CAAC,0EAA0E;QAC1H,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,WAAW,CAAA,CAAC,mCAAmC;QACxE,CAAC;IACH,CAAC;IACD,iBAAiB,EAAE,CAAC,cAAc,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;CACvE,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
export const useCourseStore = create((set) => ({
|
|
3
|
+
courses: [],
|
|
4
|
+
setSelectedCourse: (selectedCourse) => {
|
|
5
|
+
if (selectedCourse) {
|
|
6
|
+
localStorage.setItem('selected-course', selectedCourse.id);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
localStorage.removeItem('selected-course');
|
|
10
|
+
}
|
|
11
|
+
set({ selectedCourse });
|
|
12
|
+
},
|
|
13
|
+
setCourses: (courses) => set({ courses }),
|
|
14
|
+
}));
|
|
15
|
+
//# sourceMappingURL=useCourseStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCourseStore.js","sourceRoot":"","sources":["../../src/zustand/useCourseStore.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAahC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAuC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACnF,OAAO,EAAE,EAAE;IACX,iBAAiB,EAAE,CAAC,cAAuB,EAAE,EAAE;QAC7C,IAAI,cAAc,EAAE,CAAC;YACnB,YAAY,CAAC,OAAO,CAAC,iBAAiB,EAAE,cAAc,CAAC,EAAE,CAAC,CAAA;QAC5D,CAAC;aAAM,CAAC;YACN,YAAY,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAA;QAC5C,CAAC;QAED,GAAG,CAAC,EAAE,cAAc,EAAE,CAAC,CAAA;IACzB,CAAC;IACD,UAAU,EAAE,CAAC,OAAiB,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,CAAC;CACpD,CAAC,CAAC,CAAA"}
|