+
@@ -36,28 +55,24 @@ const File = ({ name, label, onChange, isDisabled,placholder,className,acceptedF
- }>
- {placholder ?? t("upload_image") }
-
-
- {isError ? "required" : ""}
+ }
+ >
+ {placholder ?? t("Click_to_upload_the_image")}
+
+ {isError ? "required" : ""}
-
-
-
- )
-}
+ );
+};
-export default File
\ No newline at end of file
+export default File;
diff --git a/src/Components/ValidationField/View/LocalSearch.tsx b/src/Components/ValidationField/View/LocalSearch.tsx
new file mode 100644
index 0000000..382f570
--- /dev/null
+++ b/src/Components/ValidationField/View/LocalSearch.tsx
@@ -0,0 +1,93 @@
+import { Form, Select } from "antd";
+import React, { useState } from "react";
+import useFormField from "../../../Hooks/useFormField";
+import { MdOutlineEdit } from "react-icons/md";
+import { translateOptions } from "../utils/translatedOptions";
+
+const LocalSelectField = ({
+ name,
+ label,
+ placeholder,
+ isDisabled,
+ option,
+ isMulti,
+ onChange,
+ className,
+ props,
+ no_label,
+ label_icon,
+}: any) => {
+ const { errorMsg, isError, t, formik } = useFormField(name, props);
+
+ // State to manage the search input value
+ const [searchValue, setSearchValue] = useState("");
+
+ const handleSearch = (
+ input: string,
+ option: { value: string; label: React.ReactNode | undefined },
+ ) =>
+ option?.label?.toString().toLowerCase().includes(toLowerCase()) ||
+ option?.value?.toString().toLowerCase().includes(toLowerCase());
+
+ const SelectableChange = (value: {
+ value: string;
+ label: React.ReactNode;
+ }) => {
+ formik.setFieldValue(name, value);
+ };
+
+ const handleSelectChange = (value: any) => {
+ formik.setFieldValue(name, value);
+ if (onChange) onChange(value);
+ };
+
+ const handleSearchChange = (input: string) => {
+ setSearchValue(input); // Update the search input value
+ };
+
+ return (
+
+ {no_label ? (
+
+ ) : label_icon ? (
+
+
+
+
+ ) : (
+
+ )}
+
+
+
+
+ );
+};
+
+export default React.memo(LocalSelectField);
diff --git a/src/Components/ValidationField/View/MaltyFile.tsx b/src/Components/ValidationField/View/MaltyFile.tsx
index c383aea..f18ad30 100644
--- a/src/Components/ValidationField/View/MaltyFile.tsx
+++ b/src/Components/ValidationField/View/MaltyFile.tsx
@@ -1,31 +1,61 @@
-import { Button, Upload } from 'antd';
-import { UploadOutlined } from '@ant-design/icons';
-import { ImageBaseURL } from '../../../api/config';
-import { useTranslation } from 'react-i18next';
-import useFormField from '../../../Hooks/useFormField';
+import { Button, Upload } from "antd";
+import { UploadOutlined } from "@ant-design/icons";
-const MaltyFile = ({ name, label, onChange, isDisabled, placholder, className, props }: any) => {
+import useFormField from "../../../Hooks/useFormField";
+
+const MaltyFile = ({
+ name,
+ label,
+ onChange,
+ isDisabled,
+ placeholder,
+ className,
+ props,
+}: any) => {
const { formik, t, isError } = useFormField(name, props);
- const imageUrl = formik?.values[name] ? ImageBaseURL + formik.values[name] : '';
- const fileList = formik?.values[name] ? formik?.values[name]?.map((file: any, index: number) => ({
- uid: index,
- name: file.name,
- status: 'done',
- url: file.url || '',
- thumbUrl: file.url || '',
- })) : [];
-
- const FilehandleChange = ({ file, fileList }: any) => {
- formik.setFieldValue(name, fileList.map((file: any) => file.originFileObj));
- };
+ let imageUrl = formik?.values?.[name] ?? null;
+ // Mapping formik values to fileList format
+ const fileList = imageUrl
+ ? imageUrl.map((file: any, index: number) => {
+ // console.log(file,"file");
+
+ return file instanceof File
+ ? {
+ uid: index,
+ name: file?.name,
+ status: "done",
+ originFileObj: file,
+ }
+ : {
+ uid: index,
+ id: file?.id,
+ name: file?.name,
+ status: "done",
+ url: file?.url || "",
+ thumbUrl: file?.url || "",
+ };
+ })
+ : [];
+
+ const FilehandleChange = ({ fileList }: any) => {
+ if (fileList.length === 0) {
+ formik.setFieldValue(name, null);
+ } else {
+ formik.setFieldValue(
+ name,
+ fileList.map((file: any) => file?.originFileObj ?? file),
+ );
+ }
+ };
+ // Custom request function
const customRequest = async ({ onSuccess }: any) => {
// Perform any necessary actions before onSuccess is called
onSuccess();
};
return (
-
+
@@ -33,17 +63,20 @@ const MaltyFile = ({ name, label, onChange, isDisabled, placholder, className, p
- }>
- {placholder ?? t("upload_image")}
+ }
+
+ >
+ {t(placeholder ?? t("upload_image") )}
- {isError ? "required" : ""}
+ {isError ? "required" : ""}
);
diff --git a/src/Components/ValidationField/View/NumberFormate.tsx b/src/Components/ValidationField/View/NumberFormate.tsx
new file mode 100644
index 0000000..ca50a4b
--- /dev/null
+++ b/src/Components/ValidationField/View/NumberFormate.tsx
@@ -0,0 +1,75 @@
+import { Form, Input, InputNumber } from "antd";
+import React from "react";
+import useFormField from "../../../Hooks/useFormField";
+import { MdOutlineEdit } from "react-icons/md";
+import { Field } from "formik";
+
+const NumberFormate = ({
+ name,
+ label,
+ placeholder,
+ isDisabled,
+ props,
+ type,
+ no_label,
+ label_icon,
+}: any) => {
+ const { errorMsg, isError, t, formik } = useFormField(name, props);
+ const SelectableChange = (value: {
+ value: string;
+ label: React.ReactNode;
+ }) => {
+ formik.setFieldValue(name, value);
+ };
+ return (
+
+ {no_label ? (
+
+ ) : label_icon ? (
+
+
+
+
+ ) : (
+
+ )}
+
+
+
+ `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
+ }
+ parser={(value: any) =>
+ value?.replace(/\$\s?|(,*)/g, "") as unknown as number
+ }
+ min="0"
+ type={type ?? "text"}
+ value={formik.values[name]}
+ onChange={SelectableChange}
+ placeholder={t(
+ `${placeholder ? placeholder : label ? label : name}`,
+ )}
+ name={name}
+ disabled={isDisabled}
+ size="large"
+
+
+ // onChange={onChange ? onChange : handleChange}
+ />
+
+
+ );
+};
+
+export default React.memo(NumberFormate);
diff --git a/src/Components/ValidationField/View/SearchField.tsx b/src/Components/ValidationField/View/SearchField.tsx
index 47f7271..ff35a45 100644
--- a/src/Components/ValidationField/View/SearchField.tsx
+++ b/src/Components/ValidationField/View/SearchField.tsx
@@ -1,65 +1,83 @@
-import { Form, Select } from 'antd';
-import React, { useEffect, useState } from 'react';
-import useFormField from '../../../Hooks/useFormField';
-import { useLocation, useNavigate } from 'react-router-dom';
+import { Form, Select } from "antd";
+import React, { useEffect, useState } from "react";
+import useFormField from "../../../Hooks/useFormField";
+import { useNavigate } from "react-router-dom";
+import { MdOutlineEdit } from "react-icons/md";
-const SearchField = ({ name, label, placeholder, isDisabled, searchBy, option, isMulti, onChange, className, loading,props }: any) => {
+const SearchField = ({
+ name,
+ label,
+ placeholder,
+ isDisabled,
+ searchBy,
+ option,
+ isMulti,
+ onChange,
+ className,
+ props,
+ no_label,
+ label_icon,
+}: any) => {
const { errorMsg, isError, t, formik } = useFormField(name, props);
- const [searchQuery, setSearchQuery] = useState
('');
- const location = useLocation()
-
- const navigate = useNavigate()
+ const [searchQuery, setSearchQuery] = useState("");
+ const navigate = useNavigate();
useEffect(() => {
- const searchParams = new URLSearchParams(location?.search);
- setSearchQuery(searchParams?.get('search') || '');
- console.log(searchParams);
-
- }, [location]);
+ const searchParams = new URLSearchParams(window?.location?.search);
+ setSearchQuery(searchParams?.get("search") || "");
+ }, []);
-
-
- const SelecthandleChange = (value: { value: string; label: React.ReactNode }) => {
+ const SelectableChange = (value: {
+ value: string;
+ label: React.ReactNode;
+ }) => {
formik?.setFieldValue(name, value);
-
- console.log(value);
};
- const SearchHandleChange = (value:any) => {
- if (value || value !== "") {
- navigate(`${window?.location?.pathname}?${searchBy}=${value}`);
- } else {
- const params = new URLSearchParams(location.search);
- params.delete(searchBy ?? "search");
- navigate(`${window?.location.pathname}?${params.toString()}`);
- }
-
+ const SearchHandleChange = (value: any) => {
+ navigate(`${window?.location?.pathname}?${searchBy}=${value}`, {
+ replace: true,
+ });
};
return (
-
-
+
+ {no_label ? (
+
+ ) : label_icon ? (
+
+
+
+
+ ) : (
+
+ )}
+
diff --git a/src/Components/ValidationField/View/SelectField.tsx b/src/Components/ValidationField/View/SelectField.tsx
index b923d8b..880a9ed 100644
--- a/src/Components/ValidationField/View/SelectField.tsx
+++ b/src/Components/ValidationField/View/SelectField.tsx
@@ -1,41 +1,72 @@
-import { Form, Select } from 'antd'
-import React from 'react'
-import useFormField from '../../../Hooks/useFormField';
-
-const SelectField = ({ name, label, placeholder, isDisabled,option,isMulti,onChange,className, props}: any) => {
-
- const { errorMsg, isError, t ,formik} = useFormField(name, props)
- const SelecthandleChange = (value: { value: string; label: React.ReactNode }) => {
- formik.setFieldValue(name, value)
+import { Form, Select } from "antd";
+import React from "react";
+import useFormField from "../../../Hooks/useFormField";
+import { MdOutlineEdit } from "react-icons/md";
+import { translateOptions } from "../utils/translatedOptions";
+const SelectField = ({
+ name,
+ label,
+ placeholder,
+ isDisabled,
+ option,
+ isMulti,
+ onChange,
+ className,
+ props,
+ no_label,
+ label_icon,
+}: any) => {
+ const { errorMsg, isError, t, formik } = useFormField(name, props);
+ const SelectableChange = (value: {
+ value: string;
+ label: React.ReactNode;
+ }) => {
+ formik.setFieldValue(name, value);
};
+ // console.log(name,"Select");
+
return (
-
+
+ {no_label ? (
-
-
+ ) : (
+
+ )}
-
-
- />
-
-
- )
-}
+
+
+
+
+ );
+};
export default React.memo(SelectField);
diff --git a/src/Components/ValidationField/View/TextArea.tsx b/src/Components/ValidationField/View/TextArea.tsx
deleted file mode 100644
index 62b9794..0000000
--- a/src/Components/ValidationField/View/TextArea.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { Form, Input } from 'antd'
-import React from 'react'
-import useFormField from '../../../Hooks/useFormField';
-const { TextArea } = Input;
-
-const TextAreaField = ({ name, label, placeholder, isDisabled, onChange, props,type }: any) => {
- const { Field, formik, isError, errorMsg, t } = useFormField(name, props);
-
-
-
- const handleChange = (e: React.ChangeEvent) => {
- console.log('Change:', e.target.value);
- formik.setFieldValue(name, e.target.value)
-
- };
-
- return (
-
-
-
-
-
-
- );
-};
-
-export default React.memo(TextAreaField);
-;
diff --git a/src/Components/ValidationField/View/TextAreaField.tsx b/src/Components/ValidationField/View/TextAreaField.tsx
new file mode 100644
index 0000000..455e056
--- /dev/null
+++ b/src/Components/ValidationField/View/TextAreaField.tsx
@@ -0,0 +1,50 @@
+import { Form, Input } from "antd";
+import React from "react";
+import useFormField from "../../../Hooks/useFormField";
+import { Field } from "formik";
+const { TextArea } = Input;
+
+const TextAreaField = ({
+ name,
+ label,
+ placeholder,
+ isDisabled,
+ onChange,
+ props,
+ type,
+}: any) => {
+ const { formik, isError, errorMsg, t } = useFormField(name, props);
+
+ const handleChange = (
+ e: React.ChangeEvent,
+ ) => {
+ // console.log('Change:', e.target.value);
+ formik.setFieldValue(name, e.target.value);
+ };
+
+ return (
+
+
+
+
+
+
+ );
+};
+
+export default React.memo(TextAreaField);
diff --git a/src/Components/ValidationField/View/TextField.tsx b/src/Components/ValidationField/View/TextField.tsx
new file mode 100644
index 0000000..ae71b55
--- /dev/null
+++ b/src/Components/ValidationField/View/TextField.tsx
@@ -0,0 +1,65 @@
+import { Form, Input } from "antd";
+import React from "react";
+import useFormField from "../../../Hooks/useFormField";
+import { MdOutlineEdit } from "react-icons/md";
+import { Field } from "formik";
+const { TextArea } = Input;
+
+const TextField = ({
+ name,
+ label,
+ placeholder,
+ isDisabled,
+ onChange,
+ props,
+ no_label,
+ label_icon,
+}: any) => {
+ const { formik, isError, errorMsg, t } = useFormField(name, props);
+ const TextFieldhandleChange = (
+ e: React.ChangeEvent,
+ ) => {
+ // console.log('Change:', e.target.value);
+ formik.setFieldValue(name, e.target.value);
+ };
+ return (
+
+ {no_label ? (
+
+ ) : label_icon ? (
+
+
+
+
+ ) : (
+
+ )}
+
+
+
+
+
+ );
+};
+
+export default React.memo(TextField);
diff --git a/src/Components/ValidationField/View/Time.tsx b/src/Components/ValidationField/View/Time.tsx
index 3d3bb0c..1847c0f 100644
--- a/src/Components/ValidationField/View/Time.tsx
+++ b/src/Components/ValidationField/View/Time.tsx
@@ -1,41 +1,68 @@
-import { Form, TimePicker } from 'antd'
-import React from 'react'
-import useFormField from '../../../Hooks/useFormField';
+import { Form, TimePicker } from "antd";
+import React from "react";
+import useFormField from "../../../Hooks/useFormField";
+import { MdOutlineEdit } from "react-icons/md";
+import dayjs from "dayjs";
-const Time = ({ name, label,className,isDisabled,onChange,props }: any) => {
-
- const { errorMsg, isError, t, formik } = useFormField(name, props)
+const Time = ({
+ name,
+ label,
+ className,
+ isDisabled,
+ onChange,
+ props,
+ placeholder,
+ no_label,
+ label_icon,
+}: any) => {
+ const { errorMsg, isError, t, formik } = useFormField(name, props);
const onCalendarChange = (value: any) => {
-
- formik.setFieldValue(name, value)
-
+ formik.setFieldValue(name, value);
};
- return (
-
-
+ const Formater = "H:mm";
+ const FormikValue = formik.values[name];
+
+ return (
+
+ {no_label ? (
+
+ ) : label_icon ? (
+
+
+
+
+ ) : (
+
+ )}
+
-
-
-
-
-
+
- )
-}
+ );
+};
-export default Time
\ No newline at end of file
+export default Time;
diff --git a/src/Components/ValidationField/View/index.tsx b/src/Components/ValidationField/View/index.tsx
index 606e8e6..0403969 100644
--- a/src/Components/ValidationField/View/index.tsx
+++ b/src/Components/ValidationField/View/index.tsx
@@ -5,18 +5,21 @@ import DataRange from "./DataRange";
import CheckboxField from "./CheckboxField";
import Default from "./Default";
import File from "./File";
-import TextAreaField from './TextArea'
-
-
+import MaltyFile from "./MaltyFile";
+import SearchField from "./SearchField";
+import TextField from "./TextField";
+import DropFile from "./DropFile.tsx";
export {
- Time,
- SelectField,
- Date,
- DataRange,
- CheckboxField,
- Default,
- File,
- TextAreaField
-
-}
\ No newline at end of file
+ Time,
+ SelectField,
+ Date,
+ DataRange,
+ CheckboxField,
+ Default,
+ File,
+ MaltyFile,
+ SearchField,
+ TextField,
+ DropFile,
+};
diff --git a/src/Components/ValidationField/index.tsx b/src/Components/ValidationField/index.tsx
index ee84bc7..20e711f 100644
--- a/src/Components/ValidationField/index.tsx
+++ b/src/Components/ValidationField/index.tsx
@@ -1,21 +1,16 @@
-import { useState } from 'react';
-import { ErrorMessage, useField, Field, useFormikContext } from 'formik';
-import { useTranslation } from 'react-i18next';
-import { FaExclamationCircle } from 'react-icons/fa';
-import Select from 'react-select';
-import { convert_data_to_select } from '../../Layout/app/Const';
-
-
-
-
+import { useState } from "react";
+import { ErrorMessage, useField, Field, useFormikContext } from "formik";
+import { useTranslation } from "react-i18next";
+import { FaExclamationCircle } from "react-icons/fa";
+import { convert_data_to_select } from "../../Layout/app/Const";
export {
- useState,
- ErrorMessage, useField, Field, useFormikContext,
- useTranslation,
- FaExclamationCircle,
- Select,
- convert_data_to_select,
-
-
-}
\ No newline at end of file
+ useState,
+ ErrorMessage,
+ useField,
+ Field,
+ useFormikContext,
+ useTranslation,
+ FaExclamationCircle,
+ convert_data_to_select,
+};
diff --git a/src/Components/ValidationField/types.ts b/src/Components/ValidationField/types.ts
deleted file mode 100644
index dd78185..0000000
--- a/src/Components/ValidationField/types.ts
+++ /dev/null
@@ -1,133 +0,0 @@
-
-// export interface ValidationFieldProps {
-// name: string;
-// type?: "text" | "Select" | "DataRange" | "Date" | "Time" | "File" | "number" | "Checkbox" | "password";
-// placeholder?: string;
-// label?: string;
-// className?: string;
-// option?: any[];
-// isMulti?: boolean;
-// isDisabled?: boolean;
-// picker?: "data" | "week" | "month" | "quarter" | "year";
-// Format?: "YYYY/MM/DD" | "MM/DD" | "YYYY/MM";
-// onChange?: (value: any) => void;
-// Group?: boolean
-// dir?:'ltr' | "rtl"
-// }
-
- export interface ValidationFieldPropsText {
- name: string;
- type: "text";
- placeholder?: string;
- label?: string;
- className?: string;
- isDisabled?: boolean;
- onChange?: (value: any) => void;
- dir?:'ltr' | "rtl"
- }
-
- export interface ValidationFieldPropsSelect {
- name: string;
- type: "Select";
- placeholder?: string;
- label?: string;
- className?: string;
- isDisabled?: boolean;
- onChange?:any;
- dir?:'ltr' | "rtl";
- option: any[];
- isMulti?: boolean;
-
- }
-
- export interface ValidationFieldPropsSearch{
- name: string;
- type: "Search";
- placeholder?: string;
- label?: string;
- className?: string;
- isDisabled?: boolean;
- onChange?: (value: any) => void;
- dir?:'ltr' | "rtl";
- option: any[];
- isMulti?: boolean;
- searchBy:string;
- loading?:boolean;
-
- }
- export interface ValidationFieldPropsDataRange {
- name: string;
- type: "DataRange";
- placeholder?: string;
- label?: string;
- className?: string;
- isDisabled?: boolean;
- onChange?: (value: any) => void;
- dir?:'ltr' | "rtl"
- Format?: "YYYY/MM/DD" | "MM/DD" | "YYYY/MM" | "YYYY-MM-DD HH:mm:ss.SSS";
- }
- export interface ValidationFieldPropsDate {
- name: string;
- type: "Date";
- placeholder?: string;
- label?: string;
- className?: string;
- isDisabled?: boolean;
- onChange?: (value: any) => void;
- dir?:'ltr' | "rtl"
- picker?: "data" | "week" | "month" | "quarter" | "year";
- Format?: "YYYY/MM/DD" | "MM/DD" | "YYYY/MM" | "YYYY-MM-DD HH:mm:ss.SSS" | "YYYY-MM-DD HH:MM:SS";
-
-
- }
-
- export interface ValidationFieldPropsTime {
- name: string;
- type: "Time";
- label?: string;
- placeholder?: string;
- className?: string;
- isDisabled?: boolean;
- onChange?: (value: any) => void;
- dir?:'ltr' | "rtl"
-
- }
-
- export interface ValidationFieldPropsFile {
- name: string;
- type: "File" | "MaltyFile";
- acceptedFileType?:string;
- placeholder?: string;
- label?: string;
- className?: string;
- isDisabled?: boolean;
- onChange?: (value: any) => void;
- dir?:'ltr' | "rtl"
-
- }
- export interface ValidationFieldPropsCheckbox {
- name: string;
- type: "Checkbox";
- label?: string;
- className?: string;
- isDisabled?: boolean;
- onChange?: (value: any) => void;
- dir?:'ltr' | "rtl"
- Group?: boolean
-
- }
- export interface ValidationFieldPropstext {
- name: string;
- type?: "text" | "number" | "password" | "TextArea";
- label?: string;
- className?: string;
- placeholder?: string;
- isDisabled?: boolean;
- onChange?: (value: any) => void;
- dir?:'ltr' | "rtl"
- Group?: boolean
-
- }
-
-
- export type ValidationFieldProps = ValidationFieldPropsText| ValidationFieldPropsSelect| ValidationFieldPropsDataRange| ValidationFieldPropsDate| ValidationFieldPropsTime| ValidationFieldPropsFile| ValidationFieldPropsCheckbox| ValidationFieldPropstext | ValidationFieldPropsSearch;
diff --git a/src/Components/ValidationField/utils/ValidationField.scss b/src/Components/ValidationField/utils/ValidationField.scss
new file mode 100644
index 0000000..ed6599e
--- /dev/null
+++ b/src/Components/ValidationField/utils/ValidationField.scss
@@ -0,0 +1,200 @@
+.LabelWithIcon {
+ display: flex;
+ width: 100%;
+ justify-content: space-between;
+}
+.ValidationField {
+ margin-bottom: 1.3vw;
+ position: relative;
+ > * {
+ width: 100%;
+ }
+ .text,
+ .ant-form-item {
+ margin-bottom: 7px !important;
+ > span {
+ color: transparent;
+ }
+ }
+
+ // .ant-select-outlined:not(.ant-select-customize-input) .ant-select-selector {
+ // border: 1px solid var(--border-color);
+ // }
+
+ .Select_error {
+ .ant-select-selector {
+ border: 1px solid red !important;
+ }
+ }
+
+ // .ValidationField{
+ // .ant-select-selector{
+ // border: 1px solid var(--border-color) ;
+
+ // }
+ // }
+ > span {
+ margin-bottom: 0px !important;
+ &:focus-within {
+ border-color: var(--primary);
+ box-shadow: 0 0 0 1px var(--primary);
+ cursor: pointer;
+ }
+ &:has(.is-invalid) {
+ border-color: red !important ;
+ }
+ input {
+ color: var(--text);
+ background: var(--bg);
+ }
+
+ input:-webkit-autofill,
+ input:-webkit-autofill:hover,
+ input:-webkit-autofill:focus,
+ input:-webkit-autofill:active {
+ -webkit-box-shadow: 0 0 0 30px white inset !important;
+ }
+ }
+}
+
+.ant-upload-select {
+ width: 100%;
+}
+.Checkboxs {
+ padding: 4%;
+}
+.SearchField {
+ button {
+ background: var(--primary);
+ }
+}
+.text {
+ color: var(--text);
+ margin-bottom: 15px;
+ font-weight: bold;
+}
+
+input:disabled {
+ color: var(--text) !important;
+}
+
+.isError {
+ outline: red 1px solid;
+ color: red;
+}
+.Error_color {
+ color: red;
+}
+// input:-webkit-autofill {
+// -webkit-box-shadow: 0 0 0 1000px white inset !important; /* Change the color to your desired background color */
+// }
+// input:-webkit-autofill:focus {
+// -webkit-box-shadow: 0 0 0 1000px white inset !important; /* Change the color to your desired background color */
+// }
+
+// /* Remove autofill background color on hover */
+// input:-webkit-autofill:hover {
+// -webkit-box-shadow: 0 0 0 1000px white inset !important; /* Change the color to your desired background color */
+// }
+// .upload_image_button {
+// .ant-btn {
+// min-height: 3vw !important;
+// border: 0.1vw solid var(--border-color);
+
+// display: flex;
+// align-items: center;
+// justify-content: center;
+// }
+// }
+// .ant-select-outlined:not(.ant-select-customize-input) .ant-select-selector {
+// min-height: 3vw !important;
+// }
+// .ant-select-multiple.ant-select-lg .ant-select-selection-overflow {
+// min-height: 3vw !important;
+// }
+
+// .ant-upload-list .ant-upload-list-item {
+// // height:3vw !important;
+// border: 1px solid var(--border-color) !important;
+// }
+
+// .TowValidationItems {
+// display: flex;
+// gap: 3%;
+// > label {
+// display: none;
+// }
+// }
+
+// .ant-select .ant-select-arrow {
+// inset-inline-end: 1vw;
+// }
+// .ant-input-affix-wrapper-lg {
+// padding: 0.5vw 1vw;
+// font-size: 1vw;
+// min-height: 3vw;
+// border-radius: 0.6vw;
+// }
+
+// .ant-picker-outlined {
+// padding: 0.5vw 1vw;
+// font-size: 1vw;
+// min-height: 3vw;
+// border-radius: 0.6vw;
+// border: 1px solid var(--border-color);
+// }
+
+// .ant-select-single.ant-select-lg .ant-select-selector {
+// min-height: 3vw;
+// border-radius: 0.6vw;
+// }
+// .ant-select-single .ant-select-selector .ant-select-selection-search-input {
+// min-height: 3vw;
+// }
+
+// .ant-select-outlined .ant-select-selector {
+// min-height: 3vw !important;
+// border-radius: 0.6vw !important;
+// }
+// .ant-select-single.ant-select-lg {
+// min-height: 3vw;
+// }
+
+// .ant-upload-wrapper .ant-upload-list .ant-upload-list-item {
+// width: 21.5vw;
+// }
+
+// .ant-input-number-outlined {
+// width: 100%;
+// height: 3vw;
+// }
+// .ant-input-number-lg ant-input-number-input {
+// width: 100%;
+// height: 3vw;
+// }
+
+// .bigRow {
+// width: 100%;
+// display: flex;
+// justify-content: space-between;
+// flex-wrap: wrap;
+// > *.w-100 {
+// width: 48% !important;
+// }
+// }
+
+// .ant-input-number-affix-wrapper-lg {
+// width: 100%;
+// height: 3vw;
+// border-radius: 0.6vw;
+// border: 1px solid var(--border-color);
+// }
+
+// .TwoSelectGroup {
+// display: flex;
+// gap: 10px;
+// margin-bottom: 20px;
+// }
+// .TwoSelectGroupbutton {
+// margin-bottom: 20px;
+// }
diff --git a/src/Components/ValidationField/utils/ValidationState.ts b/src/Components/ValidationField/utils/ValidationState.ts
new file mode 100644
index 0000000..4af51fe
--- /dev/null
+++ b/src/Components/ValidationField/utils/ValidationState.ts
@@ -0,0 +1,11 @@
+import { create } from "zustand";
+
+interface ValidationState {
+ Validation: any[];
+ setValidation: (value: any[]) => void;
+}
+
+export const useValidationState = create
((set) => ({
+ Validation: [],
+ setValidation: (value) => set((state) => ({ Validation: value })),
+}));
diff --git a/src/Components/ValidationField/utils/translatedOptions.ts b/src/Components/ValidationField/utils/translatedOptions.ts
new file mode 100644
index 0000000..eda92a2
--- /dev/null
+++ b/src/Components/ValidationField/utils/translatedOptions.ts
@@ -0,0 +1,6 @@
+export const translateOptions = (options: any, t: any) => {
+ return options.map((opt: any) => ({
+ ...opt,
+ label: t(`${opt.label}`),
+ }));
+};
diff --git a/src/Components/ValidationField/utils/types.ts b/src/Components/ValidationField/utils/types.ts
new file mode 100644
index 0000000..0959f66
--- /dev/null
+++ b/src/Components/ValidationField/utils/types.ts
@@ -0,0 +1,171 @@
+export type ValidationFieldType =
+ | "text"
+ | "Select"
+ | "LocalSearch"
+ | "Search"
+ | "DataRange"
+ | "Date"
+ | "Time"
+ | "File"
+ | "MaltyFile"
+ | "DropFile"
+ | "Checkbox"
+ | "number"
+ | "password"
+ | "email"
+ | "TextArea";
+
+export interface ValidationFieldPropsText {
+ name: string;
+ no_label?: boolean;
+ label_icon?: boolean;
+ type: "text";
+ placeholder?: string;
+ label?: string;
+ className?: string;
+ isDisabled?: boolean;
+ onChange?: (value: any) => void;
+ dir?: "ltr" | "rtl";
+}
+
+export interface ValidationFieldPropsSelect {
+ name: string;
+ no_label?: boolean;
+ label_icon?: boolean;
+ type: "Select";
+ placeholder?: string;
+ label?: string;
+ className?: string;
+ isDisabled?: boolean;
+ onChange?: any;
+ dir?: "ltr" | "rtl";
+ option: any[];
+ isMulti?: boolean;
+}
+
+export interface ValidationFieldPropsLocalSearch {
+ name: string;
+ no_label?: boolean;
+ label_icon?: boolean;
+ type: "LocalSearch";
+ placeholder?: string;
+ label?: string;
+ className?: string;
+ isDisabled?: boolean;
+ onChange?: (value: any) => void;
+ dir?: "ltr" | "rtl";
+ option: any[];
+ isMulti?: boolean;
+}
+export interface ValidationFieldPropsSearch {
+ name: string;
+ no_label?: boolean;
+ label_icon?: boolean;
+ type: "Search";
+ placeholder?: string;
+ label?: string;
+ className?: string;
+ isDisabled?: boolean;
+ onChange?: (value: any) => void;
+ dir?: "ltr" | "rtl";
+ option: any[];
+ isMulti?: boolean;
+ searchBy: string;
+}
+export interface ValidationFieldPropsDataRange {
+ name: string;
+ no_label?: boolean;
+ label_icon?: boolean;
+ type: "DataRange";
+ placeholder?: string;
+ label?: string;
+ className?: string;
+ isDisabled?: boolean;
+ onChange?: (value: any) => void;
+ dir?: "ltr" | "rtl";
+ Format?: "YYYY/MM/DD" | "MM/DD" | "YYYY/MM" | "YYYY-MM-DD HH:mm:ss.SSS";
+}
+export interface ValidationFieldPropsDate {
+ name: string;
+ no_label?: boolean;
+ label_icon?: boolean;
+ type: "Date";
+ placeholder?: string;
+ label?: string;
+ className?: string;
+ isDisabled?: boolean;
+ onChange?: (value: any) => void;
+ dir?: "ltr" | "rtl";
+ picker?: "data" | "week" | "month" | "quarter" | "year";
+}
+
+export interface ValidationFieldPropsTime {
+ name: string;
+ no_label?: boolean;
+ label_icon?: boolean;
+ type: "Time";
+ label?: string;
+ placeholder?: string;
+ className?: string;
+ isDisabled?: boolean;
+ onChange?: (value: any) => void;
+ dir?: "ltr" | "rtl";
+}
+
+export interface ValidationFieldPropsFile {
+ name: string;
+ no_label?: boolean;
+ label_icon?: boolean;
+ type: "File" | "MaltyFile" | "DropFile";
+ acceptedFileType?:string;
+ placeholder?: string;
+ label?: string;
+ className?: string;
+ isDisabled?: boolean;
+ onChange?: (value: any) => void;
+ dir?: "ltr" | "rtl";
+}
+export interface ValidationFieldPropsCheckbox {
+ name: string;
+ no_label?: boolean;
+ label_icon?: boolean;
+ type: "Checkbox";
+ label?: string;
+ className?: string;
+ isDisabled?: boolean;
+ onChange?: (value: any) => void;
+ dir?: "ltr" | "rtl";
+ Group?: boolean;
+}
+export interface ValidationFieldPropstext {
+ name: string;
+ no_label?: boolean;
+ label_icon?: boolean;
+ type?:
+ | "text"
+ | "number"
+ | "password"
+ | "email"
+ | "TextArea"
+ | "NumberFormate";
+ label?: string;
+ className?: string;
+ placeholder?: string;
+ isDisabled?: boolean;
+ onChange?: (value: any) => void;
+ dir?: "ltr" | "rtl";
+ Group?: boolean;
+ [key: string]: any; // Index signature to allow any additional props
+}
+
+export type ValidationFieldProps =
+ | ValidationFieldPropsText
+ | ValidationFieldPropsSelect
+ | ValidationFieldPropsLocalSearch
+ | ValidationFieldPropsDataRange
+ | ValidationFieldPropsDate
+ | ValidationFieldPropsTime
+ | ValidationFieldPropsFile
+ | ValidationFieldPropsCheckbox
+ | ValidationFieldPropstext
+ | ValidationFieldPropsSearch;
diff --git a/src/Extensions/Editor/HtmlEditor.tsx b/src/Extensions/Editor/HtmlEditor.tsx
deleted file mode 100644
index 9d02c9b..0000000
--- a/src/Extensions/Editor/HtmlEditor.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import React, { FC } from "react";
-import { Editor } from '@tinymce/tinymce-react';
-import { useFormikContext } from "formik";
-
-interface HtmlEditorProps {
- langCode: number;
- name: string;
- editorState: string;
-}
-
-const HtmlEditor: FC = ({ langCode, name, editorState, ...props }) => {
- const formik = useFormikContext();
-
- const ar: boolean = langCode === 2;
-
- return (
- {
- formik.setFieldValue(name, newValue)
- }}
- />
- );
-}
-
-export { HtmlEditor };
\ No newline at end of file
diff --git a/src/Extensions/Editor/SingleLangEditor.tsx b/src/Extensions/Editor/SingleLangEditor.tsx
deleted file mode 100644
index c8db2d6..0000000
--- a/src/Extensions/Editor/SingleLangEditor.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import React, { FC } from "react";
-// import PropTypes from "";
-import { HtmlEditor } from "./HtmlEditor";
-import { useFormikContext } from "formik";
-import { useTranslation } from "react-i18next";
-
-interface SingleLangEditorProps {
- langCode: number;
- property: string;
-}
-
-const PROPERTY_TYPES: string[] = [
- "privacy_description",
- "conditions_description",
- "about_us_description",
- "product_description",
- "auction_description"
-];
-
-const SingleLangEditor: FC = ({ langCode, property }) => {
- const formik:any = useFormikContext();
- const {t} = useTranslation();
-
- const label = `${t(property)} (${t(`lang_${langCode}`)})`;
- const fieldName = `translated_fields[${langCode}][${property}]`;
- return (
- <>
- {label}
-
- >
- );
-};
-
-// SingleLangEditor.propTypes = {
-// langCode: PropTypes.oneOf([1, 2]).isRequired,
-// property: PropTypes.oneOf(PROPERTY_TYPES).isRequired,
-// };
-
-export default SingleLangEditor;
\ No newline at end of file
diff --git a/src/Extensions/Editor/StatusCard.tsx b/src/Extensions/Editor/StatusCard.tsx
deleted file mode 100644
index 25993c4..0000000
--- a/src/Extensions/Editor/StatusCard.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import React, { FC } from "react";
-import { Card, CardBody, Spinner } from "reactstrap";
-
-interface StatusCardProps {
- isLoading: boolean;
- isError: boolean;
-}
-
-const StatusCard= ({ isLoading, isError }:StatusCardProps) => {
- return (
-
-
- {isLoading && }
- {isError && Failed !
}
-
-
- );
-};
-
-export default StatusCard;
\ No newline at end of file
diff --git a/src/Extensions/FileGenerator/generateAddModal.js b/src/Extensions/FileGenerator/generateAddModal.js
deleted file mode 100644
index 88f656f..0000000
--- a/src/Extensions/FileGenerator/generateAddModal.js
+++ /dev/null
@@ -1,65 +0,0 @@
-const fs = require('fs');
-
-// Get the file name from the command line arguments
-const fileName = process.argv[2];
-
-// Check if a file name is provided
-if (!fileName) {
- console.error('Please provide a file name.');
- process.exit(1);
-}
-
-let FileContiner = `
-
-import React from 'react'
-import LayoutModal from '../../Layout/Dashboard/LayoutModal'
-import Form${capitalizeFirstLetter(fileName)} from './Form${capitalizeFirstLetter(fileName)}'
-import { useAdd${capitalizeFirstLetter(fileName)} } from '../../api/${(fileName)}'
-import { getDataToSend, getInitialValues, getValidationSchema } from './formUtil'
-import { QueryStatusEnum } from '../../config/QueryStatus'
-import { useTranslation } from 'react-i18next'
-
-function Add${capitalizeFirstLetter(fileName)}Modal() {
-
-
- const [t] = useTranslation()
- const {mutate , status} = useAdd${capitalizeFirstLetter(fileName)}()
- const handelSubmit = (values:any )=>{
-
- const dataToSend = getDataToSend(values)
-
- mutate(dataToSend)
- // Submit Value
- }
- return (
-
-
-
-
- )
-}
-
-export default Add${capitalizeFirstLetter(fileName)}Modal
-
-`
-fs.writeFileSync('src/Pages/'+fileName+"/"+"Add"+ capitalizeFirstLetter(fileName)+"Modal.tsx",
-FileContiner
-);
-
-console.log(`File "${fileName}" generated successfully.`);
-
-
-
-
-
-function capitalizeFirstLetter(word) {
- return (word).charAt(0).toUpperCase() + (word).slice(1);
-}
\ No newline at end of file
diff --git a/src/Extensions/FileGenerator/generateApi.js b/src/Extensions/FileGenerator/generateApi.js
deleted file mode 100644
index 80d596e..0000000
--- a/src/Extensions/FileGenerator/generateApi.js
+++ /dev/null
@@ -1,40 +0,0 @@
-const fs = require('fs');
-
-const fileName = process.argv[2]
-
-
-if (!fileName) {
- console.error('Please provide a file name.');
- process.exit(1);
-}
-
-
-let FileContiner = `
-import useAddMutation from "./helper/useAddMutation"
-import useDeleteMutation from "./helper/useDeleteMutation"
-import useGetQuery from "./helper/useGetQuery"
-import useUpdateMutation from "./helper/useUpdateMutation"
-
- const API = {
- GET: "/api/admin/${fileName}",
- ADD: "/api/admin/${fileName}/create",
- UPDATE: "/api/admin/${fileName}/update",
- DELETE: "/api/admin/${fileName}/delete",
- };
-
- const KEY = "${fileName.toUpperCase()}";
- export const useGet${capitalizeFirstLetter(fileName)} = (params?:any) => useGetQuery(KEY, API.GET, params);
- export const useAdd${capitalizeFirstLetter(fileName)} = () => useAddMutation(KEY, API.ADD);
- export const useUpdate${capitalizeFirstLetter(fileName)} = () => useUpdateMutation(KEY, API.UPDATE);
- export const useDelete${capitalizeFirstLetter(fileName)} = () =>useDeleteMutation(KEY, API.DELETE);
-`
-fs.writeFileSync('src/api/'+fileName+".ts",
-FileContiner
-);
-
-console.log(`File "${fileName}" generated successfully.`);
-
-
-function capitalizeFirstLetter(word) {
- return (word).charAt(0).toUpperCase() + (word).slice(1);
-}
\ No newline at end of file
diff --git a/src/Extensions/FileGenerator/generateColumn.js b/src/Extensions/FileGenerator/generateColumn.js
deleted file mode 100644
index c85ad21..0000000
--- a/src/Extensions/FileGenerator/generateColumn.js
+++ /dev/null
@@ -1,63 +0,0 @@
-const fs = require('fs');
-
-// Get the file name from the command line arguments
-const fileName = process.argv[2];
-
-// Check if a file name is provided
-if (!fileName) {
- console.error('Please provide a file name.');
- process.exit(1);
-}
-
-
-
-let FileContiner = `
-import React, { useMemo } from "react";
-import { useTranslation } from "react-i18next";
-import Actions from "../../Components/Ui/tables/Actions";
-
-function fnDelete(props :any ){}
-
-const useTableColumns :any = () => {
- const [t] = useTranslation();
-
- return useMemo(
- () => [
-
- {
- name: t("email"),
- sortable: false,
- center: "true",
- cell: (row:any) => row?.email
- },
-
- {
- name: "#",
- sortable: false,
- center: "true",
- cell: (row) => (
- row}
- onView={()=>{}}
- objectToEdit={row}
- showEdit={true}
- // showDelete={false}
- onDelete={() => fnDelete({ id: row.id })}
- />
- ),
- },
- ],
- [t]
- );
-};
-
-export default useTableColumns;
-
-`
-fs.writeFileSync('src/Pages/'+fileName+"/useTableColumns"+".tsx",
-FileContiner
-);
-
-console.log(`File "${fileName}" generated successfully.`);
diff --git a/src/Extensions/FileGenerator/generateDashboard.js b/src/Extensions/FileGenerator/generateDashboard.js
deleted file mode 100644
index f291fd9..0000000
--- a/src/Extensions/FileGenerator/generateDashboard.js
+++ /dev/null
@@ -1,30 +0,0 @@
-const { exec } = require('child_process');
-
-
-const fileName = process.argv[2]
-
-
-const CreateApi = `node src/Extensions/FileGenerator/generateApi.js ${fileName}`
-const CreatePage = `node src/Extensions/FileGenerator/generatePage.js ${fileName}`
-const CreateColumn = `node src/Extensions/FileGenerator/generateColumn.js ${fileName}`
-const CreateformUtil= `node src/Extensions/FileGenerator/generateformUtils.js ${fileName}`
-const CreateAddModal= `node src/Extensions/FileGenerator/generateAddModal.js ${fileName}`
-const CreateEditModal= `node src/Extensions/FileGenerator/generateEditModal.js ${fileName}`
-const CreateForm= `node src/Extensions/FileGenerator/generateForm.js ${fileName}`
-
-
-
-const RunCommand = async()=>{
-
- exec(CreatePage)
- exec(CreateApi)
- setTimeout(()=>{},100)
- exec(CreateColumn)
- exec(CreateformUtil)
- exec(CreateAddModal)
- exec(CreateEditModal)
- exec(CreateForm)
-
-}
-
-RunCommand()
diff --git a/src/Extensions/FileGenerator/generateEditModal.js b/src/Extensions/FileGenerator/generateEditModal.js
deleted file mode 100644
index 0171481..0000000
--- a/src/Extensions/FileGenerator/generateEditModal.js
+++ /dev/null
@@ -1,47 +0,0 @@
-const fs = require('fs');
-
-// Get the file name from the command line arguments
-const fileName = process.argv[2];
-
-// Check if a file name is provided
-if (!fileName) {
- console.error('Please provide a file name.');
- process.exit(1);
-}
-
-let FileContiner = `
-import React from 'react'
-import LayoutModal from '../../Layout/Dashboard/LayoutModal'
-import Form${capitalizeFirstLetter(fileName)} from './Form${capitalizeFirstLetter(fileName)}'
-import { getInitialValues, getValidationSchema } from './formUtil'
-import { usePageState } from '../../lib/state mangment/LayoutPagestate'
-
-function Edit${capitalizeFirstLetter(fileName)}Modal() {
- const {objectToEdit} = usePageState()
- return (
- { }}
- headerText='Edit Modal'
- getValidationSchema={getValidationSchema(objectToEdit)}>
-
-
- )
-}
-
-export default Edit${capitalizeFirstLetter(fileName)}Modal
-`
-fs.writeFileSync('src/Pages/'+fileName+"/"+"Edit"+ capitalizeFirstLetter(fileName)+"Modal.tsx",
-FileContiner
-);
-
-console.log(`File "${fileName}" generated successfully.`);
-
-
-
-
-
-function capitalizeFirstLetter(word) {
- return (word).charAt(0).toUpperCase() + (word).slice(1);
-}
\ No newline at end of file
diff --git a/src/Extensions/FileGenerator/generateForm.js b/src/Extensions/FileGenerator/generateForm.js
deleted file mode 100644
index 3558bd6..0000000
--- a/src/Extensions/FileGenerator/generateForm.js
+++ /dev/null
@@ -1,66 +0,0 @@
-const fs = require('fs');
-
-// Get the file name from the command line arguments
-const fileName = process.argv[2];
-
-// Check if a file name is provided
-if (!fileName) {
- console.error('Please provide a file name.');
- process.exit(1);
-}
-
-let FileContiner = `
-import React from 'react'
-import { Col, Row } from 'reactstrap';
-import ValidationField from '../../Components/ValidationField/ValidationField';
-import { FakeSelectData } from '../../Layout/app/Const';
-import { useFormikContext } from 'formik';
-
-import { DatePicker } from 'antd';
-
-function Form${capitalizeFirstLetter(fileName)}() {
- const formik = useFormikContext();
-
-
-
- return (
-
-
- // name from form utils
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- )
-}
-
-export default Form${capitalizeFirstLetter(fileName)}
-
-
-`
-fs.writeFileSync('src/Pages/'+fileName+'/Form'+ capitalizeFirstLetter(fileName)+".tsx",
-FileContiner
-);
-
-console.log(`File "${fileName}" generated successfully.`);
-
-
-
-
-
-function capitalizeFirstLetter(word) {
- return (word).charAt(0).toUpperCase() + (word).slice(1);
-}
\ No newline at end of file
diff --git a/src/Extensions/FileGenerator/generateModel.js b/src/Extensions/FileGenerator/generateModel.js
deleted file mode 100644
index 442421c..0000000
--- a/src/Extensions/FileGenerator/generateModel.js
+++ /dev/null
@@ -1,64 +0,0 @@
-const fs = require('fs');
-
-// Get the file name from the command line arguments
-const fileName = process.argv[2];
-
-// Check if a file name is provided
-if (!fileName) {
- console.error('Please provide a file name.');
- process.exit(1);
-}
-
-let FileContiner = `
-
-import React from 'react'
-import LayoutModal from '../../Layout/Dashboard/LayoutModal'
-import Form${capitalizeFirstLetter(fileName)} from './Form${capitalizeFirstLetter(fileName)}'
-import { useAdd${capitalizeFirstLetter(fileName)} } from '../../api/${(fileName)}'
-import { getDataToSend, getInitialValues, getValidationSchema } from './formUtil'
-import { QueryStatusEnum } from '../../config/QueryStatus'
-import { useTranslation } from 'react-i18next'
-
-function Add${capitalizeFirstLetter(fileName)}Modal() {
-
-
- const [t] = useTranslation()
- const {mutate , status} = useAdd${capitalizeFirstLetter(fileName)}()
- const handelSubmit = (values:any )=>{
-
- const dataToSend = getDataToSend(values)
-
- mutate(dataToSend)
- // Submit Value
- }
- return (
-
-
-
-
- )
-}
-
-export default Add${capitalizeFirstLetter(fileName)}Modal
-
-`
-fs.writeFileSync('src/Pages/'+fileName+"/"+"Add"+ capitalizeFirstLetter(fileName)+"Modal.tsx",
-FileContiner
-);
-
-console.log(`File "${fileName}" generated successfully.`);
-
-
-
-
-
-function capitalizeFirstLetter(word) {
- return (word).charAt(0).toUpperCase() + (word).slice(1);
-}
\ No newline at end of file
diff --git a/src/Extensions/FileGenerator/generatePage.js b/src/Extensions/FileGenerator/generatePage.js
deleted file mode 100644
index f200971..0000000
--- a/src/Extensions/FileGenerator/generatePage.js
+++ /dev/null
@@ -1,67 +0,0 @@
-const fs = require('fs');
-
-// Get the file name from the command line arguments
-const fileName = process.argv[2];
-
-// Check if a file name is provided
-if (!fileName) {
- console.error('Please provide a file name.');
- process.exit(1);
-}
-
-const folderPath = 'src/Pages/'+fileName;
-
-
-if (!fs.existsSync(folderPath)) {
- fs.mkdirSync(folderPath, { recursive: true });
-}
-
-let FileContiner = `
-import React from 'react'
-import DashBody from '../../Layout/Dashboard/DashBody'
-import DashHeader from '../../Layout/Dashboard/DashHeader'
-import LyTable from '../../Layout/Dashboard/LyTable'
-import useTableColumns from './useTableColumns'
-import { useGet${capitalizeFirstLetter(fileName)}} from '../../api/${fileName}'
-import { QueryStatusEnum } from '../../config/QueryStatus'
-import Edit${capitalizeFirstLetter(fileName)}Modal from './Edit${capitalizeFirstLetter(fileName)}Modal'
-import Add${capitalizeFirstLetter(fileName)}Modal from './Add${capitalizeFirstLetter(fileName)}Modal'
-
-function ${capitalizeFirstLetter(fileName)}Page() {
-
- const column =useTableColumns()
- const {data ,status } = useGet${capitalizeFirstLetter(fileName)}()
-
-
- return (
- // Pass Status to Layout
-
-
-
-
-
-
-
-
-
- )
-}
-
-export default ${capitalizeFirstLetter(fileName)}Page
-
-`
-
-fs.writeFileSync('src/Pages/'+fileName+"/"+capitalizeFirstLetter(fileName)+"Page.tsx",
-FileContiner
-);
-
-console.log(`File "${fileName}" generated successfully.`);
-
-
-function capitalizeFirstLetter(word) {
- return (word).charAt(0).toUpperCase() + (word).slice(1);
-}
\ No newline at end of file
diff --git a/src/Extensions/FileGenerator/generateformUtils.js b/src/Extensions/FileGenerator/generateformUtils.js
deleted file mode 100644
index f608f43..0000000
--- a/src/Extensions/FileGenerator/generateformUtils.js
+++ /dev/null
@@ -1,73 +0,0 @@
-const fs = require('fs');
-
-// Get the file name from the command line arguments
-const fileName = process.argv[2];
-
-// Check if a file name is provided
-if (!fileName) {
- console.error('Please provide a file name.');
- process.exit(1);
-}
-
-let FileContiner = `
-import * as Yup from "yup";
-import { buildFormData } from "../../api/helper/buildFormData";
-
-interface formUtilCommon {
- name:string,
- email:string
-}
-
-interface ObjectToEdit extends formUtilCommon {
-
- id?:number,
-
-}
-
-interface InitialValues extends ObjectToEdit {
-
-}
-interface ValidateSchema extends formUtilCommon{
-
-}
-
-export const getInitialValues = (objectToEdit: ObjectToEdit | null = null): InitialValues => {
-
-
- return {
- id:objectToEdit?.id?? 0 ,
- name:objectToEdit?.name ?? "",
- email:objectToEdit?.email?? ""
- }
-
-
-};
-
-export const getValidationSchema = (editMode: boolean = false): Yup.Schema => {
- // validate input
- return Yup.object().shape({
- name:Yup.string().required('required'),
- email:Yup.string().required("required")
- });
-};
-
-export const getDataToSend = (values: any): FormData => {
- const data = { ...values };
-
-
- const formData = new FormData();
- buildFormData(formData, data);
- return formData;
-};
-
-`
-fs.writeFileSync('src/Pages/'+fileName+"/"+"formUtil.ts",
-FileContiner
-);
-
-console.log(`File "${fileName}" generated successfully.`);
-
-
-function capitalizeFirstLetter(word) {
- return (word).charAt(0).toUpperCase() + (word).slice(1);
-}
\ No newline at end of file
diff --git a/src/Layout/Dashboard/AddButton/AddButton.tsx b/src/Layout/Dashboard/AddButton/AddButton.tsx
index d6d8cec..3ed64d3 100644
--- a/src/Layout/Dashboard/AddButton/AddButton.tsx
+++ b/src/Layout/Dashboard/AddButton/AddButton.tsx
@@ -1,7 +1,7 @@
import React from 'react'
import './Add_Button.scss'
import { useTranslation } from 'react-i18next'
-import { usePageState } from '../../../lib/state mangment/LayoutPagestate'
+import { usePageState } from '../../../lib/statemangment/LayoutPagestate'
diff --git a/src/Layout/Dashboard/AddButton/AddButtonLayout.tsx b/src/Layout/Dashboard/AddButton/AddButtonLayout.tsx
index d796bae..67910e3 100644
--- a/src/Layout/Dashboard/AddButton/AddButtonLayout.tsx
+++ b/src/Layout/Dashboard/AddButton/AddButtonLayout.tsx
@@ -1,7 +1,7 @@
import React from 'react'
import './Add_Button.scss'
import { useTranslation } from 'react-i18next'
-import { usePageState } from '../../../lib/state mangment/LayoutPagestate'
+import { usePageState } from '../../../lib/statemangment/LayoutPagestate'
diff --git a/src/Layout/Dashboard/LayoutModal.tsx b/src/Layout/Dashboard/LayoutModal.tsx
index 926e7f0..4d67dfd 100644
--- a/src/Layout/Dashboard/LayoutModal.tsx
+++ b/src/Layout/Dashboard/LayoutModal.tsx
@@ -1,7 +1,7 @@
import { Form, Formik } from 'formik'
import React, { useEffect } from 'react'
import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap'
-import { usePageState } from '../../lib/state mangment/LayoutPagestate'
+import { usePageState } from '../../lib/statemangment/LayoutPagestate'
import { useTranslation } from 'react-i18next';
import { LoadingButton } from '../../Components/Ui/LoadingButton';
import { QueryStatusEnum } from '../../config/QueryStatus';
diff --git a/src/Layout/Dashboard/ViewPage.tsx b/src/Layout/Dashboard/ViewPage.tsx
index 74322e0..8158ec3 100644
--- a/src/Layout/Dashboard/ViewPage.tsx
+++ b/src/Layout/Dashboard/ViewPage.tsx
@@ -4,7 +4,7 @@ import { Formik, Form } from "formik";
import { LoadingButton } from "../../Components/Ui/LoadingButton";
import ProgressBar from "../../Components/Ui/ProgressBar";
import { useLocation, useNavigate } from "react-router-dom";
-import { usePageState } from "../../lib/state mangment/LayoutPagestate";
+import { usePageState } from "../../lib/statemangment/LayoutPagestate";
import { useTranslation } from "react-i18next";
type TViewPage ={
diff --git a/src/Layout/Dashboard/useCloseModal.ts b/src/Layout/Dashboard/useCloseModal.ts
index 993685d..eb8a483 100644
--- a/src/Layout/Dashboard/useCloseModal.ts
+++ b/src/Layout/Dashboard/useCloseModal.ts
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react'
-import { usePageState } from '../../lib/state mangment/LayoutPagestate'
+import { usePageState } from '../../lib/statemangment/LayoutPagestate'
function useCloseModal(statusClose:any) {
diff --git a/src/Layout/app/Header.tsx b/src/Layout/app/Header.tsx
index 5abb651..9988a1f 100644
--- a/src/Layout/app/Header.tsx
+++ b/src/Layout/app/Header.tsx
@@ -3,7 +3,7 @@ import { UserImageURL } from './Const'
import Translate from '../../Components/Utils/Translate'
import { useTranslation } from 'react-i18next'
import { useNavigate } from 'react-router-dom';
-import useAuthState from '../../lib/state mangment/AuthState';
+import useAuthState from '../../lib/statemangment/AuthState';
import { GiHamburgerMenu } from 'react-icons/gi';
import WithDrawer from './WithDrawer';
import Sidebar from './SideBar';
diff --git a/src/Layout/app/Layout.tsx b/src/Layout/app/Layout.tsx
index ca21133..2f3e409 100644
--- a/src/Layout/app/Layout.tsx
+++ b/src/Layout/app/Layout.tsx
@@ -2,7 +2,7 @@ import React, { useEffect } from 'react'
import SideBar from './SideBar'
import Header from './Header'
import { useNavigate } from 'react-router-dom'
-import useAuthState from '../../lib/state mangment/AuthState'
+import useAuthState from '../../lib/statemangment/AuthState'
const Layout = ({ children }: { children: React.ReactNode }) => {
diff --git a/src/Layout/app/SideBar.tsx b/src/Layout/app/SideBar.tsx
index c4e2b9a..828e387 100644
--- a/src/Layout/app/SideBar.tsx
+++ b/src/Layout/app/SideBar.tsx
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
import KarimLogo from './KarimLogo';
import { useWindowSize } from '../../Hooks/useWindowSize';
import Etaxi from './Etaxi';
-import { usePageState } from '../../lib/state mangment/LayoutPagestate';
+import { usePageState } from '../../lib/statemangment/LayoutPagestate';
interface SidebarProps {}
diff --git a/src/Pages/Auth/LoginForm.tsx b/src/Pages/Auth/LoginForm.tsx
index 8e1bbac..a048f32 100644
--- a/src/Pages/Auth/LoginForm.tsx
+++ b/src/Pages/Auth/LoginForm.tsx
@@ -8,7 +8,7 @@ import * as Yup from "yup";
import { getInitialValues, getValidationSchema } from './formUtil';
import { LoadingButton } from '../../Components/Ui/LoadingButton';
import useNavigateOnSuccess from '../../Hooks/useNavigateOnSuccess';
-import useAuthState from '../../lib/state mangment/AuthState';
+import useAuthState from '../../lib/statemangment/AuthState';
import ValidationField from '../../Components/ValidationField/ValidationField';
const LoginForm = () => {
diff --git a/src/Pages/Auth/Page.tsx b/src/Pages/Auth/Page.tsx
index 91e6c7e..7765a9f 100644
--- a/src/Pages/Auth/Page.tsx
+++ b/src/Pages/Auth/Page.tsx
@@ -1,7 +1,7 @@
import React, { useEffect } from 'react'
import LoginForm from './LoginForm';
import { LoginBg } from '../../Layout/app/Const';
-import useAuthState from '../../lib/state mangment/AuthState';
+import useAuthState from '../../lib/statemangment/AuthState';
import { useNavigate } from 'react-router-dom';
const Auth = () => {
diff --git a/src/Pages/Categories/View/EditPage.tsx b/src/Pages/Categories/View/EditPage.tsx
index f74b5a2..8cd4532 100644
--- a/src/Pages/Categories/View/EditPage.tsx
+++ b/src/Pages/Categories/View/EditPage.tsx
@@ -4,18 +4,22 @@ import { Tab, TabList, TabPanel as TabBody, Tabs } from 'react-tabs'
import { MdLanguage } from 'react-icons/md'
import ViewPage from '../../../Layout/Dashboard/ViewPage';
import { Rate, Spin } from 'antd';
-import { usePageState } from '../../../lib/state mangment/LayoutPagestate';
+import { usePageState } from '../../../lib/statemangment/LayoutPagestate';
import LoadingPage from '../../../Layout/app/LoadingPage';
import { useTranslation } from 'react-i18next';
-import { useGetOneCategories, useUpdateCategories } from '../../../api/Categories';
+import { useGetCategories, useUpdateCategories } from '../../../api/Categories';
import useNavigateOnSuccess from '../../../Hooks/useNavigateOnSuccess';
import Form from './EditForm';
+import { useParams } from 'react-router-dom';
const EditPage = () => {
const { setObjectToEdit, objectToEdit } = usePageState()
const { t } = useTranslation();
- const { data,isRefetching } = useGetOneCategories()
- const { mutate, isSuccess,isLoading:IsloadingButton } = useUpdateCategories("put")
+ const {id} = useParams()
+ const { data,isRefetching } = useGetCategories({
+ show:id
+ })
+ const { mutate, isSuccess,isLoading:IsloadingButton } = useUpdateCategories()
const handleSubmit = (values: any) => {
if( typeof values?.image === "string" ){
delete values["image"]
diff --git a/src/Pages/Home/Page.tsx b/src/Pages/Home/Page.tsx
new file mode 100644
index 0000000..89830ea
--- /dev/null
+++ b/src/Pages/Home/Page.tsx
@@ -0,0 +1,10 @@
+import React from 'react'
+
+const Page = () => {
+
+ return (
+ Page
+ )
+}
+
+export default Page
\ No newline at end of file
diff --git a/src/Pages/Meal/View/EditPage.tsx b/src/Pages/Meal/View/EditPage.tsx
index ca7a1f4..61c6d4e 100644
--- a/src/Pages/Meal/View/EditPage.tsx
+++ b/src/Pages/Meal/View/EditPage.tsx
@@ -4,18 +4,22 @@ import { Tab, TabList, TabPanel as TabBody, Tabs } from 'react-tabs'
import { MdLanguage } from 'react-icons/md'
import ViewPage from '../../../Layout/Dashboard/ViewPage';
import { Rate, Spin } from 'antd';
-import { usePageState } from '../../../lib/state mangment/LayoutPagestate';
+import { usePageState } from '../../../lib/statemangment/LayoutPagestate';
import LoadingPage from '../../../Layout/app/LoadingPage';
import { useTranslation } from 'react-i18next';
-import { useGetOneMeal, useUpdateMeal } from '../../../api/Meal';
+import { useGetMeal, useUpdateMeal } from '../../../api/Meal';
import useNavigateOnSuccess from '../../../Hooks/useNavigateOnSuccess';
import Form from './EditForm';
+import { useParams } from 'react-router-dom';
const EditPage = () => {
const { setObjectToEdit, objectToEdit } = usePageState()
const { t } = useTranslation();
- const { data,isRefetching } = useGetOneMeal()
- const { mutate, isSuccess,isLoading:IsloadingButton } = useUpdateMeal("put")
+ const {id} = useParams()
+ const { data,isRefetching } = useGetMeal({
+ show:id
+ })
+ const { mutate, isSuccess,isLoading:IsloadingButton } = useUpdateMeal()
const handleSubmit = (values: any) => {
if( typeof values?.image === "string" ){
diff --git a/src/Pages/Offer/View/EditPage.tsx b/src/Pages/Offer/View/EditPage.tsx
index d26342d..99375d6 100644
--- a/src/Pages/Offer/View/EditPage.tsx
+++ b/src/Pages/Offer/View/EditPage.tsx
@@ -4,18 +4,22 @@ import { Tab, TabList, TabPanel as TabBody, Tabs } from 'react-tabs'
import { MdLanguage } from 'react-icons/md'
import ViewPage from '../../../Layout/Dashboard/ViewPage';
import { Rate, Spin } from 'antd';
-import { usePageState } from '../../../lib/state mangment/LayoutPagestate';
+import { usePageState } from '../../../lib/statemangment/LayoutPagestate';
import LoadingPage from '../../../Layout/app/LoadingPage';
import { useTranslation } from 'react-i18next';
-import { useGetOneOffer, useUpdateOffer } from '../../../api/Offer';
+import { useGetOffer, useUpdateOffer } from '../../../api/Offer';
import useNavigateOnSuccess from '../../../Hooks/useNavigateOnSuccess';
import Form from './EditForm';
+import { useParams } from 'react-router-dom';
const EditPage = () => {
const { setObjectToEdit, objectToEdit } = usePageState()
const { t } = useTranslation();
- const { data,isRefetching } = useGetOneOffer()
- const { mutate, isSuccess,isLoading:IsloadingButton } = useUpdateOffer("put")
+ const {id} = useParams()
+ const { data,isRefetching } = useGetOffer({
+ show:id
+ })
+ const { mutate, isSuccess,isLoading:IsloadingButton } = useUpdateOffer()
const handleSubmit = (values: any) => {
if( typeof values?.image === "string" ){
delete values["image"]
diff --git a/src/Pages/Setting/Groups/FieldGroup.tsx b/src/Pages/Setting/Groups/FieldGroup.tsx
new file mode 100644
index 0000000..76a0760
--- /dev/null
+++ b/src/Pages/Setting/Groups/FieldGroup.tsx
@@ -0,0 +1,96 @@
+import React from "react";
+import { Input, Button } from "antd";
+import { useFormikContext } from "formik";
+import { useTranslation } from "react-i18next";
+
+interface FieldGroupProps {
+ array_name: string;
+ title:string;
+ static?: boolean;
+ only_value?: boolean;
+}
+
+const FieldGroup: React.FC = ({ array_name ,title,static:isStatic,only_value}) => {
+ const { values, setFieldValue } = useFormikContext();
+ const addFieldGroup = () => {
+ setFieldValue(array_name, [
+ ...(values?.[array_name] || []),
+ { key: null, value: null },
+ ]);
+ };
+ const deleteFieldGroup = () => {
+ const updatedArray = values?.[array_name]?.slice(0, -1) || [];
+ setFieldValue(array_name, updatedArray);
+ };
+
+
+ const handleChangeKey = (
+ e: React.ChangeEvent,
+ index: number
+ ) => {
+ const Selects = values?.[array_name] ?? [];
+ Selects[index].key = e.target.value;
+ setFieldValue(array_name, Selects);
+ };
+
+ const handleChangeValue = (
+ e: React.ChangeEvent,
+ index: number
+ ) => {
+ const Selects = values?.[array_name] ?? [];
+ Selects[index].value = e.target.value;
+ setFieldValue(array_name, Selects);
+ };
+
+ const selectsArray = values?.[array_name] ?? [];
+ const { t } = useTranslation();
+
+ return (
+ <>
+
+ {selectsArray.map((group: { key: string; value: string }, index: number) => (
+
+ handleChangeKey(e, index)}
+ value={group.key}
+ size="large"
+ style={{ width: "100%" }}
+ allowClear
+ disabled={only_value}
+ />
+ handleChangeValue(e, index)}
+ value={group.value}
+ size="large"
+ style={{ width: "100%" }}
+ allowClear
+
+ />
+
+ ))}
+ {!isStatic &&
+
+
+
+
+ }
+
+ >
+ );
+};
+
+export default FieldGroup;
diff --git a/src/Pages/Setting/Page.tsx b/src/Pages/Setting/Page.tsx
index 1a68429..51de6c1 100644
--- a/src/Pages/Setting/Page.tsx
+++ b/src/Pages/Setting/Page.tsx
@@ -1,16 +1,14 @@
import { Image, Spin } from "antd";
import React from "react";
import SimpleMap from "./Map";
-import { useGetOneSetting, useGetSetting } from "../../api/GuestApi";
+import { useGetSetting } from "../../api/GuestApi";
import { TOKEN_KEY } from "../../api/config";
-import useAuthState from "../../lib/state mangment/AuthState";
+import useAuthState from "../../lib/statemangment/AuthState";
import ReactPlayer from 'react-player'
import { FaEdit } from "react-icons/fa";
import { useNavigate } from "react-router-dom";
const Page = () => {
- const { token } = useAuthState();
- console.log(token, "token");
const navigate= useNavigate()
const fake = "900310ff-610f-11ee-9fbc-00505649cf62";
const { data, isLoading } = useGetSetting({
@@ -29,10 +27,13 @@ const Page = () => {
id
} = data?.data ?? [];
- console.log(attributes, "attribute");
-
- console.log(video,"video");
-
+ const fakeIMage = [1,1,1,1,1,1]
+ const handel_navigate = (id:number)=>{
+ console.log(id);
+
+
+ navigate(`/Setting/${id}`)
+ }
if(isLoading){
return
}
@@ -43,6 +44,7 @@ const Page = () => {
width={200}
src={logo}
className="Personal_Image"
+ fallback="/Layout/images.png"
/>
{name}
@@ -86,8 +88,8 @@ const Page = () => {
}
-
navigate(id)} >
-
+
+ handel_navigate(id)} size={30}/>
);
diff --git a/src/Pages/Setting/View/EditForm.tsx b/src/Pages/Setting/View/EditForm.tsx
index 05d863d..637410b 100644
--- a/src/Pages/Setting/View/EditForm.tsx
+++ b/src/Pages/Setting/View/EditForm.tsx
@@ -4,23 +4,28 @@ import { Col, Row } from 'reactstrap';
import ValidationField from '../../../Components/ValidationField/ValidationField';
import { useGetCategories } from '../../../api/Categories';
import useFormatToSelect from '../../../Hooks/useFormatToSelect';
-
+import FieldGroup from '../Groups/FieldGroup';
function Form() {
const {data:Categories} = useGetCategories()
const SelectCategoriesData = useFormatToSelect(Categories?.data)
-
+
return (
-
-
+
+ {/* */}
+
+
+
+
+
diff --git a/src/Pages/Setting/View/EditPage.tsx b/src/Pages/Setting/View/EditPage.tsx
index ca7a1f4..d890444 100644
--- a/src/Pages/Setting/View/EditPage.tsx
+++ b/src/Pages/Setting/View/EditPage.tsx
@@ -4,28 +4,45 @@ import { Tab, TabList, TabPanel as TabBody, Tabs } from 'react-tabs'
import { MdLanguage } from 'react-icons/md'
import ViewPage from '../../../Layout/Dashboard/ViewPage';
import { Rate, Spin } from 'antd';
-import { usePageState } from '../../../lib/state mangment/LayoutPagestate';
+import { usePageState } from '../../../lib/statemangment/LayoutPagestate';
import LoadingPage from '../../../Layout/app/LoadingPage';
import { useTranslation } from 'react-i18next';
-import { useGetOneMeal, useUpdateMeal } from '../../../api/Meal';
+import { useGetSetting, useUpdateSetting } from '../../../api/setting';
import useNavigateOnSuccess from '../../../Hooks/useNavigateOnSuccess';
import Form from './EditForm';
+import { useParams } from 'react-router-dom';
+import { convertArrayToJsonString } from '../../../utils/Array/convertArrayToJsonString';
const EditPage = () => {
const { setObjectToEdit, objectToEdit } = usePageState()
const { t } = useTranslation();
- const { data,isRefetching } = useGetOneMeal()
- const { mutate, isSuccess,isLoading:IsloadingButton } = useUpdateMeal("put")
- const handleSubmit = (values: any) => {
+ const {id} = useParams()
+
+ const { data,isRefetching } = useGetSetting({
+ show:id
+ })
+ const { mutate, isSuccess,isLoading:IsloadingButton } = useUpdateSetting()
+
+ const handleSubmit = (values:any) => {
+ const dataToSend = {...values};
+
+ const slogan = convertArrayToJsonString(values?.slogan);
+ const phone_number = values?.phone_number;
+ const email = values?.email;
+ const contact_info = convertArrayToJsonString([{key: 'phone_number', value:phone_number},{key: 'email', value:email}])
+
+ dataToSend["slogan"] = slogan;
+ dataToSend["contact_info"] = contact_info;
+
+
+ // mutate({...values, _method : "put"});
+ console.log(dataToSend,"dataToSend");
+
- if( typeof values?.image === "string" ){
- delete values["video"]
- }
- mutate({...values, _method : "put"});
}
- useNavigateOnSuccess(isSuccess, '/Meal')
+ useNavigateOnSuccess(isSuccess, '/Setting')
useEffect(() => {
@@ -42,11 +59,10 @@ const EditPage = () => {
return
}
-
-
+
const ViewProps = { getInitialValues, getValidationSchema, handleSubmit,IsloadingButton };
-
+
return (
{objectToEdit && data ?
diff --git a/src/Pages/Setting/formUtil.ts b/src/Pages/Setting/formUtil.ts
index daff665..5338671 100644
--- a/src/Pages/Setting/formUtil.ts
+++ b/src/Pages/Setting/formUtil.ts
@@ -1,15 +1,29 @@
import * as Yup from "yup";
+import { KeyAndValue, objectToArray } from "../../utils/object/objectToArray";
+import { Restaurant } from "../../types/item";
-export const getInitialValues = (objectToEdit: any | null = null): any => {
+export const getInitialValues = (objectToEdit: Restaurant ): any => {
+
+ console.log(objectToEdit,"objectToEdit");
+
+ const slogan: KeyAndValue[] = objectToArray(objectToEdit?.slogan);
+ const contact_info: KeyAndValue[] = objectToArray(objectToEdit?.contact_info);
+ const categories = objectToEdit?.categories?.map((item:any)=>(item.id)) || null;
+ console.log(categories,"categories");
+
return {
id: objectToEdit?.id ?? null,
name: objectToEdit?.name ?? null,
images: objectToEdit?.images ?? null,
+ logo: objectToEdit?.logo ?? null,
+
address: objectToEdit?.address ?? null,
- contact_info: objectToEdit?.contact_info ?? null,
- slogan: objectToEdit?.slogan ?? null,
+ phone_number:contact_info?.[0]?.value ?? null,
+ email:contact_info?.[1]?.value ?? null,
+ categories:categories,
+ slogan: slogan ?? null,
video: objectToEdit?.video ?? null,
attributes: objectToEdit?.attributes ?? null,
};
diff --git a/src/ProviderContainer.tsx b/src/ProviderContainer.tsx
index c30c964..8deda4c 100644
--- a/src/ProviderContainer.tsx
+++ b/src/ProviderContainer.tsx
@@ -2,13 +2,11 @@ import React, { ReactNode } from 'react'
import QueryProvider from './lib/ReactQueryProvider'
import { BrowserRouter } from 'react-router-dom'
import ToastProvider from './lib/ToastProvider'
-import { createBrowserHistory } from 'history'
type ProviderContainerProps = {
children:ReactNode
}
-export let history = createBrowserHistory()
function ProviderContainer({children}:ProviderContainerProps) {
return (
diff --git a/src/Routes.tsx b/src/Routes.tsx
index 347a723..aa33983 100644
--- a/src/Routes.tsx
+++ b/src/Routes.tsx
@@ -29,7 +29,7 @@ import { SettingFilled } from "@ant-design/icons";
import { GiMeal } from "react-icons/gi";
-
+import Home from './Pages/Home/Page'
@@ -48,7 +48,7 @@ export const RoutesLinks: RoutesLinksType[] = [
{
name: "Home",
- element: <>Home Page>,
+ element: ,
icon: ,
href: "/",
},
diff --git a/src/Styles/AppStyle/Varibils.scss b/src/Styles/AppStyle/Varibils.scss
index ae6688b..38d9750 100644
--- a/src/Styles/AppStyle/Varibils.scss
+++ b/src/Styles/AppStyle/Varibils.scss
@@ -1,5 +1,5 @@
:root {
- --primary:#E57DB1 ;
+ --primary:black ;
--secondary : #2D9CDB;
--text: #565656;
--bg: #ffffff;
diff --git a/src/api/Categories.ts b/src/api/Categories.ts
index 40cc176..df29ed9 100644
--- a/src/api/Categories.ts
+++ b/src/api/Categories.ts
@@ -1,9 +1,8 @@
-import useGetQueryPagination from "./helper/ueGetPagination";
+import useGetQuery from "./helper/useGetQuery";
import useAddMutation from "./helper/useAddMutation"
import useDeleteMutation from "./helper/useDeleteMutation"
-import useGetOneQuery from "./helper/useGetOneQuery";
-import useUpdateMutationPost from "./helper/useUpdateMutationPut";
+import useUpdateMutation from "./helper/useUpdateMutation";
const API = {
ADD: `category`,
@@ -15,10 +14,9 @@ const API = {
const KEY = "categories"
-export const useGetCategories = (params?:any) => useGetQueryPagination(KEY, API.GET_ALL,params);
-export const useGetOneCategories = () => useGetOneQuery(KEY, API.GET_ALL);
+export const useGetCategories = (params?:any,option?:any) => useGetQuery(KEY, API.GET_ALL,params);
export const useAddCategories = () => useAddMutation(KEY, API.ADD);
-export const useUpdateCategories = (method?:any) => useUpdateMutationPost(KEY, API.UPDATE,true,method);
+export const useUpdateCategories = (method?:any) => useUpdateMutation(KEY, API.UPDATE);
export const useDeleteCategories = () =>useDeleteMutation(KEY, API.DELETE);
diff --git a/src/api/GuestApi.ts b/src/api/GuestApi.ts
index 2be058e..9f10b1a 100644
--- a/src/api/GuestApi.ts
+++ b/src/api/GuestApi.ts
@@ -1,10 +1,8 @@
import useGetQuery from "./helper/useGetQuery";
-import useGetQueryPagination from "./helper/ueGetPagination";
import useAddMutation from "./helper/useAddMutation"
import useDeleteMutation from "./helper/useDeleteMutation"
-import useGetOneQuery from "./helper/useGetOneQuery";
-import useUpdateMutationPost from "./helper/useUpdateMutationPut";
+import useUpdateMutation from "./helper/useUpdateMutation";
const API = {
ADD: `guest/restaurant`,
@@ -16,10 +14,9 @@ const API = {
const KEY = "setting"
-export const useGetSetting = (params?:any) => useGetQuery(KEY, API.GET_ALL,params);
-export const useGetOneSetting = () => useGetOneQuery(KEY, API.GET_ALL);
+export const useGetSetting = (params?:any,option?:any) => useGetQuery(KEY, API.GET_ALL,params);
export const useAddSetting = () => useAddMutation(KEY, API.ADD);
-export const useUpdateSetting = (method?:any) => useUpdateMutationPost(KEY, API.UPDATE,true,method);
+export const useUpdateSetting = (method?:any) => useUpdateMutation(KEY, API.UPDATE);
export const useDeleteSetting = () =>useDeleteMutation(KEY, API.DELETE);
diff --git a/src/api/Meal.ts b/src/api/Meal.ts
index b348d10..ac97da0 100644
--- a/src/api/Meal.ts
+++ b/src/api/Meal.ts
@@ -1,9 +1,8 @@
-import useGetQueryPagination from "./helper/ueGetPagination";
import useAddMutation from "./helper/useAddMutation"
import useDeleteMutation from "./helper/useDeleteMutation"
-import useGetOneQuery from "./helper/useGetOneQuery";
-import useUpdateMutationPost from "./helper/useUpdateMutationPut";
+import useGetQuery from "./helper/useGetQuery";
+import useUpdateMutation from "./helper/useUpdateMutation";
const API = {
ADD: `meal`,
@@ -15,10 +14,9 @@ const API = {
const KEY = "Meal"
-export const useGetMeal = (params?:any) => useGetQueryPagination(KEY, API.GET_ALL,params);
-export const useGetOneMeal = () => useGetOneQuery(KEY, API.GET_ALL);
+export const useGetMeal = (params?:any,option?:any) => useGetQuery(KEY, API.GET_ALL,params,option);
export const useAddMeal = () => useAddMutation(KEY, API.ADD);
-export const useUpdateMeal = (method?:any) => useUpdateMutationPost(KEY, API.UPDATE,true,method);
+export const useUpdateMeal = () => useUpdateMutation(KEY, API.UPDATE);
export const useDeleteMeal = () =>useDeleteMutation(KEY, API.DELETE);
diff --git a/src/api/Offer.ts b/src/api/Offer.ts
index 8963e16..f159365 100644
--- a/src/api/Offer.ts
+++ b/src/api/Offer.ts
@@ -1,9 +1,8 @@
-import useGetQueryPagination from "./helper/ueGetPagination";
+import useGetQuery from "./helper/useGetQuery";
import useAddMutation from "./helper/useAddMutation"
import useDeleteMutation from "./helper/useDeleteMutation"
-import useGetOneQuery from "./helper/useGetOneQuery";
-import useUpdateMutationPost from "./helper/useUpdateMutationPut";
+import useUpdateMutation from "./helper/useUpdateMutation";
const API = {
ADD: `offer`,
@@ -15,10 +14,9 @@ const API = {
const KEY = "Offer"
-export const useGetOffer = (params?:any) => useGetQueryPagination(KEY, API.GET_ALL,params);
-export const useGetOneOffer = () => useGetOneQuery(KEY, API.GET_ALL);
+export const useGetOffer = (params?:any,option?:any) => useGetQuery(KEY, API.GET_ALL,params);
export const useAddOffer = () => useAddMutation(KEY, API.ADD);
-export const useUpdateOffer = (method?:any) => useUpdateMutationPost(KEY, API.UPDATE,true,method);
+export const useUpdateOffer = (method?:any) => useUpdateMutation(KEY, API.UPDATE);
export const useDeleteOffer = () =>useDeleteMutation(KEY, API.DELETE);
diff --git a/src/api/Restaurant.ts b/src/api/Restaurant.ts
index 78a191f..3e7413f 100644
--- a/src/api/Restaurant.ts
+++ b/src/api/Restaurant.ts
@@ -1,9 +1,8 @@
-import useGetQueryPagination from "./helper/ueGetPagination";
+import useGetQuery from "./helper/useGetQuery";
import useAddMutation from "./helper/useAddMutation"
import useDeleteMutation from "./helper/useDeleteMutation"
-import useGetOneQuery from "./helper/useGetOneQuery";
-import useUpdateMutationPost from "./helper/useUpdateMutationPut";
+import useUpdateMutation from "./helper/useUpdateMutation";
const API = {
ADD: `restaurant`,
@@ -15,10 +14,9 @@ const API = {
const KEY = "Restaurant"
-export const useGetRestaurant = (params?:any) => useGetQueryPagination(KEY, API.GET_ALL,params);
-export const useGetOneRestaurant = () => useGetOneQuery(KEY, API.GET_ALL);
+export const useGetRestaurant = (params?:any,option?:any) => useGetQuery(KEY, API.GET_ALL,params);
export const useAddRestaurant = () => useAddMutation(KEY, API.ADD);
-export const useUpdateRestaurant = (method?:any) => useUpdateMutationPost(KEY, API.UPDATE,true,method);
+export const useUpdateRestaurant = (method?:any) => useUpdateMutation(KEY, API.UPDATE);
export const useDeleteRestaurant = () =>useDeleteMutation(KEY, API.DELETE);
diff --git a/src/api/config.ts b/src/api/config.ts
index d6ee3de..90d02bd 100644
--- a/src/api/config.ts
+++ b/src/api/config.ts
@@ -15,3 +15,5 @@ export const TOKEN_KEY = PROJECT_NAME + "_TOKEN"
export const USER_KEY = PROJECT_NAME + "_USER"
+
+export const HEADER_KEY = "X-Custom-Query-Key";
diff --git a/src/api/helper/AxiosBuilder.ts b/src/api/helper/AxiosBuilder.ts
index 3f19067..d8cd905 100644
--- a/src/api/helper/AxiosBuilder.ts
+++ b/src/api/helper/AxiosBuilder.ts
@@ -1,49 +1,43 @@
-import axios, { AxiosInstance, AxiosRequestConfig ,ResponseType } from 'axios';
-
+import axios, { AxiosInstance, AxiosRequestConfig, ResponseType } from "axios";
class AxiosBuilder {
- private baseURL: string = '';
- private headers: Record = {};
- private timeout: number = 60000; // Request failed with 60 second
- private withCreds: boolean = false;
- private responseType: ResponseType = 'json';
- // Custom Another Props with Your Position
+ private baseURL: string = "";
+ private headers: Record = {};
+ private timeout: number = 60000; // Request failed with 60 second
+ private withCreds: boolean = false;
+ private responseType: ResponseType = "json";
+ // Custom Another Props with Your Position
-
- withBaseURL(baseURL: string): AxiosBuilder {
- this.baseURL = baseURL;
- return this;
- }
-
- withHeaders(headers: Record): AxiosBuilder {
- this.headers = headers;
- return this;
- }
-
- withTimeout(timeout: number): AxiosBuilder {
- this.timeout = timeout;
- return this;
- }
-
+ withBaseURL(baseURL: string): AxiosBuilder {
+ this.baseURL = baseURL;
+ return this;
+ }
+
+ withHeaders(headers: Record): AxiosBuilder {
+ this.headers = headers;
+ return this;
+ }
+
+ withTimeout(timeout: number): AxiosBuilder {
+ this.timeout = timeout;
+ return this;
+ }
withResponseType(responseType: ResponseType): AxiosBuilder {
this.responseType = responseType;
return this;
}
-
- build(): AxiosInstance {
- const config: AxiosRequestConfig = {
- baseURL: this.baseURL,
- headers: this.headers,
- timeout: this.timeout,
- responseType:this.responseType
- };
-
- return axios.create(config);
- }
+ build(): AxiosInstance {
+ const config: AxiosRequestConfig = {
+ baseURL: this.baseURL,
+ headers: this.headers,
+ timeout: this.timeout,
+ responseType: this.responseType,
+ };
+
+ return axios.create(config);
}
+}
-
-export default AxiosBuilder
-
+export default AxiosBuilder;
diff --git a/src/api/helper/buildFormData.ts b/src/api/helper/buildFormData.ts
deleted file mode 100644
index eb1f736..0000000
--- a/src/api/helper/buildFormData.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-export const buildFormData = (
- formData: FormData,
- data: any,
- parentKey?: string
- ): void => {
- if (
- data &&
- typeof data === "object" &&
- !(data instanceof Date) &&
- !(data instanceof File)
- ) {
- Object.keys(data).forEach((key) => {
- buildFormData(
- formData,
- data[key],
- parentKey ? `${parentKey}[${key}]` : key
- );
- });
- } else {
- const value = data == null ? "" : data;
-
- formData.append(parentKey as string, value);
- }
- };
-
\ No newline at end of file
diff --git a/src/api/helper/ueGetPagination.tsx b/src/api/helper/ueGetPagination.tsx
deleted file mode 100644
index f570e1c..0000000
--- a/src/api/helper/ueGetPagination.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-import { useQuery } from 'react-query';
-import useAxios from './useAxios';
-import { useLocation, useNavigate } from 'react-router-dom';
-import useAuthState from '../../lib/state mangment/AuthState';
-
-export default function useGetQueryPagination(KEY: string | string[], Api: string, params: any = {}, options: any = {}, dontSearchBy?: string) {
- const axios = useAxios();
- const location = useLocation();
- let pagination = location?.search || '';
- const language = localStorage.getItem("language") ?? "en"
-
- const { logout } = useAuthState();
- const navigate = useNavigate();
-
- if (dontSearchBy && pagination.includes(dontSearchBy)) {
- const searchParams = new URLSearchParams(pagination);
- searchParams.delete(dontSearchBy);
- pagination = searchParams.toString();
- }
- if (pagination && !pagination.startsWith('?')) {
- pagination = '?' + pagination;
- }
-
- // Check if pagination exists and append it to the API endpoint
- const paginationParams = pagination ? pagination + '&orderById=desc' : '?orderById=desc';
- const apiUrl = Api + paginationParams;
-
- return useQuery(
- [Array.isArray(KEY) ? KEY.join(',') : KEY, pagination,language], async () => {
- const response = await axios.get(apiUrl, { params });
- return response.data;
- },
- {
- onError: (error: any) => {
- if (error?.response?.status === 401 || error?.response?.status === 403) {
- logout();
- navigate("/auth");
- }
- },
- refetchOnWindowFocus: false,
- ...options
- }
- );
-}
diff --git a/src/api/helper/useAddMutation.ts b/src/api/helper/useAddMutation.ts
index 88ffb5d..adaccc7 100644
--- a/src/api/helper/useAddMutation.ts
+++ b/src/api/helper/useAddMutation.ts
@@ -1,38 +1,28 @@
-import { useMutation, useQueryClient, UseMutationResult } from 'react-query';
-import { toast } from 'react-toastify';
-import useAxios from './useAxios';
-import { useTranslation } from 'react-i18next';
+import { useMutation, UseMutationResult } from "react-query";
+import useAxios from "./useAxios";
+import { HEADER_KEY } from "../config";
+import { AxiosResponse } from "../../types/Axios";
-type AxiosResponse = {
- message: string;
- data:any ,
- success:true
-};
+function useAddMutation(
+ key: string,
+ url: string,
+ message?: string,
-function useAddMutation(key: string, url: string,message?:string): UseMutationResult {
+): UseMutationResult {
const axios = useAxios();
- const [t] = useTranslation();
- const queryClient = useQueryClient();
-
return useMutation(
async (dataToSend) => {
- const { data } = await axios.post(url, dataToSend,{
+
+ const { data } = await axios.post(url, dataToSend, {
headers: {
- 'Content-Type': 'multipart/form-data'
- }
- } );
+ "Content-Type": "multipart/form-data",
+ [HEADER_KEY]: key,
+ },
+ });
return data;
+
},
- {
- onSuccess: (data) => {
- queryClient.invalidateQueries([key]);
- toast.success(data.message || t(message??"") || t("added_successful"));
- },
- onError: (error:any) => {
- const message = error?.response?.data?.message || t("failed_to_add_data");
- toast.error(message);
- }
- }
+
);
}
diff --git a/src/api/helper/useAddMutationJson.ts b/src/api/helper/useAddMutationJson.ts
deleted file mode 100644
index 8e9864b..0000000
--- a/src/api/helper/useAddMutationJson.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { useMutation, useQueryClient, UseMutationResult } from 'react-query';
-import { toast } from 'react-toastify';
-import useAxios from './useAxios';
-import { useTranslation } from 'react-i18next';
-
-type AxiosResponse = {
- message: string;
- data:any ,
- success:true
-};
-
-function useAddMutationJson(key: string, url: string): UseMutationResult {
- const axios = useAxios();
- const [t] = useTranslation();
- const queryClient = useQueryClient();
-
- return useMutation(
- async (dataToSend) => {
- const { data } = await axios.post(url, dataToSend);
- return data;
- },
- {
- onSuccess: (data) => {
- queryClient.invalidateQueries([key]);
- toast.success(data.message || t("added_successful"));
- },
- onError: (error:any) => {
- const message = error?.response?.data?.message || t("failed_to_add_data");
- toast.error(message);
- }
- }
- );
-}
-
-export default useAddMutationJson;
diff --git a/src/api/helper/useAxios.ts b/src/api/helper/useAxios.ts
index 7cdd7db..bf2b6c6 100644
--- a/src/api/helper/useAxios.ts
+++ b/src/api/helper/useAxios.ts
@@ -1,25 +1,78 @@
-import { BaseURL } from '../config'
-import useAuthState from '../../lib/state mangment/AuthState'
-import AxiosBuilder from './AxiosBuilder'
+
+import { BaseURL, HEADER_KEY } from "../config";
+import AxiosBuilder from "./AxiosBuilder";
+import { useTranslation } from "react-i18next";
+import { toast } from "react-toastify";
+import { useQueryClient } from "react-query";
+import { useNavigate } from "react-router-dom";
+import useAuthState from "../../lib/statemangment/AuthState";
+import { useValidationState } from "../../Components/ValidationField/utils/ValidationState";
+import { AxiosQueryEnum, AxiosStatusEnum } from "../../enums/Axios";
function useAxios() {
- const {isAuthenticated , token}= useAuthState()
-
- const buildAxios = new AxiosBuilder().
- withBaseURL(BaseURL)
- .withResponseType('json')
- .withTimeout(120000)
- .withHeaders({"Content-Type" :"application/json"})
+ const { isAuthenticated, token } = useAuthState();
-
- if(isAuthenticated){
+ const { setValidation } = useValidationState((state) => state);
+ const [t] = useTranslation();
+ const queryClient = useQueryClient();
- buildAxios.withHeaders({ Authorization: 'Bearer '+ token })
- }
-
- return (
- buildAxios.build()
- )
+ const { logout } = useAuthState();
+ const navigate = useNavigate();
+
+ const buildAxios = new AxiosBuilder()
+ .withBaseURL(BaseURL)
+ .withResponseType("json")
+ .withTimeout(120000);
+
+ if (isAuthenticated) {
+ buildAxios.withHeaders({
+ Authorization: "Bearer " + token,
+ });
+ }
+
+ const build_Axios = buildAxios.build();
+
+ build_Axios.interceptors.response.use(
+ function (response: any) {
+ const responseMsg = response?.data?.message;
+ const method = response.config.method;
+
+ const key = response.config.headers[HEADER_KEY];
+ const ResponseMessage =
+ responseMsg || t("validation.the_possess_done_successful");
+ if (method !== AxiosQueryEnum?.GET) {
+ queryClient.invalidateQueries(key);
+ toast.success(ResponseMessage);
+ setValidation([{}]);
+ }
+ return response;
+ },
+ function (error) {
+ const status = error?.request?.status;
+ const errorMsg = error?.response?.data?.message;
+ const errorField = error?.response?.data;
+ const method = error.config.method;
+
+ if (status === AxiosStatusEnum.VALIDATION) {
+ setValidation(errorMsg ?? errorField);
+ const errorMessage = errorMsg || t("validation.some_thing_went_wrong");
+ toast.error(errorMessage);
+ }
+ if (status === AxiosStatusEnum.AUTHENTICATED) {
+ logout();
+ navigate("/auth");
+ }
+
+ if (method !== AxiosQueryEnum?.GET) {
+ const errorMessage = errorMsg || t("validation.some_thing_went_wrong");
+ toast.error(errorMessage);
+ return Promise.reject(error);
+ }
+ },
+ );
+ return build_Axios;
+
+ // return buildAxios.build();
}
-export default useAxios
\ No newline at end of file
+export default useAxios;
diff --git a/src/api/helper/useDeleteMutation.ts b/src/api/helper/useDeleteMutation.ts
index 87e84ca..c5fb446 100644
--- a/src/api/helper/useDeleteMutation.ts
+++ b/src/api/helper/useDeleteMutation.ts
@@ -1,34 +1,27 @@
-import { useMutation, useQueryClient, UseMutationResult } from 'react-query';
-import { toast } from 'react-toastify';
-import useAxios from './useAxios';
-import { useTranslation } from 'react-i18next';
+import { useMutation, UseMutationResult } from "react-query";
+import useAxios from "./useAxios";
+import { HEADER_KEY } from "../config";
+import { AxiosResponse } from "../../types/Axios";
-type AxiosResponse = {
- message: string;
- // Add other properties as needed
+type DataToSend = {
+ id: number | string;
};
-function useDeleteMutation(key:any , url: string): UseMutationResult {
+function useDeleteMutation(
+ key: any,
+ url: string,
+ message?: string,
+): UseMutationResult {
const axios = useAxios();
- const queryClient = useQueryClient();
- const {t} = useTranslation();
-
- return useMutation(
- async ({dataToSend,id}:any) => {
- const { data } = await axios.delete(url+"/"+id );
- return {...data, id,dataToSend};
+ return useMutation(
+ async (dataToSend) => {
+ const { data } = await axios.delete(url + `/` + dataToSend?.id, {
+ headers: {
+ [HEADER_KEY]: key,
+ },
+ });
+ return data;
},
- {
- onSuccess: (data) => {
- queryClient.invalidateQueries(key);
- toast.success(t('deleted_successfully'));
- },
- onError: (error:any) => {
- const message = error?.response?.data?.message || t("failed_to_add_data");
- toast.error(message);
- }
- },
-
);
}
diff --git a/src/api/helper/useGetOneQuery.ts b/src/api/helper/useGetOneQuery.ts
deleted file mode 100644
index c0719f6..0000000
--- a/src/api/helper/useGetOneQuery.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { useQuery } from 'react-query';
-import useAxios from './useAxios';
-import useAuthState from '../../lib/state mangment/AuthState';
-import { useNavigate, useParams } from 'react-router-dom';
-
-function useGetOneQuery(key: string, url: string , params:any={},options:any={}) {
- const axios = useAxios();
- const {logout} = useAuthState()
- const language = localStorage.getItem("language") ?? "en"
- const navigate = useNavigate()
- const {id} = useParams()
-
- return useQuery(
- [id, key,language],
- async () => {
- const response = await axios.get(url+"/"+ id+`?lang=${language}`);
- return response.data;
- },
-
-
- {
- onError: (error:any) => {
- if(error.response.status == 401 || error.response.status == 403){
- logout()
- navigate("/auth")
-
- }
-
- },
- cacheTime: 0, // Set cacheTime to 0 to disable caching
- refetchOnWindowFocus: false,
-
- ...options
-
- }
- );
-}
-
-export default useGetOneQuery;
diff --git a/src/api/helper/useGetQuery.ts b/src/api/helper/useGetQuery.ts
index aedcce8..e466018 100644
--- a/src/api/helper/useGetQuery.ts
+++ b/src/api/helper/useGetQuery.ts
@@ -1,24 +1,39 @@
-import { useQuery } from 'react-query';
-import useAxios from './useAxios';
+import { useQuery } from "react-query";
+import useAxios from "./useAxios";
+import { useLocation } from "react-router-dom";
+import { PaginationParams } from "../utils/PaginationParams";
+import { filterParams } from "../utils/filterParams";
-function useGetQuery(KEY: string | string[], url: string, params: any = {}, options: any = {}) {
+function useGetQuery(
+ KEY: string | string[],
+ url: string,
+ params: any = {},
+ options: any = {},
+) {
const axios = useAxios();
- const show = params.show ? "/" + params.show : '';
- const filteredParams = Object.fromEntries(
- Object.entries(params).filter(([_, value]) => value !== '')
- );
+ const { show, pagination, ...remainingParams } = params;
- return useQuery([KEY, filteredParams], async () => {
- const response = await axios.get(url + show, { params: filteredParams });
- return response.data;
- }, {
- onError: (error) => {
- console.error('An error occurred:', error);
+ const location = useLocation();
+
+ const { page, per_page } = PaginationParams(location);
+
+ const param_to_send = pagination
+ ? { ...remainingParams, page: page, per_page: per_page }
+ : { ...remainingParams };
+
+ const filteredParams = filterParams(param_to_send);
+
+ return useQuery(
+ [KEY, filteredParams, show],
+ async () => {
+ const response = await axios.get(url + (show ? `/${show}` : ""), {
+ params: filteredParams,
+ });
+ return response?.data ?? [];
},
- refetchOnWindowFocus: false,
- ...options
- });
+ options,
+ );
}
export default useGetQuery;
diff --git a/src/api/helper/useGetSingleQuery.ts b/src/api/helper/useGetSingleQuery.ts
deleted file mode 100644
index e930dc7..0000000
--- a/src/api/helper/useGetSingleQuery.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import { useQuery } from 'react-query';
-import useAxios from './useAxios';
-import useAuthState from '../../lib/state mangment/AuthState';
-import { useNavigate, useParams } from 'react-router-dom';
-
-function useGetSingleQuery(key: string, url: string , params:any={},options:any={}) {
- const axios = useAxios();
- const {logout} = useAuthState()
- const language = localStorage.getItem("language") ?? "en"
- const navigate = useNavigate()
- const {id} = useParams()
-
- return useQuery(
- [id, key,params?.id],
- async () => {
- const response = await axios.get(url+"?"+params?.name+"="+params?.id+`?lang=${language}`);
- return response.data;
- },
-
-
- {
- onError: (error:any) => {
- if(error.response.status == 401 || error.response.status == 403){
- logout()
- navigate("/auth")
-
- }
-
- },
- refetchOnWindowFocus: false,
-
- ...options
-
- }
- );
-}
-
-export default useGetSingleQuery;
diff --git a/src/api/helper/useGetWithFillter.ts b/src/api/helper/useGetWithFillter.ts
deleted file mode 100644
index 448e548..0000000
--- a/src/api/helper/useGetWithFillter.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { useQuery } from 'react-query';
-import useAxios from './useAxios';
-
-export default function useGetQueryPagination(KEY: string | string[], Api: string, options: any = {}) {
- const axios = useAxios();
- const pagination = options;
-
- return useQuery(
- [ KEY], async () => {
- const response = await axios.get(Api + pagination );
- return response.data;
- },
- {
- onError: (error:any) => {
-
- },
-
-
- }
- );
-}
-
diff --git a/src/api/helper/useToggleStatus.ts b/src/api/helper/useToggleStatus.ts
deleted file mode 100644
index 0ef86bb..0000000
--- a/src/api/helper/useToggleStatus.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import { useQueryClient, useMutation } from "react-query";
-import { toast } from "react-toastify";
-import { useTranslation } from "react-i18next";
-import useAxios from "./useAxios";
-
-export const useToggleStatus = (key:any, url:any, object_id:any) => {
- const axios = useAxios();
- const queryClient = useQueryClient();
- const [t] = useTranslation();
-
- return useMutation(
- async ({ id, new_status }:any) => {
- const { data } = await axios.post(url, {
- [object_id]: id,
- new_status,
- });
- return { ...data, id, new_status };
- },
- {
- onSuccess: ({ message, id, new_status }) => {
- toast.success(message || t("toggle_success"));
-
- queryClient.invalidateQueries([key]);
- },
- onError: (err:any) => {
- const message = err?.response?.data?.message || t("toggle_failed");
- toast.error(message);
- // validateSession(err.response);
- },
- }
- );
-};
diff --git a/src/api/helper/useUpdateMutation.ts b/src/api/helper/useUpdateMutation.ts
index 29b258f..195c32f 100644
--- a/src/api/helper/useUpdateMutation.ts
+++ b/src/api/helper/useUpdateMutation.ts
@@ -1,58 +1,36 @@
-import { useQueryClient, useMutation, UseMutationResult } from "react-query";
-import { toast } from "react-toastify";
-import useAxios from "./useAxios";
-import { useTranslation } from "react-i18next";
-import { useParams } from "react-router-dom";
-
-type AxiosResponse = {
- message: string;
- // Add other properties as needed
-};
+import { useMutation, UseMutationResult } from "react-query";
+import useAxios from "./useAxios";
+import { HEADER_KEY } from "../config";
+import { AxiosResponse } from "../../types/Axios";
const useUpdateMutation = (
key: string,
url: string,
- toastMessage: boolean = false,
- method?:string
-): UseMutationResult => {
+ message?: string,
+): UseMutationResult => {
const axios = useAxios();
- const queryClient = useQueryClient();
- const [t] = useTranslation();
- const {id}= useParams()
- return useMutation(
- async (dataToSend) => {
- if(method === "put"){
- const { data } = await axios.put(url+"/"+id, dataToSend );
- return data;
- }else{
- const { data } = await axios.post(url+"/"+id, dataToSend,{
- headers: {
- 'Content-Type': 'multipart/form-data'
- }
- });
- return data;
- }
+ return useMutation(async (dataToSend) => {
+ let request = null;
+ let id = null;
-
-
- },
- {
- onSuccess: (data) => {
- if (toastMessage) {
- toast.success(data.message || t("updated_successfully"));
- }
- queryClient.invalidateQueries([key]);
- },
- onError: (err:any) => {
- const message = err?.response?.data?.message || t("failed_to_update_data");
- toast.error(message);
-
-
- // validateSession(err.response);
- },
+ if (dataToSend instanceof FormData) {
+ dataToSend.append("_method", "PUT");
+ request = dataToSend;
+ id = dataToSend.get("id");
+ } else {
+ request = { ...dataToSend, _method: "PUT" };
+ id = dataToSend?.id;
}
- );
+
+ const { data } = await axios.post(url + `/` + id, request, {
+ headers: {
+ "Content-Type": "multipart/form-data",
+ [HEADER_KEY]: key,
+ },
+ });
+ return data;
+ });
};
export default useUpdateMutation;
diff --git a/src/api/helper/useUpdateMutationById.ts b/src/api/helper/useUpdateMutationById.ts
deleted file mode 100644
index 1d5ed72..0000000
--- a/src/api/helper/useUpdateMutationById.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-import { useQueryClient, useMutation, UseMutationResult } from "react-query";
-import { toast } from "react-toastify";
-import useAxios from "./useAxios";
-import { useTranslation } from "react-i18next";
-import { useParams } from "react-router-dom";
-
-type AxiosResponse = {
- message: string;
- // Add other properties as needed
-};
-
-const useUpdateMutationById = (
- key: string,
- url: string,
- toastMessage: boolean = false,
- method?:string
-): UseMutationResult => {
- const axios = useAxios();
- const queryClient = useQueryClient();
- const [t] = useTranslation();
-
- return useMutation(
- async (dataToSend:any) => {
- if(method === "put"){
- const { data } = await axios.put(url+"/"+dataToSend?.id, dataToSend );
- return data;
- }else{
- const { data } = await axios.post(url+"/"+dataToSend?.id, dataToSend,{
- headers: {
- 'Content-Type': 'multipart/form-data'
- }
- });
- return data;
- }
-
-
-
- },
- {
- onSuccess: (data) => {
- if (toastMessage) {
- toast.success(data.message || t("updated_successfully"));
- }
- queryClient.invalidateQueries([key]);
- },
- onError: (err:any) => {
- const message = err?.response?.data?.message || t("failed_to_update_data");
- toast.error(message);
-
-
- // validateSession(err.response);
- },
- }
- );
-};
-
-export default useUpdateMutationById;
diff --git a/src/api/helper/useUpdateMutationPut.ts b/src/api/helper/useUpdateMutationPut.ts
deleted file mode 100644
index bac1190..0000000
--- a/src/api/helper/useUpdateMutationPut.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import { useQueryClient, useMutation, UseMutationResult } from "react-query";
-import { toast } from "react-toastify";
-import useAxios from "./useAxios";
-import { useTranslation } from "react-i18next";
-import { useParams } from "react-router-dom";
-
-type AxiosResponse = {
- message: string;
- // Add other properties as needed
-};
-
-const useUpdateMutationPost = (
- key: string,
- url: string,
- toastMessage: boolean = true,
- method?:string
-): UseMutationResult => {
- const axios = useAxios();
- const queryClient = useQueryClient();
- const [t] = useTranslation();
- const {id}= useParams()
-
- return useMutation(
- async (dataToSend) => {
-
- const { data } = await axios.post(url+"/"+id, dataToSend,{
- headers: {
- 'Content-Type': 'multipart/form-data'
- }
- });
- return data;
-
- },
- {
- onSuccess: (data) => {
- if (toastMessage) {
- toast.success(data.message || t("updated_successfully"));
- }
- queryClient.invalidateQueries([key]);
- },
- onError: (err:any) => {
- const message = err?.response?.data?.message || t("failed_to_update_data");
- toast.error(message);
-
-
- // validateSession(err.response);
- },
- }
- );
-};
-
-export default useUpdateMutationPost;
diff --git a/src/api/helper/useUploadWithProgress.ts b/src/api/helper/useUploadWithProgress.ts
deleted file mode 100644
index 00db02a..0000000
--- a/src/api/helper/useUploadWithProgress.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-import { useState } from "react";
-import { useQueryClient, useMutation, MutationFunction } from "react-query";
-import { toast } from "react-toastify";
-import useAxios from "./useAxios";
-import { AxiosResponse } from "axios";
-import { useTranslation } from "react-i18next";
-import { QueryStatusEnum } from "../../config/QueryStatus";
-// import { validateSession } from "./validateSession";
-
-interface UploadWithProgressReturnType {
- percentCompleted: number;
- mutate: MutationFunction;
- isLoading: boolean;
- isError: boolean;
- error: unknown;
- isSuccess:boolean,
- value:any,
- status : QueryStatusEnum
-}
-
-export const useUploadWithProgress = (
- key: string,
- url: string
-): UploadWithProgressReturnType => {
- const axios = useAxios();
- const queryClient = useQueryClient();
- const [percentCompleted, setPercentCompleted] = useState(0.0);
- const {t} = useTranslation();
- const mutation = useMutation<
- AxiosResponse,
- unknown,
- any,
- {
- onSuccess: (data: AxiosResponse) => void;
- onError: (error: unknown) => void;
- }
- >(
- async (dataToSend) => {
- setPercentCompleted(0.0);
- const { data } = await axios.post(url, dataToSend, {
- onUploadProgress: (event:any) => {
- console.log();
-
- if (event?.event?.lengthComputable) {
- setPercentCompleted(Math.round((event.loaded * 100) / event.total));
- }
- },
- });
- return data;
- },
- {
- onSuccess: ({ data }) => {
- toast.success(data.message || t("_messages.success.upload"));
- queryClient.invalidateQueries([key]);
- },
- onError: (err:any) => {
- const message =
- err?.response?.data?.message || t("_messages.error.upload");
- toast.error(message);
- // validateSession(err.response);
- },
- }
- );
-
- return {
- percentCompleted,
- value:percentCompleted,
- mutate: mutation.mutate as MutationFunction,
- isLoading: mutation.isLoading,
- isError: mutation.isError,
- error: mutation.error,
- isSuccess :mutation.isSuccess,
- status : mutation.status as QueryStatusEnum
- };
-};
\ No newline at end of file
diff --git a/src/api/setting.ts b/src/api/setting.ts
new file mode 100644
index 0000000..1ac545f
--- /dev/null
+++ b/src/api/setting.ts
@@ -0,0 +1,22 @@
+
+import useGetQuery from "./helper/useGetQuery";
+import useAddMutation from "./helper/useAddMutation"
+import useDeleteMutation from "./helper/useDeleteMutation"
+import useUpdateMutation from "./helper/useUpdateMutation";
+
+const API = {
+ ADD: `restaurant`,
+ GET_ALL: `restaurant`,
+ DELETE: `restaurant`,
+ UPDATE: `restaurant`,
+
+};
+const KEY = "restaurant"
+
+
+export const useGetSetting = (params?:any,option?:any) => useGetQuery(KEY, API.GET_ALL,params);
+
+export const useAddSetting = () => useAddMutation(KEY, API.ADD);
+export const useUpdateSetting = (method?:any) => useUpdateMutation(KEY, API.UPDATE);
+
+export const useDeleteSetting = () =>useDeleteMutation(KEY, API.DELETE);
diff --git a/src/api/utils/PaginationParams.ts b/src/api/utils/PaginationParams.ts
new file mode 100644
index 0000000..6b1f83a
--- /dev/null
+++ b/src/api/utils/PaginationParams.ts
@@ -0,0 +1,7 @@
+export function PaginationParams(location: any) {
+ const searchParams = new URLSearchParams(location?.search);
+ return {
+ page: searchParams.get("page") || "",
+ per_page: searchParams.get("per_page") || "",
+ };
+}
diff --git a/src/api/utils/filterParams.ts b/src/api/utils/filterParams.ts
new file mode 100644
index 0000000..1381ae3
--- /dev/null
+++ b/src/api/utils/filterParams.ts
@@ -0,0 +1,5 @@
+export function filterParams(params: any) {
+ return Object.fromEntries(
+ Object.entries(params ?? {}).filter(([_, value]) => value !== ""),
+ );
+}
diff --git a/src/api/utils/useSearchQuery.ts b/src/api/utils/useSearchQuery.ts
new file mode 100644
index 0000000..2f2f298
--- /dev/null
+++ b/src/api/utils/useSearchQuery.ts
@@ -0,0 +1,16 @@
+import { useState, useEffect } from "react";
+import { useLocation } from "react-router-dom";
+
+function useSearchQuery(paramName: string): [string, (value: string) => void] {
+ const location = useLocation();
+ const [queryValue, setQueryValue] = useState("");
+
+ useEffect(() => {
+ const searchParams = new URLSearchParams(location.search);
+ setQueryValue(searchParams.get(paramName) || "");
+ }, [location, paramName]);
+
+ return [queryValue, setQueryValue];
+}
+
+export default useSearchQuery;
diff --git a/src/enums/Axios.ts b/src/enums/Axios.ts
new file mode 100644
index 0000000..2f966fd
--- /dev/null
+++ b/src/enums/Axios.ts
@@ -0,0 +1,10 @@
+export enum AxiosQueryEnum {
+ GET = "get",
+ POST = "post",
+ DELETE = "delete",
+}
+
+export enum AxiosStatusEnum {
+ VALIDATION = 422,
+ AUTHENTICATED = 401,
+}
diff --git a/src/enums/QueryStatus.ts b/src/enums/QueryStatus.ts
new file mode 100644
index 0000000..31cbdef
--- /dev/null
+++ b/src/enums/QueryStatus.ts
@@ -0,0 +1,5 @@
+export enum QueryStatusEnum {
+ LOADING = "loading",
+ ERROR = "error",
+ SUCCESS = "success",
+}
diff --git a/src/enums/Validation.ts b/src/enums/Validation.ts
new file mode 100644
index 0000000..8dcca3d
--- /dev/null
+++ b/src/enums/Validation.ts
@@ -0,0 +1,7 @@
+export enum Payments {
+ MAX_VALUE = 900000,
+}
+
+export enum Exam {
+ MAX_VALUE = 10000,
+}
diff --git a/src/enums/params.ts b/src/enums/params.ts
new file mode 100644
index 0000000..9a68120
--- /dev/null
+++ b/src/enums/params.ts
@@ -0,0 +1,8 @@
+export enum ParamsEnum {
+ STUDENT_ID = "student_id",
+ COURSE_ID = "course_id",
+ EDUCATION_CLASS_ID = "edu_class_id",
+ SUBJECT_ID = "subject_id",
+ BRANCH_ID = "branch_id",
+ CYCLE_ID = "cycle_id",
+}
diff --git a/src/index.tsx b/src/index.tsx
index 1be6dc6..15a09ab 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -1,7 +1,6 @@
import App from './App';
import 'bootstrap/dist/css/bootstrap.min.css';
import './Styles/AppStyle/Import.scss'
-import 'react-tabs/style/react-tabs.css';
import { createRoot } from "react-dom/client";
import ProviderContainer from './ProviderContainer';
@@ -12,4 +11,4 @@ root.render(
-);
\ No newline at end of file
+);
\ No newline at end of file
diff --git a/src/lib/ReactQueryProvider.tsx b/src/lib/ReactQueryProvider.tsx
index 4b56401..4320c63 100644
--- a/src/lib/ReactQueryProvider.tsx
+++ b/src/lib/ReactQueryProvider.tsx
@@ -1,17 +1,18 @@
-import React from 'react'
-import { QueryClient, QueryClientProvider } from 'react-query'
+import React from "react";
+import { QueryClient, QueryClientProvider } from "react-query";
function QueryProvider({ children }: any) {
- const queryClient = new QueryClient()
+ const queryClient = new QueryClient({
+ defaultOptions: {
+ queries: {
+ refetchOnWindowFocus: false,
+ },
+ },
+ });
return (
-
- {children}
-
-
- )
+ {children}
+ );
}
-export default QueryProvider
-
-
+export default QueryProvider;
diff --git a/src/lib/SocketProvider.tsx b/src/lib/SocketProvider.tsx
deleted file mode 100644
index aa00e9d..0000000
--- a/src/lib/SocketProvider.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-
-import { Socket, io } from 'socket.io-client';
-import { TOKEN_KEY_SOCKET } from '../config/AppKey';
-
-
-export const BASE_URL_SOCKET = 'http://192.168.1.14:8001/';
-var socket :Socket | null = null ;
-
-
-function InitSocket(){
-
-
-
- if (!socket){
- socket = io(BASE_URL_SOCKET , {
- transports:['websocket'],
- autoConnect:true,
- query:{
- token:localStorage.getItem(TOKEN_KEY_SOCKET),
-
- }
- });
- }
-}
-
-export const disconnectSocket = ()=>{
-
- socket?.disconnect();
- socket = null;
-}
-export const getScoket = ()=>{
-
- InitSocket();
- return socket;
-}
-
-
diff --git a/src/lib/state mangment/AuthState.ts b/src/lib/statemangment/AuthState.ts
similarity index 100%
rename from src/lib/state mangment/AuthState.ts
rename to src/lib/statemangment/AuthState.ts
diff --git a/src/lib/state mangment/LayoutPagestate.ts b/src/lib/statemangment/LayoutPagestate.ts
similarity index 100%
rename from src/lib/state mangment/LayoutPagestate.ts
rename to src/lib/statemangment/LayoutPagestate.ts
diff --git a/src/lib/state mangment/Pages/Products.ts b/src/lib/statemangment/Pages/Products.ts
similarity index 100%
rename from src/lib/state mangment/Pages/Products.ts
rename to src/lib/statemangment/Pages/Products.ts
diff --git a/src/lib/state mangment/driver&customer/ModelState.tsx b/src/lib/statemangment/driver&customer/ModelState.tsx
similarity index 100%
rename from src/lib/state mangment/driver&customer/ModelState.tsx
rename to src/lib/statemangment/driver&customer/ModelState.tsx
diff --git a/src/types/Axios.ts b/src/types/Axios.ts
new file mode 100644
index 0000000..c59cb16
--- /dev/null
+++ b/src/types/Axios.ts
@@ -0,0 +1,3 @@
+export type AxiosResponse = {
+ message?: string;
+};
diff --git a/src/types/item.ts b/src/types/item.ts
new file mode 100644
index 0000000..07860c8
--- /dev/null
+++ b/src/types/item.ts
@@ -0,0 +1,49 @@
+export interface Restaurant {
+ id: number;
+ name: string;
+ address: string;
+ logo: string;
+ slogan: {
+ text: string;
+ };
+ contact_info: {
+ phone_number: string;
+ email: string;
+ };
+ attributes: {
+ attribute: string;
+ };
+ video: string;
+ design_system: {
+ primary_color: string;
+ secondry_color: string;
+ };
+ location: {
+ location: string;
+ };
+ images: any[]; // Assuming the images array contains objects, replace 'any' with appropriate type if known
+ categories: Category[];
+ offers: Offer[];
+ uuid: string;
+ created_at: string;
+ updated_at: string;
+}
+
+interface Category {
+ id: number;
+ name: string;
+ image: string;
+ restaurant_id: number;
+ meals_count: number;
+ uuid: string;
+}
+
+interface Offer {
+ id: number;
+ name: string;
+ description: string;
+ image: string;
+ price: number;
+ restaurant_id: number;
+ uuid: string;
+}
diff --git a/src/utils/Array/convertArrayToJsonString.ts b/src/utils/Array/convertArrayToJsonString.ts
new file mode 100644
index 0000000..d6b40af
--- /dev/null
+++ b/src/utils/Array/convertArrayToJsonString.ts
@@ -0,0 +1,13 @@
+interface KeyValue {
+ key: string;
+ value: any;
+ }
+
+ export function convertArrayToJsonString(array: KeyValue[]): string {
+ const jsonObject: { [key: string]: any } = {};
+ array.forEach(item => {
+ jsonObject[item.key] = item.value;
+ });
+ return JSON.stringify(jsonObject);
+ }
+
\ No newline at end of file
diff --git a/src/utils/object/objectToArray.ts b/src/utils/object/objectToArray.ts
new file mode 100644
index 0000000..c75d5a3
--- /dev/null
+++ b/src/utils/object/objectToArray.ts
@@ -0,0 +1,8 @@
+export interface KeyAndValue {
+ key: string;
+ value: any;
+}
+
+export function objectToArray(obj: Record): KeyAndValue[] {
+ return Object.keys(obj).map((key: string) => ({ key, value: obj[key] }));
+}
\ No newline at end of file
diff --git a/vite.config.js b/vite.config.js
new file mode 100644
index 0000000..4e690eb
--- /dev/null
+++ b/vite.config.js
@@ -0,0 +1,11 @@
+import { defineConfig } from 'vite';
+import react from '@vitejs/plugin-react';
+
+export default defineConfig(() => {
+ return {
+ build: {
+ outDir: 'build',
+ },
+ plugins: [react()],
+ };
+});
\ No newline at end of file