diff --git a/src/Components/ValidationField/View/SearchField.tsx b/src/Components/ValidationField/View/SearchField.tsx index 35bc235..51f954d 100644 --- a/src/Components/ValidationField/View/SearchField.tsx +++ b/src/Components/ValidationField/View/SearchField.tsx @@ -8,14 +8,14 @@ const SearchField = ({ name, label, placeholder, isDisabled, searchBy, option, i const [searchQuery, setSearchQuery] = useState(''); const navigate = useNavigate() useEffect(() => { - const searchParams = new URLSearchParams(window.location.search); + const searchParams = new URLSearchParams(window?.location?.search); setSearchQuery(searchParams?.get('search') || ''); }, []); const SelecthandleChange = (value: { value: string; label: React.ReactNode }) => { - formik.setFieldValue(name, value); + formik?.setFieldValue(name, value); }; const SearchHandleChange = (value:any) => { diff --git a/src/Layout/Dashboard/AddButton/Add_Button.scss b/src/Layout/Dashboard/AddButton/Add_Button.scss index 22b4f3b..6cd01ee 100644 --- a/src/Layout/Dashboard/AddButton/Add_Button.scss +++ b/src/Layout/Dashboard/AddButton/Add_Button.scss @@ -3,7 +3,8 @@ border: 2px solid var(--primary); background-color: var(--primary); border-radius: 0.5vw; - padding:.5vw 1vw; + height: 40px; + width: 70px; font-size: 1vw ; display: flex; justify-content: center; align-items: center; box-shadow: 2px 2px 7px 0 var(--primary); diff --git a/src/Layout/Dashboard/AddButton/dist/AddButton.js b/src/Layout/Dashboard/AddButton/dist/AddButton.js new file mode 100644 index 0000000..379cac6 --- /dev/null +++ b/src/Layout/Dashboard/AddButton/dist/AddButton.js @@ -0,0 +1,28 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +exports.__esModule = true; +var react_1 = require("react"); +require("./Add_Button.scss"); +var react_i18next_1 = require("react-i18next"); +var AddButton = function (props) { + var t = react_i18next_1.useTranslation()[0]; + return (react_1["default"].createElement("div", __assign({ className: 'Add_Button' }, props), + react_1["default"].createElement("button", null, + react_1["default"].createElement("span", null, + react_1["default"].createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: 24, height: 24 }, + react_1["default"].createElement("path", { fill: "none", d: "M0 0h24v24H0z" }), + react_1["default"].createElement("path", { fill: "currentColor", d: "M11 11V5h2v6h6v2h-6v6h-2v-6H5v-2z" })), + " ", + t("Add"))))); +}; +exports["default"] = AddButton; diff --git a/src/Layout/Dashboard/AddButton/dist/AddButtonLayout.js b/src/Layout/Dashboard/AddButton/dist/AddButtonLayout.js new file mode 100644 index 0000000..26a645c --- /dev/null +++ b/src/Layout/Dashboard/AddButton/dist/AddButtonLayout.js @@ -0,0 +1,25 @@ +"use strict"; +exports.__esModule = true; +var react_1 = require("react"); +require("./Add_Button.scss"); +var react_i18next_1 = require("react-i18next"); +var LayoutPagestate_1 = require("../../../lib/state mangment/LayoutPagestate"); +var AddButtonLayout = function (_a) { + var haveAddModal = _a.haveAddModal; + var _b = LayoutPagestate_1.usePageState(), setIsOpenAddModel = _b.setIsOpenAddModel, setObjectToEdit = _b.setObjectToEdit; + var t = react_i18next_1.useTranslation()[0]; + return (react_1["default"].createElement("div", { className: 'Add_Button', onClick: function () { + if (haveAddModal) { + setIsOpenAddModel(); + } + setObjectToEdit(null); + } }, + react_1["default"].createElement("button", null, + react_1["default"].createElement("span", null, + react_1["default"].createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: 24, height: 24 }, + react_1["default"].createElement("path", { fill: "none", d: "M0 0h24v24H0z" }), + react_1["default"].createElement("path", { fill: "currentColor", d: "M11 11V5h2v6h6v2h-6v6h-2v-6H5v-2z" })), + " ", + t("Add"))))); +}; +exports["default"] = AddButtonLayout; diff --git a/src/Layout/Dashboard/AddButton/dist/Add_Button.css b/src/Layout/Dashboard/AddButton/dist/Add_Button.css new file mode 100644 index 0000000..054290f --- /dev/null +++ b/src/Layout/Dashboard/AddButton/dist/Add_Button.css @@ -0,0 +1,33 @@ +.Add_Button button { + border: 2px solid var(--primary); + background-color: var(--primary); + border-radius: 0.5vw; + font-size: 1vw; + display: flex; + justify-content: center; + align-items: center; + box-shadow: 2px 2px 7px 0 var(--primary); + height: 40px; + width:70px + +} +.Add_Button button span { + display: flex; + align-items: center; + color: var(--bg); + font-weight: bold; +} +.Add_Button button:hover { + background-color: var(--primary); +} + +@media screen and (max-width: 700px) { + .Add_Button button { + font-size: 2vw !important; + } +} +@media screen and (max-width: 470px) { + .Add_Button button { + font-size: 3vw !important; + } +} \ No newline at end of file diff --git a/src/Layout/Dashboard/AddButton/dist/dist/AddButton.dev.js b/src/Layout/Dashboard/AddButton/dist/dist/AddButton.dev.js new file mode 100644 index 0000000..09d681a --- /dev/null +++ b/src/Layout/Dashboard/AddButton/dist/dist/AddButton.dev.js @@ -0,0 +1,45 @@ +"use strict"; + +var __assign = void 0 && (void 0).__assign || function () { + __assign = Object.assign || function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + + for (var p in s) { + if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + } + + return t; + }; + + return __assign.apply(this, arguments); +}; + +exports.__esModule = true; + +var react_1 = require("react"); + +require("./Add_Button.scss"); + +var react_i18next_1 = require("react-i18next"); + +var AddButton = function AddButton(props) { + var t = react_i18next_1.useTranslation()[0]; + return react_1["default"].createElement("div", __assign({ + className: 'Add_Button' + }, props), react_1["default"].createElement("button", null, react_1["default"].createElement("span", null, react_1["default"].createElement("svg", { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24", + width: 24, + height: 24 + }, react_1["default"].createElement("path", { + fill: "none", + d: "M0 0h24v24H0z" + }), react_1["default"].createElement("path", { + fill: "currentColor", + d: "M11 11V5h2v6h6v2h-6v6h-2v-6H5v-2z" + })), " ", t("Add")))); +}; + +exports["default"] = AddButton; \ No newline at end of file diff --git a/src/Layout/Dashboard/SearchField.tsx b/src/Layout/Dashboard/SearchField.tsx new file mode 100644 index 0000000..333146d --- /dev/null +++ b/src/Layout/Dashboard/SearchField.tsx @@ -0,0 +1,47 @@ +import { Input } from 'antd'; +import { SearchProps } from 'antd/es/input' +import { useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'; +const { Search } = Input; + +const SearchField = ({searchBy } : any) => { + const navigate = useNavigate() + const [searchParams,] = useSearchParams(); + const location =useLocation() + const {t} = useTranslation(); + console.log(searchBy,"searchBy"); + + + const [searchValue, setSearchValue] = useState(searchParams.get('search')|| ""); + + const onSearch: SearchProps['onSearch'] = (value, _e, info) => { + // console.log(value); + + navigate(`${location?.pathname}?${searchBy ?? "search"}=${value}`, { replace: true }); + } + const onChange = (e :any) => { + setSearchValue(e.target.value); + + } + + + return ( +
+ + +
+ ) +} + +export default SearchField \ No newline at end of file diff --git a/src/Pages/Categories/Page.tsx b/src/Pages/Categories/Page.tsx index 4935e9f..80913ea 100644 --- a/src/Pages/Categories/Page.tsx +++ b/src/Pages/Categories/Page.tsx @@ -5,12 +5,11 @@ import DashHeader from '../../Layout/Dashboard/DashHeader' import LyTable from '../../Layout/Dashboard/LyTable' import useTableColumns from './useTableColumns' import { QueryStatusEnum } from '../../config/QueryStatus' -import { useGetProduct } from '../../api/product' -import { Button } from 'antd' import { useTranslation } from 'react-i18next' import { useNavigate } from 'react-router-dom' import AddButton from '../../Layout/Dashboard/AddButton/AddButton' import { useGetCategories } from '../../api/Categories' +import SearchField from '../../Layout/Dashboard/SearchField' function Page() { @@ -24,7 +23,11 @@ function Page() { // Pass Status to Layout - navigate('/categories/add')}> +
+ + + navigate('/categories/add')}> +
+ - navigate('/coupon/add')}> +
+ + + navigate('/coupon/add')}> +
+ {/* */} - + diff --git a/src/Pages/Coupon/View/EditForm.tsx b/src/Pages/Coupon/View/EditForm.tsx index 48294bf..e9ec62d 100644 --- a/src/Pages/Coupon/View/EditForm.tsx +++ b/src/Pages/Coupon/View/EditForm.tsx @@ -41,7 +41,7 @@ function Form() { {/* */} - + diff --git a/src/Pages/Products/ProductsPage.tsx b/src/Pages/Products/ProductsPage.tsx index 0d111f6..e7f7be6 100644 --- a/src/Pages/Products/ProductsPage.tsx +++ b/src/Pages/Products/ProductsPage.tsx @@ -9,6 +9,7 @@ import { useGetProduct } from '../../api/product' import { useTranslation } from 'react-i18next' import { useNavigate } from 'react-router-dom' import AddButton from '../../Layout/Dashboard/AddButton/AddButton' +import SearchField from '../../Layout/Dashboard/SearchField' function ProductsPage() { @@ -21,7 +22,11 @@ function ProductsPage() { return ( - navigate('/products/add')}> +
+ + + navigate('/products/add')}> +
{ const formikContext = useFormikContext(); const { values, handleChange } = formikContext; const [width, setWidth] = useState(window.innerWidth); + // const {setTapItems,TapItems,TapItemValues,setTapItemValues} = useProductVarianState(state => state) + // useEffect(() => { + // setTapItems(items) + // }, [items]) + // useEffect(() => { + // setTapItemValues(values?.variable) + // }, [values?.variable]) + + + const [t] = useTranslation() const handleAdd = () => { const newKey = `${items.length + 1}`; diff --git a/src/Pages/Products/View/FormikTab/VariableTabs.tsx b/src/Pages/Products/View/FormikTab/VariableTabs.tsx index ddecc9f..af72a00 100644 --- a/src/Pages/Products/View/FormikTab/VariableTabs.tsx +++ b/src/Pages/Products/View/FormikTab/VariableTabs.tsx @@ -5,7 +5,6 @@ import { FormItem } from './FormItem'; import { useFormikContext, FormikValues } from 'formik'; import File from './Field/File'; import MaltyFile from './Field/FileImage'; -import Select from './Field/Select'; import ObjectField from './Field/Object'; import Atteibute from './Field/Atteibute'; import { useTranslation } from 'react-i18next'; @@ -25,45 +24,8 @@ export const VariableTabs: React.FC = ({ tabKey }) => { handleChange(`variable.${tabKey}.${fieldName}`)(e); // Prepend "variable" }; const FormikName = (FormikFieldname: any) => values?.variable?.[tabKey]?.[FormikFieldname]; - const SelectedCategoriesAttribute = [ - { - name: "color", - id: 1, - data: [ - { - value: 1, - label: "red" - }, - { - value: 2, - label: "green" - }, - { - value: 3, - label: "blue" - } - ] - }, - { - name: "size", - id: 1, - data: [ - { - value: 1, - label: "xs" - }, - { - value: 2, - label: "sm" - }, - { - value: 3, - label: "lg" - } - ] - } - ] - + + return ( <> diff --git a/src/Pages/Slider/Page.tsx b/src/Pages/Slider/Page.tsx index 75eae40..1b8cf27 100644 --- a/src/Pages/Slider/Page.tsx +++ b/src/Pages/Slider/Page.tsx @@ -5,12 +5,11 @@ import DashHeader from '../../Layout/Dashboard/DashHeader' import LyTable from '../../Layout/Dashboard/LyTable' import useTableColumns from './useTableColumns' import { QueryStatusEnum } from '../../config/QueryStatus' -import { useGetProduct } from '../../api/product' -import { Button } from 'antd' import { useTranslation } from 'react-i18next' import { useNavigate } from 'react-router-dom' import AddButton from '../../Layout/Dashboard/AddButton/AddButton' import { useGetSlider } from '../../api/Slider' +import SearchField from '../../Layout/Dashboard/SearchField' function Page() { @@ -25,7 +24,11 @@ function Page() { // Pass Status to Layout - navigate('/slider/add')}> +
+ + + navigate('/slider/add')}> +
{ const [t] = useTranslation(); @@ -14,32 +15,34 @@ const OrderPage = () => { //filters const [search, setSearchText] = React.useState(""); - - + + const filterIsApplied = search !== ""; //Table Content -- Data + Columns - const { data, isLoading , status } = useGetOrder({search}); - + const { data, isLoading, status } = useGetOrder({ search }); + const totalRows = data?.pagination?.total || 0; const columns = useTableColumns(); return ( <> - + - {/* */} +
+ +
-
- + + /> +
+ ); }; diff --git a/src/Styles/Layout/Layout.scss b/src/Styles/Layout/Layout.scss index 6266380..22f82c7 100644 --- a/src/Styles/Layout/Layout.scss +++ b/src/Styles/Layout/Layout.scss @@ -487,6 +487,22 @@ padding: 10px 40px; } + /* Ant input affix wrapper */ +.ant-input-group-wrapper .ant-input-wrapper .ant-input-affix-wrapper{ + height:40px; + } + + /* Ant input search button */ + .ant-input-wrapper .ant-input-group-addon .ant-input-search-button{ + height:40px; + } + + - \ No newline at end of file + + @media screen and (max-width: 500px) { + .SearchField{ + display: none; + } +} \ No newline at end of file diff --git a/src/lib/state mangment/Pages/Products.ts b/src/lib/state mangment/Pages/Products.ts new file mode 100644 index 0000000..4679b15 --- /dev/null +++ b/src/lib/state mangment/Pages/Products.ts @@ -0,0 +1,15 @@ +import {create} from 'zustand' + +interface ProductState { + TapItems:any; + setTapItems :any ; + TapItemValues:any; + setTapItemValues :any ; +} + +export const useProductVarianState = create((set) => ({ + TapItems:[], + setTapItems: (data : any) => set(() => ({ TapItems: data })), + TapItemValues:[], + setTapItemValues: (data : any) => set(() => ({ TapItemValues: data })), +})); diff --git a/src/lib/state mangment/dist/AuthState.js b/src/lib/state mangment/dist/AuthState.js new file mode 100644 index 0000000..2857812 --- /dev/null +++ b/src/lib/state mangment/dist/AuthState.js @@ -0,0 +1,69 @@ +"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 new file mode 100644 index 0000000..7aa3c73 --- /dev/null +++ b/src/lib/state mangment/dist/LayoutPagestate.js @@ -0,0 +1,23 @@ +"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 new file mode 100644 index 0000000..faa582c --- /dev/null +++ b/src/lib/state mangment/driver&customer/dist/ModelState.js @@ -0,0 +1,22 @@ +"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 1876f3b..158dffe 100644 --- a/src/translate/ar.json +++ b/src/translate/ar.json @@ -65,7 +65,7 @@ "country": "بلد", "note": "ملاحظة", "categories": "الفئات", - "coupon": "الفسيمة", + "coupon": "القسيمة", "orders": "الطلبات", "products": "المنتجات", "slider": "الشريحة", @@ -108,6 +108,8 @@ "images": "الصور", "no_records": "لا توجد سجلات", "Total": "المجموع", - "items": "عناصر" + "items": "عناصر", + "search": "بحث" + } \ No newline at end of file diff --git a/src/translate/de.json b/src/translate/de.json index d06fd29..85037db 100644 --- a/src/translate/de.json +++ b/src/translate/de.json @@ -104,5 +104,7 @@ "Add Another Item": "Weiteres Element hinzufügen", "no_records": "Keine Datensätze", "Total": "Insgesamt", - "items": "Artikel" + "items": "Artikel", + "search": "Suche" + } \ No newline at end of file diff --git a/src/translate/en.json b/src/translate/en.json index 4f26ab7..c1a2376 100644 --- a/src/translate/en.json +++ b/src/translate/en.json @@ -104,5 +104,7 @@ "Add Another Item": "Add Another Item", "no_records": "No records", "Total": "Total", - "items": "items" + "items": "items", + "search": "Search" + } \ No newline at end of file