feat: services table, base segmented control

This commit is contained in:
2025-09-27 18:24:22 +04:00
parent 14140826a7
commit 47533ad7f5
29 changed files with 1489 additions and 44 deletions

View File

@ -0,0 +1,34 @@
import { SegmentedControl, SegmentedControlProps } from "@mantine/core";
export type BaseSegmentedControlProps<T> = Omit<
SegmentedControlProps,
"onChange" | "value" | "data"
> & {
onChange?: (value: T) => void;
value?: T;
data: { label: string; value: T }[];
};
const BaseSegmentedControl = <T extends string | number>(
props: BaseSegmentedControlProps<T>
) => {
const handleChange = (value: string) => {
const numValue = Number(value);
const convertedValue = isNaN(numValue) ? (value as T) : (numValue as T);
props.onChange?.(convertedValue);
};
return (
<SegmentedControl
{...props}
onChange={handleChange}
value={String(props.value)}
data={props.data.map(item => ({
...item,
value: item.value.toString(),
}))}
/>
);
};
export default BaseSegmentedControl;