Skip to content

Commit f27a24f

Browse files
authored
Merge pull request velopert#573 from velopert/fix/series-remove
시리즈 삭제 UE 개선
2 parents a86f21c + e45f871 commit f27a24f

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/containers/velog/SeriesPosts.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,45 @@ const SeriesPosts: React.FC<SeriesPostsProps> = ({ username, urlSlug }) => {
4040
const user = useUser();
4141
const isOwnSeries = user && user.username === username;
4242
const [askRemove, setAskRemove] = useState(false);
43+
const [isSkip, setIsSkip] = useState(false);
4344
const [removeSeries] = useMutation(REMOVE_SERIES);
4445
const { data } = useQuery<GetSeriesResponse>(GET_SERIES, {
4546
variables: {
4647
username,
4748
url_slug: urlSlug,
4849
},
4950
fetchPolicy: 'cache-and-network',
51+
skip: isSkip,
5052
});
5153

5254
const client = useApolloClient();
5355

5456
const onAskRemove = () => setAskRemove(true);
5557
const onConfirmRemove = async () => {
5658
try {
59+
setIsSkip(true);
60+
setAskRemove(false);
61+
62+
if (!data?.series?.id) {
63+
throw new Error('Series ID is not available');
64+
}
65+
5766
await removeSeries({
5867
variables: {
59-
id: data?.series?.id,
68+
id: data.series.id,
6069
},
6170
});
6271

6372
await client.resetStore();
6473

65-
const redirect = `${process.env
66-
.REACT_APP_CLIENT_V3_HOST!}/@${username}/series`;
67-
window.location.href = redirect;
74+
toast.success('시리즈가 성공적으로 삭제되었습니다.', {
75+
autoClose: 800,
76+
onClose: () => {
77+
const redirect = `${process.env
78+
.REACT_APP_CLIENT_V3_HOST!}/@${username}/series`;
79+
window.location.href = redirect;
80+
},
81+
});
6882
} catch (e) {
6983
toast.error('시리즈 삭제 실패');
7084
}

0 commit comments

Comments
 (0)