Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Button, Chip, CircularProgress, Stack, styled, Table, TableBody, TableC
import { ErrorBoundary, Suspense } from "@suspensive/react";
import { DateTime } from "luxon";
import { FC, useState } from "react";
import { Link } from "react-router-dom";
import { Link, useLocation } from "react-router-dom";
import { isArray, isEmpty, isString } from "remeda";

import { CenteredPage } from "@frontend/common/components/centered_page";
Expand Down Expand Up @@ -108,16 +108,17 @@ const SessionColumn: FC<{
rowSpan: number;
colSpan?: number;
session: SessionSchema;
selectedDate: string;
getSessionUrl?: (session: SessionSchema) => string;
}> = ({ rowSpan, colSpan, session, getSessionUrl }) => {
}> = ({ rowSpan, colSpan, session, selectedDate, getSessionUrl }) => {
const sessionUrl = getSessionUrl ? getSessionUrl(session) : undefined;
const clickable = isArray(session.speakers) && !isEmpty(session.speakers) && !!sessionUrl;
// Firefox는 rowSpan된 td의 height를 계산할 때 rowSpan을 고려하지 않습니다. 따라서 직접 계산하여 height를 설정합니다.
const sessionBoxHeight = `${TD_HEIGHT * rowSpan}rem`;
return (
<SessionTableCell rowSpan={rowSpan} colSpan={colSpan}>
{clickable ? (
<Link to={sessionUrl!} style={{ textDecoration: "none", display: "block" }}>
<Link to={sessionUrl!} style={{ textDecoration: "none", display: "block" }} state={{ selectedDate: selectedDate }}>
<SessionBox className="clickable" sx={{ height: sessionBoxHeight, gap: 0.75, padding: "0.5rem" }}>
<SessionTitle children={session.title.replace("\\n", "\n")} align="center" />
<Stack direction="row" alignItems="center" justifyContent="center" sx={{ width: "100%", flexWrap: "wrap", gap: 0.5 }}>
Expand Down Expand Up @@ -155,7 +156,9 @@ type SessionTimeTablePropType = {
export const SessionTimeTable: FC<SessionTimeTablePropType> = ErrorBoundary.with(
{ fallback: ErrorFallback },
Suspense.with({ fallback: <CenteredPage children={<CircularProgress />} /> }, ({ event, types, getSessionUrl }) => {
const [confDate, setConfDate] = useState("");
const location = useLocation();

const [confDate, setConfDate] = useState<string>(location.state?.selectedDate ?? "");

const { language } = Common.useCommonContext();
const backendAPIClient = BackendAPI.useBackendClient();
Expand All @@ -168,7 +171,7 @@ export const SessionTimeTable: FC<SessionTimeTablePropType> = ErrorBoundary.with
const roomCount = Object.keys(rooms).length;
const sortedRoomList = Object.keys(rooms).sort();

const selectedDate = confDate || dates[0];
const [selectedDate, setSelectedDate] = useState<string>(location.state?.selectedDate ?? (confDate || dates[0]));
const selectedTableData = timeTableData[selectedDate];

let breakCount = 0;
Expand All @@ -186,7 +189,15 @@ export const SessionTimeTable: FC<SessionTimeTablePropType> = ErrorBoundary.with
{dates.map((date, i) => {
const dateStr = DateTime.fromISO(date).setLocale(language).toLocaleString({ weekday: "long", month: "long", day: "numeric" });
return (
<Button variant="text" key={date} onClick={() => setConfDate(date)} className={selectedDate === date ? "selected" : ""}>
<Button
variant="text"
key={date}
onClick={() => {
setConfDate(date);
setSelectedDate(date);
}}
className={selectedDate === date ? "selected" : ""}
>
<SessionDateItemContainer direction="column">
<SessionDateTitle children={"Day " + (i + 1)} isSelected={selectedDate === date} />
<SessionDateSubTitle children={dateStr} isSelected={selectedDate === date} />
Expand Down Expand Up @@ -273,6 +284,7 @@ export const SessionTimeTable: FC<SessionTimeTablePropType> = ErrorBoundary.with
rowSpan={firstSessionInfo.rowSpan}
colSpan={roomCount}
session={firstSessionInfo.session}
selectedDate={selectedDate}
getSessionUrl={getSessionUrl}
/>
</SessionTableRow>
Expand All @@ -293,7 +305,15 @@ export const SessionTimeTable: FC<SessionTimeTablePropType> = ErrorBoundary.with
}
// 세션이 여러 줄에 걸쳐있는 경우, n-1 줄만큼 해당 room에 column을 생성하지 않도록 합니다.
if (roomDatum.rowSpan > 1) rooms[room] = roomDatum.rowSpan - 1;
return <SessionColumn key={room} rowSpan={roomDatum.rowSpan} session={roomDatum.session} getSessionUrl={getSessionUrl} />;
return (
<SessionColumn
key={room}
rowSpan={roomDatum.rowSpan}
session={roomDatum.session}
selectedDate={selectedDate}
getSessionUrl={getSessionUrl}
/>
);
})}
</SessionTableRow>
);
Expand Down