+25
-12
@@ -15,28 +15,41 @@ type Props = {
|
|||||||
readOnly?: boolean,
|
readOnly?: boolean,
|
||||||
} & SelectHTMLAttributes<HTMLSelectElement>
|
} & SelectHTMLAttributes<HTMLSelectElement>
|
||||||
|
|
||||||
const Select: FC<Props> = (props: Props) => {
|
const Select: FC<Props> = ({
|
||||||
|
className,
|
||||||
|
items,
|
||||||
|
error_text,
|
||||||
|
placeholder,
|
||||||
|
label,
|
||||||
|
readOnly,
|
||||||
|
...selectProps
|
||||||
|
}) => {
|
||||||
|
const isControlled = selectProps.value !== undefined
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='w-full'>
|
<div className='w-full'>
|
||||||
{
|
{
|
||||||
props.label &&
|
label &&
|
||||||
<label className='text-sm text-primary-content'>
|
<label className='text-sm text-primary-content'>
|
||||||
{props.label}
|
{label}
|
||||||
</label>
|
</label>
|
||||||
}
|
}
|
||||||
<div className='relative'>
|
<div className='relative'>
|
||||||
<select {...props} className={clx(
|
<select
|
||||||
|
{...selectProps}
|
||||||
|
{...(!isControlled && placeholder ? { defaultValue: '' } : {})}
|
||||||
|
className={clx(
|
||||||
'w-full bg-white border border-border input-surface relative block appearance-none px-2.5 h-10 text-sm rounded-[10px] transition-colors',
|
'w-full bg-white border border-border input-surface relative block appearance-none px-2.5 h-10 text-sm rounded-[10px] transition-colors',
|
||||||
props.readOnly && 'bg-muted border-0 text-muted-foreground',
|
readOnly && 'bg-muted border-0 text-muted-foreground',
|
||||||
props.className,
|
className,
|
||||||
props.label && 'mt-1'
|
label && 'mt-1'
|
||||||
)}>
|
)}>
|
||||||
{
|
{
|
||||||
props.placeholder &&
|
placeholder &&
|
||||||
<option value="" disabled selected>{props.placeholder}</option>
|
<option value="" disabled>{placeholder}</option>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
props.items?.map((item) => {
|
items?.map((item) => {
|
||||||
return (
|
return (
|
||||||
<option key={item.value} value={item.value}>
|
<option key={item.value} value={item.value}>
|
||||||
{item.label}
|
{item.label}
|
||||||
@@ -50,9 +63,9 @@ const Select: FC<Props> = (props: Props) => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
props.error_text && props.error_text !== '' ?
|
error_text && error_text !== '' ?
|
||||||
<div className='text-xs text-right text-red-600 mt-2 mr-2 font-medium'>
|
<div className='text-xs text-right text-red-600 mt-2 mr-2 font-medium'>
|
||||||
{props.error_text}
|
{error_text}
|
||||||
</div>
|
</div>
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,14 @@ const OrdersList: FC = () => {
|
|||||||
{
|
{
|
||||||
key: 'designer',
|
key: 'designer',
|
||||||
title: 'مجری / طراح',
|
title: 'مجری / طراح',
|
||||||
|
render: (item) => {
|
||||||
|
const designer = item.designer
|
||||||
|
if (!designer || typeof designer === 'string') {
|
||||||
|
return <div>{typeof designer === 'string' ? designer : '—'}</div>
|
||||||
|
}
|
||||||
|
const name = `${designer.firstName ?? ''} ${designer.lastName ?? ''}`.trim()
|
||||||
|
return <div>{name || designer.phone || '—'}</div>
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'status',
|
key: 'status',
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export interface OrderListItemType extends RowDataType {
|
|||||||
title: string;
|
title: string;
|
||||||
type: string;
|
type: string;
|
||||||
user: UserType;
|
user: UserType;
|
||||||
designer: string | null;
|
designer: OrderDetailCreatorType | string | null;
|
||||||
creator: string;
|
creator: string;
|
||||||
orderNumber: number;
|
orderNumber: number;
|
||||||
status: string;
|
status: string;
|
||||||
|
|||||||
@@ -9,21 +9,27 @@ type Props = {
|
|||||||
|
|
||||||
} & SelectHTMLAttributes<HTMLSelectElement>
|
} & SelectHTMLAttributes<HTMLSelectElement>
|
||||||
|
|
||||||
const CategoriesSelect: FC<Props> = (props) => {
|
const CategoriesSelect: FC<Props> = ({
|
||||||
|
isDisableShowLable,
|
||||||
|
placeholder,
|
||||||
|
error_text,
|
||||||
|
...selectProps
|
||||||
|
}) => {
|
||||||
|
|
||||||
const { data: categories } = useGetCategory()
|
const { data: categories } = useGetCategory()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
label={props.isDisableShowLable ? undefined : 'دسته'}
|
label={isDisableShowLable ? undefined : 'دسته'}
|
||||||
placeholder={props.placeholder || 'انتخاب'}
|
placeholder={placeholder || 'انتخاب'}
|
||||||
|
error_text={error_text}
|
||||||
items={categories?.data?.map((item) => {
|
items={categories?.data?.map((item) => {
|
||||||
return {
|
return {
|
||||||
label: item.title,
|
label: item.title,
|
||||||
value: item.id + ''
|
value: item.id + ''
|
||||||
}
|
}
|
||||||
}) || []}
|
}) || []}
|
||||||
{...props}
|
{...selectProps}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user