get lessons list

This commit is contained in:
2024-02-29 09:18:13 +03:00
parent 5134d44e39
commit 80713f7e0f
7 changed files with 72 additions and 54 deletions

View File

@@ -2,6 +2,7 @@ import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
import { getConfigValue } from "@ijl/cli";
import { keycloak } from "../kc";
import { BaseResponse, Lesson } from "../model";
export const api = createApi({
reducerPath: "auth",
@@ -13,7 +14,7 @@ export const api = createApi({
},
}),
endpoints: (builder) => ({
lessonList: builder.query({
lessonList: builder.query<BaseResponse<Lesson[]>, void>({
query: () => '/lesson/list'
})
// signIn: builder.mutation<SignInResponce, SignInRequestBody>({

View File

@@ -11,7 +11,7 @@ interface TokenData {
nonce: string;
session_state: string;
acr: string;
'allowed-origins': string[];
"allowed-origins": string[];
realm_access: Realmaccess;
resource_access: Resourceaccess;
scope: string;
@@ -25,25 +25,34 @@ interface TokenData {
}
interface Resourceaccess {
'realm-management': Realmaccess;
jurnal: Realmaccess;
broker: Realmaccess;
account: Realmaccess;
'microfrontend-admin': Realmaccess
journal: Realmaccess;
}
interface Realmaccess {
roles: string[];
roles: (string | "teacher")[];
}
export interface UserData extends TokenData {
sub: string;
gravatar: string;
email_verified: boolean;
attributes: Record<string, string[]>
attributes: Record<string, string[]>;
name: string;
preferred_username: string;
given_name: string;
family_name: string;
email: string;
}
export type BaseResponse<Data> = {
success: boolean;
body: Data;
};
export interface Lesson {
_id: string;
name: string;
students: any[];
date: string;
created: string;
}

View File

@@ -1,4 +1,5 @@
import { configureStore } from '@reduxjs/toolkit';
import { TypedUseSelectorHook, useSelector } from 'react-redux';
import { api } from './api/api';
import { userSlice } from './slices/user';
@@ -13,4 +14,6 @@ export const createStore= (preloadedState = {}) => configureStore({
getDefaultMiddleware().concat(api.middleware),
});
export type Store = ReturnType<ReturnType<typeof createStore>['getState']>;
export type Store = ReturnType<ReturnType<typeof createStore>['getState']>;
export const useAppSelector: TypedUseSelectorHook<Store> = useSelector;