Merge branch 'dev' of into dev
This commit is contained in:
commit
4b3246e6e8
|
|
@ -11,7 +11,6 @@ import { RoleByType } from "./utils/RoleByType";
|
|||
const Page404 = lazy(() => import("./Layout/Ui/NotFoundPage"));
|
||||
const Auth = lazy(() => import("./Pages/Auth/Page"));
|
||||
const App = () => {
|
||||
|
||||
return (
|
||||
<Routes>
|
||||
<Route
|
||||
|
|
@ -36,10 +35,10 @@ const App = () => {
|
|||
{renderRoutesRecursively(menuItems)}
|
||||
|
||||
{CrudRoute.map((route) => {
|
||||
const useAbility = hasAbility(route.abilities, route.abilities_value);
|
||||
if(!RoleByType(route)){
|
||||
return false ;
|
||||
}
|
||||
const useAbility = hasAbility(route.abilities, route.abilities_value);
|
||||
if (!RoleByType(route)) {
|
||||
return false;
|
||||
}
|
||||
if (!useAbility) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const PdfUploader = ({
|
|||
}: any) => {
|
||||
const { formik, t, isError } = useFormField(name, props);
|
||||
let FormikName = formik.values[name];
|
||||
const imageUrl = formik.values[name] ? FormikName : "";
|
||||
const imageUrl = formik.values[name] ? FormikName : "";
|
||||
const [Imageurl, setImageurl] = useState(null);
|
||||
|
||||
const FilehandleChange = (value: any) => {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { useFormikContext } from "formik";
|
|||
|
||||
const SelectTag: React.FC = () => {
|
||||
const [searchValue, setSearchValue] = useState<string>("");
|
||||
|
||||
|
||||
const [fieldValue, setFieldValue] = useState<string>("");
|
||||
const formik = useFormikContext<any>();
|
||||
const handleChange = (value: string[]) => {
|
||||
|
|
@ -38,18 +38,16 @@ const SelectTag: React.FC = () => {
|
|||
const [t] = useTranslation();
|
||||
|
||||
const options = data?.data ?? [];
|
||||
const additionalData =
|
||||
options.length < 1 && searchValue.length > 1 && !isLoading
|
||||
? [{ id: searchValue, name: searchValue }]
|
||||
: [];
|
||||
const additionalData =
|
||||
options.length < 1 && searchValue.length > 1 && !isLoading
|
||||
? [{ id: searchValue, name: searchValue }]
|
||||
: [];
|
||||
|
||||
const value =
|
||||
formik?.values?.tags?.map((item: any) => item?.id ?? item) ?? [];
|
||||
|
||||
const AllOptions = [...options, ...additionalData];
|
||||
|
||||
const value = formik?.values?.tags?.map((item: any) => item?.id ?? item) ?? [];
|
||||
|
||||
|
||||
const AllOptions = [...options, ...additionalData]
|
||||
|
||||
return (
|
||||
<div className="SelectTag">
|
||||
<label htmlFor="">{t("models.tag")}</label>
|
||||
|
|
|
|||
|
|
@ -15,22 +15,17 @@ const SearchField: React.FC<Props> = ({ placeholder, searchBy }) => {
|
|||
const [searchQuery, setSearchQuery] = useState<string>("");
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
|
||||
|
||||
const {setFilter} = useFilterStateState()
|
||||
const { setFilter } = useFilterStateState();
|
||||
|
||||
const handleInputChange = (value: string) => {
|
||||
setSearchQuery(value);
|
||||
|
||||
};
|
||||
|
||||
const handleInputChangeWithDebounce = useDebounce(
|
||||
(value: string) => {
|
||||
setFilter({
|
||||
name:value
|
||||
})
|
||||
}
|
||||
)
|
||||
const handleInputChangeWithDebounce = useDebounce((value: string) => {
|
||||
setFilter({
|
||||
name: value,
|
||||
});
|
||||
});
|
||||
|
||||
const handleToggleDropdown = () => {
|
||||
setIsOpen(!isOpen);
|
||||
|
|
@ -60,7 +55,10 @@ const SearchField: React.FC<Props> = ({ placeholder, searchBy }) => {
|
|||
className="search__input"
|
||||
placeholder={t(placeholder)}
|
||||
value={searchQuery}
|
||||
onChange={(e) => {handleInputChange(e.target.value) ; handleInputChangeWithDebounce(e.target.value)}}
|
||||
onChange={(e) => {
|
||||
handleInputChange(e.target.value);
|
||||
handleInputChangeWithDebounce(e.target.value);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ import { useFilterStateState } from "../../zustand/Filter";
|
|||
|
||||
const OrderBySelect = () => {
|
||||
const { t } = useTranslation();
|
||||
const {setFilter} = useFilterStateState()
|
||||
const { setFilter } = useFilterStateState();
|
||||
const handleChange = (value: string) => {
|
||||
setFilter({
|
||||
sort_by:value
|
||||
})
|
||||
sort_by: value,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
@ -29,8 +29,14 @@ const OrderBySelect = () => {
|
|||
options={[
|
||||
{ value: "ascending", label: t("select.array.order.ascending") },
|
||||
{ value: "descending", label: t("select.array.order.descending") },
|
||||
{ value: "recently_viewed", label: t("select.array.order.recently_viewed") },
|
||||
{ value: "recently_arrived", label: t("select.array.order.recently_arrived") },
|
||||
{
|
||||
value: "recently_viewed",
|
||||
label: t("select.array.order.recently_viewed"),
|
||||
},
|
||||
{
|
||||
value: "recently_arrived",
|
||||
label: t("select.array.order.recently_arrived"),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import { Divider, Select } from "antd";
|
|||
import usePagination from "../../Layout/Dashboard/usePagination";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
|
||||
const PaginationColumn = () => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
|
|
@ -13,7 +12,6 @@ const PaginationColumn = () => {
|
|||
navigate(`?per_page=${value}`);
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<div className="pagination_column">
|
||||
<Select
|
||||
|
|
|
|||
|
|
@ -1,30 +1,20 @@
|
|||
import React from 'react'
|
||||
|
||||
|
||||
import React from "react";
|
||||
|
||||
interface IFilterBody {
|
||||
children:React.ReactNode
|
||||
children: React.ReactNode;
|
||||
}
|
||||
const useFilter = () => {
|
||||
const FilterButton = () => {
|
||||
return <div>FilterButton</div>;
|
||||
};
|
||||
const FilterBody = ({ children }: IFilterBody) => {
|
||||
return <div>FilterBody</div>;
|
||||
};
|
||||
|
||||
const FilterButton = ()=>{
|
||||
return (
|
||||
<div>
|
||||
FilterButton
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const FilterBody = ({children}:IFilterBody)=>{
|
||||
return (
|
||||
<div>
|
||||
FilterBody
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return {
|
||||
FilterButton,
|
||||
FilterBody,
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
FilterButton , FilterBody
|
||||
}
|
||||
}
|
||||
|
||||
export default useFilter
|
||||
export default useFilter;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
export enum FilterEnum {
|
||||
FILTER="FILTER"
|
||||
|
||||
|
||||
FILTER = "FILTER",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,14 +21,6 @@ export const useFilterState = create<FilterState>((set, get) => ({
|
|||
},
|
||||
}));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// import { create } from "zustand";
|
||||
|
||||
// interface FilterState {
|
||||
|
|
@ -66,7 +58,7 @@ export const useFilterState = create<FilterState>((set, get) => ({
|
|||
// ...data,
|
||||
// starting_date: formatDate(data.starting_date),
|
||||
// };
|
||||
|
||||
|
||||
// set(() => ({ filterState: formattedData }));
|
||||
// },
|
||||
// }));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
import React, { ReactNode, useEffect, useState } from "react";
|
||||
import { FaFilter } from "react-icons/fa";
|
||||
import { Form, Formik, FormikConfig, FormikHelpers, useFormikContext } from "formik";
|
||||
import {
|
||||
Form,
|
||||
Formik,
|
||||
FormikConfig,
|
||||
FormikHelpers,
|
||||
useFormikContext,
|
||||
} from "formik";
|
||||
import { Button, ButtonProps, Divider, Modal } from "antd";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useModalState } from "./Modal";
|
||||
|
|
@ -38,12 +44,12 @@ const useFilter = () => {
|
|||
const { filterState, setFilterState, clearFilterState } = useFilterState();
|
||||
const [t] = useTranslation();
|
||||
const [formValues, setFormValues] = useState({});
|
||||
const formik = useFormikContext()
|
||||
const formik = useFormikContext();
|
||||
// Define the type for the callback
|
||||
type SubmitCallback = () => void;
|
||||
// console.log(formik?.values);
|
||||
// console.log(InitialValue);
|
||||
|
||||
|
||||
const FilterButton = () => {
|
||||
const handleState = () => {
|
||||
if (isOpen === ModalEnum?.FILTER) {
|
||||
|
|
@ -61,15 +67,12 @@ const useFilter = () => {
|
|||
{t("Filter")}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
useEffect(() => {
|
||||
setFormValues({})
|
||||
setFilterState({})
|
||||
}, [])
|
||||
|
||||
};
|
||||
useEffect(() => {
|
||||
setFormValues({});
|
||||
setFilterState({});
|
||||
}, []);
|
||||
|
||||
|
||||
|
||||
const FilterBody = ({
|
||||
onSubmit,
|
||||
children,
|
||||
|
|
@ -83,7 +86,7 @@ const useFilter = () => {
|
|||
isOpen,
|
||||
...formikProps
|
||||
}: FormikFormProps) => {
|
||||
const handleSubmit = (values: any) => {
|
||||
const handleSubmit = (values: any) => {
|
||||
setFilterState(values);
|
||||
setFormValues(values);
|
||||
if (onSubmit) {
|
||||
|
|
@ -93,76 +96,85 @@ const useFilter = () => {
|
|||
setIsOpen("");
|
||||
};
|
||||
const handleCancel = (isCancel = false) => {
|
||||
|
||||
if(isCancel){
|
||||
if (isCancel) {
|
||||
setIsOpen("");
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
setIsOpen("");
|
||||
clearFilterState();
|
||||
setFormValues({});
|
||||
};
|
||||
|
||||
|
||||
const handleOpen = () => {
|
||||
setIsOpen(true);
|
||||
// setObjectToEdit({});
|
||||
};
|
||||
|
||||
|
||||
const [t] = useTranslation();
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
className={"ModalForm " + ModelClassName}
|
||||
centered
|
||||
width={width}
|
||||
footer={null}
|
||||
open={isOpen}
|
||||
onOk={handleOpen}
|
||||
onCancel={()=>{}}
|
||||
mask={false}
|
||||
style={{ position: "absolute", top: "31.4%", left: "16.7%" }}
|
||||
>
|
||||
<Formik
|
||||
enableReinitialize={true}
|
||||
onSubmit={handleSubmit}
|
||||
initialValues={formValues}
|
||||
onReset={()=>{handleCancel(false)}}
|
||||
{...formikProps}
|
||||
<Modal
|
||||
className={"ModalForm " + ModelClassName}
|
||||
centered
|
||||
width={width}
|
||||
footer={null}
|
||||
open={isOpen}
|
||||
onOk={handleOpen}
|
||||
onCancel={() => {}}
|
||||
mask={false}
|
||||
style={{ position: "absolute", top: "31.4%", left: "16.7%" }}
|
||||
>
|
||||
{(formik) => {
|
||||
|
||||
return (
|
||||
<Form>
|
||||
|
||||
<div>
|
||||
<header> {t("models.filter")} <FaXmark onClick={()=>handleCancel(true)} /> </header>
|
||||
<Divider />
|
||||
<main className="main_modal">
|
||||
{isLoading ? <SpinContainer /> : children}
|
||||
<Divider />
|
||||
</main>
|
||||
</div>
|
||||
</Form>
|
||||
)
|
||||
}}
|
||||
|
||||
</Formik>
|
||||
</Modal>
|
||||
</>
|
||||
<Formik
|
||||
enableReinitialize={true}
|
||||
onSubmit={handleSubmit}
|
||||
initialValues={formValues}
|
||||
onReset={() => {
|
||||
handleCancel(false);
|
||||
}}
|
||||
{...formikProps}
|
||||
>
|
||||
{(formik) => {
|
||||
return (
|
||||
<Form>
|
||||
<div>
|
||||
<header>
|
||||
{" "}
|
||||
{t("models.filter")}{" "}
|
||||
<FaXmark onClick={() => handleCancel(true)} />{" "}
|
||||
</header>
|
||||
<Divider />
|
||||
<main className="main_modal">
|
||||
{isLoading ? <SpinContainer /> : children}
|
||||
<Divider />
|
||||
</main>
|
||||
</div>
|
||||
</Form>
|
||||
);
|
||||
}}
|
||||
</Formik>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
interface SubmitButtonProps extends Omit<ButtonProps, "loading"> {
|
||||
}
|
||||
interface SubmitButtonProps extends Omit<ButtonProps, "loading"> {}
|
||||
const FilterSubmit = ({ ...buttonProps }: SubmitButtonProps) => {
|
||||
|
||||
return (
|
||||
<div className="filter-submit-buttons buttons">
|
||||
<Button className="back_button filter_modal_add_button" type="default" htmlType="reset">
|
||||
<Button
|
||||
className="back_button filter_modal_add_button"
|
||||
type="default"
|
||||
htmlType="reset"
|
||||
>
|
||||
{t("practical.reset")}
|
||||
</Button>
|
||||
<Button className="add_button pointer filter_modal_add_button" type="primary" {...buttonProps} htmlType="submit">
|
||||
<Button
|
||||
className="add_button pointer filter_modal_add_button"
|
||||
type="primary"
|
||||
{...buttonProps}
|
||||
htmlType="submit"
|
||||
>
|
||||
{t(`practical.submit`)}
|
||||
</Button>
|
||||
</div>
|
||||
|
|
@ -186,5 +198,4 @@ const useFilter = () => {
|
|||
};
|
||||
};
|
||||
|
||||
|
||||
export default useFilter;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const Default = ({
|
|||
label_icon,
|
||||
...props
|
||||
}: any) => {
|
||||
const { errorMsg, isError, t,formik } = useFormField(name, props);
|
||||
const { errorMsg, isError, t, formik } = useFormField(name, props);
|
||||
|
||||
return (
|
||||
<div className="ValidationField w-100">
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ const SelectField = ({
|
|||
};
|
||||
const options = translateOptions(option, t);
|
||||
console.log(options);
|
||||
|
||||
|
||||
return (
|
||||
<div className="ValidationField w-100">
|
||||
<ValidationFieldLabel
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
.ant-btn-default {
|
||||
padding: 7px 11px;
|
||||
height: var(--fieldHeight);
|
||||
min-height: var(--fieldHeight);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
|
@ -45,12 +45,12 @@
|
|||
|
||||
/// input hight
|
||||
.ant-form-item-control-input-content {
|
||||
height: var(--fieldHeight);
|
||||
min-height: var(--fieldHeight);
|
||||
}
|
||||
|
||||
//// date picker
|
||||
.ant-picker-large {
|
||||
height: var(--fieldHeight);
|
||||
min-height: var(--fieldHeight);
|
||||
}
|
||||
|
||||
/// text area
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
export const translateOptions = (options: any, t: any) => {
|
||||
console.log(options);
|
||||
|
||||
console.log(options);
|
||||
|
||||
return options?.map((opt: any) => ({
|
||||
...opt,
|
||||
label: t(`${opt?.label}`),
|
||||
|
|
|
|||
|
|
@ -26,23 +26,27 @@ const Header = () => {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
const content = (
|
||||
<div>
|
||||
<p> (CTRL + SHIFT + {CombinationKeyEnum.CHOICE}) {t("header.add_choice")} </p>
|
||||
<p> (CTRL + SHIFT + {CombinationKeyEnum.QUESTION}) {t("header.add_question")} </p>
|
||||
</div>
|
||||
);
|
||||
const content = (
|
||||
<div>
|
||||
<p>
|
||||
{" "}
|
||||
(CTRL + SHIFT + {CombinationKeyEnum.CHOICE}) {t("header.add_choice")}{" "}
|
||||
</p>
|
||||
<p>
|
||||
{" "}
|
||||
(CTRL + SHIFT + {CombinationKeyEnum.QUESTION}){" "}
|
||||
{t("header.add_question")}{" "}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<header className="exercise_add_header mb-4">
|
||||
<article>
|
||||
|
||||
|
||||
<Popover content={content} title={t("practical.Abbreviations")}>
|
||||
<img src="/Icon/QuestionIcon.svg" alt="" />
|
||||
</Popover>
|
||||
|
||||
<img src="/Icon/QuestionIcon.svg" alt="" />
|
||||
</Popover>
|
||||
|
||||
<div>
|
||||
{t("practical.add")} {t("models.exercise")}{" "}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,30 +1,35 @@
|
|||
import { useEffect } from 'react';
|
||||
import { useEffect } from "react";
|
||||
|
||||
type KeyCombination = {
|
||||
ctrlKey?: boolean;
|
||||
shiftKey?: boolean;
|
||||
code: string; // Use string here for flexibility
|
||||
code: string; // Use string here for flexibility
|
||||
};
|
||||
|
||||
const useKeyCombination = (keyCombination: KeyCombination, callback: () => void) => {
|
||||
const useKeyCombination = (
|
||||
keyCombination: KeyCombination,
|
||||
callback: () => void,
|
||||
) => {
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
const matches =
|
||||
(keyCombination.ctrlKey === undefined || event.ctrlKey === keyCombination.ctrlKey) &&
|
||||
(keyCombination.shiftKey === undefined || event.shiftKey === keyCombination.shiftKey) &&
|
||||
(keyCombination.ctrlKey === undefined ||
|
||||
event.ctrlKey === keyCombination.ctrlKey) &&
|
||||
(keyCombination.shiftKey === undefined ||
|
||||
event.shiftKey === keyCombination.shiftKey) &&
|
||||
event.code === keyCombination.code;
|
||||
|
||||
if (matches) {
|
||||
callback();
|
||||
event.preventDefault(); // Prevent the default action for the event
|
||||
event.preventDefault(); // Prevent the default action for the event
|
||||
event.stopPropagation(); // Stop the event from propagating further
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('keydown', handleKeyDown);
|
||||
window.removeEventListener("keydown", handleKeyDown);
|
||||
};
|
||||
}, [keyCombination, callback]);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ interface ModalFormProps {
|
|||
deleteMutation: any;
|
||||
ModelEnum: any;
|
||||
isNavigate?: boolean;
|
||||
idVerify?:boolean
|
||||
idVerify?: boolean;
|
||||
}
|
||||
|
||||
const DeleteModels: React.FC<ModalFormProps> = ({
|
||||
deleteMutation,
|
||||
ModelEnum,
|
||||
isNavigate = false,
|
||||
idVerify = true
|
||||
idVerify = true,
|
||||
}) => {
|
||||
const { isOpen, setIsOpen } = useModalState((state) => state);
|
||||
const [inputValue, setInputValue] = useState("");
|
||||
|
|
@ -27,10 +27,9 @@ const DeleteModels: React.FC<ModalFormProps> = ({
|
|||
console.log(objectToEdit?.key);
|
||||
console.log(inputValue);
|
||||
|
||||
const iaDisabled =
|
||||
idVerify ?
|
||||
Number(objectToEdit?.id) !== Number(inputValue) || isLoading
|
||||
: objectToEdit?.key !== inputValue || isLoading;
|
||||
const iaDisabled = idVerify
|
||||
? Number(objectToEdit?.id) !== Number(inputValue) || isLoading
|
||||
: objectToEdit?.key !== inputValue || isLoading;
|
||||
|
||||
const navigate = useNavigate();
|
||||
useEffect(() => {
|
||||
|
|
@ -44,13 +43,13 @@ const DeleteModels: React.FC<ModalFormProps> = ({
|
|||
}, [isSuccess, setIsOpen]);
|
||||
|
||||
const handleSubmit = () => {
|
||||
idVerify?
|
||||
mutate({
|
||||
id: Number(objectToEdit?.id),
|
||||
})
|
||||
: mutate({
|
||||
id:objectToEdit?.key,
|
||||
})
|
||||
idVerify
|
||||
? mutate({
|
||||
id: Number(objectToEdit?.id),
|
||||
})
|
||||
: mutate({
|
||||
id: objectToEdit?.key,
|
||||
});
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
|
|
|
|||
|
|
@ -25,10 +25,9 @@ const FilterLayout = ({
|
|||
// type: type,
|
||||
// page: currentPage,
|
||||
|
||||
const { FilterBody , FilterSubmit} = useFilter();
|
||||
const { FilterBody, FilterSubmit } = useFilter();
|
||||
return (
|
||||
<div className="filter_header">
|
||||
|
||||
<div className="filter_header_top">
|
||||
<h4>{t(filterTitle)}</h4>
|
||||
|
||||
|
|
@ -40,7 +39,7 @@ const FilterLayout = ({
|
|||
setIsOpen={setIsOpen}
|
||||
>
|
||||
<div className="model_sub_children">{sub_children}</div>
|
||||
<FilterSubmit/>
|
||||
<FilterSubmit />
|
||||
</FilterBody>
|
||||
<div className="filter_button" onClick={() => setIsOpen(true)}>
|
||||
<span>
|
||||
|
|
@ -55,7 +54,6 @@ const FilterLayout = ({
|
|||
<OrderBySelect />
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
|
|
@ -70,7 +68,6 @@ const FilterLayout = ({
|
|||
<div className="header_search">
|
||||
<SearchField searchBy="" placeholder={t("practical.search_here")} />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ const FormikFormModel: React.FC<FormikFormProps> = ({
|
|||
initialValues={initialValues}
|
||||
validationSchema={validationSchema}
|
||||
onSubmit={handleSubmit}
|
||||
|
||||
>
|
||||
{(formik) => {
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ const PageHeader = ({
|
|||
navigate(location);
|
||||
};
|
||||
console.log();
|
||||
const {PageTitle} = usePageTitleState()
|
||||
const { PageTitle } = usePageTitleState();
|
||||
return (
|
||||
<div className="page_header">
|
||||
<header className="d-flex justify-content-between">
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ const DataTable: React.FC<DataTableProps> = ({
|
|||
rowClassName={(record, index) => getRowClassName(record, index)}
|
||||
className="DataTable"
|
||||
loading={{
|
||||
spinning: isLoading || isRefetching ,
|
||||
spinning: isLoading || isRefetching,
|
||||
indicator: (
|
||||
<Suspense fallback={<></>}>
|
||||
<LoadingLottie />
|
||||
|
|
@ -56,7 +56,10 @@ const DataTable: React.FC<DataTableProps> = ({
|
|||
nextIcon: <>{t("practical.next")}</>,
|
||||
prevIcon: <> {t("practical.prev")} </>,
|
||||
className: "pagination_antd",
|
||||
showSizeChanger:false
|
||||
|
||||
}}
|
||||
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ const usePagination = (data: Data) => {
|
|||
current: data?.meta?.current_page || 1,
|
||||
pageSize: data?.meta?.per_page || 2,
|
||||
total: data?.meta?.total || 0,
|
||||
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -21,6 +22,7 @@ const usePagination = (data: Data) => {
|
|||
current: data?.meta?.current_page || 1,
|
||||
pageSize: data?.meta?.per_page || 2,
|
||||
total: data?.meta?.total || 0,
|
||||
|
||||
});
|
||||
}, [data]);
|
||||
|
||||
|
|
|
|||
|
|
@ -50,10 +50,9 @@ const SideBar = ({
|
|||
if (!useAbility) {
|
||||
return <React.Fragment key={index}></React.Fragment>;
|
||||
}
|
||||
if(!RoleByType(item)){
|
||||
|
||||
return <React.Fragment key={index}></React.Fragment> ;
|
||||
}
|
||||
if (!RoleByType(item)) {
|
||||
return <React.Fragment key={index}></React.Fragment>;
|
||||
}
|
||||
return (
|
||||
<MenuItem
|
||||
key={index}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { useFormikContext } from "formik";
|
|||
|
||||
const FilterForm = () => {
|
||||
const formik = useFormikContext();
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Row>
|
||||
|
|
@ -17,4 +17,4 @@ const FilterForm = () => {
|
|||
);
|
||||
};
|
||||
|
||||
export default FilterForm;
|
||||
export default FilterForm;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ const DeleteModalForm = lazy(
|
|||
const TableHeader = () => {
|
||||
const [t] = useTranslation();
|
||||
const deleteMutation = useDeleteGrade();
|
||||
|
||||
|
||||
useSetPageTitle(t(`page_header.grade`));
|
||||
|
||||
return (
|
||||
|
|
@ -30,10 +30,7 @@ const TableHeader = () => {
|
|||
ModelAbility={ModalEnum?.GRADE_ADD}
|
||||
canAdd={canAddGrade}
|
||||
/>
|
||||
<FilterLayout
|
||||
sub_children={<FilterForm />}
|
||||
filterTitle="table.grade"
|
||||
/>
|
||||
<FilterLayout sub_children={<FilterForm />} filterTitle="table.grade" />
|
||||
<Table />
|
||||
<AddModalForm />
|
||||
<EditModalForm />
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ import { useFilterState } from "../../../Components/Utils/Filter/FilterState";
|
|||
const App: React.FC = () => {
|
||||
const { filterState } = useFilterState();
|
||||
|
||||
const response = useGetAllGrade({
|
||||
const response = useGetAllGrade({
|
||||
pagination: true,
|
||||
...filterState,
|
||||
});
|
||||
});
|
||||
|
||||
return <DataTable response={response} useColumns={useColumns} />;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export const useColumns = () => {
|
|||
const { setObjectToEdit } = useObjectToEdit((state) => state);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handelShow = (record: Grade) => {
|
||||
const handelShow = (record: Grade) => {
|
||||
navigate(`${record?.id}`);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
import { Col, Row } from "reactstrap";
|
||||
import ValidationField from "../../../../Components/ValidationField/ValidationField";
|
||||
|
||||
const Form = ({isEdit}:{isEdit?:boolean}) => {
|
||||
const Form = ({ isEdit }: { isEdit?: boolean }) => {
|
||||
return (
|
||||
<Row className="w-100">
|
||||
<Col>
|
||||
<ValidationField placeholder="key" label="key" name="key" disabled={isEdit? true : false} />
|
||||
<ValidationField
|
||||
placeholder="key"
|
||||
label="key"
|
||||
name="key"
|
||||
disabled={isEdit ? true : false}
|
||||
/>
|
||||
<ValidationField placeholder="value" label="value" name="value" />
|
||||
</Col>
|
||||
</Row>
|
||||
|
|
|
|||
|
|
@ -12,4 +12,4 @@ export const getValidationSchema = () => {
|
|||
key: Yup.mixed().required("validation.required"),
|
||||
value: Yup.mixed().required("validation.required"),
|
||||
});
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ const DeleteModalForm = lazy(
|
|||
|
||||
const TableHeader = () => {
|
||||
const [t] = useTranslation();
|
||||
useSetPageTitle(
|
||||
t(`page_header.param`),
|
||||
);
|
||||
useSetPageTitle(t(`page_header.param`));
|
||||
const deleteMutation = useDeleteParam();
|
||||
return (
|
||||
<div className="TableWithHeader">
|
||||
|
|
|
|||
|
|
@ -15,21 +15,27 @@ const App: React.FC = () => {
|
|||
pagination: true,
|
||||
...filterState,
|
||||
});
|
||||
const [t] = useTranslation()
|
||||
const transformedData = response?.data?.data && typeof response.data.data === 'object'
|
||||
? Object.entries(response.data.data).map(([key, value]) => ({
|
||||
key: key,
|
||||
value: value
|
||||
}))
|
||||
: [];
|
||||
|
||||
return <DataTable response={response} useColumns={useColumns} dataSource={transformedData}
|
||||
pagination={{
|
||||
nextIcon: <>{t("practical.next")}</>,
|
||||
prevIcon: <> {t("practical.prev")} </>,
|
||||
className: "pagination_antd",
|
||||
}}
|
||||
/>;
|
||||
const [t] = useTranslation();
|
||||
const transformedData =
|
||||
response?.data?.data && typeof response.data.data === "object"
|
||||
? Object.entries(response.data.data).map(([key, value]) => ({
|
||||
key: key,
|
||||
value: value,
|
||||
}))
|
||||
: [];
|
||||
|
||||
return (
|
||||
<DataTable
|
||||
response={response}
|
||||
useColumns={useColumns}
|
||||
dataSource={transformedData}
|
||||
pagination={{
|
||||
nextIcon: <>{t("practical.next")}</>,
|
||||
prevIcon: <> {t("practical.prev")} </>,
|
||||
className: "pagination_antd",
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,12 @@ import { ModalEnum } from "../../../enums/Model";
|
|||
import { useObjectToEdit } from "../../../zustand/ObjectToEditState";
|
||||
import { useModalState } from "../../../zustand/Modal";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { canDeleteParam, canDeleteUser, canEditParam, canEditUser } from "../../../utils/hasAbilityFn";
|
||||
import {
|
||||
canDeleteParam,
|
||||
canDeleteUser,
|
||||
canEditParam,
|
||||
canEditUser,
|
||||
} from "../../../utils/hasAbilityFn";
|
||||
import ActionButtons from "../../../Components/Table/ActionButtons";
|
||||
|
||||
export const useColumns = () => {
|
||||
|
|
@ -56,5 +61,3 @@ export const useColumns = () => {
|
|||
|
||||
return columns;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,20 +6,17 @@ import { Spin } from "antd";
|
|||
import { ModalEnum } from "../../../../enums/Model";
|
||||
import { canAddReSeller } from "../../../../utils/hasAbilityFn";
|
||||
import PersonalDetailsForm from "../Form/PersonalDetailsForm";
|
||||
import { Formik ,Form} from "formik";
|
||||
import { Formik, Form } from "formik";
|
||||
import { getInitialValues, getValidationSchema } from "../Form/formUtils";
|
||||
import TitleDetailsForm from "../Form/TitleDetailsForm";
|
||||
import AttachmentForm from "../Form/AttachmentForm";
|
||||
|
||||
|
||||
|
||||
const TableHeader = () => {
|
||||
const [t] = useTranslation();
|
||||
useSetPageTitle(t(`page_header.add_reseller`));
|
||||
const handelSubmit = (values:any)=>{
|
||||
console.log(values,"values");
|
||||
|
||||
}
|
||||
const handelSubmit = (values: any) => {
|
||||
console.log(values, "values");
|
||||
};
|
||||
return (
|
||||
<div className="TableWithHeader">
|
||||
<Suspense fallback={<Spin />}>
|
||||
|
|
@ -28,21 +25,22 @@ const TableHeader = () => {
|
|||
ModelAbility={ModalEnum?.RE_SELLER_ADD}
|
||||
canAdd={false}
|
||||
/>
|
||||
<div className="bg2" >
|
||||
<Formik initialValues={getInitialValues({})} validationSchema={getValidationSchema} onSubmit={handelSubmit} >
|
||||
<div className="bg2">
|
||||
<Formik
|
||||
initialValues={getInitialValues({})}
|
||||
validationSchema={getValidationSchema}
|
||||
onSubmit={handelSubmit}
|
||||
>
|
||||
<Form>
|
||||
<PersonalDetailsForm/>
|
||||
<TitleDetailsForm/>
|
||||
<AttachmentForm/>
|
||||
<div className="resellerButton">
|
||||
<button type="button">
|
||||
{t("practical.cancel")}
|
||||
</button>
|
||||
<button type="submit">
|
||||
{t("practical.add")} {t("models.reseller")}
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<PersonalDetailsForm />
|
||||
<TitleDetailsForm />
|
||||
<AttachmentForm />
|
||||
<div className="resellerButton">
|
||||
<button type="button">{t("practical.cancel")}</button>
|
||||
<button type="submit">
|
||||
{t("practical.add")} {t("models.reseller")}
|
||||
</button>
|
||||
</div>
|
||||
</Form>
|
||||
</Formik>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
import React from 'react'
|
||||
import React from "react";
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
<div>Page</div>
|
||||
)
|
||||
}
|
||||
return <div>Page</div>;
|
||||
};
|
||||
|
||||
export default Page
|
||||
export default Page;
|
||||
|
|
|
|||
|
|
@ -1,24 +1,23 @@
|
|||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { FaImage } from 'react-icons/fa'
|
||||
import ImageBoxField from './ImageBoxField/ImageBoxField';
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FaImage } from "react-icons/fa";
|
||||
import ImageBoxField from "./ImageBoxField/ImageBoxField";
|
||||
|
||||
const AttachmentForm = () => {
|
||||
const [t] = useTranslation();
|
||||
|
||||
return (
|
||||
<div className='AttachmentForm'>
|
||||
<header className='header_form'>
|
||||
<div className="AttachmentForm">
|
||||
<header className="header_form">
|
||||
<FaImage />
|
||||
<h4>{t("header.attachment")}</h4>
|
||||
</header>
|
||||
<main className='main_form_body'>
|
||||
|
||||
<ImageBoxField name="personal_image" />
|
||||
<ImageBoxField name="id_image" />
|
||||
<main className="main_form_body">
|
||||
<ImageBoxField name="personal_image" />
|
||||
<ImageBoxField name="id_image" />
|
||||
</main>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default AttachmentForm
|
||||
export default AttachmentForm;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,11 @@ const FilterForm = () => {
|
|||
<div>
|
||||
<Row>
|
||||
<Col>
|
||||
<ValidationField placeholder="first_name" label="first_name" name="first_name" />
|
||||
<ValidationField
|
||||
placeholder="first_name"
|
||||
label="first_name"
|
||||
name="first_name"
|
||||
/>
|
||||
{/* <ValidationField placeholder="last_name" label="last_name" name="last_name" /> */}
|
||||
</Col>
|
||||
{/* <Col>
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ const ImageBoxField = ({ name }: any) => {
|
|||
fileInputRef.current.value = "";
|
||||
}
|
||||
};
|
||||
const [t] = useTranslation()
|
||||
const [t] = useTranslation();
|
||||
return (
|
||||
<div className="ImageBoxField">
|
||||
<header>{t(`input.${name}`)}</header>
|
||||
|
|
|
|||
|
|
@ -1,35 +1,76 @@
|
|||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { FaStore } from 'react-icons/fa'
|
||||
import ValidationField from '../../../../Components/ValidationField/ValidationField';
|
||||
import { convert_data_to_select } from '../../../../Layout/app/Const';
|
||||
import { userTypeOptions } from '../../../../config/userTypeOptions';
|
||||
import { statusType } from '../../../../config/statusType';
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FaStore } from "react-icons/fa";
|
||||
import ValidationField from "../../../../Components/ValidationField/ValidationField";
|
||||
import { convert_data_to_select } from "../../../../Layout/app/Const";
|
||||
import { userTypeOptions } from "../../../../config/userTypeOptions";
|
||||
import { statusType } from "../../../../config/statusType";
|
||||
|
||||
const PersonalDetailsForm = () => {
|
||||
const [t] = useTranslation();
|
||||
return (
|
||||
<div className='PersonalDetailsForm'>
|
||||
<header className='header_form'>
|
||||
<div className="PersonalDetailsForm">
|
||||
<header className="header_form">
|
||||
<FaStore />
|
||||
<h4>{t("header.personal_information")}</h4>
|
||||
</header>
|
||||
<main className='main_form_body'>
|
||||
<ValidationField name={"id_number"} placeholder={"_"} label={"ID Number"} />
|
||||
<ValidationField name={"addition_date"} placeholder={"_"} type='Date' label={"Addition Date"} />
|
||||
<ValidationField name={"status"} placeholder={"_"} label={"Status"} type='Select' option={statusType} />
|
||||
<main className="main_form_body">
|
||||
<ValidationField
|
||||
name={"id_number"}
|
||||
placeholder={"_"}
|
||||
label={"ID Number"}
|
||||
/>
|
||||
<ValidationField
|
||||
name={"addition_date"}
|
||||
placeholder={"_"}
|
||||
type="Date"
|
||||
label={"Addition Date"}
|
||||
/>
|
||||
<ValidationField
|
||||
name={"status"}
|
||||
placeholder={"_"}
|
||||
label={"Status"}
|
||||
type="Select"
|
||||
option={statusType}
|
||||
/>
|
||||
|
||||
<ValidationField name={"full_name"} placeholder={"_"} label={"Full Name"} />
|
||||
<ValidationField name={"phone_number"} placeholder={"_"} label={"Phone Number"} type='text' />
|
||||
<ValidationField name={"mobile_number"} placeholder={"_"} label={"Mobile Number"} />
|
||||
|
||||
<ValidationField name={"username"} placeholder={"_"} label={"Username"} />
|
||||
<ValidationField name={"password"} placeholder={"_"} label={"Password"} type='text' />
|
||||
<ValidationField name={"seller_percentage"} placeholder={"_"} label={"Seller Percentage"} type='text' />
|
||||
<ValidationField
|
||||
name={"full_name"}
|
||||
placeholder={"_"}
|
||||
label={"Full Name"}
|
||||
/>
|
||||
<ValidationField
|
||||
name={"phone_number"}
|
||||
placeholder={"_"}
|
||||
label={"Phone Number"}
|
||||
type="text"
|
||||
/>
|
||||
<ValidationField
|
||||
name={"mobile_number"}
|
||||
placeholder={"_"}
|
||||
label={"Mobile Number"}
|
||||
/>
|
||||
|
||||
<ValidationField
|
||||
name={"username"}
|
||||
placeholder={"_"}
|
||||
label={"Username"}
|
||||
/>
|
||||
<ValidationField
|
||||
name={"password"}
|
||||
placeholder={"_"}
|
||||
label={"Password"}
|
||||
type="text"
|
||||
/>
|
||||
<ValidationField
|
||||
name={"seller_percentage"}
|
||||
placeholder={"_"}
|
||||
label={"Seller Percentage"}
|
||||
type="text"
|
||||
/>
|
||||
</main>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default PersonalDetailsForm
|
||||
export default PersonalDetailsForm;
|
||||
|
|
|
|||
|
|
@ -1,25 +1,30 @@
|
|||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { FaRegAddressBook } from 'react-icons/fa'
|
||||
import ValidationField from '../../../../Components/ValidationField/ValidationField';
|
||||
import { nationalities } from '../../../../types/App';
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FaRegAddressBook } from "react-icons/fa";
|
||||
import ValidationField from "../../../../Components/ValidationField/ValidationField";
|
||||
import { nationalities } from "../../../../types/App";
|
||||
|
||||
const TitleDetailsForm = () => {
|
||||
const [t] = useTranslation();
|
||||
|
||||
return (
|
||||
<div className='TitleDetailsForm'>
|
||||
<header className='header_form'>
|
||||
<div className="TitleDetailsForm">
|
||||
<header className="header_form">
|
||||
<FaRegAddressBook />
|
||||
<h4>{t("header.address")}</h4>
|
||||
</header>
|
||||
<main className='main_form_body'>
|
||||
<ValidationField name={"city_id"} placeholder={"_"} label={"city"} type='Select' option={nationalities} />
|
||||
<ValidationField name={"address"} placeholder={"_"} label={"address"} />
|
||||
|
||||
<main className="main_form_body">
|
||||
<ValidationField
|
||||
name={"city_id"}
|
||||
placeholder={"_"}
|
||||
label={"city"}
|
||||
type="Select"
|
||||
option={nationalities}
|
||||
/>
|
||||
<ValidationField name={"address"} placeholder={"_"} label={"address"} />
|
||||
</main>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default TitleDetailsForm
|
||||
export default TitleDetailsForm;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,13 @@
|
|||
import * as Yup from "yup";
|
||||
|
||||
export const getInitialValues = (
|
||||
objectToEdit: Partial<any>,
|
||||
) => {
|
||||
export const getInitialValues = (objectToEdit: Partial<any>) => {
|
||||
return {
|
||||
id: objectToEdit?.id ?? null ,
|
||||
id: objectToEdit?.id ?? null,
|
||||
name: objectToEdit?.name ?? null,
|
||||
};
|
||||
};
|
||||
|
||||
export const getValidationSchema = () => {
|
||||
// validate input
|
||||
return Yup.object().shape({
|
||||
|
||||
});
|
||||
return Yup.object().shape({});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ const TableHeader = () => {
|
|||
deleteMutation={deleteMutation}
|
||||
ModelEnum={ModalEnum?.RE_SELLER_DELETE}
|
||||
/>
|
||||
|
||||
</Suspense>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const App: React.FC = () => {
|
|||
const response = useGetAllReseller({
|
||||
name: searchQuery,
|
||||
pagination: true,
|
||||
...filterState
|
||||
...filterState,
|
||||
});
|
||||
|
||||
return <DataTable response={response} useColumns={useColumns} />;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ export const useColumns = () => {
|
|||
const { setObjectToEdit } = useObjectToEdit((state) => state);
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
||||
const handelDelete = (data: ReSeller) => {
|
||||
setObjectToEdit(data);
|
||||
handel_open_model(ModalEnum?.RE_SELLER_DELETE);
|
||||
|
|
@ -63,7 +62,7 @@ export const useColumns = () => {
|
|||
render: (_text, record) => record?.user?.username,
|
||||
},
|
||||
{
|
||||
title:"",
|
||||
title: "",
|
||||
|
||||
key: "actions",
|
||||
align: "center",
|
||||
|
|
@ -72,11 +71,9 @@ export const useColumns = () => {
|
|||
<ActionButtons
|
||||
canDelete={canDeleteReSeller}
|
||||
canEdit={canEditReSeller}
|
||||
|
||||
index={index}
|
||||
onDelete={() => handelDelete(record)}
|
||||
onEdit={() => handleEdit(record)}
|
||||
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -7,8 +7,16 @@ const FilterForm = () => {
|
|||
<div>
|
||||
<Row>
|
||||
<Col>
|
||||
<ValidationField placeholder="first_name" label="first_name" name="first_name" />
|
||||
<ValidationField placeholder="last_name" label="last_name" name="last_name" />
|
||||
<ValidationField
|
||||
placeholder="first_name"
|
||||
label="first_name"
|
||||
name="first_name"
|
||||
/>
|
||||
<ValidationField
|
||||
placeholder="last_name"
|
||||
label="last_name"
|
||||
name="last_name"
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ import { useFilterState } from "../../../Components/Utils/Filter/FilterState";
|
|||
const App: React.FC = () => {
|
||||
const { filterState } = useFilterState();
|
||||
|
||||
const response = useGetAllStudent({
|
||||
const response = useGetAllStudent({
|
||||
pagination: true,
|
||||
...filterState,
|
||||
});
|
||||
});
|
||||
|
||||
return <DataTable response={response} useColumns={useColumns} />;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ const DrapableTable: React.FC = () => {
|
|||
const { subject_id } = useParams<ParamsEnum>();
|
||||
const { filterState } = useFilterState();
|
||||
|
||||
const response = useGetAllUnit({
|
||||
const response = useGetAllUnit({
|
||||
subject_id: subject_id,
|
||||
pagination: false,
|
||||
...filterState,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ const Form = () => {
|
|||
placeholder="term"
|
||||
label="term"
|
||||
option={termsArray}
|
||||
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ const TableHeader = () => {
|
|||
const SubjectName = Subject?.data?.name ?? "";
|
||||
useSetPageTitle(
|
||||
t(`page_header.grade`) +
|
||||
" / " +
|
||||
` ${t("header.subject_of_class")} (${gradeName})` +
|
||||
" / " +
|
||||
SubjectName
|
||||
` ${t("header.subject_of_class")} (${gradeName})` +
|
||||
" / " +
|
||||
SubjectName,
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
@ -56,7 +56,7 @@ const TableHeader = () => {
|
|||
<FilterLayout
|
||||
sub_children={<FilterForm />}
|
||||
filterTitle={` ${gradeName} (${SubjectName}) `}
|
||||
/>
|
||||
/>
|
||||
<Table />
|
||||
<AddModalForm />
|
||||
<EditModalForm />
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ import { useFilterState } from "../../../Components/Utils/Filter/FilterState";
|
|||
|
||||
const App: React.FC = () => {
|
||||
const { subject_id } = useParams<ParamsEnum>();
|
||||
|
||||
const response = useGetAllUnit({
|
||||
|
||||
const response = useGetAllUnit({
|
||||
subject_id: subject_id,
|
||||
pagination: true,
|
||||
});
|
||||
});
|
||||
const { setOldObjectToEdit } = useObjectToEdit();
|
||||
// console.log(response?.data?.data, "response?.data");
|
||||
const data = response?.data?.data;
|
||||
|
|
|
|||
|
|
@ -8,11 +8,25 @@ const FilterForm = () => {
|
|||
<div>
|
||||
<Row>
|
||||
<Col>
|
||||
<ValidationField placeholder="username" label="username" name="username" />
|
||||
<ValidationField placeholder="phone_number" label="phone_number" name="phone_number" />
|
||||
<ValidationField
|
||||
placeholder="username"
|
||||
label="username"
|
||||
name="username"
|
||||
/>
|
||||
<ValidationField
|
||||
placeholder="phone_number"
|
||||
label="phone_number"
|
||||
name="phone_number"
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
<ValidationField type="Select" option={userTypeOptions} placeholder="type" label="type" name="type" />
|
||||
<ValidationField
|
||||
type="Select"
|
||||
option={userTypeOptions}
|
||||
placeholder="type"
|
||||
label="type"
|
||||
name="type"
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -3,25 +3,59 @@ import ValidationField from "../../../../Components/ValidationField/ValidationFi
|
|||
import useFormatDataToSelect from "../../../../utils/useFormatDataToSelect";
|
||||
import { userTypeOptions } from "../../../../config/userTypeOptions";
|
||||
|
||||
const Form = ({isEdit}:{isEdit?:boolean}) => {
|
||||
|
||||
|
||||
|
||||
const Form = ({ isEdit }: { isEdit?: boolean }) => {
|
||||
return (
|
||||
<Row className="w-100">
|
||||
{isEdit ? "" :
|
||||
{isEdit ? (
|
||||
""
|
||||
) : (
|
||||
<Col>
|
||||
<>
|
||||
<ValidationField placeholder="username" label="username" name="username" />
|
||||
<ValidationField placeholder="password" label="password" name="password" />
|
||||
<ValidationField placeholder="phone_number" label="phone_number" name="phone_number" />
|
||||
</>
|
||||
</Col>}
|
||||
<>
|
||||
<ValidationField
|
||||
placeholder="username"
|
||||
label="username"
|
||||
name="username"
|
||||
/>
|
||||
<ValidationField
|
||||
placeholder="password"
|
||||
label="password"
|
||||
name="password"
|
||||
/>
|
||||
<ValidationField
|
||||
placeholder="phone_number"
|
||||
label="phone_number"
|
||||
name="phone_number"
|
||||
/>
|
||||
</>
|
||||
</Col>
|
||||
)}
|
||||
<Col>
|
||||
{isEdit ? "":
|
||||
<ValidationField type="Select" option={userTypeOptions} placeholder="type" label="type" name="type" />}
|
||||
<ValidationField type="Select" option={userTypeOptions} placeholder="roles" label="roles" name="role_id" />
|
||||
<ValidationField type="Select" option={userTypeOptions} placeholder="abilities" label="abilities" name="abilities" isMulti={true} />
|
||||
{isEdit ? (
|
||||
""
|
||||
) : (
|
||||
<ValidationField
|
||||
type="Select"
|
||||
option={userTypeOptions}
|
||||
placeholder="type"
|
||||
label="type"
|
||||
name="type"
|
||||
/>
|
||||
)}
|
||||
<ValidationField
|
||||
type="Select"
|
||||
option={userTypeOptions}
|
||||
placeholder="roles"
|
||||
label="roles"
|
||||
name="role_id"
|
||||
/>
|
||||
<ValidationField
|
||||
type="Select"
|
||||
option={userTypeOptions}
|
||||
placeholder="abilities"
|
||||
label="abilities"
|
||||
name="abilities"
|
||||
isMulti={true}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ export const getInitialValues = (objectToEdit: any): any => {
|
|||
password: objectToEdit?.password ?? null,
|
||||
phone_number: objectToEdit?.phone_number ?? null,
|
||||
type: objectToEdit?.type ?? null,
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -16,7 +15,7 @@ export const getValidationSchema = () => {
|
|||
// password: Yup.string().required("validation.required"),
|
||||
phone_number: Yup.string()
|
||||
.required("validation.required")
|
||||
.min(10, "Phone number must be at least 10 characters long"),
|
||||
.min(10, "Phone number must be at least 10 characters long"),
|
||||
type: Yup.string().required("validation.required"),
|
||||
});
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ const DeleteModalForm = lazy(
|
|||
|
||||
const TableHeader = () => {
|
||||
const [t] = useTranslation();
|
||||
useSetPageTitle(
|
||||
t(`page_header.user`),
|
||||
);
|
||||
useSetPageTitle(t(`page_header.user`));
|
||||
const deleteMutation = useDeleteUser();
|
||||
return (
|
||||
<div className="TableWithHeader">
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const App: React.FC = () => {
|
|||
pagination: true,
|
||||
...filterState,
|
||||
});
|
||||
|
||||
|
||||
return <DataTable response={response} useColumns={useColumns} />;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -37,22 +37,20 @@ const TableHeader = () => {
|
|||
show: grade_id,
|
||||
});
|
||||
|
||||
|
||||
const gradeName = grade?.data?.name ?? "";
|
||||
const SubjectName = Subject?.data?.name ?? "";
|
||||
const unitName = unit?.data?.name ?? "";
|
||||
|
||||
useSetPageTitle(
|
||||
t(`page_header.grade`) +
|
||||
" / " +
|
||||
` ${t("header.subject_of_class")} (${gradeName})` +
|
||||
" / " +
|
||||
` ${t("header.subject_of_class")} (${gradeName})` +
|
||||
" / " +
|
||||
SubjectName +
|
||||
" / " +
|
||||
unitName
|
||||
unitName,
|
||||
);
|
||||
|
||||
|
||||
return (
|
||||
<div className="TableWithHeader">
|
||||
<Suspense fallback={<Spin />}>
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ import { useFilterState } from "../../../Components/Utils/Filter/FilterState";
|
|||
const App: React.FC = () => {
|
||||
const { unit_id } = useParams<ParamsEnum>();
|
||||
|
||||
const response = useGetAllLesson({
|
||||
const response = useGetAllLesson({
|
||||
unit_id: unit_id,
|
||||
pagination: true,
|
||||
});
|
||||
});
|
||||
|
||||
const { setOldObjectToEdit } = useObjectToEdit();
|
||||
// console.log(response?.data?.data, "response?.data");
|
||||
|
|
|
|||
|
|
@ -71,8 +71,7 @@ export const useColumns = () => {
|
|||
// ),
|
||||
title: t("columns.procedure"),
|
||||
key: "actions",
|
||||
align: "end",
|
||||
width: "25vw",
|
||||
align: "center",
|
||||
render: (_text, record, index) => {
|
||||
return (
|
||||
<ActionButtons
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React, { Suspense, lazy, useEffect } from "react";
|
||||
import { Spin } from "antd";
|
||||
import { Spin } from "antd";
|
||||
import FormikForm from "../../../Layout/Dashboard/FormikFormModel";
|
||||
import {
|
||||
getInitialValues,
|
||||
|
|
@ -22,31 +22,24 @@ import { toast } from "react-toastify";
|
|||
const AcceptModal = lazy(() => import("./Model/AcceptModal"));
|
||||
|
||||
const AddPage: React.FC = () => {
|
||||
|
||||
const { mutateAsync } = useAddQuestionAsync();
|
||||
const { mutate, isLoading ,isSuccess} = useAddQuestion();
|
||||
const {
|
||||
isBseQuestion,
|
||||
setTagsSearch,
|
||||
objectToEdit,
|
||||
setSuccess
|
||||
} = useObjectToEdit();
|
||||
|
||||
const { mutateAsync,isLoading:LoadingAsync } = useAddQuestionAsync();
|
||||
const { mutate, isLoading, isSuccess } = useAddQuestion();
|
||||
const { isBseQuestion, setTagsSearch, objectToEdit, setSuccess } =
|
||||
useObjectToEdit();
|
||||
|
||||
const [t] = useTranslation();
|
||||
const { subject_id, lesson_id } =
|
||||
useParams<ParamsEnum>();
|
||||
|
||||
console.log(objectToEdit,"objectToEdit");
|
||||
const { subject_id, lesson_id } = useParams<ParamsEnum>();
|
||||
|
||||
console.log(objectToEdit, "objectToEdit");
|
||||
|
||||
const handleSubmit = (
|
||||
values: any,
|
||||
{ resetForm }: { resetForm: () => void },
|
||||
) => {
|
||||
|
||||
const DataToSend = structuredClone(values);
|
||||
setTagsSearch(null);
|
||||
|
||||
console.log(1);
|
||||
|
||||
const canAnswersBeShuffled = DataToSend?.canAnswersBeShuffled ? 1 : 0;
|
||||
|
||||
if (isBseQuestion || DataToSend?.isBase === 1) {
|
||||
|
|
@ -75,14 +68,11 @@ console.log(objectToEdit,"objectToEdit");
|
|||
};
|
||||
});
|
||||
console.log(answers);
|
||||
if(answers?.length > 0){
|
||||
const isValidAnswers = answers?.some((answer:any) => answer?.isCorrect === 1)
|
||||
|
||||
if(!isValidAnswers){
|
||||
toast.error(t("validation.at_least_one_answer_should_be_correct"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (answers?.length > 0) {
|
||||
const isValidAnswers = answers?.some(
|
||||
(answer: any) => answer?.isCorrect === 1,
|
||||
);
|
||||
}
|
||||
mutate({
|
||||
...item,
|
||||
parent_id: newBseQuestionId,
|
||||
|
|
@ -95,26 +85,28 @@ console.log(objectToEdit,"objectToEdit");
|
|||
console.log(newBseQuestionId, "newBseQuestionId");
|
||||
});
|
||||
} else {
|
||||
console.log(1);
|
||||
|
||||
const tags = processTags(DataToSend);
|
||||
const answers = values?.answers?.map((item: any, index: number) => {
|
||||
console.log(item,"item");
|
||||
|
||||
return {
|
||||
order: index,
|
||||
...item,
|
||||
};
|
||||
});
|
||||
|
||||
if(answers?.length > 0){
|
||||
|
||||
const isValidAnswers = answers?.some((answer:any) => answer?.isCorrect === 1)
|
||||
|
||||
if(!isValidAnswers){
|
||||
toast.error(t("validation.at_least_one_answer_should_be_correct"));
|
||||
return;
|
||||
|
||||
if (answers?.length > 0) {
|
||||
const isValidAnswers = answers?.some(
|
||||
(answer: any) => answer?.isCorrect === 1,
|
||||
);
|
||||
console.log(!isValidAnswers);
|
||||
|
||||
if (!isValidAnswers) {
|
||||
toast.error(t("validation.at_least_one_answer_should_be_correct"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const NewQuestion = {
|
||||
...values,
|
||||
subject_id: subject_id,
|
||||
|
|
@ -132,26 +124,16 @@ console.log(objectToEdit,"objectToEdit");
|
|||
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
||||
const handleCancel = () => {
|
||||
navigate(-1);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const Loading = LoadingAsync || isLoading
|
||||
useEffect(() => {
|
||||
|
||||
|
||||
console.log("all api success");
|
||||
if(isSuccess){
|
||||
|
||||
setSuccess(true )
|
||||
if (isSuccess) {
|
||||
setSuccess(true);
|
||||
}
|
||||
}, [isSuccess])
|
||||
|
||||
|
||||
}, [isSuccess]);
|
||||
|
||||
if (isBseQuestion) {
|
||||
return (
|
||||
|
|
@ -167,10 +149,10 @@ console.log(objectToEdit,"objectToEdit");
|
|||
|
||||
<div className="exercise_add_buttons">
|
||||
<div onClick={handleCancel}>{t("practical.back")}</div>
|
||||
<button disabled={isLoading} className="relative" type="submit">
|
||||
<button disabled={Loading} className="relative" type="submit">
|
||||
{t("practical.add")}
|
||||
|
||||
{isLoading && (
|
||||
{Loading && (
|
||||
<span className="Spinier_Div">
|
||||
<Spin />
|
||||
</span>
|
||||
|
|
@ -198,10 +180,10 @@ console.log(objectToEdit,"objectToEdit");
|
|||
|
||||
<div className="exercise_add_buttons">
|
||||
<div onClick={handleCancel}>{t("practical.back")}</div>
|
||||
<button disabled={isLoading} className="relative" type="submit">
|
||||
<button disabled={Loading} className="relative" type="submit">
|
||||
{t("practical.add")}
|
||||
|
||||
{isLoading && (
|
||||
{Loading && (
|
||||
<span className="Spinier_Div">
|
||||
<Spin />
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import {
|
|||
useUpdateQuestion,
|
||||
} from "../../../api/Question";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useLocation, useNavigate, useParams } from "react-router-dom";
|
||||
import { ParamsEnum } from "../../../enums/params";
|
||||
import { useObjectToEdit } from "../../../zustand/ObjectToEditState";
|
||||
import { removeStringKeys } from "../../../utils/removeStringKeys";
|
||||
|
|
@ -24,20 +24,16 @@ import ModelForm from "./Model/ModelForm";
|
|||
import BaseForm from "./Model/Malty/Form";
|
||||
import { Question } from "../../../types/Item";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
import { deletePathSegments } from "../../../utils/deletePathSegments";
|
||||
|
||||
const EditPage: React.FC = () => {
|
||||
const {
|
||||
subject_id,
|
||||
lesson_id,
|
||||
question_id,
|
||||
} = useParams<ParamsEnum>();
|
||||
const { subject_id, lesson_id, question_id } = useParams<ParamsEnum>();
|
||||
const { isBseQuestion, setIsBseQuestion, setTagsSearch, DeletedQuestions } =
|
||||
useObjectToEdit();
|
||||
|
||||
const { mutate, isSuccess, isLoading } = useUpdateQuestion();
|
||||
const { mutate: DeleteQuestion } = useDeleteQuestion();
|
||||
const { mutate: mutateAdd } = useAddQuestion();
|
||||
const { mutate: mutateAdd , isLoading:LoadingAsync } = useAddQuestion();
|
||||
|
||||
const { data, isLoading: dataLoading } = useGetAllQuestion({
|
||||
show: question_id,
|
||||
|
|
@ -58,8 +54,6 @@ const EditPage: React.FC = () => {
|
|||
|
||||
const [t] = useTranslation();
|
||||
|
||||
|
||||
|
||||
const handleSubmit = (values: any) => {
|
||||
const DataToSend = structuredClone(values);
|
||||
setTagsSearch(null);
|
||||
|
|
@ -100,21 +94,22 @@ const EditPage: React.FC = () => {
|
|||
const tags = processTags(updatedObject);
|
||||
const oldAnswers = [] as any;
|
||||
const newAnswers = [] as any;
|
||||
|
||||
if(updatedObject?.answers?.length > 0){
|
||||
|
||||
const isValidAnswers = updatedObject?.answers?.some((answer:any) => answer?.isCorrect === 1)
|
||||
|
||||
if(!isValidAnswers){
|
||||
toast.error(t("validation.at_least_one_answer_should_be_correct"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (updatedObject?.answers?.length > 0) {
|
||||
const isValidAnswers = updatedObject?.answers?.some(
|
||||
(answer: any) => answer?.isCorrect === 1,
|
||||
);
|
||||
|
||||
// if(!isValidAnswers){
|
||||
// toast.error(t("validation.at_least_one_answer_should_be_correct"));
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
updatedObject?.answers?.forEach((item: any) => {
|
||||
if (item?.id) {
|
||||
oldAnswers.push({...item,isCorrect:item?.isCorrect ? 1 : 0});
|
||||
oldAnswers.push({ ...item, isCorrect: item?.isCorrect ? 1 : 0 });
|
||||
} else {
|
||||
newAnswers.push({...item,isCorrect:item?.isCorrect ? 1 : 0});
|
||||
newAnswers.push({ ...item, isCorrect: item?.isCorrect ? 1 : 0 });
|
||||
}
|
||||
});
|
||||
const answers = {
|
||||
|
|
@ -142,7 +137,6 @@ const EditPage: React.FC = () => {
|
|||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
const keysToRemove = ["content_image"];
|
||||
console.log(DataToSend);
|
||||
const updatedObject = removeStringKeys(DataToSend, keysToRemove);
|
||||
|
|
@ -154,22 +148,21 @@ const EditPage: React.FC = () => {
|
|||
|
||||
const oldAnswers = [] as any;
|
||||
const newAnswers = [] as any;
|
||||
if(updatedObject?.answers?.length > 0){
|
||||
|
||||
const isValidAnswers = updatedObject?.answers?.some((answer:any) => answer?.isCorrect === 1 || answer?.isCorrect === true)
|
||||
const isValidAnswers2 = updatedObject?.answers?.filter((answer: any) => answer?.isCorrect === 1 || answer?.isCorrect === true ).length > 1;
|
||||
console.log(isValidAnswers2);
|
||||
|
||||
if(!isValidAnswers || isValidAnswers2){
|
||||
toast.error(t("validation.at_least_one_answer_should_be_correct"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (updatedObject?.answers?.length > 0) {
|
||||
// const isValidAnswers = updatedObject?.answers?.some((answer:any) => answer?.isCorrect === 1 || answer?.isCorrect === true)
|
||||
// const isValidAnswers2 = updatedObject?.answers?.filter((answer: any) => answer?.isCorrect === 1 || answer?.isCorrect === true ).length > 1;
|
||||
// console.log(isValidAnswers2);
|
||||
// console.log(isValidAnswers,"isValidAnswers");
|
||||
// if(!isValidAnswers || isValidAnswers2){
|
||||
// toast.error(t("validation.at_least_one_answer_should_be_correct"));
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
updatedObject?.answers?.forEach((item: any) => {
|
||||
if (item?.id) {
|
||||
oldAnswers.push({...item,isCorrect:item?.isCorrect ? 1 : 0});
|
||||
oldAnswers.push({ ...item, isCorrect: item?.isCorrect ? 1 : 0 });
|
||||
} else {
|
||||
newAnswers.push({...item,isCorrect:item?.isCorrect ? 1 : 0});
|
||||
newAnswers.push({ ...item, isCorrect: item?.isCorrect ? 1 : 0 });
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -177,22 +170,31 @@ const EditPage: React.FC = () => {
|
|||
old: oldAnswers,
|
||||
new: newAnswers,
|
||||
};
|
||||
|
||||
mutate({ ...updatedObject, answers, tags });
|
||||
console.log(tags, "tags");
|
||||
if (tags?.new?.length < 1 && tags?.old?.length < 1) {
|
||||
mutate({ ...updatedObject, answers, tags: "" });
|
||||
} else {
|
||||
mutate({ ...updatedObject, answers, tags });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const location = useLocation();
|
||||
|
||||
const navigate = useNavigate();
|
||||
const handleCancel = () => {
|
||||
navigate(-1);
|
||||
};
|
||||
|
||||
// useEffect(() => {
|
||||
// if (isSuccess) {
|
||||
// toast.success(t("validation.the_possess_done_successful"));
|
||||
// navigate(-1);
|
||||
// }
|
||||
// }, [isSuccess]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
toast.success(t("validation.the_possess_done_successful"));
|
||||
navigate(deletePathSegments(location.pathname, 2));
|
||||
}
|
||||
}, [isSuccess]);
|
||||
|
||||
const Loading = LoadingAsync || isLoading
|
||||
|
||||
if (dataLoading || QuestionsDataLoading) {
|
||||
return <SpinContainer />;
|
||||
|
|
@ -216,10 +218,10 @@ const EditPage: React.FC = () => {
|
|||
<BaseForm />
|
||||
<div className="exercise_add_buttons">
|
||||
<div onClick={handleCancel}>{t("practical.back")}</div>
|
||||
<button disabled={isLoading} className="relative" type="submit">
|
||||
<button disabled={Loading} className="relative" type="submit">
|
||||
{t("practical.edit")}
|
||||
|
||||
{isLoading && (
|
||||
{Loading && (
|
||||
<span className="Spinier_Div">
|
||||
<Spin />
|
||||
</span>
|
||||
|
|
@ -250,10 +252,10 @@ const EditPage: React.FC = () => {
|
|||
<ModelForm />
|
||||
<div className="exercise_add_buttons">
|
||||
<div onClick={handleCancel}>{t("practical.back")}</div>
|
||||
<button disabled={isLoading} className="relative" type="submit">
|
||||
<button disabled={Loading} className="relative" type="submit">
|
||||
{t("practical.edit")}
|
||||
|
||||
{isLoading && (
|
||||
{Loading && (
|
||||
<span className="Spinier_Div">
|
||||
<Spin />
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -4,15 +4,19 @@ import { Col, Row } from "reactstrap";
|
|||
import useFormatDataToSelect from "../../../utils/useFormatDataToSelect";
|
||||
|
||||
const FilterForm = () => {
|
||||
const yesNoArray = [
|
||||
{id: "لا", name:"لا"},
|
||||
{id: "نعم", name:"نعم"},
|
||||
]
|
||||
const yesNoArray = [
|
||||
{ id: "لا", name: "لا" },
|
||||
{ id: "نعم", name: "نعم" },
|
||||
];
|
||||
return (
|
||||
<div>
|
||||
<Row>
|
||||
<Col>
|
||||
<ValidationField placeholder="content" label="content" name="content" />
|
||||
<ValidationField
|
||||
placeholder="content"
|
||||
label="content"
|
||||
name="content"
|
||||
/>
|
||||
{/* <ValidationField type="Select" option={yesNoArray} placeholder="isBase" label="isBase" name="isBase" /> */}
|
||||
</Col>
|
||||
{/* <Col>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React from "react";
|
||||
import { Modal } from "antd";
|
||||
import { Modal } from "antd";
|
||||
import { useModalState } from "../../../../zustand/Modal";
|
||||
import { ModalEnum } from "../../../../enums/Model";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
|
|
|||
|
|
@ -35,7 +35,10 @@ const CheckboxField = ({
|
|||
<Checkbox
|
||||
onChange={onChange || CheckboxhandleChange}
|
||||
disabled={isDisabled}
|
||||
checked={formik.values?.answers?.[name]?.isCorrect === 1 || formik.values?.answers?.[name]?.isCorrect === true}
|
||||
checked={
|
||||
formik.values?.answers?.[name]?.isCorrect === 1 ||
|
||||
formik.values?.answers?.[name]?.isCorrect === true
|
||||
}
|
||||
className={className}
|
||||
>
|
||||
{t(`input.${label ? label : name}`)}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ const ChoiceFields = ({ index, data }: { index: number; data: Choice }) => {
|
|||
return (
|
||||
<>
|
||||
<div className="ChoiceFields">
|
||||
|
||||
<TextField
|
||||
className="textarea_exercise"
|
||||
placeholder={"choice"}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ const Choices = () => {
|
|||
{...provided.dragHandleProps}
|
||||
>
|
||||
<div className="HolderQuestion">
|
||||
<HolderOutlined/>
|
||||
<HolderOutlined />
|
||||
</div>
|
||||
<ChoiceFields index={index} data={item} />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,9 @@ const CheckboxField = ({
|
|||
disabled={isDisabled}
|
||||
checked={
|
||||
formik.values?.Questions?.[parent_index]?.answers?.[name]
|
||||
?.isCorrect === 1
|
||||
?.isCorrect === 1 ||
|
||||
formik.values?.Questions?.[parent_index]?.answers?.[name]
|
||||
?.isCorrect === true
|
||||
}
|
||||
className={className}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ const ChoiceFields = ({
|
|||
formik.setFieldValue(`Questions[${parent_index}].answers`, updatedAnswers);
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="ChoiceFields">
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ const Choices = ({ parent_index }: { parent_index: number }) => {
|
|||
{...provided.draggableProps}
|
||||
{...provided.dragHandleProps}
|
||||
>
|
||||
<div className="HolderQuestion">
|
||||
<HolderOutlined/>
|
||||
</div>
|
||||
<div className="HolderQuestion">
|
||||
<HolderOutlined />
|
||||
</div>
|
||||
<ChoiceFields
|
||||
key={index}
|
||||
parent_index={parent_index}
|
||||
|
|
|
|||
|
|
@ -18,18 +18,21 @@ const Form = () => {
|
|||
const formik = useFormikContext<any>();
|
||||
const { setSuccess, Success, setSavedQuestionData } = useObjectToEdit();
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setSavedQuestionData(formik.values);
|
||||
}, [formik?.values]);
|
||||
|
||||
// console.log(formik?.errors);
|
||||
|
||||
const handleAddChoice = (parent_index: number,fromKeyCombination:boolean = false) => {
|
||||
const handleAddChoice = (
|
||||
parent_index: number,
|
||||
fromKeyCombination: boolean = false,
|
||||
) => {
|
||||
console.log(parent_index);
|
||||
|
||||
formik.setFieldValue(`Questions.[${parent_index}].answers`, [
|
||||
...((formik?.values as any)?.Questions?.[parent_index]?.answers as Choice[]),
|
||||
...((formik?.values as any)?.Questions?.[parent_index]
|
||||
?.answers as Choice[]),
|
||||
|
||||
{
|
||||
answer: null,
|
||||
|
|
@ -38,12 +41,12 @@ const Form = () => {
|
|||
},
|
||||
]);
|
||||
|
||||
if(fromKeyCombination){
|
||||
toast.success(t("header.new_choice_have_been_added"))
|
||||
if (fromKeyCombination) {
|
||||
toast.success(t("header.new_choice_have_been_added"));
|
||||
}
|
||||
};
|
||||
|
||||
const handleAddQuestion = (fromKeyCombination:boolean = false) => {
|
||||
const handleAddQuestion = (fromKeyCombination: boolean = false) => {
|
||||
formik.setFieldValue("Questions", [
|
||||
...((formik?.values as any)?.Questions as Choice[]),
|
||||
|
||||
|
|
@ -62,27 +65,28 @@ const Form = () => {
|
|||
const max_mark = formik?.values?.max_mark + 1;
|
||||
|
||||
formik.setFieldValue("max_mark", max_mark);
|
||||
if(fromKeyCombination){
|
||||
toast.success(t("header.new_question_have_been_added"))
|
||||
if (fromKeyCombination) {
|
||||
toast.success(t("header.new_question_have_been_added"));
|
||||
}
|
||||
};
|
||||
const [t] = useTranslation();
|
||||
|
||||
const lastQuestions = formik?.values?.Questions?.length - 1;
|
||||
useKeyCombination(
|
||||
{ ctrlKey: true, shiftKey: true, code: CombinationKeyEnum.CHOICE },
|
||||
() => {
|
||||
handleAddChoice(lastQuestions, true);
|
||||
},
|
||||
);
|
||||
|
||||
const lastQuestions = formik?.values?.Questions?.length -1 ;
|
||||
useKeyCombination({ ctrlKey: true, shiftKey: true, code: CombinationKeyEnum.CHOICE }, () => {
|
||||
handleAddChoice(lastQuestions,true)
|
||||
});
|
||||
|
||||
useKeyCombination({ ctrlKey: true, shiftKey: true, code: CombinationKeyEnum.QUESTION }, () => {
|
||||
|
||||
handleAddQuestion(true)
|
||||
});
|
||||
|
||||
|
||||
useKeyCombination(
|
||||
{ ctrlKey: true, shiftKey: true, code: CombinationKeyEnum.QUESTION },
|
||||
() => {
|
||||
handleAddQuestion(true);
|
||||
},
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
<Row className="w-100 exercise_form_container">
|
||||
<div className="exercise_form">
|
||||
<ValidationField
|
||||
|
|
@ -139,7 +143,7 @@ const Form = () => {
|
|||
)}
|
||||
|
||||
<p className="add_new_button">
|
||||
<FaCirclePlus onClick={()=>handleAddQuestion()} size={23} />{" "}
|
||||
<FaCirclePlus onClick={() => handleAddQuestion()} size={23} />{" "}
|
||||
{t("header.add_new_question")}
|
||||
</p>
|
||||
</Row>
|
||||
|
|
|
|||
|
|
@ -36,20 +36,22 @@ const MaltySelectTag = ({ parent_index }: { parent_index: number }) => {
|
|||
const [t] = useTranslation();
|
||||
|
||||
const options = data?.data ?? [];
|
||||
const additionalData =
|
||||
options.length < 1 && searchValue.length > 1 && !isLoading
|
||||
? [{ id: searchValue, name: searchValue }]
|
||||
: [];
|
||||
const additionalData =
|
||||
options.length < 1 && searchValue.length > 1 && !isLoading
|
||||
? [{ id: searchValue, name: searchValue }]
|
||||
: [];
|
||||
|
||||
|
||||
console.log(options);
|
||||
const value = formik?.values?.Questions[parent_index]?.tags?.map((item: any) => item?.id ?? item) ?? [];
|
||||
console.log(options);
|
||||
const value =
|
||||
formik?.values?.Questions[parent_index]?.tags?.map(
|
||||
(item: any) => item?.id ?? item,
|
||||
) ?? [];
|
||||
console.log(formik?.values?.Questions[parent_index]);
|
||||
|
||||
console.log(value);
|
||||
|
||||
const AllOptions = [...options, ...additionalData]
|
||||
|
||||
|
||||
console.log(value);
|
||||
|
||||
const AllOptions = [...options, ...additionalData];
|
||||
|
||||
return (
|
||||
<div className="SelectTag">
|
||||
<label htmlFor="">{t("models.tag")}</label>
|
||||
|
|
@ -59,7 +61,6 @@ const value = formik?.values?.Questions[parent_index]?.tags?.map((item: any) =>
|
|||
style={{ width: "100%", height: "40px" }}
|
||||
placeholder=""
|
||||
fieldNames={{ label: "name", value: "id" }}
|
||||
|
||||
onChange={handleChange}
|
||||
options={AllOptions}
|
||||
filterOption={false}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,7 @@ const Form = () => {
|
|||
const formik = useFormikContext<any>();
|
||||
const { setSuccess, Success } = useObjectToEdit();
|
||||
|
||||
|
||||
|
||||
|
||||
const handleAddChoice = (fromKeyCombination:boolean = false ) => {
|
||||
|
||||
const handleAddChoice = (fromKeyCombination: boolean = false) => {
|
||||
formik.setFieldValue("answers", [
|
||||
...((formik?.values as any)?.answers as Choice[]),
|
||||
{
|
||||
|
|
@ -32,31 +28,26 @@ const Form = () => {
|
|||
},
|
||||
]);
|
||||
|
||||
if(fromKeyCombination){
|
||||
toast.success(t("header.new_choice_have_been_added"))
|
||||
if (fromKeyCombination) {
|
||||
toast.success(t("header.new_choice_have_been_added"));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
useKeyCombination({ ctrlKey: true, shiftKey: true, code: CombinationKeyEnum.CHOICE }, () => {
|
||||
|
||||
handleAddChoice(true)
|
||||
|
||||
});
|
||||
console.log(Success);
|
||||
|
||||
useKeyCombination(
|
||||
{ ctrlKey: true, shiftKey: true, code: CombinationKeyEnum.CHOICE },
|
||||
() => {
|
||||
handleAddChoice(true);
|
||||
},
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
console.log(Success);
|
||||
|
||||
if(Success){
|
||||
formik?.setValues({})
|
||||
formik.setErrors({})
|
||||
setSuccess(false)
|
||||
console.log(formik.errors);
|
||||
|
||||
if (Success) {
|
||||
formik?.setValues({});
|
||||
formik.setErrors({});
|
||||
setSuccess(false);
|
||||
console.log(formik.errors);
|
||||
}
|
||||
}, [Success])
|
||||
}, [Success]);
|
||||
|
||||
return (
|
||||
<Row className="w-100 exercise_form_container">
|
||||
|
|
@ -73,7 +64,7 @@ console.log(Success);
|
|||
<Choices />
|
||||
{formik?.values?.answers?.length < 5 && (
|
||||
<p className="add_new_button">
|
||||
<FaCirclePlus onClick={()=>handleAddChoice()} size={23} />{" "}
|
||||
<FaCirclePlus onClick={() => handleAddChoice()} size={23} />{" "}
|
||||
{t("header.add_new_choice")}
|
||||
</p>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,11 @@ import * as Yup from "yup";
|
|||
import { Question } from "../../../../types/Item";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
|
||||
export const getInitialValues = (objectToEdit: Question): any => {
|
||||
const tags = objectToEdit?.tags?.map((item: any, index: number) => {
|
||||
return { ...item };
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
id: objectToEdit?.id ?? null,
|
||||
content: objectToEdit?.content ?? "",
|
||||
|
|
@ -27,21 +26,13 @@ export const getValidationSchema = () => {
|
|||
return Yup.object().shape({
|
||||
content_image: Yup.string().nullable(),
|
||||
content: Yup.string().required("validation.required"),
|
||||
answers: Yup.array()
|
||||
.of(
|
||||
Yup.object().shape({
|
||||
content: Yup.string().required("validation.required"),
|
||||
content_image: Yup.string().nullable(),
|
||||
isCorrect: Yup.boolean(),
|
||||
}),
|
||||
).test(
|
||||
'at-least-one-correct',
|
||||
'At least one answer must be correct',
|
||||
(answers:any) => {
|
||||
return answers.some((answer:any) => answer.isCorrect === true);
|
||||
}
|
||||
),
|
||||
|
||||
answers: Yup.array().of(
|
||||
Yup.object().shape({
|
||||
content: Yup.string().required("validation.required"),
|
||||
content_image: Yup.string().nullable(),
|
||||
isCorrect: Yup.boolean(),
|
||||
}),
|
||||
),
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -51,13 +42,13 @@ export const getInitialValuesBase = (objectToEdit: Question): any => {
|
|||
id: tag?.id,
|
||||
name: tag?.name,
|
||||
}));
|
||||
console.log(item,"item");
|
||||
|
||||
console.log(item, "item");
|
||||
|
||||
return {
|
||||
...item,
|
||||
canAnswersBeShuffled: objectToEdit?.canAnswersBeShuffled ? 1 : 0,
|
||||
hint: objectToEdit?.hint ?? "",
|
||||
isBase:0,
|
||||
isBase: 0,
|
||||
tags,
|
||||
};
|
||||
});
|
||||
|
|
@ -95,13 +86,16 @@ export const getValidationSchemaBase = () => {
|
|||
}),
|
||||
)
|
||||
.test(
|
||||
'at-least-one-correct',
|
||||
'At least one answer must be correct',
|
||||
(answers:any) => {
|
||||
console.log(answers,"answers");
|
||||
|
||||
return answers.some((answer:any) => answer.isCorrect === true);
|
||||
}
|
||||
"at-least-one-correct",
|
||||
"At least one answer must be correct",
|
||||
(answers: any) => {
|
||||
console.log(answers, "answers");
|
||||
|
||||
return answers.some(
|
||||
(answer: any) =>
|
||||
answer.isCorrect === true || answer.isCorrect === 1,
|
||||
);
|
||||
},
|
||||
),
|
||||
}),
|
||||
),
|
||||
|
|
@ -113,8 +107,8 @@ export function processTags(DataToSend: any) {
|
|||
|
||||
const oldTags = DataToSend?.tags
|
||||
?.map((item: any, index: number) => {
|
||||
if (typeof item === "number") {
|
||||
return item;
|
||||
if (typeof item === "number" || typeof item?.id === "number") {
|
||||
return item?.id ?? item;
|
||||
}
|
||||
})
|
||||
.filter((item: any) => item !== undefined);
|
||||
|
|
@ -123,10 +117,13 @@ export function processTags(DataToSend: any) {
|
|||
?.map((item: any, index: number) => {
|
||||
console.log(item);
|
||||
|
||||
if (typeof item === "string" && item !== "") {
|
||||
if (
|
||||
(typeof item === "string" && item !== "") ||
|
||||
(typeof item?.id === "string" && item?.id !== "")
|
||||
) {
|
||||
console.log(item);
|
||||
|
||||
return { name: item };
|
||||
return { name: item?.id ?? item };
|
||||
}
|
||||
})
|
||||
.filter((item: any) => item !== undefined);
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@ const TableHeader = () => {
|
|||
|
||||
const deleteMutation = useDeleteQuestion();
|
||||
|
||||
const { unit_id, grade_id, subject_id, lesson_id } =
|
||||
useParams<ParamsEnum>();
|
||||
const { unit_id, grade_id, subject_id, lesson_id } = useParams<ParamsEnum>();
|
||||
const { data: unit } = useGetAllUnit({ show: unit_id });
|
||||
|
||||
const { data: Subject } = useGetAllSubject({
|
||||
|
|
@ -46,14 +45,14 @@ const TableHeader = () => {
|
|||
|
||||
useSetPageTitle(
|
||||
t(`page_header.grade`) +
|
||||
" / " +
|
||||
` ${t("header.subject_of_class")} (${gradeName})` +
|
||||
" / " +
|
||||
` ${t("header.subject_of_class")} (${gradeName})` +
|
||||
" / " +
|
||||
SubjectName +
|
||||
" / " +
|
||||
unitName +
|
||||
" / " +
|
||||
LessonName
|
||||
unitName +
|
||||
" / " +
|
||||
LessonName,
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
@ -68,7 +67,8 @@ const TableHeader = () => {
|
|||
/>
|
||||
<FilterLayout
|
||||
sub_children={<FilterForm />}
|
||||
filterTitle={` ${unitName} (${LessonName}) `} />
|
||||
filterTitle={` ${unitName} (${LessonName}) `}
|
||||
/>
|
||||
<Table />
|
||||
</Suspense>
|
||||
<DeleteModels
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ const TableWithHeader = () => {
|
|||
useSetPageTitle(
|
||||
t(`page_header.grade`) +
|
||||
" / " +
|
||||
` ${t("header.subject_of_class")} (${gradeName})`
|
||||
` ${t("header.subject_of_class")} (${gradeName})`,
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ const TablePage: React.FC = () => {
|
|||
const { grade_id } = useParams<ParamsEnum>();
|
||||
const { filterState } = useFilterState();
|
||||
|
||||
const response = useGetAllSubject({
|
||||
grade_id: grade_id,
|
||||
const response = useGetAllSubject({
|
||||
grade_id: grade_id,
|
||||
pagination: true,
|
||||
...filterState,
|
||||
});
|
||||
});
|
||||
|
||||
return <DataTable response={response} useColumns={useColumns} />;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,14 +7,11 @@ import useFilter from "../../Components/FilterField/components/useFilter";
|
|||
const Dummy = () => {
|
||||
const [t] = useTranslation();
|
||||
useSetPageTitle(`${t(ABILITIES_ENUM?.MAIN_PAGE)} / ${t("dashboard")}`);
|
||||
const {FilterButton,FilterBody} = useFilter()
|
||||
return(
|
||||
<div className="DummyHomePage">
|
||||
<FilterButton/>
|
||||
<FilterBody>
|
||||
karim
|
||||
</FilterBody>
|
||||
|
||||
const { FilterButton, FilterBody } = useFilter();
|
||||
return (
|
||||
<div className="DummyHomePage">
|
||||
{/* <FilterButton />
|
||||
<FilterBody>karim</FilterBody> */}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,7 +7,11 @@ const FilterForm = () => {
|
|||
<div>
|
||||
<Row>
|
||||
<Col>
|
||||
<ValidationField placeholder="activation_date" label="activation_date" name="activation_date" />
|
||||
<ValidationField
|
||||
placeholder="activation_date"
|
||||
label="activation_date"
|
||||
name="activation_date"
|
||||
/>
|
||||
{/* <ValidationField placeholder="name" label="name" name="name" /> */}
|
||||
</Col>
|
||||
</Row>
|
||||
|
|
|
|||
|
|
@ -2,24 +2,41 @@ import { Col, Row } from "reactstrap";
|
|||
import ValidationField from "../../../../Components/ValidationField/ValidationField";
|
||||
import useFormatDataToSelect from "../../../../utils/useFormatDataToSelect";
|
||||
|
||||
const Form = ({isEdit}:{isEdit?:boolean}) => {
|
||||
|
||||
const Form = ({ isEdit }: { isEdit?: boolean }) => {
|
||||
const typeOptions = [
|
||||
{ id: "student", name: "student" },
|
||||
{ id: "reseller", name: "reseller" },
|
||||
{ id: "admin", name: "admin" },
|
||||
]
|
||||
const typeArray = useFormatDataToSelect(typeOptions)
|
||||
|
||||
];
|
||||
const typeArray = useFormatDataToSelect(typeOptions);
|
||||
|
||||
return (
|
||||
<Row className="w-100">
|
||||
<Col>
|
||||
<ValidationField type="Date" placeholder="activation_date" label="activation_date" name="activation_date" />
|
||||
<ValidationField type="Date" placeholder="expiration_date" label="expiration_date" name="expiration_date" />
|
||||
<ValidationField placeholder="student_id" label="student_id" name="student_id" />
|
||||
<ValidationField
|
||||
type="Date"
|
||||
placeholder="activation_date"
|
||||
label="activation_date"
|
||||
name="activation_date"
|
||||
/>
|
||||
<ValidationField
|
||||
type="Date"
|
||||
placeholder="expiration_date"
|
||||
label="expiration_date"
|
||||
name="expiration_date"
|
||||
/>
|
||||
<ValidationField
|
||||
placeholder="student_id"
|
||||
label="student_id"
|
||||
name="student_id"
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
<ValidationField placeholder="package_id" label="package_id" name="package_id" />
|
||||
<ValidationField
|
||||
placeholder="package_id"
|
||||
label="package_id"
|
||||
name="package_id"
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ export const getInitialValues = (objectToEdit: any): any => {
|
|||
: null,
|
||||
student_id: objectToEdit?.student_id ?? null,
|
||||
package_id: objectToEdit?.package_id ?? null,
|
||||
|
||||
};
|
||||
};
|
||||
export const getValidationSchema = () => {
|
||||
|
|
@ -22,4 +21,4 @@ export const getValidationSchema = () => {
|
|||
student_id: Yup.number().required("validation.required"),
|
||||
package_id: Yup.number().required("validation.required"),
|
||||
});
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ const DeleteModalForm = lazy(
|
|||
|
||||
const TableHeader = () => {
|
||||
const [t] = useTranslation();
|
||||
useSetPageTitle(
|
||||
t(`page_header.student_package`),
|
||||
);
|
||||
useSetPageTitle(t(`page_header.student_package`));
|
||||
// const deleteMutation = useDeleteUser();
|
||||
return (
|
||||
<div className="TableWithHeader">
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ const App: React.FC = () => {
|
|||
pagination: true,
|
||||
...filterState,
|
||||
});
|
||||
|
||||
|
||||
return <DataTable response={response} useColumns={useColumns} />;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -46,24 +46,24 @@ export const useColumns = () => {
|
|||
key: "first_name",
|
||||
align: "center",
|
||||
render: (row) => {
|
||||
return(row?.student?.first_name)
|
||||
}
|
||||
return row?.student?.first_name;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t("columns.last_name"),
|
||||
key: "last_name",
|
||||
align: "center",
|
||||
render: (row) => {
|
||||
return(row?.student?.last_name)
|
||||
}
|
||||
return row?.student?.last_name;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t("columns.sex"),
|
||||
key: "sex",
|
||||
align: "center",
|
||||
render: (row) => {
|
||||
return(row?.student?.sex)
|
||||
}
|
||||
return row?.student?.sex;
|
||||
},
|
||||
},
|
||||
// {
|
||||
// title: t("columns.procedure"),
|
||||
|
|
@ -78,7 +78,7 @@ export const useColumns = () => {
|
|||
// index={index}
|
||||
// onDelete={() => handelDelete(record)}
|
||||
// onEdit={() => handleEdit(record)}
|
||||
|
||||
|
||||
// />
|
||||
// );
|
||||
// },
|
||||
|
|
|
|||
|
|
@ -25,15 +25,18 @@ const ShowStudent = React.lazy(() => import("./Pages/Admin/Student/show/Page"));
|
|||
|
||||
const ReSeller = React.lazy(() => import("./Pages/Admin/Reseller/Page"));
|
||||
const AddReSeller = React.lazy(() => import("./Pages/Admin/Reseller/Add/Page"));
|
||||
const EditReSeller = React.lazy(() => import("./Pages/Admin/Reseller/Edit/Page"));
|
||||
const EditReSeller = React.lazy(
|
||||
() => import("./Pages/Admin/Reseller/Edit/Page"),
|
||||
);
|
||||
|
||||
const User = React.lazy(() => import("./Pages/Admin/User/Page"));
|
||||
|
||||
const Param = React.lazy(() => import("./Pages/Admin/Param/Page"));
|
||||
|
||||
/// RESELLER ///
|
||||
const Student_Package = React.lazy(() => import("./Pages/ReSeller/StudentPackage/Page"));
|
||||
|
||||
const Student_Package = React.lazy(
|
||||
() => import("./Pages/ReSeller/StudentPackage/Page"),
|
||||
);
|
||||
|
||||
import { hasAbility } from "./utils/hasAbility";
|
||||
import { ABILITIES_ENUM, ABILITIES_VALUES_ENUM } from "./enums/abilities";
|
||||
|
|
@ -51,7 +54,7 @@ export const menuItems: TMenuItem[] = [
|
|||
abilities: ABILITIES_ENUM?.PASS,
|
||||
abilities_value: ABILITIES_VALUES_ENUM.INDEX,
|
||||
prevPath: 0,
|
||||
type:UserTypeEnum?.PASS
|
||||
type: UserTypeEnum?.PASS,
|
||||
},
|
||||
{
|
||||
header: "page_header.grade",
|
||||
|
|
@ -92,7 +95,6 @@ export const menuItems: TMenuItem[] = [
|
|||
abilities: ABILITIES_ENUM?.STUDENT,
|
||||
abilities_value: ABILITIES_VALUES_ENUM.INDEX,
|
||||
prevPath: 0,
|
||||
|
||||
},
|
||||
{
|
||||
header: "page_header.reSeller",
|
||||
|
|
@ -125,7 +127,6 @@ export const menuItems: TMenuItem[] = [
|
|||
prevPath: 0,
|
||||
},
|
||||
|
||||
|
||||
/// RESELLER /////
|
||||
|
||||
{
|
||||
|
|
@ -137,7 +138,7 @@ export const menuItems: TMenuItem[] = [
|
|||
abilities: ABILITIES_ENUM?.Student_Package,
|
||||
abilities_value: ABILITIES_VALUES_ENUM.INDEX,
|
||||
prevPath: 0,
|
||||
type:UserTypeEnum.RE_SELLER
|
||||
type: UserTypeEnum.RE_SELLER,
|
||||
},
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -298,25 +298,21 @@ button:disabled {
|
|||
visibility: hidden;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.bg2{
|
||||
.bg2 {
|
||||
background: var(--bg2);
|
||||
}
|
||||
.header_form{
|
||||
.header_form {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
padding: 20px;
|
||||
h4{
|
||||
h4 {
|
||||
font-size: 20px;
|
||||
|
||||
}
|
||||
svg{
|
||||
background: var(--bg);
|
||||
padding: 10px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
svg {
|
||||
background: var(--bg);
|
||||
padding: 10px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,12 +18,10 @@
|
|||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--white);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.AuthForm {
|
||||
|
||||
height: 440px;
|
||||
width: 600px;
|
||||
min-width: 300px;
|
||||
|
|
|
|||
|
|
@ -61,5 +61,3 @@
|
|||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -74,13 +74,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
.filter_modal_add_button, .filter_modal_cancel_button{
|
||||
.filter_modal_add_button,
|
||||
.filter_modal_cancel_button {
|
||||
padding: 20px 10px !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width:800px) {
|
||||
.filter_modal_add_button, .filter_modal_cancel_button{
|
||||
@media screen and (max-width: 800px) {
|
||||
.filter_modal_add_button,
|
||||
.filter_modal_cancel_button {
|
||||
font-size: 8px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@
|
|||
border: none;
|
||||
color: var(--borderColor);
|
||||
font-size: 16px;
|
||||
|
||||
|
||||
span {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@
|
|||
margin: 0 !important;
|
||||
box-shadow: 0px 0px 4px 2px rgba(0, 0, 0, 0.1);
|
||||
|
||||
img{
|
||||
img {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
|
@ -197,21 +197,17 @@
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.SelectTag {
|
||||
padding-inline: 20px;
|
||||
}
|
||||
|
||||
.exercise_add{
|
||||
|
||||
.add_new_button{
|
||||
.exercise_add {
|
||||
.add_new_button {
|
||||
padding-inline: 20px !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.HolderQuestion{
|
||||
.HolderQuestion {
|
||||
transform: translateY(55px);
|
||||
z-index: -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@
|
|||
@import "./Marks.scss";
|
||||
@import "./exercise.scss";
|
||||
@import './reSeller.scss';
|
||||
@import './StudentInfoCard.scss';
|
||||
@import './StudentInfoCard.scss';
|
||||
|
|
|
|||
|
|
@ -1,50 +1,43 @@
|
|||
.main_form_body{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
background: var(--bg);
|
||||
padding: 40px 10px;
|
||||
>*{
|
||||
// max-width: 30%;
|
||||
flex-basis: 33%;
|
||||
|
||||
|
||||
}
|
||||
.main_form_body {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
background: var(--bg);
|
||||
padding: 40px 10px;
|
||||
> * {
|
||||
// max-width: 30%;
|
||||
flex-basis: 33%;
|
||||
}
|
||||
}
|
||||
|
||||
.AttachmentForm {
|
||||
.main_form_body {
|
||||
padding: 30px 50px;
|
||||
gap: 40px;
|
||||
> * {
|
||||
// max-width: 30%;
|
||||
flex-basis: 10%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.AttachmentForm{
|
||||
.main_form_body{
|
||||
padding: 30px 50px;
|
||||
gap: 40px;
|
||||
>*{
|
||||
// max-width: 30%;
|
||||
flex-basis: 10%;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
.resellerButton {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 20px;
|
||||
padding: 20px;
|
||||
button {
|
||||
all: unset;
|
||||
cursor: pointer;
|
||||
padding: 8px 26px;
|
||||
font-size: 15px;
|
||||
border-radius: 5px;
|
||||
background: var(--primary);
|
||||
color: var(--white);
|
||||
&:first-child {
|
||||
background: #f2f4f8;
|
||||
color: #515b73;
|
||||
box-shadow: 0px 0px 4px rgb(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.resellerButton{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 20px;
|
||||
padding: 20px;
|
||||
button{
|
||||
all: unset;
|
||||
cursor: pointer;
|
||||
padding: 8px 26px;
|
||||
font-size: 15px;
|
||||
border-radius: 5px;
|
||||
background: var(--primary);
|
||||
color: var(--white);
|
||||
&:first-child{
|
||||
background: #F2F4F8;
|
||||
color: #515B73;
|
||||
box-shadow: 0px 0px 4px rgb(0, 0, 0,.08);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export const BaseURL = "https://nerd-back.point-dev.net/api/";
|
||||
// export const BaseURL = "http://192.168.1.109:8000/api/";
|
||||
|
||||
export const HEADER_KEY = "X-Custom-Query-Key";
|
||||
export const HEADER_KEY = "X-Custom-Query-Key";
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { AxiosResponse } from "../../types/Axios";
|
|||
|
||||
type DataToSend = {
|
||||
id?: number | string | any;
|
||||
key?: string | any
|
||||
key?: string | any;
|
||||
};
|
||||
|
||||
function useDeleteMutation(
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ function useGetQuery(
|
|||
options: any = {},
|
||||
) {
|
||||
const axios = useAxios();
|
||||
const {Filter} = useFilterStateState()
|
||||
const { Filter } = useFilterStateState();
|
||||
const sort_by = Filter?.sort_by ?? null;
|
||||
const name = Filter?.name ?? null;
|
||||
const { show, pagination, ...remainingParams } = params;
|
||||
|
|
@ -23,8 +23,8 @@ function useGetQuery(
|
|||
const { page, per_page } = PaginationParams(location);
|
||||
|
||||
const paramToSend = pagination
|
||||
? { page: page, per_page: per_page, name,...remainingParams , sort_by }
|
||||
: { name,...remainingParams ,sort_by};
|
||||
? { page: page, per_page: per_page, name, ...remainingParams, sort_by }
|
||||
: { name, ...remainingParams, sort_by };
|
||||
|
||||
const filteredParams = filterParams(paramToSend);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ const useUpdateMutation = (
|
|||
request = dataToSend;
|
||||
id = dataToSend.get("id");
|
||||
console.log(dataToSend);
|
||||
|
||||
} else {
|
||||
request = { ...dataToSend, _method: "PUT" };
|
||||
id = dataToSend?.id || dataToSend?.key;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export const statusType = [
|
||||
{ id: "upcoming", name: "select.upcoming" },
|
||||
{ id: "waiting", name: "select.waiting" },
|
||||
{ id: "done", name: "select.done" },
|
||||
]
|
||||
{ id: "upcoming", name: "select.upcoming" },
|
||||
{ id: "waiting", name: "select.waiting" },
|
||||
{ id: "done", name: "select.done" },
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export const userTypeOptions = [
|
||||
{ id: "student", name: "student" },
|
||||
{ id: "reseller", name: "reseller" },
|
||||
{ id: "admin", name: "admin" },
|
||||
]
|
||||
{ id: "student", name: "student" },
|
||||
{ id: "reseller", name: "reseller" },
|
||||
{ id: "admin", name: "admin" },
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
export enum CombinationKeyEnum {
|
||||
|
||||
QUESTION = "KeyK",
|
||||
CHOICE = "KeyJ"
|
||||
|
||||
}
|
||||
export enum CombinationKeyEnum {
|
||||
QUESTION = "KeyK",
|
||||
CHOICE = "KeyJ",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,6 +186,4 @@ export enum ModalEnum {
|
|||
Student_Package_EDIT = "Student_Package.edit",
|
||||
Student_Package_ADD = "Student_Package.add",
|
||||
Student_Package_DELETE = "Student_Package.delete",
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
export enum UserTypeEnum {
|
||||
ADMIN = "admin",
|
||||
RE_SELLER = "reseller",
|
||||
PASS="pass"
|
||||
}
|
||||
|
||||
ADMIN = "admin",
|
||||
RE_SELLER = "reseller",
|
||||
PASS = "pass",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export enum ABILITIES_ENUM {
|
|||
Report = "report",
|
||||
User = "user",
|
||||
RE_SELLER = "reseller",
|
||||
Student_Package = "student_package"
|
||||
Student_Package = "student_package",
|
||||
|
||||
////
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user