merge claim detail

This commit is contained in:
2023-11-01 22:46:59 +07:00
parent 01fcaf7181
commit 5b3cddf5fe
18 changed files with 4371 additions and 3416 deletions

View File

@@ -0,0 +1,59 @@
import { FormHelperText } from "@mui/material";
import { Autocomplete, TextField } from "@mui/material";
import { Controller, useFormContext } from "react-hook-form";
type Props = {
name: string,
label: string,
options: string[];
disabled?: boolean,
}
const RHFAutocompleteNonTerminology = ({ ...props }: Props) => {
const { control } = useFormContext();
return (
<Controller
name={props.name}
control={control}
render={({ field: { onChange, value }, fieldState: { error } }) => {
let xValue = (value && value.codingCode!=="" ? value : null );
return (
<>
<Autocomplete
handleHomeEndKeys
fullWidth
options={props.options}
value={xValue}
disabled={props.disabled}
freeSolo={false}
onChange={(e, newValue) => {
onChange(newValue);
}}
renderInput={(params) => (
<TextField
{...params}
label={props.label}
name={props.name}
error={!!error}
variant="outlined"
/>
)}
/>
{!!error && (
<FormHelperText error sx={{ px: 2 }}>
{error.message}
</FormHelperText>
)}
</>
)
}}
/>
)
}
export default RHFAutocompleteNonTerminology

View File

@@ -0,0 +1,102 @@
// form
import { useFormContext, Controller } from 'react-hook-form';
// @mui
import { Autocomplete, AutocompleteProps, FormHelperText, TextField, UseAutocompleteProps } from '@mui/material';
import { useState } from 'react';
import { FilterOptionsState } from '@mui/material/useAutocomplete';
// ----------------------------------------------------------------------
interface IProps {
name: string,
label: string,
options: any,
getOptionLabel: (option: any) => string,
isOptionEqualToValue: any,
disableClearable: boolean,
freeSolo: boolean,
renderOption?: any,
onInputChange?: any,
onKeyDown?: any,
onKeyPress?: any,
noOptionsText?: string,
popupIcon?: any,
disabled?: boolean,
sx?: any,
sxTextField?: any,
InputProps?: any,
onSelect?: (option: any) => void,
filterOptions?: (options: any[], state: FilterOptionsState<any>) => any[];
}
const RHFAutocompleteV2 = ( {name, label, options, ...rest} : IProps ) => {
const { control } = useFormContext();
const {
sx, sxTextField, InputProps,
onSelect,
getOptionLabel, filterOptions,
popupIcon,
isOptionEqualToValue, disableClearable,
freeSolo, renderOption,
onInputChange, onKeyDown, onKeyPress,
noOptionsText, disabled } = rest;
return (
<Controller
name={name}
control={control}
render={({ field: { onChange, value }, fieldState: { error } }) => {
return (
<>
<Autocomplete
disabled={disabled}
handleHomeEndKeys
getOptionLabel={getOptionLabel}
options={options}
freeSolo={freeSolo}
disableClearable={disableClearable}
isOptionEqualToValue={isOptionEqualToValue}
value={value}
filterOptions={filterOptions}
renderOption={renderOption}
onInputChange={onInputChange}
onKeyDown={onKeyDown}
onKeyPress={onKeyPress}
sx={sx}
popupIcon={popupIcon}
noOptionsText={noOptionsText}
renderInput={(params) => (
<TextField
{...params}
label={label}
sx={sxTextField}
InputProps={{
...params.InputProps,
...InputProps
}}
/>
)}
onChange={(e, newValue) => {
onChange(newValue);
onSelect && onSelect(newValue);
}}
/>
{!!error && (
<FormHelperText error sx={{ px: 2 }}>
{error.message}
</FormHelperText>
)}
</>
);
}}
/>
);
}
export default RHFAutocompleteV2;

View File

@@ -55,6 +55,6 @@ export default function TableMoreMenu({ actions, disableRipple }: Props) {
>
{actions}
</MenuPopover>
    </>
  );
</>
);
}