Skip to content

Commit c5e1bd7

Browse files
authored
fix: 칸반보드의 라벨이 계속 늘어나는 문제 해결 (#216)
2 parents 0909c09 + e225890 commit c5e1bd7

File tree

4 files changed

+32
-42
lines changed

4 files changed

+32
-42
lines changed

frontend/components/applicant/applicantNode/Label.component.tsx

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface ApplicantLabelProps {
1818
const ApplicantLabel = ({ postId, generation }: ApplicantLabelProps) => {
1919
const [openAdditional, setOpenAdditional] = useState(false);
2020

21-
const { data, error, isLoading } = useQuery<ApplicantLabelReq[]>(
21+
const { data, error, isLoading } = useQuery(
2222
["applicantLabel", postId],
2323
() => getApplicantLabel(postId),
2424
{
@@ -38,6 +38,8 @@ const ApplicantLabel = ({ postId, generation }: ApplicantLabelProps) => {
3838
setOpenAdditional((prev) => !prev);
3939
};
4040

41+
const omitLabels = openAdditional ? data : data.slice(0, 6);
42+
4143
return (
4244
<div className="my-12">
4345
<div className="text-lg font-semibold">
@@ -48,25 +50,14 @@ const ApplicantLabel = ({ postId, generation }: ApplicantLabelProps) => {
4850
</div>
4951
<div className="flex items-baseline gap-2">
5052
<div className="grid grid-cols-6 gap-2 my-4 w-fit">
51-
{openAdditional
52-
? data.map((label) => (
53-
<ApplicantLabelButton
54-
generation={generation}
55-
key={label.name}
56-
label={label}
57-
postId={postId}
58-
/>
59-
))
60-
: data
61-
.map((label) => (
62-
<ApplicantLabelButton
63-
generation={generation}
64-
key={label.name}
65-
label={label}
66-
postId={postId}
67-
/>
68-
))
69-
.slice(0, 6)}
53+
{omitLabels.map((label) => (
54+
<ApplicantLabelButton
55+
generation={generation}
56+
key={label.id}
57+
label={label}
58+
postId={postId}
59+
/>
60+
))}
7061
</div>
7162
<button
7263
onClick={toggleOpen}

frontend/components/kanban/content/work/Label.component.tsx

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface WorkLabelProps {
1414
const WorkLabel = ({ cardId, generation }: WorkLabelProps) => {
1515
const [openAdditional, setOpenAdditional] = useState(false);
1616

17-
const { data, error, isLoading } = useQuery<WorkLabelReq[]>(
17+
const { data, error, isLoading } = useQuery(
1818
["workLabel", cardId],
1919
() => getWorkLabel(cardId),
2020
{
@@ -34,6 +34,8 @@ const WorkLabel = ({ cardId, generation }: WorkLabelProps) => {
3434
setOpenAdditional((prev) => !prev);
3535
};
3636

37+
const omitLabels = openAdditional ? data : data.slice(0, 6);
38+
3739
return (
3840
<div className="my-12">
3941
<div className="text-lg font-semibold">
@@ -44,25 +46,14 @@ const WorkLabel = ({ cardId, generation }: WorkLabelProps) => {
4446
</div>
4547
<div className="flex items-baseline gap-2">
4648
<div className="grid grid-cols-6 gap-2 my-4 w-fit">
47-
{openAdditional
48-
? data.map((label) => (
49-
<WorkLabelButton
50-
generation={generation}
51-
key={label.name}
52-
label={label}
53-
cardId={cardId}
54-
/>
55-
))
56-
: data
57-
.map((label) => (
58-
<WorkLabelButton
59-
generation={generation}
60-
key={label.name}
61-
label={label}
62-
cardId={cardId}
63-
/>
64-
))
65-
.slice(0, 6)}
49+
{omitLabels.map((label) => (
50+
<WorkLabelButton
51+
key={label.id}
52+
generation={generation}
53+
label={label}
54+
cardId={cardId}
55+
/>
56+
))}
6657
</div>
6758
<button
6859
onClick={toggleOpen}

frontend/src/apis/applicant/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,14 @@ export const getApplicationById = async (id: string) => {
9191
};
9292

9393
export interface ApplicantLabelReq {
94+
id: number;
9495
name: string;
9596
active: boolean;
9697
}
9798

98-
export const getApplicantLabel = async (id: string) => {
99+
export const getApplicantLabel = async (
100+
id: string
101+
): Promise<ApplicantLabelReq[]> => {
99102
const allInterviewers = await getAllInterviewerWithOrder("name");
100103

101104
try {
@@ -104,13 +107,15 @@ export const getApplicantLabel = async (id: string) => {
104107
.map((interviewer) => {
105108
const label = data.find((label) => label === interviewer.name);
106109
return {
110+
id: interviewer.id,
107111
name: interviewer.name,
108112
active: !!label,
109113
};
110114
})
111115
.sort((a, b) => (a.active === b.active ? 0 : a.active ? -1 : 1));
112116
} catch (e) {
113117
return allInterviewers.map((interviewer) => ({
118+
id: interviewer.id,
114119
name: interviewer.name,
115120
active: false,
116121
}));

frontend/src/apis/work/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const deleteWork = async (cardId: string) => {
3434
};
3535

3636
export interface WorkLabelReq {
37+
id: number;
3738
name: string;
3839
active: boolean;
3940
}
@@ -44,20 +45,22 @@ export const postWorkLabel = async (cardId: number) => {
4445
return data;
4546
};
4647

47-
export const getWorkLabel = async (cardId: number) => {
48+
export const getWorkLabel = async (cardId: number): Promise<WorkLabelReq[]> => {
4849
const allInterviewers = await getAllInterviewerWithOrder("");
4950

5051
try {
5152
const { data } = await https.get<string[]>(`/cards/${cardId}/labels`);
5253
return allInterviewers.map((interviewer) => {
5354
const label = data.find((label) => label === interviewer.name);
5455
return {
56+
id: interviewer.id,
5557
name: interviewer.name,
5658
active: !!label,
5759
};
5860
});
5961
} catch (e) {
6062
return allInterviewers.map((interviewer) => ({
63+
id: interviewer.id,
6164
name: interviewer.name,
6265
active: false,
6366
}));

0 commit comments

Comments
 (0)