Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
FLOW-969 changes countdown
Browse files Browse the repository at this point in the history
  • Loading branch information
mayankfulera committed Dec 18, 2023
1 parent fe52d6e commit 4003915
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions packages/flow-core/src/components/f-countdown/f-countdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const sizes = ["large", "medium", "small", "x-small"] as const;
const categories = ["fill", "outline"] as const;
const placements = ["left", "right", "bottom", "top", "none"] as const;

export type FCountdownStateProp = (typeof states)[number];
export type FCountdownCategoryProp = (typeof categories)[number];
export type FCountdownSizesProp = (typeof sizes)[number];
export type FCountdownLabelProp = (typeof placements)[number];
export type FCountdownStateProp = typeof states[number];
export type FCountdownCategoryProp = typeof categories[number];
export type FCountdownSizesProp = typeof sizes[number];
export type FCountdownLabelProp = typeof placements[number];
export type FCountdownDuration = number | string;

@flowElement("f-countdown")
Expand Down Expand Up @@ -163,28 +163,34 @@ export class FCountdown extends FRoot {
}

validateProperties() {
if (this.duration) {
const time = this.duration as string;
const regexNum = /^\d+$/;
if (!this.duration) {
throw new Error("f-countdown: Duration is required");
}

const time = this.duration;
const regexNum = /^\d+$/;

if (typeof time === "string") {
if (time.includes(":")) {
const [min, sec] = time.split(":");
if (!regexNum.test(min) || !regexNum.test(sec)) {
throw new Error("f-countdown: Please enter numeric values for minutes and seconds");
} else if (Number(min) >= 60 || Number(sec) > 60) {
}
if (Number(min) >= 60 || Number(sec) > 60) {
throw new Error(
"f-countdown: Please enter valid values for minutes (less than 60) and seconds (less than 60)"
);
}
} else {
if (!regexNum.test(time)) {
throw new Error("f-countdown: Please enter a numeric value for time");
} else if (Number(time) >= 3600) {
}
if (Number(time) >= 3600) {
throw new Error("f-countdown: Please enter a value for time less than 3600 seconds");
}
}
} else {
throw new Error("f-countdown: Duration is required");
} else if (time >= 3600) {
throw new Error("f-countdown: Please enter a value for time less than 3600 seconds");
}
if (
this.state?.includes("custom") &&
Expand Down

0 comments on commit 4003915

Please sign in to comment.