diff --git a/.env b/.env new file mode 100644 index 0000000..90e2eef --- /dev/null +++ b/.env @@ -0,0 +1,4 @@ +VITE_API_URL=https://ssa.betadelivery.com/apia/v1 +VITE_USER_NAME="Admin" +VITE_PASSWORD="71%@L%es^bUX94`J9XT*%4&^%tUU^%Q^ffgt" +VITE_APP_NAME=MyViteApp \ No newline at end of file diff --git a/dev-dist/sw.js b/dev-dist/sw.js index 6e232b1..9c5feb8 100644 --- a/dev-dist/sw.js +++ b/dev-dist/sw.js @@ -82,7 +82,7 @@ define(['./workbox-54d0af47'], (function (workbox) { 'use strict'; "revision": "3ca0b8505b4bec776b69afdba2768812" }, { "url": "index.html", - "revision": "0.57smkc9q598" + "revision": "0.tg13lftuk78" }], {}); workbox.cleanupOutdatedCaches(); workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { diff --git a/package-lock.json b/package-lock.json index 565b898..9005efe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,8 @@ "@chakra-ui/react": "^3.2.3", "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.0", + "@reduxjs/toolkit": "^2.5.1", + "axios": "^1.7.9", "chart.js": "^4.4.7", "framer-motion": "^11.18.0", "next-themes": "^0.4.4", @@ -19,6 +21,7 @@ "react-dom": "^18.3.1", "react-hook-form": "^7.54.2", "react-icons": "^5.4.0", + "react-redux": "^9.2.0", "react-router-dom": "^7.1.1", "vite-plugin-pwa": "^0.21.1" }, @@ -2721,6 +2724,30 @@ "node": ">=14" } }, + "node_modules/@reduxjs/toolkit": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.5.1.tgz", + "integrity": "sha512-UHhy3p0oUpdhnSxyDjaRDYaw8Xra75UiLbCiRozVPHjfDwNYkh0TsVm/1OmTW8Md+iDAJmYPWUKMvsMc2GtpNg==", + "license": "MIT", + "dependencies": { + "immer": "^10.0.3", + "redux": "^5.0.1", + "redux-thunk": "^3.1.0", + "reselect": "^5.1.0" + }, + "peerDependencies": { + "react": "^16.9.0 || ^17.0.0 || ^18 || ^19", + "react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + }, + "react-redux": { + "optional": true + } + } + }, "node_modules/@rollup/plugin-babel": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz", @@ -3245,14 +3272,14 @@ "version": "15.7.14", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.14.tgz", "integrity": "sha512-gNMvNH49DJ7OJYv+KAKn0Xp45p8PLl6zo2YnvDIbTd4J6MER2BmWN49TG7n9LvkyihINxeKW8+3bfS2yDC9dzQ==", - "dev": true, + "devOptional": true, "license": "MIT" }, "node_modules/@types/react": { "version": "18.3.18", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.18.tgz", "integrity": "sha512-t4yC+vtgnkYjNSKlFx1jkAhH8LgTo2N/7Qvi83kdEaUtMDiwpbLAktKDaAMlRcJ5eSxZkH74eEGt1ky31d7kfQ==", - "dev": true, + "devOptional": true, "license": "MIT", "dependencies": { "@types/prop-types": "*", @@ -3281,6 +3308,12 @@ "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", "license": "MIT" }, + "node_modules/@types/use-sync-external-store": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.6.tgz", + "integrity": "sha512-zFDAD+tlpf2r4asuHEj0XH6pY6i0g5NeAHPn+15wk3BV6JA69eERFXC1gyGThDkVa1zCyKr5jox1+2LbV/AMLg==", + "license": "MIT" + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "8.18.2", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.18.2.tgz", @@ -4536,6 +4569,12 @@ "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", "license": "MIT" }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, "node_modules/at-least-node": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", @@ -4560,6 +4599,17 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/axios": { + "version": "1.7.9", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", + "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/babel-plugin-macros": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/babel-plugin-macros/-/babel-plugin-macros-3.1.0.tgz", @@ -5317,6 +5367,18 @@ "node": ">=0.1.90" } }, + "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==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/commander": { "version": "12.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", @@ -5553,6 +5615,15 @@ "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==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", @@ -6227,6 +6298,26 @@ "tabbable": "^6.2.0" } }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "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", @@ -6253,6 +6344,20 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/form-data": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/formdata-polyfill": { "version": "4.0.10", "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", @@ -6709,6 +6814,16 @@ "node": ">= 4" } }, + "node_modules/immer": { + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/immer/-/immer-10.1.1.tgz", + "integrity": "sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/immer" + } + }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -7495,6 +7610,27 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "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==", + "license": "MIT", + "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==", + "license": "MIT", + "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", @@ -8007,6 +8143,12 @@ "integrity": "sha512-y44MCkgtZUCT9tZGuE278fB7PWVf7fRYy0vbRXAts2o5F0EfC4fIQrvQQGBJo1WJbFcVLXzApOscyJuZqHQc1w==", "license": "MIT" }, + "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==", + "license": "MIT" + }, "node_modules/proxy-memoize": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/proxy-memoize/-/proxy-memoize-3.0.1.tgz", @@ -8121,6 +8263,29 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", "license": "MIT" }, + "node_modules/react-redux": { + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz", + "integrity": "sha512-ROY9fvHhwOD9ySfrF0wmvu//bKCQ6AeZZq1nJNtbDC+kk5DuSuNX/n6YWYF/SYy7bSba4D4FSz8DJeKY/S/r+g==", + "license": "MIT", + "dependencies": { + "@types/use-sync-external-store": "^0.0.6", + "use-sync-external-store": "^1.4.0" + }, + "peerDependencies": { + "@types/react": "^18.2.25 || ^19", + "react": "^18.0 || ^19", + "redux": "^5.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "redux": { + "optional": true + } + } + }, "node_modules/react-refresh": { "version": "0.14.2", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.2.tgz", @@ -8197,6 +8362,21 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/redux": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz", + "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==", + "license": "MIT" + }, + "node_modules/redux-thunk": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz", + "integrity": "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==", + "license": "MIT", + "peerDependencies": { + "redux": "^5.0.0" + } + }, "node_modules/reflect.getprototypeof": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz", @@ -8328,6 +8508,12 @@ "node": ">=0.10.0" } }, + "node_modules/reselect": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.1.1.tgz", + "integrity": "sha512-K/BG6eIky/SBpzfHZv/dd+9JBFiS4SWV7FIujVyJRux6e45+73RaUHXLmIR1f7WOMaQ0U1km6qwklRQxpJJY0w==", + "license": "MIT" + }, "node_modules/resolve": { "version": "1.22.10", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", @@ -9460,6 +9646,15 @@ "punycode": "^2.1.0" } }, + "node_modules/use-sync-external-store": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.4.0.tgz", + "integrity": "sha512-9WXSPC5fMv61vaupRkCKCxsPxBocVnwakBEkMIHHpkTTg6icbJtg6jzgtLDm4bl3cSHAca52rYWih0k4K3PfHw==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, "node_modules/vite": { "version": "6.0.6", "resolved": "https://registry.npmjs.org/vite/-/vite-6.0.6.tgz", @@ -10079,20 +10274,6 @@ "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "license": "ISC" }, - "node_modules/yaml": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.0.tgz", - "integrity": "sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==", - "license": "ISC", - "optional": true, - "peer": true, - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14" - } - }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index ca92e73..aef7be3 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,8 @@ "@chakra-ui/react": "^3.2.3", "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.0", + "@reduxjs/toolkit": "^2.5.1", + "axios": "^1.7.9", "chart.js": "^4.4.7", "framer-motion": "^11.18.0", "next-themes": "^0.4.4", @@ -21,6 +23,7 @@ "react-dom": "^18.3.1", "react-hook-form": "^7.54.2", "react-icons": "^5.4.0", + "react-redux": "^9.2.0", "react-router-dom": "^7.1.1", "vite-plugin-pwa": "^0.21.1" }, diff --git a/src/Contexts/GlobalStateProvider.tsx b/src/Contexts/GlobalStateProvider.tsx index 1f2c713..105a8cb 100644 --- a/src/Contexts/GlobalStateProvider.tsx +++ b/src/Contexts/GlobalStateProvider.tsx @@ -1,10 +1,10 @@ -import { ReactNode, useState } from 'react'; +import { ReactNode, useState } from 'react'; import GlobalStateContext from './GlobalStateContext'; -const GlobalStateProvider = ({ children }:{children:ReactNode}) => { +const GlobalStateProvider = ({ children }: { children: ReactNode }) => { const [isAuthenticate, setIsAuthenticate] = useState(true); return ( diff --git a/src/Pages/Dashboard/AgencyName.tsx b/src/Pages/Dashboard/AgencyName.tsx new file mode 100644 index 0000000..9941623 --- /dev/null +++ b/src/Pages/Dashboard/AgencyName.tsx @@ -0,0 +1,103 @@ +import { Box, HStack, Image, Input, Stack, Text } from "@chakra-ui/react"; +import React, { useState, useEffect } from "react"; +import { Button } from "../../components/ui/button"; +import { IoAddSharp } from "react-icons/io5"; +import delateIcon from "../../assets/deleteIcon.png"; +import { FaClockRotateLeft } from "react-icons/fa6"; + +interface Todo { + id: number; + text: string; + completed: boolean; + timestamp: string; +} + +const AgencyName: React.FC = () => { + const [todos, setTodos] = useState([]); + const [input, setInput] = useState(""); + + + const getCurrentTime = () => { + const now = new Date(); + return now.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }); + }; + + + const addTodo = () => { + if (input.trim() === "") return; + setTodos([...todos, { id: Date.now(), text: input, completed: false, timestamp: getCurrentTime() }]); + setInput(""); + }; + + // Delete a task + const deleteTodo = (id: number) => { + setTodos(todos.filter((todo) => todo.id !== id)); + }; + + useEffect(() => { + const savedTodos = localStorage.getItem("todos"); + if (savedTodos) { + setTodos(JSON.parse(savedTodos)); + } + }, []); // Runs only on mount + + // 🔹 Save todos to localStorage whenever they change + useEffect(() => { + if (todos.length > 0) { + localStorage.setItem("todos", JSON.stringify(todos)); + } + }, [todos]); // Runs when `todos` changes + + + return ( + + + + Add Agency Name + + + + setInput(e.target.value)} + placeholder="Add a task..." + backgroundColor={"#fff"} + size={"sm"} + w={"100%"} + p={2} + mb={4} + /> + {todos.map((todo) => ( + + {todo.text} + + + + {todo.timestamp} + + deleteTodo(todo.id)} + bg={"none"} + color={"#22222299"} + cursor={'pointer'} + > + + + + + ))} + + ); +}; + +export default AgencyName; diff --git a/src/Pages/Dashboard/Dashboard.tsx b/src/Pages/Dashboard/Dashboard.tsx index 5a0e63e..056fa6c 100644 --- a/src/Pages/Dashboard/Dashboard.tsx +++ b/src/Pages/Dashboard/Dashboard.tsx @@ -3,33 +3,68 @@ import { createListCollection, Heading, HStack, - Stack, Status, Tabs, Text, } from "@chakra-ui/react"; -import MainFrame from "../../components/MainFrame"; import BarChart from "../../components/Charts/BarChart"; +import CircularApp from "../../components/Charts/CircularProgress"; +import SemiDoughnutChart from "../../components/Charts/SemiDoughnutChart"; +import MainFrame from "../../components/MainFrame"; +import { + AccordionItem, + AccordionItemContent, + AccordionItemTrigger, + AccordionRoot, +} from "../../components/ui/accordion"; +import { Button } from "../../components/ui/button"; import { SelectContent, SelectItem, - SelectLabel, SelectRoot, SelectTrigger, - SelectValueText, + SelectValueText } from "../../components/ui/select"; -import SemiDoughnutChart from "../../components/Charts/SemiDoughnutChart"; +import AgencyName from "./AgencyName"; const Dashboard = () => { const frameworks = createListCollection({ items: [ - { label: "React.js", value: "react" }, - { label: "Vue.js", value: "vue" }, - { label: "Angular", value: "angular" }, - { label: "Svelte", value: "svelte" }, + { label: "Today", value: "Today" }, + { label: "Week", value: "Week" }, + { label: "Month", value: "Month" }, + { label: "Year", value: "Year" }, ], }); + const accItems = [ + { + value: "1", + title: "How to create new account?", + text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since. Lorem Ipsum has been the industry's standard dummy text ever since.", + }, + { + value: "2", + title: "How to create new account?", + text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since. Lorem Ipsum has been the industry's standard dummy text ever since.", + }, + { + value: "3", + title: "How to create new account?", + text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since. Lorem Ipsum has been the industry's standard dummy text ever since.", + }, + { + value: "4", + title: "How to create new account?", + text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since. Lorem Ipsum has been the industry's standard dummy text ever since.", + }, + { + value: "5", + title: "How to create new account?", + text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since. Lorem Ipsum has been the industry's standard dummy text ever since.", + }, + ]; + return ( @@ -47,16 +82,28 @@ const Dashboard = () => { mb={6} > - Tab 1 - Tab 2 - Tab 3 + + Past 24 hrs + + + Total Users + + + New Signups + - + Recruiter 2554 @@ -92,11 +139,50 @@ const Dashboard = () => { + p={'10px'} + > + Number Of Groups created + + - - + + + Faqs + + + + {accItems.map((item, index) => ( + + + {item.title} + + + {item.text} + + + ))} + + + + + ); diff --git a/src/Pages/Login.tsx b/src/Pages/Login.tsx index c479a26..b8d4a68 100644 --- a/src/Pages/Login.tsx +++ b/src/Pages/Login.tsx @@ -1,18 +1,22 @@ import { Center, HStack, Image, Input, Text, VStack } from "@chakra-ui/react" +import axios from "axios" import { useContext, useState } from "react" import { useForm } from "react-hook-form" +import { useDispatch } from "react-redux" import GlobalStateContext from "../Contexts/GlobalStateContext" +import { setToken } from "../Redux/Service/authSlice" import logo from '../assets/logo.svg' import { Button } from "../components/ui/button" import { Field } from "../components/ui/field" -import { Toaster, toaster } from "../components/ui/toaster" +import { Toaster } from "../components/ui/toaster" interface FormValues { mobileNumber: number + password: string } const Login = () => { - + const dispatch = useDispatch() const [isLoading, setIsLoading] = useState(false) const context = useContext(GlobalStateContext); if (!context) { @@ -25,24 +29,45 @@ const Login = () => { formState: { errors }, } = useForm() + const onSubmit = handleSubmit(async (data) => { + setIsLoading(true); + + // Encode Basic Auth Credentials + const username = import.meta.env.VITE_USER_NAME||''; // Replace with actual username + const password = import.meta.env.VITE_PASSWORD||''; // Replace with actual password + const basicAuth = btoa(`${username}:${password}`); // Encode to Base64 + + try { + const response = await axios.post( + `${import.meta.env.VITE_API_URL}/v1/login`, + { + mobile_number: data.mobileNumber, + password: data.password, + }, + { + headers: { + Authorization: `Basic ${basicAuth}`, + "Content-Type": "application/json", + }, + } + ); + + console.log("===================================="); + console.log(response); + console.log("===================================="); + dispatch(setToken(String(response.data["access-token"]))); + } catch (error) { + if (error) { - const onSubmit = handleSubmit((data) => { - setIsLoading(true) - if (data?.mobileNumber === 1234567890) { - setTimeout(() => { - setIsAuthenticate(true); + console.error("Login failed", error); setIsLoading(false) - }, 3000); // 3-second delay - - } else { - toaster.create({ - title: `Invalid Credentials`, - type: "error", - }) - setIsLoading(false) + + } } }); + + return ( @@ -79,7 +104,11 @@ const Login = () => { {/* Forget password */} - + + + {/* Forget password */} + + Forgot password diff --git a/src/Pages/ManageCMS/AboutUs/AboutUs.tsx b/src/Pages/ManageCMS/AboutUs/AboutUs.tsx index 51377a3..a080942 100644 --- a/src/Pages/ManageCMS/AboutUs/AboutUs.tsx +++ b/src/Pages/ManageCMS/AboutUs/AboutUs.tsx @@ -1,7 +1,7 @@ import { Box, HStack, Text } from "@chakra-ui/react"; import MainFrame from "../../../components/MainFrame" import { p } from "framer-motion/client"; -import AboutUsAddModel from "../../../components/AboutUsAddModel"; +import AboutUsAddModel from "../../ManageCMS/AboutUs/AboutUsAddModel"; const AboutUs = () => { @@ -20,7 +20,7 @@ const AboutUs = () => { AboutUs - + diff --git a/src/components/AboutUsAddModel.tsx b/src/Pages/ManageCMS/AboutUs/AboutUsAddModel.tsx similarity index 60% rename from src/components/AboutUsAddModel.tsx rename to src/Pages/ManageCMS/AboutUs/AboutUsAddModel.tsx index 6643c16..75b9c73 100644 --- a/src/components/AboutUsAddModel.tsx +++ b/src/Pages/ManageCMS/AboutUs/AboutUsAddModel.tsx @@ -1,7 +1,7 @@ import { FaRegEdit } from "react-icons/fa" -import { Button } from "./ui/button" -import { DialogBody, DialogCloseTrigger, DialogContent, DialogFooter, DialogHeader, DialogRoot, DialogTitle, DialogTrigger } from "./ui/dialog" +import { DialogBody, DialogCloseTrigger, DialogContent, DialogFooter, DialogHeader, DialogRoot, DialogTitle, DialogTrigger } from "../../../components/ui/dialog" import { Field, Stack, Text, Textarea } from "@chakra-ui/react" +import { Button } from "../../../components/ui/button" function AboutUsAddModel() { return ( @@ -11,31 +11,33 @@ function AboutUsAddModel() { {/* */} - + - - Edit + + Edit - + - AboutUs -