;
+}
+function isTextfieldProps(type: I_InnovenergyTextfieldProps | CheckmarkProps): type is I_InnovenergyTextfieldProps{
+ return typeof((type as I_InnovenergyTextfieldProps).value) === "string";
}
-
export const InnovenergyPropertyGrid = (
props: I_InnovenergyPropertyGridProps
) => {
@@ -25,7 +28,8 @@ export const InnovenergyPropertyGrid = (
{props.rows.map((element) => {
- return (
+ if(isTextfieldProps(element)){
+ return (
- );
+ );}
+ else{
+ return(
+
+ )
+ }
})}
diff --git a/typescript/Frontend/src/components/Layout/InnovenergyTextfield.tsx b/typescript/Frontend/src/components/Layout/InnovenergyTextfield.tsx
index 14abdfb7d..573ed73c0 100644
--- a/typescript/Frontend/src/components/Layout/InnovenergyTextfield.tsx
+++ b/typescript/Frontend/src/components/Layout/InnovenergyTextfield.tsx
@@ -1,16 +1,12 @@
import { Grid, InputLabel, TextField } from "@mui/material";
+import UserProps from "./UserProps";
-export interface I_InnovenergyTextfieldProps {
- id: string;
- label: string;
+
+
+export type I_InnovenergyTextfieldProps = UserProps & {
value: string;
- name: string;
- handleChange: (e: React.ChangeEvent) => void;
type?: string;
- readOnly?: boolean;
- disabled?: boolean;
helperText?: string;
- error?: boolean;
}
const InnovenergyTextfield = (props: I_InnovenergyTextfieldProps) => {
diff --git a/typescript/Frontend/src/components/Layout/UserProps.tsx b/typescript/Frontend/src/components/Layout/UserProps.tsx
new file mode 100644
index 000000000..98a01aafb
--- /dev/null
+++ b/typescript/Frontend/src/components/Layout/UserProps.tsx
@@ -0,0 +1,13 @@
+
+
+export type UserProps = {
+ id: string;
+ label: string;
+ name: string;
+ handleChange: (e: React.ChangeEvent) => void;
+ readOnly?: boolean;
+ disabled?: boolean;
+ error?: boolean;
+}
+
+export default UserProps;
\ No newline at end of file
diff --git a/typescript/Frontend/src/components/Users/UserForm.tsx b/typescript/Frontend/src/components/Users/UserForm.tsx
index 08c118baf..bb1b00833 100644
--- a/typescript/Frontend/src/components/Users/UserForm.tsx
+++ b/typescript/Frontend/src/components/Users/UserForm.tsx
@@ -15,6 +15,7 @@ import { I_InnovenergyTextfieldProps } from "../Layout/InnovenergyTextfield";
import { UserContext } from "../Context/UserContextProvider";
import { UsersContext } from "../Context/UsersContextProvider";
import InnovenergyPropertyGrid from "../Layout/InnovenergyPropertyGrid";
+import CheckmarkProps from "../Layout/Checkmark";
interface I_UserFormProps {
handleSubmit: (formikValues: Partial) => Promise;
@@ -62,7 +63,7 @@ const UserForm = (props: I_UserFormProps) => {
setOpen(false);
};
- const rows: I_InnovenergyTextfieldProps[] = [
+ const rows: (I_InnovenergyTextfieldProps | CheckmarkProps)[] = [
{
id: "name-textfield",
label: intl.formatMessage({
@@ -96,20 +97,20 @@ const UserForm = (props: I_UserFormProps) => {
handleChange: formik.handleChange,
disabled: readOnly,
},
-// This does not work as each field must be a textfield, great....
-// {
-// id: "mustResetPassword-checkbox",
-// label: intl.formatMessage({
-// id: "mustResetPassword",
-// defaultMessage: "Must reset password",
-// }),
-// name: "mustResetPassword",
-// checked:formik.values.mustResetPassword,
-// handleChange: formik.handleChange,
-// disabled: readOnly,
-// },
+ {
+ id: "mustResetPassword-checkbox",
+ label: intl.formatMessage({
+ id: "mustResetPassword",
+ defaultMessage: "Must reset password",
+ }),
+ name: "mustResetPassword",
+ value:formik.values.mustResetPassword,
+ handleChange: formik.handleChange,
+ disabled: readOnly,
+ },
];
+
return (