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] || "";
|
let value: any = fm.data?.[name] || "";
|
||||||
|
|
||||||
if (type === "time") {
|
|
||||||
value = time(value) || "";
|
|
||||||
}
|
|
||||||
const [rating, setRating] = useState(value); // State untuk menyimpan nilai rating
|
const [rating, setRating] = useState(value); // State untuk menyimpan nilai rating
|
||||||
const handleClick = (index: number) => {
|
const handleClick = (index: number) => {
|
||||||
setRating(index); // Update nilai rating
|
setRating(index); // Update nilai rating
|
||||||
|
|
@ -70,9 +67,6 @@ export const TypeInput: React.FC<any> = ({
|
||||||
const convertColor = tinycolor(meta.inputValue);
|
const convertColor = tinycolor(meta.inputValue);
|
||||||
meta.rgbValue = convertColor.toRgbString();
|
meta.rgbValue = convertColor.toRgbString();
|
||||||
meta.render();
|
meta.render();
|
||||||
} else if (type === "time") {
|
|
||||||
if (fm.data?.[name]) fm.data[name] = time(fm.data[name]);
|
|
||||||
fm.render();
|
|
||||||
} else {
|
} else {
|
||||||
setRating(value ? value - 1 : value);
|
setRating(value ? value - 1 : value);
|
||||||
}
|
}
|
||||||
|
|
@ -126,7 +120,7 @@ export const TypeInput: React.FC<any> = ({
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<MaskedInput
|
<MaskedInput
|
||||||
value={value}
|
value={time(value) || ""}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
className={cx(
|
className={cx(
|
||||||
css`
|
css`
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,6 @@ export const TableList = <T extends object>({
|
||||||
onChange,
|
onChange,
|
||||||
filter = true,
|
filter = true,
|
||||||
}: TableListProps<T>) => {
|
}: TableListProps<T>) => {
|
||||||
console.log({ filter });
|
|
||||||
const [show, setShow] = useState(false as boolean);
|
const [show, setShow] = useState(false as boolean);
|
||||||
const [data, setData] = useState<any[]>([]);
|
const [data, setData] = useState<any[]>([]);
|
||||||
const sideLeft =
|
const sideLeft =
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ export const formatTime = (date: string | Date) => {
|
||||||
|
|
||||||
export const time = (date: string | Date) => {
|
export const time = (date: string | Date) => {
|
||||||
if (date === "string") {
|
if (date === "string") {
|
||||||
const timeFormatRegex = /^([01]\d|2[0-3]):([0-5]\d)$/;
|
const timeFormatRegex = /^(\d{2}):(\d{2})$/;
|
||||||
if (timeFormatRegex.test(date)) {
|
if (timeFormatRegex.test(date)) {
|
||||||
return date; // Jika sudah format HH:mm, langsung return
|
return date; // Jika sudah format HH:mm, langsung return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue