Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(client): 타임테이블 이미지 저장 개선 #282

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
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 @@ -12,6 +12,7 @@ import { useEffect, useState } from 'react';
import { usePatchTimeTableMutation } from '@pages/time-table/hooks/use-patch-time-table-mutation';

interface Props {
clickedFestivalTitle: string | null;
timeTableInfo: TimeTableInfo;
isEditTimeTableMode: boolean;
isFestivalDeleteMode: boolean;
Expand All @@ -20,14 +21,15 @@ interface Props {
}

const TimeTableBoard = ({
clickedFestivalTitle,
timeTableInfo,
isEditTimeTableMode,
isFestivalDeleteMode,
isComplete,
onToggleComplete,
}: Props) => {
const { elementRef, downloadImage } = useImageDownload<HTMLDivElement>({
fileName: 'timetable',
fileName: `${clickedFestivalTitle}`,
});
const [openHour, openMin] = parseTimeString(timeTableInfo.ticketOpenAt);
const isHalfHourOpen = openMin === HALF_HOUR_TO_MINUTES;
Expand Down
10 changes: 7 additions & 3 deletions apps/client/src/pages/time-table/hooks/use-button-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export const useButtonSelection = (festivals: Festival[]) => {
const [clickedFestivalId, setClickedFestivalId] = useState<number | null>(
festivals.length > 0 ? festivals[0].festivalId : null,
);
const [clickedFestivalTitle, setClickedFestivalTitle] = useState<
string | null
>(festivals.length > 0 ? festivals[0].title : null);

const festivalDatesMap = useMemo(
() =>
Expand All @@ -40,19 +43,20 @@ export const useButtonSelection = (festivals: Festival[]) => {
: null,
);

const handleFestivalClick = (festivalId: number) => {
const handleFestivalClick = (festivalId: number, title: string) => {
setClickedFestivalId(festivalId);
setClickedFestivalTitle(title);
const newDates = festivalDatesMap.get(festivalId) || [];
setSelectedFestivalDateId(
newDates.length > 0 ? newDates[0].festivalDateId : null,
);
};

return {
clickedFestivalId,
selectedFestivalDates,
handleFestivalClick,
selectedFestivalDateId,
clickedFestivalTitle,
handleFestivalClick,
setSelectedFestivalDateId,
};
};
9 changes: 5 additions & 4 deletions apps/client/src/pages/time-table/page/time-table.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useState, useEffect } from 'react';
import { Spacing } from '@confeti/design-system';
import TimeTableBoard from '@pages/time-table/components/time-table-board/time-table-board';
import EditFloatingButton from '@pages/time-table/components/edit/edit-floating-button';
Expand All @@ -11,9 +12,7 @@ import {
useFestivalButtonData,
useFestivalTimetableData,
} from '../hooks/use-festival-data';

import * as styles from './time-table.css';
import { useState, useEffect } from 'react';

const TimeTable = () => {
const {
Expand All @@ -39,8 +38,9 @@ const TimeTable = () => {
const {
clickedFestivalId,
selectedFestivalDates,
handleFestivalClick,
selectedFestivalDateId,
clickedFestivalTitle,
handleFestivalClick,
setSelectedFestivalDateId,
} = useButtonSelection(festivals);

Expand Down Expand Up @@ -77,7 +77,7 @@ const TimeTable = () => {
src={logoUrl}
alt={title}
text={title}
onClick={() => handleFestivalClick(festivalId)}
onClick={() => handleFestivalClick(festivalId, title)}
isClicked={clickedFestivalId === festivalId}
/>
{festivalId && (
Expand All @@ -99,6 +99,7 @@ const TimeTable = () => {
<Spacing />
{boardData && (
<TimeTableBoard
clickedFestivalTitle={clickedFestivalTitle}
timeTableInfo={boardData}
isEditTimeTableMode={isEditTimeTableMode}
isFestivalDeleteMode={isFestivalDeleteMode}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export const textSection = style({
});

export const description = style({
...themeVars.display.flexColumn,
gap: '0.8rem',
position: 'absolute',
top: '1.6rem',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,17 @@ const CarouselContainer = ({
}: CarouselContainerProps) => {
const navigate = useNavigate();

const handleContainerClick = () => {
navigate(`/${performanceType}-detail/${currentImageId}`);
const handleNavigateDetail = () => {
if (performanceType === 'FESTIVAL') {
navigate(`/festival-detail/${currentImageId}`);
}
if (performanceType === 'CONCERT') {
navigate(`/concert-detail/${currentImageId}`);
}
};

return (
<div className={styles.container} onClick={handleContainerClick}>
<div className={styles.container} onClick={handleNavigateDetail}>
{children}
</div>
);
Expand Down
Loading