-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] - Create Dashboard page (#218)
* feat(dashboard): initial config to create dashboard page * feat(dashboard): create initial dashboard page and add semantic classes to header and footer * feat(dashboard): create overview cards * feat(dashboard): create need supplies card * feat(dashboar): add dashboard service * feat(dashboard): add chevron right * feat(dashboard): add link to filters page * Update src/components/BurgerMenu/BurgerMenu.tsx Co-authored-by: Rafael Alves <138794120+rafael-alves-cs@users.noreply.github.com> * feat(dashboard): create need supplies * feat(dashboard): integration with service * fix(dashboard): remove console log * fix(donation): fix errors in other issues * fix(sync): merge adjust --------- Co-authored-by: mateus.nogueira-extern <mateus.nogueira-extern@renault.com> Co-authored-by: Rafael Alves <138794120+rafael-alves-cs@users.noreply.github.com>
- Loading branch information
1 parent
740b49c
commit 95bb703
Showing
18 changed files
with
404 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export interface IUseDashboardOptions { | ||
cache?: boolean; | ||
} | ||
|
||
export interface ISupplieShelter { | ||
id: string; | ||
name: string; | ||
} | ||
export interface ISuppliesCategories { | ||
categoryId: string; | ||
categoryName: string; | ||
priority100: number; | ||
priority10: number; | ||
priority1: number; | ||
} | ||
|
||
export interface IUseDashboardData { | ||
allShelters?: number; | ||
allPeopleSheltered?: number; | ||
shelterAvailable?: number; | ||
shelterFull?: number; | ||
shelterWithoutInformation?: number; | ||
categoriesWithPriorities?: ISuppliesCategories[]; | ||
} |
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 { useState, useCallback, useEffect } from 'react'; | ||
import { AxiosRequestConfig } from 'axios'; | ||
|
||
import { api } from '@/api'; | ||
import { IServerResponse } from '@/types'; | ||
|
||
import { PaginatedQueryPath } from '../usePaginatedQuery/paths'; | ||
import { IUseDashboardData, IUseDashboardOptions } from './types'; | ||
|
||
const useDashboard = (options: IUseDashboardOptions = {}) => { | ||
const { cache } = options; | ||
const [loading, setLoading] = useState<boolean>(false); | ||
const [data, setData] = useState<IUseDashboardData>({ | ||
allShelters: 0, | ||
allPeopleSheltered: 0, | ||
shelterAvailable: 0, | ||
shelterFull: 0, | ||
shelterWithoutInformation: 0, | ||
}); | ||
|
||
const refresh = useCallback( | ||
(config: AxiosRequestConfig<any> = {}, append: boolean = false) => { | ||
const headers = config.headers ?? {}; | ||
if (cache) headers['x-app-cache'] = 'true'; | ||
if (!append) setLoading(true); | ||
api | ||
.get<IServerResponse<any>>(PaginatedQueryPath.Dashboard, { | ||
...config, | ||
headers, | ||
}) | ||
.then(({ data }) => { | ||
if (append) { | ||
setData((prev) => ({ | ||
...prev, | ||
...data.data, | ||
})); | ||
} else { | ||
setData((prev) => ({ | ||
...prev, | ||
...data.data, | ||
})); | ||
} | ||
}) | ||
.finally(() => { | ||
if (!append) setLoading(false); | ||
}); | ||
}, | ||
[cache] | ||
); | ||
|
||
useEffect(() => { | ||
refresh(); | ||
}, [refresh]); | ||
|
||
return { data, loading, refresh }; | ||
}; | ||
|
||
export { useDashboard }; |
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.