Skip to content

Commit

Permalink
fix(portal): adjust setting params and dates
Browse files Browse the repository at this point in the history
  • Loading branch information
KsiBart committed Nov 15, 2024
1 parent e652de0 commit 310bd12
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type Props = {

const { RangePicker } = DatePicker;



const ActivityDiagrams = ({ envs }: Props) => {
const stageEnvId =
envs?.find((env: IEnv) => env.name?.toLowerCase() === "stage")?.id ?? "";
Expand All @@ -52,27 +54,28 @@ const ActivityDiagrams = ({ envs }: Props) => {
buyer: undefined,
});

const parseDate = (date: string | undefined, type: "start" | "end") =>
date
? dayjs(date)[type === "start" ? "startOf" : "endOf"]("day").format(TIME_ZONE_FORMAT)
: currentTime;

const handleFormValues = useCallback(
(values: DiagramProps) => {
const { requestTime = [] } = values ?? {};
if(requestTime?.[0]) {
if (requestTime?.[0]) {
setSelectedRecentDate(undefined);
setParams({
...params,
requestStartTime: requestTime?.[0]
? dayjs(requestTime[0]).startOf("day").format(TIME_ZONE_FORMAT)
: currentTime,
requestEndTime: requestTime?.[1]
? dayjs(requestTime[1]).endOf("day").format(TIME_ZONE_FORMAT)
: currentTime,
requestStartTime: parseDate(requestTime?.[0], "start"),
requestEndTime: parseDate(requestTime?.[1], "end")
});
}
setParams({
...params,
envId: values.envId || params.envId,
buyer: values.buyer || params.buyer,
})

},
[setParams, params]
);
Expand Down

0 comments on commit 310bd12

Please sign in to comment.