Skip to content

Commit

Permalink
Merge pull request #152 from hotosm/minor-updates
Browse files Browse the repository at this point in the history
fix: minor issues
  • Loading branch information
nrjadkry authored Aug 15, 2024
2 parents 8676535 + b15005c commit d31a111
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/frontend/src/components/Dashboard/RequestLogs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -12,11 +12,14 @@ const RequestLogs = () => {
(task: Record<string, any>) => task?.state === 'request logs',
),
});
const queryClient = useQueryClient();

const { mutate: respondToRequest } = useMutation<any, any, any, unknown>({
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);
Expand All @@ -27,7 +30,7 @@ const RequestLogs = () => {
respondToRequest({
projectId,
taskId,
data: { event: 'bad' },
data: { event: 'reject' },
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand All @@ -37,11 +39,19 @@ export default function Login() {

const { mutate, isLoading } = useMutation<any, any, any, unknown>({
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 => {
Expand Down
10 changes: 8 additions & 2 deletions src/frontend/src/routes/types.ts
Original file line number Diff line number Diff line change
@@ -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[];
}

0 comments on commit d31a111

Please sign in to comment.