From 5bdf50d3ee67b21664439d004c1a7cb41190e0ba Mon Sep 17 00:00:00 2001 From: Sujit Date: Thu, 15 Aug 2024 11:50:14 +0545 Subject: [PATCH 1/3] fix(login): user profile blank issue while login using username password call my-info api after login success (similar to gmail login) --- .../src/components/Authentication/Login/index.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/modules/user-auth-module/src/components/Authentication/Login/index.tsx b/src/frontend/src/modules/user-auth-module/src/components/Authentication/Login/index.tsx index 25ffa35e..32c3abc2 100644 --- a/src/frontend/src/modules/user-auth-module/src/components/Authentication/Login/index.tsx +++ b/src/frontend/src/modules/user-auth-module/src/components/Authentication/Login/index.tsx @@ -17,6 +17,8 @@ import { setUserState } from '@UserModule/store/actions/user'; import googleIcon from '@Assets/images/google-icon.svg'; import { toast } from 'react-toastify'; +const { BASE_URL } = process.env; + const initialState = { username: '', password: '', @@ -37,11 +39,19 @@ export default function Login() { const { mutate, isLoading } = useMutation({ mutationFn: signInUser, - onSuccess: (res: any) => { + onSuccess: async (res: any) => { dispatch(setUserState({ user: res.data })); localStorage.setItem('token', res.data.access_token); localStorage.setItem('refresh', res.data.refresh_token); toast.success('Logged In Successfully'); + const userDetailsUrl = `${BASE_URL}/users/my-info/`; + const response2 = await fetch(userDetailsUrl, { + credentials: 'include', + headers: { 'access-token': res.data.access_token }, + }); + const userDetails = await response2.json(); + const userDetailsString = JSON.stringify(userDetails); + localStorage.setItem('userprofile', userDetailsString); navigate('/projects'); }, onError: err => { From 815dcc7807ce69eda0c17b07bbcb5bbaa9ebbd9a Mon Sep 17 00:00:00 2001 From: Sujit Date: Thu, 15 Aug 2024 11:52:06 +0545 Subject: [PATCH 2/3] fix: type issue on IRoute add type to accept component as a prop and return new jsx element `((props: { children?: ReactNode }) => JSX.Element)` --- src/frontend/src/routes/types.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/routes/types.ts b/src/frontend/src/routes/types.ts index 07607633..30e93e45 100644 --- a/src/frontend/src/routes/types.ts +++ b/src/frontend/src/routes/types.ts @@ -1,10 +1,16 @@ -import { LazyExoticComponent } from 'react'; +import { LazyExoticComponent, ReactNode } from 'react'; export interface IRoute { id?: number; path: string; name: string; - component: LazyExoticComponent<() => JSX.Element> | (() => JSX.Element); + component: + | LazyExoticComponent<() => JSX.Element> + | (() => JSX.Element) + // eslint-disable-next-line no-unused-vars + | ((props: { children?: ReactNode }) => JSX.Element) + | (() => JSX.Element) + | (() => JSX.Element); authenticated?: boolean; children?: IRoute[]; } From b15005c6b1656511e49c3c8dfb9a59f58260a420 Mon Sep 17 00:00:00 2001 From: Sujit Date: Thu, 15 Aug 2024 13:57:32 +0545 Subject: [PATCH 3/3] feat(dashboard): update body for rejecting `request for mapping` and update the request logs and count --- .../src/components/Dashboard/RequestLogs/index.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/components/Dashboard/RequestLogs/index.tsx b/src/frontend/src/components/Dashboard/RequestLogs/index.tsx index 7a5b098a..a2c98142 100644 --- a/src/frontend/src/components/Dashboard/RequestLogs/index.tsx +++ b/src/frontend/src/components/Dashboard/RequestLogs/index.tsx @@ -2,7 +2,7 @@ import { useGetTaskListQuery } from '@Api/dashboard'; import { FlexColumn } from '@Components/common/Layouts'; import { Button } from '@Components/RadixComponents/Button'; import { postTaskStatus } from '@Services/project'; -import { useMutation } from '@tanstack/react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; import { toast } from 'react-toastify'; const RequestLogs = () => { @@ -12,11 +12,14 @@ const RequestLogs = () => { (task: Record) => task?.state === 'request logs', ), }); + const queryClient = useQueryClient(); const { mutate: respondToRequest } = useMutation({ mutationFn: postTaskStatus, onSuccess: () => { toast.success('Responded to the request'); + queryClient.invalidateQueries({ queryKey: ['task-list'] }); + queryClient.invalidateQueries({ queryKey: ['task-statistics'] }); }, onError: (err: any) => { toast.error(err.message); @@ -27,7 +30,7 @@ const RequestLogs = () => { respondToRequest({ projectId, taskId, - data: { event: 'bad' }, + data: { event: 'reject' }, }); };