mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 05:22:04 +00:00
chore(calendar): disable routes until backend exists
This commit is contained in:
parent
0187556d03
commit
ba34a3eb8e
5 changed files with 35 additions and 63 deletions
|
|
@ -0,0 +1,22 @@
|
|||
import { Alert, Box, Typography } from "@mui/material";
|
||||
|
||||
export function CalendarUnavailablePanel() {
|
||||
return (
|
||||
<Box className="mx-auto max-w-3xl">
|
||||
<Alert severity="warning" className="mb-4">
|
||||
Calendário indisponível — a API de calendário ainda não está implementada no backend.
|
||||
</Alert>
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
As rotas permanecem reservadas para quando o CalendarController for disponibilizado.
|
||||
</Typography>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
export default function CalendarUnavailablePage() {
|
||||
return (
|
||||
<Box className="p-4">
|
||||
<CalendarUnavailablePanel />
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,5 +1,13 @@
|
|||
import { Navigate } from "react-router-dom";
|
||||
import { Outlet } from "react-router-dom";
|
||||
import { Alert, Box } from "@mui/material";
|
||||
|
||||
export default function CalendarLayout() {
|
||||
return <Navigate to="/" replace />;
|
||||
return (
|
||||
<Box className="flex flex-col gap-4">
|
||||
<Alert severity="warning" className="mx-4 mt-4">
|
||||
Calendário indisponível — a API de calendário ainda não está implementada no backend.
|
||||
</Alert>
|
||||
<Outlet />
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
export { default } from "../_components/event-form";
|
||||
export { default } from "../_components/calendar-unavailable";
|
||||
|
|
|
|||
|
|
@ -1,59 +1 @@
|
|||
import { useMemo, useRef, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import type { DatesSetArg, EventClickArg } from "@fullcalendar/core";
|
||||
import type { DateClickArg } from "@fullcalendar/interaction";
|
||||
import FullCalendar from "@fullcalendar/react";
|
||||
import { Box } from "@mui/material";
|
||||
import { CalendarActionBar } from "@/components/common/calendar/calendar-action-bar";
|
||||
import { EventCalendar } from "@/components/common/calendar/event-calendar";
|
||||
import { mapEventToFullCalendar } from "@/components/common/calendar/calendar-utils";
|
||||
import { useCalendarEvents } from "@/domain/calendar/use-cases/use-calendar-events";
|
||||
|
||||
export default function CalendarPage() {
|
||||
const navigate = useNavigate();
|
||||
const calendarRef = useRef<FullCalendar>(null);
|
||||
const [range, setRange] = useState<{ start: Date; end: Date } | null>(null);
|
||||
const [title, setTitle] = useState("");
|
||||
|
||||
const { data: events = [], isFetching } = useCalendarEvents(
|
||||
range?.start ?? null,
|
||||
range?.end ?? null,
|
||||
);
|
||||
|
||||
const fullCalendarEvents = useMemo(() => events.map(mapEventToFullCalendar), [events]);
|
||||
|
||||
const handleDatesSet = (info: DatesSetArg) => {
|
||||
setRange({ start: info.start, end: info.end });
|
||||
setTitle(info.view.title);
|
||||
};
|
||||
|
||||
const handleEventClick = (clickInfo: EventClickArg) => {
|
||||
navigate(`/calendar/edit/${clickInfo.event.id}`);
|
||||
};
|
||||
|
||||
const handleDateClick = (dateInfo: DateClickArg) => {
|
||||
navigate(`/calendar/new?date=${dateInfo.dateStr}`);
|
||||
};
|
||||
|
||||
const calendarApi = () => calendarRef.current?.getApi();
|
||||
|
||||
return (
|
||||
<Box className="p-4">
|
||||
<CalendarActionBar
|
||||
title={title}
|
||||
onTodayClick={() => calendarApi()?.today()}
|
||||
onPrevClick={() => calendarApi()?.prev()}
|
||||
onNextClick={() => calendarApi()?.next()}
|
||||
onViewChange={(view) => calendarApi()?.changeView(view)}
|
||||
/>
|
||||
<EventCalendar
|
||||
ref={calendarRef}
|
||||
events={fullCalendarEvents}
|
||||
loading={isFetching}
|
||||
onDatesSet={handleDatesSet}
|
||||
onEventClick={handleEventClick}
|
||||
onDateClick={handleDateClick}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
export { default } from "./_components/calendar-unavailable";
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
export { default } from "./_components/event-form";
|
||||
export { default } from "./_components/calendar-unavailable";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue