feat: implement skeleton layout for settings and search pages (#366)
Co-authored-by: Lê Nhân Phụng <lenhanphung@Phung-Mac-M4.local>
This commit is contained in:
@@ -5,10 +5,12 @@
|
|||||||
justify-content space-between
|
justify-content space-between
|
||||||
|
|
||||||
.main-layout
|
.main-layout
|
||||||
|
display flex
|
||||||
|
height calc(100vh - 90px)
|
||||||
|
|
||||||
|
.main-layout.calendar-layout
|
||||||
background-color #fff
|
background-color #fff
|
||||||
flex-direction row
|
flex-direction row
|
||||||
height calc(100vh - 90px)
|
|
||||||
display flex
|
|
||||||
|
|
||||||
.calendar
|
.calendar
|
||||||
flex-grow 1
|
flex-grow 1
|
||||||
|
|||||||
@@ -574,7 +574,7 @@ export default function CalendarApp({
|
|||||||
const { t, lang } = useI18n();
|
const { t, lang } = useI18n();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="main-layout">
|
<main className="main-layout calendar-layout">
|
||||||
<Box
|
<Box
|
||||||
className="sidebar"
|
className="sidebar"
|
||||||
sx={{
|
sx={{
|
||||||
|
|||||||
@@ -7,12 +7,16 @@ import { useAppSelector } from "../../app/hooks";
|
|||||||
import { refreshCalendars } from "../Event/utils/eventUtils";
|
import { refreshCalendars } from "../Event/utils/eventUtils";
|
||||||
import { ErrorSnackbar } from "../Error/ErrorSnackbar";
|
import { ErrorSnackbar } from "../Error/ErrorSnackbar";
|
||||||
|
|
||||||
|
import SettingsPage from "../../features/Settings/SettingsPage";
|
||||||
|
import SearchResultsPage from "../../features/Search/SearchResultsPage";
|
||||||
|
|
||||||
export default function CalendarLayout() {
|
export default function CalendarLayout() {
|
||||||
const calendarRef = useRef<any>(null);
|
const calendarRef = useRef<any>(null);
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const error = useAppSelector((state) => state.calendars.error);
|
const error = useAppSelector((state) => state.calendars.error);
|
||||||
const selectedCalendars = useAppSelector((state) => state.calendars.list);
|
const selectedCalendars = useAppSelector((state) => state.calendars.list);
|
||||||
const tempcalendars = useAppSelector((state) => state.calendars.templist);
|
const tempcalendars = useAppSelector((state) => state.calendars.templist);
|
||||||
|
const view = useAppSelector((state) => state.settings.view);
|
||||||
const [currentDate, setCurrentDate] = useState<Date>(new Date());
|
const [currentDate, setCurrentDate] = useState<Date>(new Date());
|
||||||
const [currentView, setCurrentView] = useState<string>("timeGridWeek");
|
const [currentView, setCurrentView] = useState<string>("timeGridWeek");
|
||||||
|
|
||||||
@@ -59,11 +63,15 @@ export default function CalendarLayout() {
|
|||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<Menubar {...menubarProps} />
|
<Menubar {...menubarProps} />
|
||||||
<CalendarApp
|
{view === "calendar" && (
|
||||||
calendarRef={calendarRef}
|
<CalendarApp
|
||||||
onDateChange={handleDateChange}
|
calendarRef={calendarRef}
|
||||||
onViewChange={handleViewChange}
|
onDateChange={handleDateChange}
|
||||||
/>
|
onViewChange={handleViewChange}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{view === "settings" && <SettingsPage />}
|
||||||
|
{view === "search" && <SearchResultsPage />}
|
||||||
<ErrorSnackbar error={error} type="calendar" />
|
<ErrorSnackbar error={error} type="calendar" />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export default function SearchResultsPage() {
|
||||||
|
return (
|
||||||
|
<main className="main-layout search-layout">
|
||||||
|
<h1>Search Results</h1>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export default function SettingsPage() {
|
||||||
|
return (
|
||||||
|
<main className="main-layout settings-layout">
|
||||||
|
<h1>Settings Page</h1>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|||||||
|
|
||||||
export interface SettingsState {
|
export interface SettingsState {
|
||||||
language: string;
|
language: string;
|
||||||
|
view: "calendar" | "settings" | "search";
|
||||||
}
|
}
|
||||||
|
|
||||||
const savedLang = localStorage.getItem("lang");
|
const savedLang = localStorage.getItem("lang");
|
||||||
@@ -9,6 +10,7 @@ const defaultLang = savedLang ?? (window as any).LANG ?? "en";
|
|||||||
|
|
||||||
const initialState: SettingsState = {
|
const initialState: SettingsState = {
|
||||||
language: defaultLang,
|
language: defaultLang,
|
||||||
|
view: "calendar",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const settingsSlice = createSlice({
|
export const settingsSlice = createSlice({
|
||||||
@@ -19,8 +21,14 @@ export const settingsSlice = createSlice({
|
|||||||
state.language = action.payload;
|
state.language = action.payload;
|
||||||
localStorage.setItem("lang", action.payload);
|
localStorage.setItem("lang", action.payload);
|
||||||
},
|
},
|
||||||
|
setView: (
|
||||||
|
state,
|
||||||
|
action: PayloadAction<"calendar" | "settings" | "search">
|
||||||
|
) => {
|
||||||
|
state.view = action.payload;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const { setLanguage } = settingsSlice.actions;
|
export const { setLanguage, setView } = settingsSlice.actions;
|
||||||
export default settingsSlice.reducer;
|
export default settingsSlice.reducer;
|
||||||
|
|||||||
Reference in New Issue
Block a user