feat(FE-85-87-88): slicing ui and integrate api for search and edit

This commit is contained in:
randy-ar
2025-10-18 10:46:47 +07:00
parent da92874a40
commit a573551110
18 changed files with 281 additions and 112 deletions
+8 -19
View File
@@ -1,12 +1,6 @@
'use client';
import {
ComponentType,
ReactNode,
useEffect,
useMemo,
useState,
} from 'react';
import { ComponentType, ReactNode, useEffect, useMemo, useState } from 'react';
import Select, {
OptionProps,
GroupBase,
@@ -98,10 +92,7 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
return { ...base, IndicatorSeparator: () => null };
}, [isAnimated]);
const internalInputChangeHandler = (
val: string,
meta: InputActionMeta
) => {
const internalInputChangeHandler = (val: string, meta: InputActionMeta) => {
if (meta.action === 'input-change') setInternalInputValue(val);
if (meta.action === 'menu-close') setInternalInputValue('');
};
@@ -113,9 +104,7 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
const SelectComponent = createables ? CreatableSelect : Select;
/** 🎯 handleChange tanpa any */
const handleChange = (
val: MultiValue<T> | SingleValue<T>
): void => {
const handleChange = (val: MultiValue<T> | SingleValue<T> | null): void => {
if (!val) {
onChange?.(null);
return;
@@ -145,15 +134,15 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
>
{label}
{required && (
<span className="tooltip tooltip-error" data-tip="required">
<span className="text-error"> *</span>
<span className='tooltip tooltip-error' data-tip='required'>
<span className='text-error'> *</span>
</span>
)}
</span>
)}
<SelectComponent<T, boolean, GroupBase<T>>
instanceId="select"
instanceId='select'
value={value ?? (isMulti ? [] : null)}
onChange={handleChange}
options={options}
@@ -225,9 +214,9 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
}}
/>
{isError && <p className="w-full text-sm text-error">{errorMessage}</p>}
{isError && <p className='w-full text-sm text-error'>{errorMessage}</p>}
{!isError && bottomLabel && (
<p className="w-full text-sm opacity-60">{bottomLabel}</p>
<p className='w-full text-sm opacity-60'>{bottomLabel}</p>
)}
</div>
);