fix: selected day reset after go back to /schedule
This commit is contained in:
parent
adbd07600c
commit
35afc862d6
6
apps/web/app/(main)/profile/schedule/layout.tsx
Normal file
6
apps/web/app/(main)/profile/schedule/layout.tsx
Normal file
@ -0,0 +1,6 @@
|
||||
import { ScheduleContextProvider } from '@/context/schedule';
|
||||
import { type PropsWithChildren } from 'react';
|
||||
|
||||
export default async function Layout({ children }: Readonly<PropsWithChildren>) {
|
||||
return <ScheduleContextProvider>{children}</ScheduleContextProvider>;
|
||||
}
|
||||
@ -2,11 +2,10 @@ import { HorizontalDivider } from '@/components/common/divider';
|
||||
import { Container } from '@/components/layout';
|
||||
import { PageHeader } from '@/components/navigation';
|
||||
import { DaySlotAddForm, DaySlotsList, ScheduleCalendar } from '@/components/schedule';
|
||||
import { ScheduleContextProvider } from '@/context/schedule';
|
||||
|
||||
export default function SchedulePage() {
|
||||
return (
|
||||
<ScheduleContextProvider>
|
||||
<>
|
||||
<PageHeader title="График работы" />
|
||||
<Container className="px-0">
|
||||
<ScheduleCalendar />
|
||||
@ -14,6 +13,6 @@ export default function SchedulePage() {
|
||||
<HorizontalDivider className="px-4" />
|
||||
<DaySlotAddForm />
|
||||
</Container>
|
||||
</ScheduleContextProvider>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import { Enum_Slot_State } from '@repo/graphql/types';
|
||||
import { Badge } from '@repo/ui/components/ui/badge';
|
||||
import { cn } from '@repo/ui/lib/utils';
|
||||
import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
|
||||
const MAP_BADGE_TEXT: Record<Enum_Slot_State, string> = {
|
||||
closed: 'Закрыто',
|
||||
@ -15,6 +16,7 @@ const MAP_BADGE_TEXT: Record<Enum_Slot_State, string> = {
|
||||
};
|
||||
|
||||
export function SlotCard(props: Readonly<SlotComponentProps>) {
|
||||
const pathname = usePathname();
|
||||
const { documentId } = props;
|
||||
|
||||
const { data } = useSlotQuery({ documentId });
|
||||
@ -29,7 +31,7 @@ export function SlotCard(props: Readonly<SlotComponentProps>) {
|
||||
const isClosed = slot?.state === Enum_Slot_State.Closed;
|
||||
|
||||
return (
|
||||
<Link href={`/slots/${documentId}`} rel="noopener noreferrer">
|
||||
<Link href={`${pathname}/slots/${documentId}`} rel="noopener noreferrer">
|
||||
<div className="flex items-center justify-between rounded-2xl bg-background p-4 px-6 dark:bg-primary/5">
|
||||
<div className="flex flex-col gap-2">
|
||||
<ReadonlyTimeRange {...slot} />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user