fix: update time utility to improve regex validation and refactor TypeInput component for consistent time handling

This commit is contained in:
faisolavolut 2025-03-14 12:32:07 +07:00
parent dbe47210ce
commit 10c2379a34
3 changed files with 2 additions and 9 deletions

View File

@ -30,9 +30,6 @@ export const TypeInput: React.FC<any> = ({
let value: any = fm.data?.[name] || "";
if (type === "time") {
value = time(value) || "";
}
const [rating, setRating] = useState(value); // State untuk menyimpan nilai rating
const handleClick = (index: number) => {
setRating(index); // Update nilai rating
@ -70,9 +67,6 @@ export const TypeInput: React.FC<any> = ({
const convertColor = tinycolor(meta.inputValue);
meta.rgbValue = convertColor.toRgbString();
meta.render();
} else if (type === "time") {
if (fm.data?.[name]) fm.data[name] = time(fm.data[name]);
fm.render();
} else {
setRating(value ? value - 1 : value);
}
@ -126,7 +120,7 @@ export const TypeInput: React.FC<any> = ({
return (
<>
<MaskedInput
value={value}
value={time(value) || ""}
disabled={disabled}
className={cx(
css`

View File

@ -122,7 +122,6 @@ export const TableList = <T extends object>({
onChange,
filter = true,
}: TableListProps<T>) => {
console.log({ filter });
const [show, setShow] = useState(false as boolean);
const [data, setData] = useState<any[]>([]);
const sideLeft =

View File

@ -62,7 +62,7 @@ export const formatTime = (date: string | Date) => {
export const time = (date: string | Date) => {
if (date === "string") {
const timeFormatRegex = /^([01]\d|2[0-3]):([0-5]\d)$/;
const timeFormatRegex = /^(\d{2}):(\d{2})$/;
if (timeFormatRegex.test(date)) {
return date; // Jika sudah format HH:mm, langsung return
}