-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #403 from panoratech/feat/fix-issues
🚑 Fixes on unified objects
- Loading branch information
Showing
123 changed files
with
3,450 additions
and
1,561 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
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
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
58 changes: 58 additions & 0 deletions
58
apps/client-ts/src/hooks/mutations/useRefreshAccessTokenMutation.tsx
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,58 @@ | ||
import config from '@/lib/config'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { toast } from "sonner" | ||
import Cookies from 'js-cookie'; | ||
|
||
interface IRefreshOutputDto { | ||
access_token: string | ||
} | ||
|
||
const useRefreshAccessTokenMutation = () => { | ||
const refreshAccessToken = async (projectId: string) => { | ||
const response = await fetch(`${config.API_URL}/auth/refresh-token`, { | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
projectId: projectId | ||
}), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Authorization': `Bearer ${Cookies.get('access_token')}`, | ||
}, | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error("Login Failed!!") | ||
} | ||
|
||
return response.json(); | ||
}; | ||
return useMutation({ | ||
mutationFn: refreshAccessToken, | ||
onMutate: () => { | ||
}, | ||
onError: (error) => { | ||
toast.error("Refreshing token generation failed !", { | ||
description: error as any, | ||
action: { | ||
label: "Close", | ||
onClick: () => console.log("Close"), | ||
}, | ||
}) | ||
}, | ||
onSuccess: (data : IRefreshOutputDto) => { | ||
Cookies.remove('access_token'); | ||
Cookies.set('access_token', data.access_token, {expires:1}); | ||
/*toast.success("Refresh has been generated !", { | ||
description: "", | ||
action: { | ||
label: "Close", | ||
onClick: () => console.log("Close"), | ||
}, | ||
})*/ | ||
}, | ||
onSettled: () => { | ||
}, | ||
}); | ||
}; | ||
|
||
export default useRefreshAccessTokenMutation; |
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
Oops, something went wrong.