-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
329 additions
and
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from "react"; | ||
import { Box, Flex, Heading } from "@radix-ui/themes"; | ||
import { Table } from "../Table/Table"; | ||
import { Chart } from "../Chart/Chart"; | ||
import { StatisticData } from "../../services/refact"; | ||
import { Spinner } from "../Spinner"; | ||
import { ErrorCallout } from "../Callout"; | ||
|
||
export const StatisticView: React.FC<{ | ||
statisticData: StatisticData | null; | ||
isLoading: boolean; | ||
error: string; | ||
}> = ({ statisticData, isLoading, error }) => { | ||
if (isLoading) { | ||
return <Spinner />; | ||
} | ||
|
||
if (error || !statisticData) { | ||
return <ErrorCallout>{error}</ErrorCallout>; | ||
} | ||
|
||
return ( | ||
<Box | ||
style={{ | ||
width: "inherit", | ||
}} | ||
> | ||
<Flex | ||
direction="column" | ||
style={{ | ||
width: "inherit", | ||
}} | ||
> | ||
<Heading as="h3" align="center" mb="5"> | ||
Statistics | ||
</Heading> | ||
<Flex align="center" justify="center" direction="column"> | ||
<Table refactImpactTable={statisticData.table_refact_impact.data} /> | ||
<Chart | ||
refactImpactDatesWeekly={ | ||
statisticData.refact_impact_dates.data.weekly | ||
} | ||
/> | ||
</Flex> | ||
</Flex> | ||
</Box> | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,76 @@ | ||
export enum EVENT_NAMES_FROM_STATISTIC { | ||
BACK_FROM_STATISTIC = "back_from_statistic", | ||
} | ||
|
||
export enum EVENT_NAMES_TO_STATISTIC { | ||
REQUEST_STATISTIC_DATA = "request_statistic_data", | ||
RECEIVE_STATISTIC_DATA = "receive_statistic_data", | ||
RECEIVE_STATISTIC_DATA_ERROR = "receive_statistic_data_error", | ||
SET_LOADING_STATISTIC_DATA = "set_loading_statistic_data", | ||
} | ||
|
||
interface BaseAction { | ||
type: EVENT_NAMES_FROM_STATISTIC | EVENT_NAMES_TO_STATISTIC; | ||
payload?: { data?: string; [key: string]: unknown }; | ||
} | ||
|
||
export interface ActionToStatistic extends BaseAction { | ||
type: EVENT_NAMES_TO_STATISTIC; | ||
} | ||
|
||
export interface RequestDataForStatistic extends ActionToStatistic { | ||
type: EVENT_NAMES_TO_STATISTIC.REQUEST_STATISTIC_DATA; | ||
} | ||
|
||
export interface SetLoadingStatisticData extends ActionToStatistic { | ||
type: EVENT_NAMES_TO_STATISTIC.SET_LOADING_STATISTIC_DATA; | ||
} | ||
|
||
export function isActionToStatistic( | ||
action: unknown, | ||
): action is ActionToStatistic { | ||
if (!action) return false; | ||
if (typeof action !== "object") return false; | ||
if (!("type" in action)) return false; | ||
if (typeof action.type !== "string") return false; | ||
const ALL_EVENT_NAMES: Record<string, string> = { | ||
...EVENT_NAMES_TO_STATISTIC, | ||
}; | ||
return Object.values(ALL_EVENT_NAMES).includes(action.type); | ||
} | ||
|
||
export function isRequestDataForStatistic( | ||
action: unknown, | ||
): action is RequestDataForStatistic { | ||
if (!isActionToStatistic(action)) return false; | ||
return action.type === EVENT_NAMES_TO_STATISTIC.REQUEST_STATISTIC_DATA; | ||
} | ||
|
||
export function isReceiveDataForStatistic( | ||
action: unknown, | ||
): action is RequestDataForStatistic { | ||
if (!isActionToStatistic(action)) return false; | ||
return action.type === EVENT_NAMES_TO_STATISTIC.RECEIVE_STATISTIC_DATA; | ||
} | ||
|
||
export interface ReceiveDataForStatisticError extends ActionToStatistic { | ||
type: EVENT_NAMES_TO_STATISTIC.RECEIVE_STATISTIC_DATA_ERROR; | ||
payload: { | ||
data: string; | ||
message: string; | ||
}; | ||
} | ||
|
||
export function isReceiveDataForStatisticError( | ||
action: unknown, | ||
): action is ReceiveDataForStatisticError { | ||
if (!isActionToStatistic(action)) return false; | ||
return action.type === EVENT_NAMES_TO_STATISTIC.RECEIVE_STATISTIC_DATA_ERROR; | ||
} | ||
|
||
export function isSetLoadingStatisticData( | ||
action: unknown, | ||
): action is SetLoadingStatisticData { | ||
if (!isActionToStatistic(action)) return false; | ||
return action.type === EVENT_NAMES_TO_STATISTIC.SET_LOADING_STATISTIC_DATA; | ||
} |
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.