Edit and actions updates

This commit is contained in:
Darren Clarke 2024-04-25 12:31:03 +02:00
parent 0997e449bb
commit f87bcc43a5
30 changed files with 759 additions and 139 deletions

View file

@ -1,10 +1,18 @@
import { FC } from "react";
import { TextField as InternalTextField } from "@mui/material";
import {
TextField as InternalTextField,
InputAdornment,
IconButton,
} from "@mui/material";
import { Refresh as RefreshIcon } from "@mui/icons-material";
import { colors } from "../styles/theme";
type TextFieldProps = {
name: string;
label: string;
formState: Record<string, any>;
refreshable?: boolean;
disabled?: boolean;
required?: boolean;
lines?: number;
helperText?: string;
@ -14,25 +22,45 @@ export const TextField: FC<TextFieldProps> = ({
name,
label,
formState,
refreshable = false,
disabled = false,
required = false,
lines = 1,
helperText,
}) => (
<InternalTextField
fullWidth
name={name}
label={label}
size="small"
multiline={lines > 1}
rows={lines}
required={required}
defaultValue={formState.values[name]}
error={Boolean(formState.errors[name])}
helperText={formState.errors[name] ?? helperText}
InputProps={{
sx: {
backgroundColor: "#fff",
},
}}
/>
);
}) => {
const { darkMediumGray } = colors;
return (
<InternalTextField
fullWidth
name={name}
label={label}
size="small"
disabled={disabled}
multiline={lines > 1}
rows={lines}
required={required}
defaultValue={formState.values[name]}
error={Boolean(formState.errors[name])}
helperText={formState.errors[name] ?? helperText}
InputProps={{
endAdornment: refreshable ? (
<InputAdornment position="end">
<IconButton
onClick={() => {}}
size="small"
color="primary"
sx={{ p: 0, color: darkMediumGray }}
>
<RefreshIcon />
</IconButton>
</InputAdornment>
) : null,
sx: {
backgroundColor: "#fff",
},
}}
/>
);
};