feat: implement AI-driven learning content generation service and interactive student dashboard
This commit is contained in:
@@ -6,7 +6,7 @@ const AppContext = createContext();
|
||||
const initialState = {
|
||||
currentUser: null,
|
||||
users: [],
|
||||
weekNumber: 1,
|
||||
weekNumber: getWeekNumber(new Date()),
|
||||
isLoading: true
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ function appReducer(state, action) {
|
||||
return {
|
||||
...state,
|
||||
users: action.payload.users,
|
||||
weekNumber: action.payload.weekNumber,
|
||||
weekNumber: action.payload.weekNumber || state.weekNumber,
|
||||
isLoading: false
|
||||
};
|
||||
case 'LOGIN':
|
||||
@@ -30,6 +30,13 @@ function appReducer(state, action) {
|
||||
}
|
||||
}
|
||||
|
||||
function getWeekNumber(d) {
|
||||
d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
|
||||
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay()||7));
|
||||
const yearStart = new Date(Date.UTC(d.getUTCFullYear(),0,1));
|
||||
return Math.ceil(( ( (d - yearStart) / 86400000) + 1)/7);
|
||||
}
|
||||
|
||||
export function AppProvider({ children }) {
|
||||
const [state, dispatch] = useReducer(appReducer, initialState);
|
||||
|
||||
@@ -47,7 +54,7 @@ export function AppProvider({ children }) {
|
||||
}
|
||||
}
|
||||
|
||||
const storedWeek = Number(await db.getSetting('admin:current_week', 1));
|
||||
const storedWeek = getWeekNumber(new Date());
|
||||
|
||||
const sessionUserId = sessionStorage.getItem('respellion_session');
|
||||
if (sessionUserId) {
|
||||
|
||||
Reference in New Issue
Block a user