-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 티켓 옵션 생성 퍼블리싱 #79
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
Changes from 31 commits
c36de1c
fec23cf
d75df84
26a5e13
b990317
ae05602
5858129
f62cd2d
a923471
edb0123
bc44590
fe7862e
a6ef5d1
8e8804b
63b5675
9d3024b
485b8c5
6d0cf0c
4940d3a
b7aa249
d6ff8c1
302ed19
e021cdc
c5fd7cd
d3831a8
a0308ef
12e68ab
4e19b2e
21ecad6
ac86f88
5d19491
ed77565
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| import { useNavigate } from 'react-router-dom'; | ||
| import DraggableList from './DraggableList'; | ||
| import { Droppable } from '@hello-pangea/dnd'; | ||
| import AddButton2 from '../../../../public/assets/dashboard/ticket/AddButton2.svg'; | ||
| import HorizontalCardButton from '../../../../design-system/ui/buttons/HorizontalCardButton'; | ||
|
|
||
| interface OptionTitle { | ||
| id: string; | ||
| content: string; | ||
| answerToggled: boolean; | ||
| responseFormat: string; | ||
| } | ||
|
|
||
| interface DragAreaProps { | ||
| data: { | ||
| options: { [key: string]: OptionTitle }; | ||
| dragAreas: { | ||
| [key: string]: { | ||
| id: string; | ||
| title: string; | ||
| optionIds: string[]; | ||
| }; | ||
| }; | ||
| dragAreaOrder: string[]; | ||
| }; | ||
| setData: React.Dispatch<React.SetStateAction<DragAreaProps['data']>>; | ||
| droppableId: string; | ||
| answerToggled: boolean; | ||
| responseFormat: string; | ||
| ticketSurveyAddButton?: boolean; | ||
|
Comment on lines
+28
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 미사용 props 제거 또는 활용이 필요합니다. 컴포넌트에서 미사용 props를 제거하거나 다음과 같이 수정하는 것을 권장합니다: interface DragAreaProps {
data: {
options: { [key: string]: OptionTitle };
dragAreas: {
[key: string]: {
id: string;
title: string;
optionIds: string[];
};
};
dragAreaOrder: string[];
};
setData: React.Dispatch<React.SetStateAction<DragAreaProps['data']>>;
droppableId: string;
- answerToggled: boolean;
- responseFormat: string;
ticketSurveyAddButton?: boolean;
}
const DragArea = ({
data,
setData,
droppableId,
- answerToggled,
- responseFormat,
ticketSurveyAddButton = true,
}: DragAreaProps) => {Also applies to: 37-38 |
||
| } | ||
|
|
||
| const DragArea = ({ | ||
| data, | ||
| setData, | ||
| droppableId, | ||
| answerToggled, | ||
| responseFormat, | ||
| ticketSurveyAddButton = true, | ||
| }: DragAreaProps) => { | ||
| const navigate = useNavigate(); | ||
| const dragArea = data.dragAreas[droppableId]; | ||
| const isOptionsArea = droppableId === 'options'; | ||
| const isTicketArea = droppableId === 'ticket'; | ||
|
|
||
| const handleDelete = (id: string) => { | ||
| if (isTicketArea) { | ||
| setData(prev => ({ | ||
| ...prev, | ||
| dragAreas: { | ||
| ...prev.dragAreas, | ||
| ticket: { | ||
| ...prev.dragAreas.ticket, | ||
| optionIds: prev.dragAreas.ticket.optionIds.filter(optionId => optionId !== id), | ||
| }, | ||
| }, | ||
| })); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="w-full"> | ||
| <Droppable droppableId={droppableId} isDropDisabled={isOptionsArea}> | ||
| {provided => ( | ||
| <div | ||
| ref={provided.innerRef} | ||
| {...provided.droppableProps} | ||
| className={`${ | ||
| isOptionsArea | ||
| ? 'h-80 grid grid-cols-2 gap-2 grid-flow-row content-start' | ||
| : isTicketArea | ||
| ? 'h-48 bg-opacity-5 flex flex-col gap-2 overflow-y-auto [&>*]:flex-shrink-0 scrollbar-thin scrollbar-thumb-gray-200 scrollbar-track-transparent hover:scrollbar-thumb-gray-300' | ||
| : 'h-80 grid grid-cols-2 gap-2 grid-flow-row content-start' | ||
| }`} | ||
| > | ||
| {dragArea.optionIds.map((optionId, index) => { | ||
| const option = data.options[optionId]; | ||
| return ( | ||
| <DraggableList | ||
| key={option.id} | ||
| id={option.id} | ||
| content={option.content} | ||
| index={index} | ||
| answerToggled={option.answerToggled} | ||
| responseFormat={option.responseFormat} | ||
| droppableId={droppableId} | ||
| isDragDisabled={false} | ||
| onDelete={handleDelete} | ||
| /> | ||
| ); | ||
| })} | ||
| {ticketSurveyAddButton && isOptionsArea && ( | ||
| <div className="col-span-1 flex items-center h-[3.5rem] bg-deDayBgLight rounded"> | ||
| <HorizontalCardButton | ||
| iconPath={<img src={AddButton2} alt="추가 버튼" />} | ||
| className="text-sm !justify-start [&>div]:!justify-start" | ||
| label="티켓 설문 새로 생성하기" | ||
| onClick={() => { | ||
| navigate('/dashboard/ticket/option/create'); | ||
| }} | ||
| /> | ||
| </div> | ||
| )} | ||
| {provided.placeholder} | ||
| </div> | ||
| )} | ||
| </Droppable> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default DragArea; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
중복된
checkLists선언으로 인해 사용되지 않는 변수입니다.첫 번째
checkLists(7-9행)는 17행 이후에 다시 선언되는 동일 이름의checkLists변수로 덮어씌워지고 있어 ESLint에서 미사용 변수가 된 것으로 보입니다. 두 선언 중 하나만 사용하거나, 로직을 통합해 불필요한 중복을 제거하세요.아래와 같은 방식으로 기존
checkLists필드를 통합해보세요:📝 Committable suggestion
🧰 Tools
🪛 ESLint
[error] 7-7: 'checkLists' is assigned a value but never used.
(@typescript-eslint/no-unused-vars)