Skip to content

Commit

Permalink
feat(Indicator): format date, datetime and time data
Browse files Browse the repository at this point in the history
  • Loading branch information
ecarreras committed Feb 7, 2025
1 parent f609ac5 commit d655596
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/widgets/custom/Indicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
import { GraphCard } from "../views/Graph";
import { useFormContext } from "@/context/FormContext";
import styled from "styled-components";
import dayjs from "@/helpers/dayjs";
const { useToken } = theme;

type IndicatorProps = WidgetProps & {
Expand Down Expand Up @@ -72,6 +73,19 @@ const IndicatorInput = (props: IndicatorInputProps) => {
formattedValue = ooui.selectionValues.get(value);
} else if (Array.isArray(value)) {
formattedValue = value[1];
} else if (
ooui.fieldType === "date" ||
ooui.fieldType === "time" ||
ooui.fieldType === "datetime"
) {
const formats = {
date: "DD/MM/YYYY",
time: "HH:mm",
datetime: "DD/MM/YYYY HH:mm",
};
formattedValue = value
? dayjs(value).format(formats[ooui.fieldType as keyof typeof formats])
: " ";
}
const field = (
<Statistic
Expand Down

0 comments on commit d655596

Please sign in to comment.