-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/2.1.0' into feat/#309-last_card
- Loading branch information
Showing
18 changed files
with
227 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
import { LocationType } from "../../../types/cardCollection"; | ||
|
||
// 파라미터로 보이지 않아야할 locationType 전달 | ||
export default function useShowByCardType(locationTypes: LocationType[]) { | ||
const [isShow, setIsShow] = useState<boolean>(false); | ||
|
||
useEffect(() => { | ||
const cardType = new URLSearchParams(window.location.search.split("?")[1]).get("type"); | ||
setIsShow(!locationTypes.includes((cardType as LocationType) || "")); | ||
}, [locationTypes]); | ||
|
||
return { isShow }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { useCallback, useState } from "react"; | ||
|
||
import { cardCollectionApi } from "../../../core/api/cardCollection"; | ||
import useAuth from "../../../core/hooks/useAuth"; | ||
|
||
interface handleClickParams { | ||
_id: string; | ||
onSuccess?: () => void; | ||
} | ||
|
||
export type handleClickBlacklistType = (params: handleClickParams) => void; | ||
|
||
const useBlacklist = (handleClickBeforeLogin: () => void) => { | ||
const { isLogin } = useAuth(); | ||
const [blacklist, setBlacklist] = useState<string[]>([]); | ||
|
||
const handleClickAddBlacklist: handleClickBlacklistType = useCallback( | ||
({ _id, onSuccess: onSuccessAdd }) => { | ||
switch (isLogin) { | ||
case true: | ||
cardCollectionApi.addBlacklist(_id); | ||
onSuccessAdd && onSuccessAdd(); | ||
setBlacklist((prev) => [...prev, _id]); | ||
break; | ||
case false: | ||
handleClickBeforeLogin(); | ||
break; | ||
} | ||
}, | ||
[isLogin, handleClickBeforeLogin], | ||
); | ||
|
||
const handleClickCancelBlacklist: handleClickBlacklistType = useCallback(({ _id, onSuccess: onSuccessDelete }) => { | ||
cardCollectionApi.deleteBlacklist(_id); | ||
setBlacklist((prev) => prev.filter((id) => id !== _id)); | ||
onSuccessDelete && onSuccessDelete(); | ||
}, []); | ||
|
||
const getIsBlacklist = useCallback((_id: string) => blacklist.includes(_id), [blacklist]); | ||
|
||
return { | ||
getIsBlacklist, | ||
handleClickAddBlacklist, | ||
handleClickCancelBlacklist, | ||
}; | ||
}; | ||
|
||
export default useBlacklist; |
Oops, something went wrong.