Skip to content

Commit

Permalink
feat(label): suport date/datetime/time fields to human
Browse files Browse the repository at this point in the history
  • Loading branch information
ecarreras committed Jan 8, 2025
1 parent b952c08 commit 4a6facb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/widgets/base/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { QuestionCircleOutlined } from "@ant-design/icons";
import { Label as LabelOoui } from "@gisce/ooui";
import { FormContext, FormContextType } from "@/context/FormContext";
import { Interweave } from "interweave";
import dayjs from "dayjs";
const { Text, Title } = Typography;
const { useToken } = theme;

Expand All @@ -28,6 +29,13 @@ const Label = (props: Props) => {
let labelText = addColon && label.length > 1 ? label + " :" : label;
if (!ooui.fieldForLabel && ooui._id) {
labelText = formContext.getFieldValue(ooui._id);
if (
ooui.fieldType === "date" ||
ooui.fieldType === "time" ||
ooui.fieldType === "datetime"
) {
labelText = labelText ? dayjs(labelText).fromNow() : "";
}
}
const responsiveAlign = responsiveBehaviour ? "left" : "right";
const labelAlgin = align || (fieldForLabel ? responsiveAlign : "left");
Expand Down

0 comments on commit 4a6facb

Please sign in to comment.