Skip to content

Commit

Permalink
adjust favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
Janderson Souza Matias authored and Janderson Souza Matias committed Dec 20, 2023
1 parent 1a085ea commit f34dba2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/main.tsx

Large diffs are not rendered by default.

18 changes: 13 additions & 5 deletions src/pages/Dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,52 @@ const DashboardPage: React.FC = () => {
const [dashboard, setDashboard] = useState<IDashboard>();
const [regionId, setRegionId] = useState(user?.region_id);
const [selected, setSelected] = useState<ITeachingPractices>();
const [dataRange, setDataRange] = useState<Range>();
const [dateRange, setDateRange] = useState<Range>();
const isMobile = useBreakpointValue({ base: true, md: false });

useEffect(() => {
if (!loading) {
setLoading(true);

DashboardService.getData(regionId, dataRange).then((data) => {
DashboardService.getData(regionId, dateRange).then((data) => {
setDashboard(data);
setSelected(data?.teachingPractices[0]);
setLoading(false);
});
}
}, [regionId, dataRange]);
}, [regionId, dateRange]);

const handleRegion = (regionId?: string) => {
setRegionId(regionId);
};

const calcAverageStars = (stars: IStars) => {
const total = stars.needsWork + stars.keepWorking + stars.needsAttention + stars.almostThere + stars.doingGreat;
if (total === 0) return 0;
return (
(stars.needsWork * 1 +
stars.keepWorking * 2 +
stars.needsAttention * 3 +
stars.almostThere * 4 +
stars.doingGreat * 5) /
(stars.needsWork + stars.keepWorking + stars.needsAttention + stars.almostThere + stars.doingGreat)
total
);
};

const handleChangeDateRange = (range: Range) => {
if (dateRange?.startDate !== range.startDate || dateRange?.endDate !== range.endDate) {
setDateRange(range);
}
};

return (
<VStack mx="auto" minH="100vh" maxW="1200px" position="relative" overflow="scroll" alignItems="flex-start" p="56px">
<Flex mb="20px" ml={'-12px'} flexDir={isMobile ? 'column' : 'row'} w="full">
<Flex flex={1}>
<RegionSelect direction="row" level={0} onSelect={handleRegion} />
</Flex>
<Flex flex={1} maxW="220px" ml="12px">
<DataRangePicker onChange={setDataRange} />
<DataRangePicker onChange={handleChangeDateRange} />
</Flex>
</Flex>

Expand Down
2 changes: 1 addition & 1 deletion src/services/dashboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const DashboardService = {
getData: async (regionId?: string, dataRange?: Range): Promise<IDashboard> =>
(
await _axios.get<IDashboard>('dashboard', {
params: { regionId, startDate: dataRange?.startDate, endDate: dataRange?.endDate },
params: { regionId, startDate: dataRange?.startDate?.toJSON(), endDate: dataRange?.endDate?.toJSON() },
})
).data,
};
Expand Down

0 comments on commit f34dba2

Please sign in to comment.