Skip to content

Commit

Permalink
feat: 활성화 전 이벤트만 편집 가능
Browse files Browse the repository at this point in the history
  • Loading branch information
jhj2713 committed Aug 12, 2024
1 parent d1f52e8 commit 9fa7b3c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion admin/src/components/DatePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { ChangeEvent } from "react";

interface DatePickerProps {
date: string;
disabled?: boolean;
onChangeDate: (date: string) => void;
}

export default function DatePicker({ date, onChangeDate }: DatePickerProps) {
export default function DatePicker({ date, disabled = false, onChangeDate }: DatePickerProps) {
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
onChangeDate(e.target.value);
};
Expand All @@ -17,6 +18,7 @@ export default function DatePicker({ date, onChangeDate }: DatePickerProps) {
</div>
<input
type="date"
disabled={disabled}
value={date}
onChange={handleChange}
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5"
Expand Down
4 changes: 3 additions & 1 deletion admin/src/components/TimePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { ChangeEvent } from "react";

interface TimePickerProps {
time: string;
disabled?: boolean;
onChangeTime: (time: string) => void;
}

export default function TimePicker({ time, onChangeTime }: TimePickerProps) {
export default function TimePicker({ time, disabled = false, onChangeTime }: TimePickerProps) {
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
onChangeTime(e.target.value);
};
Expand All @@ -31,6 +32,7 @@ export default function TimePicker({ time, onChangeTime }: TimePickerProps) {
<input
type="time"
id="time"
disabled={disabled}
className="bg-gray-50 border leading-none border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5"
min="09:00"
max="18:00"
Expand Down
9 changes: 8 additions & 1 deletion admin/src/features/Rush/EventList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Button from "@/components/Button";
import DatePicker from "@/components/DatePicker";
import Table from "@/components/Table";
import TimePicker from "@/components/TimePicker";
import { STATUS_MAP } from "@/constants/common";
import { EVENT_STATUS, STATUS_MAP } from "@/constants/common";
import { EVENT_LIST_HEADER, QUERY_OPTION } from "@/constants/rush";
import useFetch from "@/hooks/useFetch";
import useRushEventDispatchContext from "@/hooks/useRushEventDispatchContext";
Expand Down Expand Up @@ -42,35 +42,42 @@ export default function EventList() {

const getTableData = () => {
return rushList.map((item, idx) => {
const canEdit = item.status !== EVENT_STATUS.BEFORE;
return [
item.rushEventId,
<DatePicker
disabled={canEdit}
date={item.eventDate}
onChangeDate={(date) => handleChangeItem("eventDate", idx, date)}
/>,
<TimePicker
disabled={canEdit}
time={item.openTime}
onChangeTime={(time) => handleChangeItem("openTime", idx, time)}
/>,
<TimePicker
disabled={canEdit}
time={item.closeTime}
onChangeTime={(time) => handleChangeItem("closeTime", idx, time)}
/>,
getTimeDifference(item.openTime, item.closeTime),
<Button
disabled={canEdit}
buttonSize="sm"
onClick={() => navigate(`/rush?q=${QUERY_OPTION.OPTION}`, { state: { idx } })}
>
선택지 관리
</Button>,
<Button
disabled={canEdit}
buttonSize="sm"
onClick={() => navigate(`/rush?q=${QUERY_OPTION.PRIZE}`, { state: { idx } })}
>
경품 관리
</Button>,
<div className="flex w-full border-b">
<input
disabled={canEdit}
value={item.winnerCount}
onChange={(e) =>
handleChangeItem("winnerCount", idx, parseInt(e.target.value) || 0)
Expand Down

0 comments on commit 9fa7b3c

Please sign in to comment.