-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/refreshtoken #272
base: dev
Are you sure you want to change the base?
Feature/refreshtoken #272
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There is currently an issue with the cookies not working properly. I have submitted a pr on the backend to resolve this |
|
||
const getUserAsync = () => | ||
GET<User>("api/v1/users/me", token, "force-cache", "me"); | ||
export async function getUser() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we going to create a module also for this logic following the hexagonal pattern but in another pull request?
} | ||
const [features, setFeatures] = useState<FeaturesList[]>([]); | ||
|
||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do something like that maybe?
// Function to fetch features
const fetchFeatures = async () => {
try {
const response = await axiosInstance.get(
/api/v1/voyages/teams/${teamId}/features
,
);
const transformedFeatures = transformData(response.data);
setFeatures(transformedFeatures);
} catch (error: any) {
console.error('Failed to fetch features', error);
}
};
useEffect(() => {
fetchFeatures(); // Simply call the function
}, [teamId]);
// }, []); | ||
|
||
useEffect(() => { | ||
const fetchDirectory = async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do something like thah maybe?
// Function to fetch team directory
const fetchDirectory = async () => {
try {
const response = await axiosInstance.get(/api/v1/teams/${teamId}
);
setTeamDirectory(response.data);
} catch (error: any) {
console.error('Failed to fetch team directory', error);
}
};
useEffect(() => {
fetchDirectory(); // Only call the function
}, [teamId]);
const { isAuthenticated } = useAuth(); | ||
const router = useRouter(); | ||
|
||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do something like that maybe?
// Function to fetch user and dispatch actions
const fetchUserAndDispatch = async () => {
try {
const data = await getUser();
dispatch(clientSignIn());
const currentDateInUserTimezone = formatInTimeZone(
currentDate,
data.timezone,
"yyyy-MM-dd HH:mm:ss",
);
const userWithDate = {
...data,
currentDate: new Date(currentDateInUserTimezone),
};
// Dispatch the getUserState action with the user object
dispatch(getUserState(userWithDate));
} catch (error) {
console.error('Failed to fetch user', error);
router.push(routePaths.signIn());
}
};
useEffect(() => {
fetchUserAndDispatch(); // Call the separated function
}, [dispatch, router]);
Description
This is an implementation using client components and fetching data on the client instead of the server. A lot of the project is broken because it'd take a lot of time and refactors to fix it all, so I just did some parts. Logging in works (logging out doesn't), directory page (fetching directory and setting avg hours) and features page works (only fetching features). Rest of the application is broken.
You can see the cookies in the browser and you can test the refresh token by deleting the access token and either going to features page (if you're on directory) or directory page (if you're on features). You can also test by changing the avg hours and submit it. Just a note, the loading spinner doesn't work and you have to refresh because I didn't implement the stuff you need to update the ui after an update
Issue link
Fixes # (issue)
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: