diff --git a/app/UserPanel/(Admin)/AdminDashboard/layout.tsx b/app/UserPanel/(Admin)/AdminDashboard/layout.tsx index 1e3d64f..1c0558a 100644 --- a/app/UserPanel/(Admin)/AdminDashboard/layout.tsx +++ b/app/UserPanel/(Admin)/AdminDashboard/layout.tsx @@ -6,7 +6,8 @@ export default function RootLayout({ children: React.ReactNode; }) { return ( - <> + <> + {children} diff --git a/app/UserPanel/(Controller)/ControllerDashboard/Complaints/page.tsx b/app/UserPanel/(Controller)/ControllerDashboard/Complaints/page.tsx index eba8b59..441aec1 100644 --- a/app/UserPanel/(Controller)/ControllerDashboard/Complaints/page.tsx +++ b/app/UserPanel/(Controller)/ControllerDashboard/Complaints/page.tsx @@ -4,6 +4,5 @@ import React from 'react' export default function page() { return ( - ) } diff --git a/app/UserPanel/(Controller)/ControllerDashboard/Reports/page.tsx b/app/UserPanel/(Controller)/ControllerDashboard/Reports/page.tsx index 48557be..bc34bb4 100644 --- a/app/UserPanel/(Controller)/ControllerDashboard/Reports/page.tsx +++ b/app/UserPanel/(Controller)/ControllerDashboard/Reports/page.tsx @@ -2,6 +2,7 @@ import ReportsController from '@/components/ReportsController' import React from 'react' export default function page() { + const a = useMut return ( ) diff --git a/components/Login.tsx b/components/Login.tsx index b67fca8..8fa78ec 100644 --- a/components/Login.tsx +++ b/components/Login.tsx @@ -20,6 +20,8 @@ import { Input } from "@/components/ui/input"; import { toast } from "@/components/ui/use-toast"; import Image from "next/image"; import LoginIcon from "../public/img/login-icon.svg"; +import { useMutation } from "@tanstack/react-query"; +import { loginStaff } from "@/utils/authenticateApi"; const FormSchema = z.object({ username: z.string().min(2, { @@ -31,11 +33,26 @@ const FormSchema = z.object({ }); export default function Login() { + const LoginMutation = useMutation({ + mutationFn: loginStaff, + onSuccess: (res) => { + console.log(res); + // localStorage.setItem("roles", res.roles[0]); + // setCookie("token", res.token); + // if (res.roles[0] == "Operator") { + // router.push("/MainPage/Prescriptions"); + // } else { + // router.push("/MainPage"); + // } + }, + onError: (err) => {}, + }); + const form = useForm>({ resolver: zodResolver(FormSchema), defaultValues: { username: "", - password:"", + password: "", }, }); @@ -52,10 +69,12 @@ export default function Login() { } return ( -
+
- icon + icon

ورود به پنل کاربری @@ -71,36 +90,47 @@ export default function Login() { name="username" render={({ field }) => ( - نام کاربری + + نام کاربری + - + {/* This is your public display name. */} - )} /> - + ( - رمز عبور + + رمز عبور + - + - )} />

- +
diff --git a/components/NavbarSm.tsx b/components/NavbarSm.tsx index 02b2d93..c62da18 100644 --- a/components/NavbarSm.tsx +++ b/components/NavbarSm.tsx @@ -22,23 +22,6 @@ export default function NavbarSm() { const [isOpen, setOpen] = useState(false); const ref = useRef(null); - // resize - function getSize() { - return { - width: window.innerWidth, - }; - } - const [windowSize, setWindowSize] = useState(getSize); - - useEffect(() => { - function handleResize() { - setWindowSize(getSize()); - } - - window.addEventListener("resize", handleResize); - return () => window.removeEventListener("resize", handleResize); - }, [windowSize]); - return ( <>
*/} - {window.innerWidth <= 768 ? : <>} +
+ +
{isOpen && ( diff --git a/components/Search.tsx b/components/Search.tsx index 4872774..51e646d 100644 --- a/components/Search.tsx +++ b/components/Search.tsx @@ -18,40 +18,25 @@ import { } from "@/components/ui/alert-dialog"; import { IoMdClose } from "react-icons/io"; -export default function Search({mode}:{mode:string}) { - // resize - function getSize() { - return { - width: window.innerWidth, - }; - } - const [windowSize, setWindowSize] = useState(getSize); - - useEffect(() => { - function handleResize() { - setWindowSize(getSize()); - } - - window.addEventListener("resize", handleResize); - return () => window.removeEventListener("resize", handleResize); - }, [windowSize]); - +export default function Search({ mode }: { mode: string }) { + return (
- {window.innerWidth >= 768 || mode === 'controller' || mode === 'admin'? ( + {mode === "controller" || mode === "admin" || mode == "landing" ? (
{/*
) : ( -
+
- diff --git a/components/TopNav.tsx b/components/TopNav.tsx index 68a7ba5..0584e50 100644 --- a/components/TopNav.tsx +++ b/components/TopNav.tsx @@ -4,26 +4,23 @@ import React from "react"; import { Input } from "./ui/input"; import Link from "next/link"; import Search from "./Search"; -import { usePathname } from 'next/navigation' +import { usePathname } from "next/navigation"; export default function TopNav() { - const pathname = usePathname() + const pathname = usePathname(); return ( -
- -

+
+

سال 1402 | مهارم تورم، رشد تولید

{/*

Current pathname: {pathname}

*/}
- -
-

امروز: چهارشنبه 24 آبان 1402

@@ -57,8 +54,7 @@ export default function TopNav() {
- - +
); diff --git a/components/Verify.tsx b/components/Verify.tsx new file mode 100644 index 0000000..1e5f786 --- /dev/null +++ b/components/Verify.tsx @@ -0,0 +1,75 @@ +"use client"; +import Image from "next/image"; +import React from "react"; +import LoginIcon from "../public/img/login-icon.svg"; +export default function Verify() { + return ( +
+
+ icon + +

+ تایید کد +

+ + {/*
+ + ( + + + نام کاربری + + + + + + This is your public display name. + + + + )} + /> + + ( + + + رمز عبور + + + + + + + )} + /> + +
+ +
+ + */} +
+
+ ); +} diff --git a/package-lock.json b/package-lock.json index fe491b2..87c0622 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,9 +18,11 @@ "@radix-ui/react-toast": "^1.1.5", "@tanstack/react-query": "^5.8.7", "@uidotdev/usehooks": "^2.4.1", + "axios": "^1.6.2", "chart.js": "^4.4.1", "class-variance-authority": "^0.7.0", "clsx": "^2.0.0", + "cookies-next": "^4.1.0", "framer-motion": "^10.16.16", "hamburger-react": "^2.5.0", "leaflet": "^1.9.4", @@ -33,6 +35,7 @@ "react-hook-form": "^7.48.2", "react-icons": "^4.12.0", "react-leaflet": "^4.2.1", + "react-otp-input": "^3.1.1", "react-use": "^17.4.2", "swiper": "^11.0.5", "tailwind-merge": "^2.1.0", @@ -1253,6 +1256,11 @@ } } }, + "node_modules/@types/cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" + }, "node_modules/@types/geojson": { "version": "7946.0.13", "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.13.tgz", @@ -1699,6 +1707,11 @@ "has-symbols": "^1.0.3" } }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, "node_modules/autoprefixer": { "version": "10.4.16", "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.16.tgz", @@ -1757,6 +1770,16 @@ "node": ">=4" } }, + "node_modules/axios": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/axobject-query": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz", @@ -1998,6 +2021,17 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/commander": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", @@ -2011,6 +2045,29 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, + "node_modules/cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookies-next": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cookies-next/-/cookies-next-4.1.0.tgz", + "integrity": "sha512-BREVc4TJT4NwXfyKjdjnYFXM6iRns+MYpCd34ClXuYqeisXnkPkbq7Ok9xaqi9mHmV6H2rwPE+p3EpMz4pF/kQ==", + "dependencies": { + "@types/cookie": "^0.4.1", + "@types/node": "^16.10.2", + "cookie": "^0.4.0" + } + }, + "node_modules/cookies-next/node_modules/@types/node": { + "version": "16.18.68", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.68.tgz", + "integrity": "sha512-sG3hPIQwJLoewrN7cr0dwEy+yF5nD4D/4FxtQpFciRD/xwUzgD+G05uxZHv5mhfXo4F9Jkp13jjn0CC2q325sg==" + }, "node_modules/copy-to-clipboard": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/copy-to-clipboard/-/copy-to-clipboard-3.3.3.tgz", @@ -2129,6 +2186,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/dequal": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", @@ -2881,6 +2946,25 @@ "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==", "dev": true }, + "node_modules/follow-redirects": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", + "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/for-each": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", @@ -2890,6 +2974,19 @@ "is-callable": "^1.1.3" } }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fraction.js": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz", @@ -3876,6 +3973,25 @@ "node": ">=8.6" } }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -4444,6 +4560,11 @@ "react-is": "^16.13.1" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -4546,6 +4667,15 @@ "react-dom": "^18.0.0" } }, + "node_modules/react-otp-input": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/react-otp-input/-/react-otp-input-3.1.1.tgz", + "integrity": "sha512-bjPavgJ0/Zmf/AYi4onj8FbH93IjeD+e8pWwxIJreDEWsU1ILR5fs8jEJmMGWSBe/yyvPP6X/W6Mk9UkOCkTPw==", + "peerDependencies": { + "react": ">=16.8.6 || ^17.0.0 || ^18.0.0", + "react-dom": ">=16.8.6 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/react-remove-scroll": { "version": "2.5.5", "resolved": "https://registry.npmjs.org/react-remove-scroll/-/react-remove-scroll-2.5.5.tgz", diff --git a/package.json b/package.json index e63ec65..074469e 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,11 @@ "@radix-ui/react-toast": "^1.1.5", "@tanstack/react-query": "^5.8.7", "@uidotdev/usehooks": "^2.4.1", + "axios": "^1.6.2", "chart.js": "^4.4.1", "class-variance-authority": "^0.7.0", "clsx": "^2.0.0", + "cookies-next": "^4.1.0", "framer-motion": "^10.16.16", "hamburger-react": "^2.5.0", "leaflet": "^1.9.4", @@ -34,6 +36,7 @@ "react-hook-form": "^7.48.2", "react-icons": "^4.12.0", "react-leaflet": "^4.2.1", + "react-otp-input": "^3.1.1", "react-use": "^17.4.2", "swiper": "^11.0.5", "tailwind-merge": "^2.1.0", diff --git a/utils/authenticateApi.ts b/utils/authenticateApi.ts new file mode 100644 index 0000000..4253180 --- /dev/null +++ b/utils/authenticateApi.ts @@ -0,0 +1,24 @@ +import axios from "axios"; +import { CookieValueTypes } from "cookies-next"; + +axios.defaults.baseURL = "https://sootzaniapi.shetabdahi.ir/"; + +export async function loginStaff({ + token, + Data, +}: { + token: CookieValueTypes; + Data: { + userName: string; + password: string; + captcha: { + key: string; + value: string; + }; + }; +}) { + const data = await axios.post("api/Authenticate/LoginStaff", Data, { + headers: { Authorization: `Bearer ${token}` }, + }); + return data.data; +} diff --git a/utils/clientAPI.js b/utils/clientAPI.js deleted file mode 100644 index d8ed582..0000000 --- a/utils/clientAPI.js +++ /dev/null @@ -1,49 +0,0 @@ -import axios from "axios"; - -axios.defaults.baseURL = "https://ticketingapi.shahrbincenter.ir/"; - -export async function openTicket({ Token, Data }) { - const data = await axios.post("ClientTicket/Open", Data, { - headers: { - Authorization: `Bearer ${Token}`, - "Content-Type": "multipart/form-data", - }, - }); - return data.data; -} - -export async function getAllTickets(Token) { - const data = await axios.get("ClientTicket/Get?PageNumber=1&PageSize=20", { - headers: { - Authorization: `Bearer ${Token}`, - }, - }); - return data.data; -} - -export async function getTicket({ Token, id }) { - const data = await axios.get(`ClientTicket/Get/${id}`, { - headers: { - Authorization: `Bearer ${Token}`, - }, - }); - return data.data; -} - -export async function replyTicket({ id, Data, Token }) { - const data = await axios.post(`ClientTicket/Reply/${id}`, Data, { - headers: { - Authorization: `Bearer ${Token}`, - }, - }); - return data.data; -} - -export async function closeTicket({ id, Data, Token }) { - const data = await axios.put(`ClientTicket/Close/${id}`, Data, { - headers: { - Authorization: `Bearer ${Token}`, - }, - }); - return data.data; -} \ No newline at end of file diff --git a/utils/commonAPI.js b/utils/commonAPI.js deleted file mode 100644 index 4649db4..0000000 --- a/utils/commonAPI.js +++ /dev/null @@ -1,25 +0,0 @@ -import axios from "axios"; - -axios.defaults.baseURL = "https://ticketingapi.shahrbincenter.ir/"; - -export async function getCaptcha() { - const data = await axios.get("api/Authenticate/Captcha"); - return data; -} - -export async function login(Data) { - const data = await axios.post("api/Authenticate/LogisterAppUser", Data); - return data.data; -} - -export async function LoginCode(Data) { - const data = await axios.post("api/Authenticate/LoginCode", Data); - return data.data; -} - -export async function getCategories(Token) { - const data = await axios.get("CommonCategory/Get", { - headers: { Authorization: `Bearer ${Token}` }, - }); - return data.data; -}