Skip to content

Commit bca0885

Browse files
committed
refactor: fetchをwrapせずそのまま使用するよう修正
1 parent ca12ffb commit bca0885

File tree

1 file changed

+11
-25
lines changed

1 file changed

+11
-25
lines changed

atcoder-problems-frontend/src/pages/Internal/ProblemList/SingleProblemList.tsx

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,6 @@ interface Props {
3131
listId: string;
3232
}
3333

34-
const updateList = async (name: string, listId: string) => {
35-
await updateProblemList(name, listId);
36-
};
37-
38-
const addItem = async (problemId: string, listId: string) => {
39-
await addProblemItem(problemId, listId);
40-
};
41-
42-
const deleteItem = async (problemId: string, listId: string) => {
43-
await deleteProblemItem(problemId, listId);
44-
};
45-
46-
const updateItem = async (problemId: string, memo: string, listId: string) => {
47-
await updateProblemItem(problemId, memo, listId);
48-
};
49-
5034
export const SingleProblemList = (props: Props) => {
5135
const { listId } = props;
5236
const loginState = useLoginState();
@@ -94,7 +78,7 @@ export const SingleProblemList = (props: Props) => {
9478
<h2>
9579
<DoubleClickEdit
9680
modifiable={modifiable}
97-
saveText={(name) => updateList(name, listId)}
81+
saveText={async (name) => await updateProblemList(name, listId)}
9882
initialText={listInfo.internal_list_name}
9983
/>
10084
</h2>
@@ -105,8 +89,8 @@ export const SingleProblemList = (props: Props) => {
10589
{adding ? (
10690
<ProblemSearchBox
10791
problems={problems}
108-
selectProblem={(problem) =>
109-
addItem(problem.id, listId).then(() =>
92+
selectProblem={async (problem) =>
93+
await addProblemItem(problem.id, listId).then(() =>
11094
problemListFetch.mutate()
11195
)
11296
}
@@ -139,13 +123,15 @@ export const SingleProblemList = (props: Props) => {
139123
key={item.problem_id}
140124
item={item}
141125
problem={problem}
142-
saveText={(memo: string) =>
143-
updateItem(item.problem_id, memo, listId).then(() =>
144-
problemListFetch.mutate()
145-
)
126+
saveText={async (memo: string) =>
127+
await updateProblemItem(
128+
item.problem_id,
129+
memo,
130+
listId
131+
).then(() => problemListFetch.mutate())
146132
}
147-
deleteItem={() =>
148-
deleteItem(item.problem_id, listId).then(() =>
133+
deleteItem={async () =>
134+
await deleteProblemItem(item.problem_id, listId).then(() =>
149135
problemListFetch.mutate()
150136
)
151137
}

0 commit comments

Comments
 (0)