feat(calendar): add calendar to home page
This commit is contained in:
parent
998ce5af93
commit
746a243dc3
6 changed files with 23 additions and 23 deletions
|
@ -1,21 +1,14 @@
|
|||
'use client';
|
||||
|
||||
import { RedirectButton } from '@/components/buttons/redirect-button';
|
||||
import Calendar from '@/components/calendar';
|
||||
import { useGetApiUserMe } from '@/generated/api/user/user';
|
||||
|
||||
export default function Home() {
|
||||
const { data, isLoading } = useGetApiUserMe();
|
||||
const { data } = useGetApiUserMe();
|
||||
|
||||
return (
|
||||
<div className='flex flex-col items-center justify-center h-full'>
|
||||
<div>
|
||||
<h1>
|
||||
Hello{' '}
|
||||
{isLoading ? 'Loading...' : data?.data.user?.name || 'Unknown User'}
|
||||
</h1>
|
||||
<RedirectButton redirectUrl='/logout' buttonText='Logout' />
|
||||
<RedirectButton redirectUrl='/settings' buttonText='Settings' />
|
||||
</div>
|
||||
<div className='max-h-full'>
|
||||
<Calendar userId={data?.data.user?.id} height='calc(100svh - 50px - (var(--spacing) * 2 * 5))' />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -217,6 +217,9 @@ export const GET = auth(async function GET(req, { params }) {
|
|||
|
||||
return returnZodTypeCheckedResponse(UserCalendarResponseSchema, {
|
||||
success: true,
|
||||
calendar,
|
||||
calendar: calendar.filter(
|
||||
(event, index, self) =>
|
||||
self.findIndex((e) => e.id === event.id && e.type === event.type) === index,
|
||||
),
|
||||
});
|
||||
});
|
||||
|
|
|
@ -41,7 +41,7 @@ const DaDRBCalendar = withDragAndDrop<
|
|||
|
||||
const localizer = momentLocalizer(moment);
|
||||
|
||||
export default function Calendar({ userId }: { userId?: string }) {
|
||||
export default function Calendar({ userId, height }: { userId?: string; height: string }) {
|
||||
return (
|
||||
<QueryErrorResetBoundary>
|
||||
{({ reset }) => (
|
||||
|
@ -62,9 +62,9 @@ export default function Calendar({ userId }: { userId?: string }) {
|
|||
)}
|
||||
>
|
||||
{userId ? (
|
||||
<CalendarWithUserEvents userId={userId} />
|
||||
<CalendarWithUserEvents userId={userId} height={height} />
|
||||
) : (
|
||||
<CalendarWithoutUserEvents />
|
||||
<CalendarWithoutUserEvents height={height} />
|
||||
)}
|
||||
</ErrorBoundary>
|
||||
)}
|
||||
|
@ -72,7 +72,7 @@ export default function Calendar({ userId }: { userId?: string }) {
|
|||
);
|
||||
}
|
||||
|
||||
function CalendarWithUserEvents({ userId }: { userId: string }) {
|
||||
function CalendarWithUserEvents({ userId, height }: { userId: string; height: string }) {
|
||||
const sesstion = useSession();
|
||||
const [currentView, setCurrentView] = React.useState<
|
||||
'month' | 'week' | 'day' | 'agenda' | 'work_week'
|
||||
|
@ -131,6 +131,9 @@ function CalendarWithUserEvents({ userId }: { userId: string }) {
|
|||
components={{
|
||||
toolbar: CustomToolbar,
|
||||
}}
|
||||
style={{
|
||||
height: height,
|
||||
}}
|
||||
onView={setCurrentView}
|
||||
view={currentView}
|
||||
date={currentDate}
|
||||
|
@ -213,7 +216,7 @@ function CalendarWithUserEvents({ userId }: { userId: string }) {
|
|||
);
|
||||
}
|
||||
|
||||
function CalendarWithoutUserEvents() {
|
||||
function CalendarWithoutUserEvents({ height }: { height: string }) {
|
||||
const [currentView, setCurrentView] = React.useState<
|
||||
'month' | 'week' | 'day' | 'agenda' | 'work_week'
|
||||
>('week');
|
||||
|
@ -224,6 +227,9 @@ function CalendarWithoutUserEvents() {
|
|||
localizer={localizer}
|
||||
culture='de-DE'
|
||||
defaultView='week'
|
||||
style={{
|
||||
height: height,
|
||||
}}
|
||||
components={{
|
||||
toolbar: CustomToolbar,
|
||||
}}
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
padding: calc(var(--spacing) * 2);
|
||||
padding-left: calc(50px + var(--spacing));
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ export default function Header({
|
|||
<UserDropdown />
|
||||
</span>
|
||||
</header>
|
||||
<main>{children}</main>
|
||||
<main className='max-h-full overflow-y-auto p-5'>{children}</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -810,9 +810,6 @@ button.rbc-input::-moz-focus-inner {
|
|||
-ms-flex-direction: row;
|
||||
flex-direction: row;
|
||||
}
|
||||
.rbc-time-header.rbc-overflowing {
|
||||
border-right: 1px solid #ddd;
|
||||
}
|
||||
.rbc-rtl .rbc-time-header.rbc-overflowing {
|
||||
border-right-width: 0;
|
||||
border-left: 1px solid #ddd;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue