user
This commit is contained in:
parent
9509943a60
commit
e6df238ef0
|
|
@ -16,6 +16,7 @@ const EditModel: React.FC = () => {
|
||||||
...values,
|
...values,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<LayoutModel
|
<LayoutModel
|
||||||
|
|
@ -27,7 +28,7 @@ const EditModel: React.FC = () => {
|
||||||
getValidationSchema={getValidationSchema}
|
getValidationSchema={getValidationSchema}
|
||||||
isAddModal={false}
|
isAddModal={false}
|
||||||
>
|
>
|
||||||
<ModelForm />
|
<ModelForm isEdit={true} />
|
||||||
</LayoutModel>
|
</LayoutModel>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,30 @@
|
||||||
import { Col, Row } from "reactstrap";
|
import { Col, Row } from "reactstrap";
|
||||||
import ValidationField from "../../../../Components/ValidationField/ValidationField";
|
import ValidationField from "../../../../Components/ValidationField/ValidationField";
|
||||||
|
import { convert_data_to_select } from "../../../../Components/ValidationField";
|
||||||
|
import useFormatDataToSelect from "../../../../utils/useFormatDataToSelect";
|
||||||
|
|
||||||
const Form = () => {
|
const Form = ({isEdit}:{isEdit?:boolean}) => {
|
||||||
|
|
||||||
|
const typeOptions = [
|
||||||
|
{ id: "student", name: "student" },
|
||||||
|
{ id: "reseller", name: "reseller" },
|
||||||
|
{ id: "admin", name: "admin" },
|
||||||
|
]
|
||||||
|
const typeArray = useFormatDataToSelect(typeOptions)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row className="w-100">
|
<Row className="w-100">
|
||||||
<Col>
|
<Col>
|
||||||
<ValidationField
|
<ValidationField placeholder="username" label="username" name="username" />
|
||||||
placeholder="name"
|
{isEdit ? ""
|
||||||
label="name"
|
:
|
||||||
name="name"
|
<ValidationField placeholder="password" label="password" name="password" />}
|
||||||
type="Number"
|
<ValidationField placeholder="phone_number" label="phone_number" name="phone_number" />
|
||||||
/>
|
</Col>
|
||||||
|
<Col>
|
||||||
|
<ValidationField type="Select" option={typeArray} placeholder="type" label="type" name="type" />
|
||||||
|
{/* <ValidationField type="Select" option={typeArray} placeholder="type" label="type" name="type" />
|
||||||
|
<ValidationField type="Select" option={typeArray} placeholder="type" label="type" name="type" /> */}
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,21 @@ import * as Yup from "yup";
|
||||||
export const getInitialValues = (objectToEdit: any): any => {
|
export const getInitialValues = (objectToEdit: any): any => {
|
||||||
return {
|
return {
|
||||||
id: objectToEdit?.id ?? null,
|
id: objectToEdit?.id ?? null,
|
||||||
name: objectToEdit?.name ?? null,
|
username: objectToEdit?.username ?? null,
|
||||||
|
password: objectToEdit?.password ?? null,
|
||||||
|
phone_number: objectToEdit?.phone_number ?? null,
|
||||||
|
type: objectToEdit?.type ?? null,
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getValidationSchema = () => {
|
export const getValidationSchema = () => {
|
||||||
return Yup.object().shape({
|
return Yup.object().shape({
|
||||||
name: Yup.string().required("validation.required"),
|
username: Yup.string().required("validation.required"),
|
||||||
|
// password: Yup.string().required("validation.required"),
|
||||||
|
phone_number: Yup.string()
|
||||||
|
.required("validation.required")
|
||||||
|
.min(10, "Phone number must be at least 10 characters long"),
|
||||||
|
type: Yup.string().required("validation.required"),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -8,6 +8,7 @@ import { useDeleteTag } from "../../../api/tags";
|
||||||
import PageHeader from "../../../Layout/Dashboard/PageHeader";
|
import PageHeader from "../../../Layout/Dashboard/PageHeader";
|
||||||
import FilterLayout from "../../../Layout/Dashboard/FilterLayout";
|
import FilterLayout from "../../../Layout/Dashboard/FilterLayout";
|
||||||
import FilterForm from "./Model/FilterForm";
|
import FilterForm from "./Model/FilterForm";
|
||||||
|
import { useDeleteUser } from "../../../api/user";
|
||||||
const Table = lazy(() => import("./Table"));
|
const Table = lazy(() => import("./Table"));
|
||||||
const AddModalForm = lazy(() => import("./Model/AddModel"));
|
const AddModalForm = lazy(() => import("./Model/AddModel"));
|
||||||
const EditModalForm = lazy(() => import("./Model/EditModel"));
|
const EditModalForm = lazy(() => import("./Model/EditModel"));
|
||||||
|
|
@ -17,8 +18,10 @@ const DeleteModalForm = lazy(
|
||||||
|
|
||||||
const TableHeader = () => {
|
const TableHeader = () => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
useSetPageTitle(t(`page_header.user`));
|
useSetPageTitle(
|
||||||
const deleteMutation = useDeleteTag();
|
t(`page_header.user`),
|
||||||
|
);
|
||||||
|
const deleteMutation = useDeleteUser();
|
||||||
return (
|
return (
|
||||||
<div className="TableWithHeader">
|
<div className="TableWithHeader">
|
||||||
<Suspense fallback={<Spin />}>
|
<Suspense fallback={<Spin />}>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ const App: React.FC = () => {
|
||||||
name: searchQuery,
|
name: searchQuery,
|
||||||
pagination: true,
|
pagination: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
return <DataTable response={response} useColumns={useColumns} />;
|
return <DataTable response={response} useColumns={useColumns} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,23 @@ export const useColumns = () => {
|
||||||
align: "center",
|
align: "center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("columns.name"),
|
title: t("columns.username"),
|
||||||
dataIndex: "name",
|
dataIndex: "username",
|
||||||
key: "name",
|
key: "username",
|
||||||
|
align: "center",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t("columns.phone_number"),
|
||||||
|
dataIndex: "phone_number",
|
||||||
|
key: "phone_number",
|
||||||
|
align: "center",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t("columns.type"),
|
||||||
|
dataIndex: "type",
|
||||||
|
key: "type",
|
||||||
align: "center",
|
align: "center",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
title: t("columns.procedure"),
|
title: t("columns.procedure"),
|
||||||
key: "actions",
|
key: "actions",
|
||||||
|
|
|
||||||
|
|
@ -158,9 +158,9 @@
|
||||||
"isBase": "سؤال رئيسي",
|
"isBase": "سؤال رئيسي",
|
||||||
"question_options_count": "عدد الخيارات",
|
"question_options_count": "عدد الخيارات",
|
||||||
"procedure": "اجراء",
|
"procedure": "اجراء",
|
||||||
"icon": "الايقونة",
|
"icon":"الايقونة",
|
||||||
"canAnswersBeShuffled": "يمكن خلط الإجابات",
|
"canAnswersBeShuffled":"يمكن خلط الإجابات",
|
||||||
"first_name":"الاسم الأول"
|
"phone_number":"رقم الهاتف"
|
||||||
},
|
},
|
||||||
"practical": {
|
"practical": {
|
||||||
"to_confirm_deletion_please_re_enter": "لتأكيد الحذف، يرجى إعادة الإدخال",
|
"to_confirm_deletion_please_re_enter": "لتأكيد الحذف، يرجى إعادة الإدخال",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user