fix: update time utility to improve regex validation and refactor TypeInput component for consistent time handling
This commit is contained in:
parent
dbe47210ce
commit
10c2379a34
|
|
@ -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`
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue