- {objectToEdit && data ?
+ {objectToEdit && data?.data && objectToEdit ?
@@ -308,7 +289,7 @@ const ViewProduct = () => {
- {isLoading ? : }
+ {isLoading && objectToEdit ? : }
diff --git a/src/Pages/Products/View/FormikTab/VariableTabs.tsx b/src/Pages/Products/View/FormikTab/VariableTabs.tsx
index fd5625c..578fde1 100644
--- a/src/Pages/Products/View/FormikTab/VariableTabs.tsx
+++ b/src/Pages/Products/View/FormikTab/VariableTabs.tsx
@@ -50,11 +50,17 @@ export const VariableTabs: React.FC = ({ tabKey }) => {
onChange={handleFieldChange('name_de')}
/>
- */}
+
{values?.category_id &&
@@ -79,12 +85,7 @@ export const VariableTabs: React.FC = ({ tabKey }) => {
value={FormikName("description_de")}
onChange={handleFieldChange('description_de')}
/>
-
+
diff --git a/src/Pages/Products/formUtil.ts b/src/Pages/Products/formUtil.ts
index 6dd28bb..975ec2a 100644
--- a/src/Pages/Products/formUtil.ts
+++ b/src/Pages/Products/formUtil.ts
@@ -5,17 +5,18 @@ import { ImageBaseURL } from "../../api/config";
export const getInitialValues = (objectToEdit: any) => {
- if (!objectToEdit || !objectToEdit.products) {
+ if (!objectToEdit || !objectToEdit?.products) {
return {};
}
- const products = objectToEdit?.products.map((item: any) => {
- if (!item || !item.info) {
- return {};
- }
- const formattedData = Object.entries(item?.info).map(([key, value]) => ({
- [`Description`]: key,
- [`key`]: value,
- }));
+ const products = objectToEdit?.products?.map((item: any) => {
+ console.log(item,"item");
+
+
+ const formattedData = item?.info ? Object.entries(item?.info).map(([key, value], index) => ({
+ [`${index}.Description`]: key,
+ [`${index}.key`]: value,
+ })) : [];
+
return ({
@@ -41,6 +42,9 @@ export const getInitialValues = (objectToEdit: any) => {
[`${index}.Description`]: key,
[`${index}.key`]: value,
}));
+ console.log(products,"products");
+ console.log(objectToEdit,"objectToEdit");
+
return {
id:objectToEdit?.id,
diff --git a/src/Pages/Users/Page.tsx b/src/Pages/Users/Page.tsx
new file mode 100644
index 0000000..2d63c17
--- /dev/null
+++ b/src/Pages/Users/Page.tsx
@@ -0,0 +1,46 @@
+
+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 { QueryStatusEnum } from '../../config/QueryStatus'
+import { useTranslation } from 'react-i18next'
+import { useNavigate } from 'react-router-dom'
+import AddButton from '../../Layout/Dashboard/AddButton/AddButton'
+import { useGetUsers } from '../../api/users'
+import SearchField from '../../Layout/Dashboard/SearchField'
+
+function Page() {
+
+ const column =useTableColumns()
+ const {data ,status } = useGetUsers()
+ const [t] = useTranslation()
+ const navigate = useNavigate()
+ const totalRows = data?.meta?.total;
+
+ return (
+ // Pass Status to Layout
+
+
+
+
+
+
+ {/*
navigate('/users/add')}> */}
+
+
+
+
+
+ )
+}
+
+export default Page
+
diff --git a/src/Pages/Users/SendNotifcation/View/AddForm.tsx b/src/Pages/Users/SendNotifcation/View/AddForm.tsx
new file mode 100644
index 0000000..aa95cf8
--- /dev/null
+++ b/src/Pages/Users/SendNotifcation/View/AddForm.tsx
@@ -0,0 +1,42 @@
+
+import { Col, Row } from 'reactstrap';
+import ValidationField from '../../../../Components/ValidationField/ValidationField';
+
+function Form() {
+ const type = [{ lable: "other", value: "other" },{ lable: "product", value: "product"},{ lable: "order", value: "order" }]
+
+
+
+ return (
+
+
+
+
+
+ {/* */}
+
+
+
+
+
+
+
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+ )
+}
+
+export default Form
+
+
+
+
diff --git a/src/Pages/Users/SendNotifcation/View/AddPage.tsx b/src/Pages/Users/SendNotifcation/View/AddPage.tsx
new file mode 100644
index 0000000..02f097d
--- /dev/null
+++ b/src/Pages/Users/SendNotifcation/View/AddPage.tsx
@@ -0,0 +1,79 @@
+import React, { useEffect, useState } from 'react'
+import { getInitialValuesForAdd as getInitialValues, getValidationSchema, getDataToSend } from '../formUtil'
+import { Tab, TabList, TabPanel as TabBody, Tabs } from 'react-tabs'
+import 'react-tabs/style/react-tabs.css';
+import { MdLanguage } from 'react-icons/md'
+import ViewPage from '../../../../Layout/Dashboard/ViewPage';
+import { useTranslation } from 'react-i18next';
+import useNavigateOnSuccess from '../../../../Hooks/useNavigateOnSuccess';
+import { useAddUsers } from '../../../../api/users';
+import Form from './AddForm';
+import { useParams } from 'react-router-dom';
+import { useAddNotification } from '../../../../api/notification';
+
+const AddPage = () => {
+
+
+ const { mutate, isLoading, isSuccess } = useAddNotification()
+ const {id} = useParams()
+ const handleSubmit = (values: any) => {
+
+ const body = {
+ en: values.body_en,
+ ar: values.body_ar,
+ du: values.body_de
+ }
+ const meta = {}
+ const title = {
+ en: values.title_en,
+ ar: values.title_ar,
+ du: values.title_de
+ }
+ const dataToSend = {
+ body: JSON.stringify(body),
+ meta: JSON.stringify(meta),
+ title:JSON.stringify(title),
+ user_ids: [id],
+ type: "other",
+
+ };
+
+
+ mutate(dataToSend);
+ };
+
+ const { t } = useTranslation();
+
+ useNavigateOnSuccess(isSuccess, '/users')
+
+
+
+ const ViewProps = { getInitialValues, getValidationSchema, getDataToSend, handleSubmit };
+
+
+ return (
+
+
+
+
+
+
{t("BasicInfo")}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+
+}
+
+export default AddPage
\ No newline at end of file
diff --git a/src/Pages/Users/SendNotifcation/formUtil.ts b/src/Pages/Users/SendNotifcation/formUtil.ts
new file mode 100644
index 0000000..c0a9188
--- /dev/null
+++ b/src/Pages/Users/SendNotifcation/formUtil.ts
@@ -0,0 +1,73 @@
+
+import * as Yup from "yup";
+import { buildFormData } from "../../../api/helper/buildFormData";
+import moment from 'moment';
+import * as dayjs from 'dayjs'
+
+
+export const getInitialValues = (objectToEdit: any | null = null): any => {
+ //@ts-ignore
+ return {
+ id: objectToEdit?.id ,
+ name: objectToEdit?.name ,
+ email: objectToEdit?.email ,
+ type: objectToEdit?.type ,
+ avatar: objectToEdit?.avatar ,
+
+ };
+};
+
+export const getInitialValuesForAdd = (objectToEdit: any | null = null): any => {
+ return {
+ body_en: "" ,
+ body_ar: "" ,
+ body_de: "" ,
+ // meta: "" ,
+ title_en: "" ,
+ title_ar: "" ,
+ title_de: "" ,
+ user_ids:[],
+ // type: "" ,
+
+ };
+};
+
+export const getValidationSchema = (editMode: boolean = false): Yup.Schema => {
+ // Validate input
+ return Yup.object().shape({
+ body_en: Yup.string().required('Required'),
+ body_ar: Yup.string().required('Required'),
+ body_de: Yup.string().required('Required'),
+ // meta: Yup.string().required('Required'),
+
+ title_en: Yup.string().required('Required'),
+ title_ar: Yup.string().required('Required'),
+ title_de: Yup.string().required('Required'),
+ // type: Yup.string().required('Required'),
+
+
+
+
+ });
+};
+
+
+
+export const getDataToSend = (values: any): FormData => {
+ const data = { ...values };
+
+
+ const formData = new FormData();
+ buildFormData(formData, data);
+ return formData;
+};
+
+export const ChangeDataToPrint = (data: any) => {
+
+ let new_array = data
+ for (let i = 0; i < data.length; i++) {
+ new_array[i]['status'] = !data[i]['deleted_at'] ? 'available' : 'unavailable'
+ delete new_array[i]['deleted_at']
+ }
+ return new_array
+}
\ No newline at end of file
diff --git a/src/Pages/Users/View/AddForm.tsx b/src/Pages/Users/View/AddForm.tsx
new file mode 100644
index 0000000..6ca365c
--- /dev/null
+++ b/src/Pages/Users/View/AddForm.tsx
@@ -0,0 +1,31 @@
+
+import { Col, Row } from 'reactstrap';
+import ValidationField from '../../../Components/ValidationField/ValidationField';
+
+function Form() {
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+export default Form
+
+
+
+
diff --git a/src/Pages/Users/View/AddPage.tsx b/src/Pages/Users/View/AddPage.tsx
new file mode 100644
index 0000000..9d6d788
--- /dev/null
+++ b/src/Pages/Users/View/AddPage.tsx
@@ -0,0 +1,57 @@
+import React, { useEffect, useState } from 'react'
+import { getInitialValuesForAdd as getInitialValues, getValidationSchema, getDataToSend } from '../formUtil'
+import { Tab, TabList, TabPanel as TabBody, Tabs } from 'react-tabs'
+import 'react-tabs/style/react-tabs.css';
+import { MdLanguage } from 'react-icons/md'
+import ViewPage from '../../../Layout/Dashboard/ViewPage';
+import { useTranslation } from 'react-i18next';
+import useNavigateOnSuccess from '../../../Hooks/useNavigateOnSuccess';
+import { useAddUsers } from '../../../api/users';
+import Form from './AddForm';
+
+const AddPage = () => {
+
+
+ const { mutate, isLoading, isSuccess } = useAddUsers()
+ const handleSubmit = (values: any) => {
+
+
+mutate(values)
+
+ };
+
+ const { t } = useTranslation();
+
+ useNavigateOnSuccess(isSuccess, '/users')
+
+
+
+ const ViewProps = { getInitialValues, getValidationSchema, getDataToSend, handleSubmit };
+
+
+ return (
+
+
+
+
+
+
{t("BasicInfo")}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+
+}
+
+export default AddPage
\ No newline at end of file
diff --git a/src/Pages/Users/formUtil.ts b/src/Pages/Users/formUtil.ts
new file mode 100644
index 0000000..581c2f5
--- /dev/null
+++ b/src/Pages/Users/formUtil.ts
@@ -0,0 +1,60 @@
+
+import * as Yup from "yup";
+import { buildFormData } from "../../api/helper/buildFormData";
+import moment from 'moment';
+import * as dayjs from 'dayjs'
+
+
+export const getInitialValues = (objectToEdit: any | null = null): any => {
+ //@ts-ignore
+ return {
+ id: objectToEdit?.id ,
+ name: objectToEdit?.name ,
+ email: objectToEdit?.email ,
+ type: objectToEdit?.type ,
+ avatar: objectToEdit?.avatar ,
+
+ };
+};
+
+export const getInitialValuesForAdd = (objectToEdit: any | null = null): any => {
+ return {
+ name: null ,
+ email: null ,
+ type: null ,
+ avatar: null ,
+
+ };
+};
+
+export const getValidationSchema = (editMode: boolean = false): Yup.Schema => {
+ // Validate input
+ return Yup.object().shape({
+ name: Yup.string().required('Required'),
+ email: Yup.string().required('Required'),
+ type: Yup.string().required('Required'),
+ avatar: Yup.string().required('Required'),
+
+ });
+};
+
+
+
+export const getDataToSend = (values: any): FormData => {
+ const data = { ...values };
+
+
+ const formData = new FormData();
+ buildFormData(formData, data);
+ return formData;
+};
+
+export const ChangeDataToPrint = (data: any) => {
+
+ let new_array = data
+ for (let i = 0; i < data.length; i++) {
+ new_array[i]['status'] = !data[i]['deleted_at'] ? 'available' : 'unavailable'
+ delete new_array[i]['deleted_at']
+ }
+ return new_array
+}
\ No newline at end of file
diff --git a/src/Pages/Users/useTableColumns.tsx b/src/Pages/Users/useTableColumns.tsx
new file mode 100644
index 0000000..cfb8665
--- /dev/null
+++ b/src/Pages/Users/useTableColumns.tsx
@@ -0,0 +1,99 @@
+
+import React, { useMemo } from "react";
+import { useTranslation } from "react-i18next";
+import Actions from "../../Components/Ui/tables/Actions";
+import ColumnsImage from "../../Components/Columns/ColumnsImage";
+import { useNavigate } from "react-router-dom";
+import { useDeleteUsers, useUpdateUsers } from "../../api/users";
+import { Switch } from "antd";
+import { MdEmail } from "react-icons/md";
+import { useModalState } from "../../zustand/Modal";
+
+
+const useTableColumns: any = () => {
+ const [t] = useTranslation();
+ const deleteMutation = useDeleteUsers()
+ const navigate = useNavigate()
+
+ const { mutate: update_status } = useUpdateUsers("put")
+ const onChange = (checked: boolean, row: any) => {
+ console.log(`switch to ${checked}`);
+ update_status({
+ id: row.id,
+ status: checked ? "active" : "suspended"
+
+ })
+ };
+
+
+ return useMemo(
+ () => [
+
+
+ {
+ name: t("avatar"),
+ sortable: false,
+ center: "true",
+ cell: (row: any) => {
+ let str = row?.avatar;
+ str = str?.replace(`public`, "/storage") ?? "";
+ return
+ }
+
+ },
+ {
+ name: t("name"),
+ sortable: false,
+ center: "true",
+ cell: (row: any) => row?.name
+ },
+ {
+ name: t("email"),
+ sortable: false,
+ center: "true",
+ cell: (row: any) => row?.email
+ },
+ {
+ name: t("type"),
+ sortable: false,
+ center: "true",
+ cell: (row: any) => row?.type
+ },
+ {
+ name: t("status"),
+ sortable: false,
+ center: "true",
+ cell: (row: any) => {
+ let status = row?.status;
+ return onChange(value, row)} />;
+
+ }
+
+ },
+
+ {
+ name: "#",
+ sortable: false,
+ center: true,
+ cell: (row: any) => (
+ navigate(`/users/${row.id}`)}
+ showView={false}
+ // onDelete={() => deleteMutation.mutate({ id: row.id })}
+ showDelete={false}
+ >
+ navigate(`/users/${row.id}`)} className="cursor-pointer m-2" size={25} />
+
+
+ ),
+ },
+
+ ],
+ [t]
+ );
+};
+
+export default useTableColumns;
+
diff --git a/src/Pages/order/Edit/EditForm.tsx b/src/Pages/order/Edit/EditForm.tsx
index a8c69e4..17697c9 100644
--- a/src/Pages/order/Edit/EditForm.tsx
+++ b/src/Pages/order/Edit/EditForm.tsx
@@ -28,7 +28,7 @@ function Form() {
-
+
diff --git a/src/Pages/order/Edit/EditPage.tsx b/src/Pages/order/Edit/EditPage.tsx
index 34024c6..fbff27b 100644
--- a/src/Pages/order/Edit/EditPage.tsx
+++ b/src/Pages/order/Edit/EditPage.tsx
@@ -25,7 +25,12 @@ const EditPage = () => {
const { id } = useParams();
const { data, isLoading } = useGetOneOrder({id: id })
const handleSubmit = (values:any)=>{
- return mutate(values);
+
+ console.log(values?.deliviration_estimated_time?.format('YYYY-MM-DD HH:mm:ss'));
+ return mutate({
+ ...values,
+ deliviration_estimated_time:values?.deliviration_estimated_time?.format('YYYY-MM-DD HH:mm:ss')
+ });
}
useNavigateOnSuccess(isSuccess , '/order')
diff --git a/src/Routes.tsx b/src/Routes.tsx
index 1ce2e9f..0d6dea7 100644
--- a/src/Routes.tsx
+++ b/src/Routes.tsx
@@ -1,7 +1,7 @@
import { ReactNode } from "react";
// Icons Import
-import { FaCartArrowDown, FaHome, FaProductHunt, FaRegImages } from "react-icons/fa"
+import { FaCartArrowDown, FaHome, FaProductHunt, FaRegImages, FaUser } from "react-icons/fa"
import { BiSolidCategory } from "react-icons/bi";
import { BiSolidCoupon } from "react-icons/bi";
@@ -30,6 +30,15 @@ import SliderPage from "./Pages/Slider/Page";
import AddSliderPage from "./Pages/Slider/View/AddPage";
import EditSlider from "./Pages/Slider/View/EditPage";
+import UsersPage from "./Pages/Users/Page";
+import AddUsersPage from "./Pages/Users/View/AddPage";
+
+import AddUsersNotifactionPage from "./Pages/Users/SendNotifcation/View/AddPage";
+
+import NotificationPage from "./Pages/Notifcation/Page";
+import AddNotificationPage from "./Pages/Notifcation/View/AddPage";
+import { MdEmail } from "react-icons/md";
+
interface RoutesLinksType {
@@ -143,7 +152,35 @@ export const RoutesLinks: RoutesLinksType[] = [
hidden:true
},
+ {
+ name: "users",
+ element: ,
+ icon: ,
+ href: "/users",
+ },
+ {
+ href: "/users/add",
+ element: ,
+ hidden:true
+ },
+
+ {
+ href: "/users/:id",
+ element: ,
+ hidden:true
+ }
+ , {
+ name: "notification",
+ element: ,
+ icon: ,
+ href: "/notification",
+ },
+ {
+ href: "/notification/add",
+ element: ,
+ hidden:true
+ },
]
\ No newline at end of file
diff --git a/src/api/helper/useAddMutation.ts b/src/api/helper/useAddMutation.ts
index aafaa05..0f60207 100644
--- a/src/api/helper/useAddMutation.ts
+++ b/src/api/helper/useAddMutation.ts
@@ -9,7 +9,7 @@ type AxiosResponse = {
success:true
};
-function useAddMutation(key: string, url: string): UseMutationResult {
+function useAddMutation(key: string, url: string): UseMutationResult {
const axios = useAxios();
const [t] = useTranslation();
const queryClient = useQueryClient();
@@ -26,7 +26,7 @@ function useAddMutation(key: string, url: string): UseMutationResult {
queryClient.invalidateQueries([key]);
- toast.success(data.message || t("Add Successful"));
+ toast.success(data.message || t("added_uccessful"));
},
onError: (error:any) => {
const message = error?.response?.data?.message || t("failed_to_add_data");
diff --git a/src/api/notification.ts b/src/api/notification.ts
new file mode 100644
index 0000000..1ccd2e3
--- /dev/null
+++ b/src/api/notification.ts
@@ -0,0 +1,23 @@
+
+import useGetQueryPagination from "./helper/ueGetPagination";
+import useAddMutation from "./helper/useAddMutation"
+import useDeleteMutation from "./helper/useDeleteMutation"
+import useGetOneQuery from "./helper/useGetOneQuery";
+
+const API = {
+ ADD: `notification`,
+ GET_ALL: `notification`,
+ DELETE: `notification`,
+
+};
+const KEY = "notification"
+
+
+export const useGetNotification = (params?:any) => useGetQueryPagination(KEY, API.GET_ALL,params);
+export const useGetOnenotification = (params?:any) => useGetOneQuery(KEY, API.GET_ALL,params);
+
+export const useAddNotification = () => useAddMutation(KEY, API.ADD);
+
+export const useDeleteNotification = () =>useDeleteMutation(KEY, API.DELETE);
+
+
diff --git a/src/api/users.ts b/src/api/users.ts
index f72957f..b6bb803 100644
--- a/src/api/users.ts
+++ b/src/api/users.ts
@@ -5,12 +5,13 @@ import useDeleteMutation from "./helper/useDeleteMutation"
import useGetOneQuery from "./helper/useGetOneQuery";
import useGetQuery from "./helper/useGetQuery"
import useUpdateMutation from "./helper/useUpdateMutation";
+import useUpdateMutationById from "./helper/useUpdateMutationById";
const API = {
ADD: `user`,
- GET_ALL: `user`,
+ GET_ALL: `user?notOfType=admin`,
DELETE: `user`,
- UPDATE: `user`,
+ UPDATE: `user/updateStatus`,
};
const KEY = "User"
@@ -20,6 +21,8 @@ export const useGetUsers = (params?:any) => useGetQueryPagination(KEY, API.GET_A
export const useGetOneUser = (params?:any) => useGetOneQuery(KEY, API.GET_ALL,params);
export const useAddUsers = () => useAddMutation(KEY, API.ADD);
-export const useUpdateUsers = () => useUpdateMutation(KEY, API.UPDATE);
+export const useUpdateUsers = (method?:string) => useUpdateMutationById(KEY, API.UPDATE,true,method);
export const useDeleteUsers = () =>useDeleteMutation(KEY, API.DELETE);
+
+
diff --git a/src/lib/state mangment/dist/AuthState.js b/src/lib/state mangment/dist/AuthState.js
deleted file mode 100644
index 2857812..0000000
--- a/src/lib/state mangment/dist/AuthState.js
+++ /dev/null
@@ -1,69 +0,0 @@
-"use strict";
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
-};
-exports.__esModule = true;
-var zustand_1 = require("zustand");
-var AppKey_1 = require("../../config/AppKey");
-var useAuthState = zustand_1.create(function (set) {
- var storedUser = localStorage.getItem(AppKey_1.USER_KEY);
- var storedToken = localStorage.getItem(AppKey_1.TOKEN_KEY);
- var initialUser = (storedUser && storedUser !== 'undefined') ? JSON.parse(storedUser) : null;
- return {
- user: initialUser,
- isAuthenticated: !!storedToken,
- token: storedToken,
- login: function (userData) { return __awaiter(void 0, void 0, void 0, function () {
- return __generator(this, function (_a) {
- console.log(userData);
- localStorage.setItem(AppKey_1.TOKEN_KEY, userData.token);
- localStorage.setItem(AppKey_1.USER_KEY, JSON.stringify(userData.admin));
- set(function (state) { return ({ user: userData.admin, isAuthenticated: true, token: userData.token }); });
- return [2 /*return*/];
- });
- }); },
- logout: function () { return __awaiter(void 0, void 0, void 0, function () {
- return __generator(this, function (_a) {
- localStorage.removeItem(AppKey_1.TOKEN_KEY);
- localStorage.removeItem(AppKey_1.TOKEN_KEY_SOCKET);
- localStorage.removeItem(AppKey_1.USER_KEY);
- set(function (state) { return ({ user: null, isAuthenticated: false, token: null }); });
- return [2 /*return*/];
- });
- }); }
- };
-});
-exports["default"] = useAuthState;
diff --git a/src/lib/state mangment/dist/LayoutPagestate.js b/src/lib/state mangment/dist/LayoutPagestate.js
deleted file mode 100644
index 7aa3c73..0000000
--- a/src/lib/state mangment/dist/LayoutPagestate.js
+++ /dev/null
@@ -1,23 +0,0 @@
-"use strict";
-exports.__esModule = true;
-exports.usePageState = void 0;
-var zustand_1 = require("zustand");
-exports.usePageState = zustand_1.create(function (set) { return ({
- isOpenAddModel: false,
- isOpenEditModel: false,
- objectToEdit: null,
- isThemChanged: false,
- setThemChange: function () {
- return set(function (state) { return ({ isThemChanged: !state.isThemChanged }); });
- },
- setIsOpenAddModel: function () {
- return set(function (state) { return ({ isOpenAddModel: !state.isOpenAddModel }); });
- },
- setIsOpenEditModel: function () {
- return set(function (state) { return ({ isOpenEditModel: !state.isOpenEditModel }); });
- },
- CloseAllModal: function () {
- return set(function (state) { return ({ isOpenAddModel: false, isOpenEditModel: false }); });
- },
- setObjectToEdit: function (data) { return set(function () { return ({ objectToEdit: data }); }); }
-}); });
diff --git a/src/lib/state mangment/driver&customer/dist/ModelState.js b/src/lib/state mangment/driver&customer/dist/ModelState.js
deleted file mode 100644
index faa582c..0000000
--- a/src/lib/state mangment/driver&customer/dist/ModelState.js
+++ /dev/null
@@ -1,22 +0,0 @@
-"use strict";
-exports.__esModule = true;
-exports.useCommonModelState = void 0;
-var zustand_1 = require("zustand");
-exports.useCommonModelState = zustand_1.create(function (set) { return ({
- isOpenBlock: false,
- isOpenGift: false,
- isOpenUnBlock: false,
- setIsopenBlock: function () {
- return set(function (state) { return ({ isOpenBlock: !state.isOpenBlock }); });
- },
- setIsopenUnBlock: function () {
- return set(function (state) { return ({ isOpenUnBlock: !state.isOpenUnBlock }); });
- },
- setIsopenGift: function () {
- return set(function (state) { return ({ isOpenGift: !state.isOpenGift }); });
- },
- setObjectId: function (data) {
- return set(function (state) { return ({ objectID: data }); });
- },
- objectID: 0
-}); });
diff --git a/src/translate/ar.json b/src/translate/ar.json
index cda035d..32360ea 100644
--- a/src/translate/ar.json
+++ b/src/translate/ar.json
@@ -128,9 +128,22 @@
"unique_error_names": "اسم فريد لكل سمة مطلوب",
"deliviration_estimated_time": "الوقت المقدر للتسليم",
"delivery_link": "رابط التسليم",
- "failed_to_add_data": "فشل في إضافة البيانات",
"delete_are_you_sure": "هل أنت متأكد أنك تريد الحذف؟",
- "yes_delete_it": "نعم، احذفه"
+ "yes_delete_it": "نعم، احذفه",
+ "notification": "إشعار",
+ "users": "المستخدمون",
+ "body": "جسم",
+ "body_en": "الجسم (الإنجليزية)",
+ "body_ar": "الجسم (العربية)",
+ "body_de": "الجسم (الألمانية)",
+ "title_en": "العنوان (الإنجليزية)",
+ "title_ar": "العنوان (العربية)",
+ "title_de": "العنوان (الألمانية)",
+ "avatar": "الصورة الرمزية",
+ "added_successful": "تمت الإضافة بنجاح",
+ "failed_to_add_data": "فشلت عملية الإضافة",
+ "deleted_successfully": "تم الحذف بنجاح",
+ "updated_successfully": "تم التحديث بنجاح"
diff --git a/src/translate/de.json b/src/translate/de.json
index f8567ba..c3d853c 100644
--- a/src/translate/de.json
+++ b/src/translate/de.json
@@ -124,10 +124,23 @@
"unique_error_names": "Einzigartiger Name für jede Eigenschaft ist erforderlich",
"deliviration_estimated_time": "Voraussichtliche Lieferzeit",
"delivery_link": "Lieferlink",
- "failed_to_add_data": "Fehler beim Hinzufügen von Daten",
"delete_are_you_sure": "Möchten Sie wirklich löschen?",
"yes_delete_it": "Ja, löschen",
- "cancel": "Abbrechen"
+ "cancel": "Abbrechen",
+ "notification": "Benachrichtigung",
+ "users": "Benutzer",
+ "body": "Körper",
+ "body_en": "Körper (Englisch)",
+ "body_ar": "Körper (Arabisch)",
+ "body_de": "Körper (Deutsch)",
+ "title_en": "Titel (Englisch)",
+ "title_ar": "Titel (Arabisch)",
+ "title_de": "Titel (Deutsch)",
+ "avatar": "Avatar",
+ "added_successful": "Erfolgreich hinzugefügt",
+ "failed_to_add_data": "Daten konnten nicht hinzugefügt werden",
+ "deleted_successfully": "Erfolgreich gelöscht",
+ "updated_successfully": "Erfolgreich aktualisiert"
diff --git a/src/translate/en.json b/src/translate/en.json
index 133ec7f..cb06792 100644
--- a/src/translate/en.json
+++ b/src/translate/en.json
@@ -124,11 +124,24 @@
"unique_error_names": "Unique name for each attribute is required",
"deliviration_estimated_time": "Delivery Estimated Time",
"delivery_link": "Delivery Link",
- "failed_to_add_data": "Failed to add data",
"delete_are_you_sure": "Are you sure you want to delete?",
"yes_delete_it": "Yes, delete it",
"cancel": "Cancel",
- "required_error":"required_error"
+ "required_error":"required_error",
+ "notification": "Notification",
+ "users": "Users",
+ "body": "Body",
+ "body_en": "Body (English)",
+ "body_ar": "Body (Arabic)",
+ "body_de": "Body (German)",
+ "title_en": "Title (English)",
+ "title_ar": "Title (Arabic)",
+ "title_de": "Title (German)",
+ "avatar": "Avatar",
+ "added_successful": "added successful",
+ "failed_to_add_data": "Failed to add data",
+ "deleted_successfully": "deleted successfully",
+ "updated_successfully": "updated successfully"
}
\ No newline at end of file
diff --git a/src/translate/text b/src/translate/text
index 5398dcf..179925a 100644
--- a/src/translate/text
+++ b/src/translate/text
@@ -1,3 +1,6 @@
-BasicInfo
-attributes
-Add New Attribute
\ No newline at end of file
+{
+added_uccessful
+failed_to_add_data
+deleted_successfully
+updated_successfully
+}
\ No newline at end of file
diff --git a/src/utils/Array/filterUndefinedAndEmpty.ts b/src/utils/Array/filterUndefinedAndEmpty.ts
new file mode 100644
index 0000000..cb6229e
--- /dev/null
+++ b/src/utils/Array/filterUndefinedAndEmpty.ts
@@ -0,0 +1,5 @@
+const filterUndefinedAndEmpty = (array:any) => {
+ return array.filter((data:any) => data !== undefined && Object.keys(data).length !== 0);
+ };
+
+ export default filterUndefinedAndEmpty;
\ No newline at end of file
diff --git a/src/zustand/Modal.ts b/src/zustand/Modal.ts
new file mode 100644
index 0000000..97cd522
--- /dev/null
+++ b/src/zustand/Modal.ts
@@ -0,0 +1,15 @@
+import {create} from 'zustand'
+
+interface ModalState {
+ isOpen: boolean;
+ setIsOpen: (value:boolean) => void;
+
+}
+
+
+export const useModalState = create((set) => ({
+ isOpen: false,
+ setIsOpen: () =>
+ set((state) => ({ isOpen: !state.isOpen })),
+
+}));