Skip to content

Commit

Permalink
Merge branch 'main' into feat/CLAP-142
Browse files Browse the repository at this point in the history
  • Loading branch information
thgee authored Aug 15, 2024
2 parents e8f7bb6 + 59db53b commit 9823959
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
3 changes: 2 additions & 1 deletion packages/core/src/hooks/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export const useAuth = () => {
* API 호출 후 catch에서 받아온 Error 객체를 인자로 넣어주세요
*/
const handleTokenError = async (error: Error) => {
if (error.message === "403") {
const TOKEN_ERROR_STATUS = "403";
if (error.message === TOKEN_ERROR_STATUS) {
await reLogin();
location.reload();
} else {
Expand Down
14 changes: 3 additions & 11 deletions packages/service/src/pages/PartsCollection/PartsCollection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,12 @@ import { IMyParts } from "@watermelon-clap/core/src/types";
import { getAccessToken } from "@watermelon-clap/core/src/utils";

export const PartsCollection = () => {
const { getIsLogin, login, reLogin } = useAuth();
const { getIsLogin, login, handleTokenError } = useAuth();

const [equippedPartsImg, setEquippedPartsImg] = useState<ICustomCardProps>();

const getPartsData = async () => {
try {
return await apiGetMyParts();
} catch (error: any) {
if (error.message === "403") {
reLogin().then(() => refetch());
}
throw error;
}
};
const getPartsData = () =>
apiGetMyParts().catch(handleTokenError) as Promise<IMyParts[]>;

const { data: partsDatas, refetch } = useQuery<IMyParts[]>({
queryKey: ["myParts", getAccessToken()],
Expand Down

0 comments on commit 9823959

Please sign in to comment.