Skip to content

Commit

Permalink
fix(portal): adjust helper methods location
Browse files Browse the repository at this point in the history
  • Loading branch information
KsiBart committed Nov 13, 2024
1 parent f4527c9 commit 62f900c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test("Hompage test", () => {
id: "32b4832f-fb2f-4c99-b89a-c5c995b18dfc",
productId: "mef.sonata",
createdAt: "2024-05-30T13:02:03.224486Z",
name: "production",
name: "stage",
},
],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Text } from "@/components/Text";
import {
getCurrentTimeWithZone,
recentXDays,
TIME_ZONE_FORMAT,
} from "@/utils/constants/format";
import { IEnv } from "@/utils/types/env.type";
Expand Down Expand Up @@ -82,11 +83,7 @@ const DiagramWrapper = ({ envs }: Props) => {
}, [envs]);

const setRecentDate = (e: RadioChangeEvent) => {
const requestEndTime = currentTime;
const requestStartTime =
e.target.value === "7"
? dayjs().subtract(7, "days").format(TIME_ZONE_FORMAT)
: dayjs().subtract(7, "months").format(TIME_ZONE_FORMAT);
const { requestStartTime, requestEndTime } = recentXDays(e);
setParams({ ...params, requestStartTime, requestEndTime });
};

Expand Down
10 changes: 10 additions & 0 deletions kraken-app/kraken-app-portal/src/utils/constants/format.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { RadioChangeEvent } from 'antd';
import dayjs from "dayjs";
import timezone from "dayjs/plugin/timezone";
import utc from "dayjs/plugin/utc";
Expand All @@ -16,3 +17,12 @@ export const getCurrentTimeWithZone = () => {
export const formatDiagramDate = (value: any): string => {
return dayjs(value).format("D-M");
};

export const recentXDays = (e: RadioChangeEvent) => {
const requestEndTime = getCurrentTimeWithZone();
const requestStartTime =
e.target.value === "7"
? dayjs().subtract(7, "days").format(TIME_ZONE_FORMAT)
: dayjs().subtract(7, "months").format(TIME_ZONE_FORMAT);
return { requestStartTime, requestEndTime }
};

0 comments on commit 62f900c

Please sign in to comment.