+25
-12
@@ -15,28 +15,41 @@ type Props = {
|
||||
readOnly?: boolean,
|
||||
} & 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 (
|
||||
<div className='w-full'>
|
||||
{
|
||||
props.label &&
|
||||
label &&
|
||||
<label className='text-sm text-primary-content'>
|
||||
{props.label}
|
||||
{label}
|
||||
</label>
|
||||
}
|
||||
<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',
|
||||
props.readOnly && 'bg-muted border-0 text-muted-foreground',
|
||||
props.className,
|
||||
props.label && 'mt-1'
|
||||
readOnly && 'bg-muted border-0 text-muted-foreground',
|
||||
className,
|
||||
label && 'mt-1'
|
||||
)}>
|
||||
{
|
||||
props.placeholder &&
|
||||
<option value="" disabled selected>{props.placeholder}</option>
|
||||
placeholder &&
|
||||
<option value="" disabled>{placeholder}</option>
|
||||
}
|
||||
{
|
||||
props.items?.map((item) => {
|
||||
items?.map((item) => {
|
||||
return (
|
||||
<option key={item.value} value={item.value}>
|
||||
{item.label}
|
||||
@@ -50,9 +63,9 @@ const Select: FC<Props> = (props: Props) => {
|
||||
/>
|
||||
</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'>
|
||||
{props.error_text}
|
||||
{error_text}
|
||||
</div>
|
||||
: null
|
||||
}
|
||||
|
||||
@@ -119,6 +119,14 @@ const OrdersList: FC = () => {
|
||||
{
|
||||
key: 'designer',
|
||||
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',
|
||||
|
||||
@@ -84,7 +84,7 @@ export interface OrderListItemType extends RowDataType {
|
||||
title: string;
|
||||
type: string;
|
||||
user: UserType;
|
||||
designer: string | null;
|
||||
designer: OrderDetailCreatorType | string | null;
|
||||
creator: string;
|
||||
orderNumber: number;
|
||||
status: string;
|
||||
|
||||
@@ -9,21 +9,27 @@ type Props = {
|
||||
|
||||
} & SelectHTMLAttributes<HTMLSelectElement>
|
||||
|
||||
const CategoriesSelect: FC<Props> = (props) => {
|
||||
const CategoriesSelect: FC<Props> = ({
|
||||
isDisableShowLable,
|
||||
placeholder,
|
||||
error_text,
|
||||
...selectProps
|
||||
}) => {
|
||||
|
||||
const { data: categories } = useGetCategory()
|
||||
|
||||
return (
|
||||
<Select
|
||||
label={props.isDisableShowLable ? undefined : 'دسته'}
|
||||
placeholder={props.placeholder || 'انتخاب'}
|
||||
label={isDisableShowLable ? undefined : 'دسته'}
|
||||
placeholder={placeholder || 'انتخاب'}
|
||||
error_text={error_text}
|
||||
items={categories?.data?.map((item) => {
|
||||
return {
|
||||
label: item.title,
|
||||
value: item.id + ''
|
||||
}
|
||||
}) || []}
|
||||
{...props}
|
||||
{...selectProps}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user