You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

790 lines
18 KiB

import logo from "./logo.svg";
import "./App.css";
import {
BrowserRouter as Router,
Routes,
Route,
useNavigate,
} from "react-router-dom";
import Dashboard2 from "./view/dashboard2/Dashboard2";
import Header from "./components/header/Header";
import Nav from "./components/nav/Nav";
import Dashboard from "./view/dashboard/Dashboard";
import Accounting from "./view/accounting/Accounting";
import Messages from "./view/messages/Messages";
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
// import "react-modern-drawer/dist/index.css";
import Login from "./view/login/Login";
import { useEffect, useState } from "react";
// import {useParams} from 'react-router-dom';
import avatar1 from "./assets/img/avatar/080cd026ce8cd30f68acfa086ebde7fb.jpg";
import avatar2 from "./assets/img/avatar/alex-suprun-bYODySpLIhE-unsplash.jpg";
import avatar3 from "./assets/img/avatar/alex-suprun-ZHvM3XIOHoE-unsplash.jpg";
import avatar4 from "./assets/img/avatar/alexander-hipp-iEEBWgY_6lA-unsplash.jpg";
import avatar5 from "./assets/img/avatar/julian-wan-WNoLnJo7tS8-unsplash.jpg";
import avatar6 from "./assets/img/avatar/nicolas-horn-MTZTGvDsHFY-unsplash.jpg";
import avatar7 from "./assets/img/avatar/pexels-yuri-manei-2690323.jpg";
import LoginSignUp from "./view/LoginSignUp";
import Register from "./view/register";
import Services from "./view/services";
import { Provider, provider } from "react-redux";
import store from "./redux/store";
import ContactUs from "./view/contact";
import ENTER_EXAM from "./view/Exam/EnterExam/index";
import EXAM from "./view/Exam";
import CallBack from "./view/CallBack";
import AdminPanel from "./view/admin";
import AddProduct from "./view/addProduct";
import AddExam from "./view/addExam";
import ChatPage from "./view/chatPage";
import ShoppingCart from "./components/ShoppingCart";
import MyServices from "./view/my-services/MyServices";
import MobileMyServices from "./view/my-services/mobile/MyServices";
let data = [
{
id: 1,
img: avatar6,
firstName: "فرشید",
lastName: "وکیلی",
nationalId: "0010855770",
age: "7",
phoneNumber: "09101292134",
credit: 200000,
packages: [
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی معمارک",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
],
documents: "",
situation: 0,
},
{
id: 2,
img: avatar2,
firstName: "سپند",
lastName: "معروف",
nationalId: "0040855880",
age: "10",
phoneNumber: "09101292134",
credit: 100000,
packages: [
{
id: 1,
games: [
{
id: 101,
title: "بازی معمارک",
},
{
id: 102,
title: "بازی آشپزباشی",
},
],
time: 2,
remainderTime: "1:29:13",
isActive: false,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
],
documents: "",
situation: 0,
},
{
id: 11,
img: avatar3,
firstName: "مهرداد",
lastName: "فانی",
nationalId: "0040855880",
age: "10",
phoneNumber: "09101292134",
credit: 100000,
packages: [
{
id: 1,
games: [
{
id: 101,
title: "بازی معمارک",
},
{
id: 102,
title: "بازی آشپزباشی",
},
],
time: 2,
remainderTime: "1:29:13",
isActive: false,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
],
documents: "",
situation: 2,
},
{
id: 3,
img: avatar1,
firstName: "فرزین",
lastName: "همت",
nationalId: "0050855880",
age: "11",
phoneNumber: "09101292134",
credit: 111000,
packages: [
{
id: 1,
games: [
{
id: 101,
title: "بازی معمارک",
},
{
id: 102,
title: "بازی آشپزباشی",
},
],
time: 2,
remainderTime: "1:29:13",
isActive: false,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
],
documents: "",
situation: 3,
},
{
id: 4,
img: avatar4,
firstName: "مهتاب",
lastName: "آیتی",
nationalId: "0060855880",
age: "11",
phoneNumber: "09101292134",
credit: 0,
packages: [
{
id: 1,
games: [
{
id: 101,
title: "بازی معمارک",
},
{
id: 102,
title: "بازی آشپزباشی",
},
],
time: 2,
remainderTime: "1:29:13",
isActive: false,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
],
documents: "",
situation: 1,
},
{
id: 5,
img: avatar5,
firstName: "محمدرضا",
lastName: "شایع",
nationalId: "0080855990",
age: "12",
phoneNumber: "09101292235",
credit: 0,
packages: [
{
id: 1,
games: [
{
id: 101,
title: "بازی معمارک",
},
{
id: 102,
title: "بازی آشپزباشی",
},
],
time: 2,
remainderTime: "1:29:13",
isActive: false,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
],
documents: "",
situation: 3,
},
{
id: 6,
img: avatar6,
firstName: "فرزاد",
lastName: "همت",
nationalId: "0090855990",
age: "13",
phoneNumber: "09101292444",
credit: 50000,
packages: [
{
id: 1,
games: [
{
id: 101,
title: "بازی معمارک",
},
{
id: 102,
title: "بازی آشپزباشی",
},
],
time: 2,
remainderTime: "1:29:13",
isActive: false,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
],
documents: "",
situation: 3,
},
{
id: 7,
img: avatar7,
firstName: "مهنگار",
lastName: "همتی",
nationalId: "0090855222",
age: "9",
phoneNumber: "09101292111",
credit: 50000,
packages: [
{
id: 1,
games: [
{
id: 101,
title: "بازی معمارک",
},
{
id: 102,
title: "بازی آشپزباشی",
},
],
time: 2,
remainderTime: "1:29:13",
isActive: false,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
],
documents: "",
situation: 1,
},
{
id: 8,
img: avatar7,
firstName: "سها",
lastName: "آسایش",
nationalId: "0090855333",
age: "10",
phoneNumber: "09101292888",
credit: 50000,
packages: [
{
id: 1,
games: [
{
id: 101,
title: "بازی معمارک",
},
{
id: 102,
title: "بازی آشپزباشی",
},
],
time: 2,
remainderTime: "1:29:13",
isActive: false,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
{
id: 2,
games: [
{
id: 201,
title: "بازی کنجکاو",
},
],
time: 1,
remainderTime: "0:30:11",
isActive: true,
},
],
documents: "",
situation: 1,
},
];
function App() {
let location = window.location.pathname;
// const {id} = useParams();
console.log(location);
let buyPackagesData = null;
if (location.includes("buy-packages")) {
let pathList = location.split("/");
let id = pathList[pathList.length - 1];
for (let i = 0; i < data.length; i++) {
if (data[i].id === Number(id)) {
buyPackagesData = data[i];
break;
}
}
}
let loginStorage = localStorage.getItem("userData");
let userData = JSON.parse(loginStorage);
console.log(loginStorage == null);
console.log(userData);
const [LOGIN, setLOGIN] = useState(loginStorage == undefined ? false : true);
const activeLogin = () => {
setLOGIN(true);
localStorage.setItem("login", true);
};
const logOut = () => {
setLOGIN(false);
localStorage.setItem("login", false);
};
if (location === "/") {
window.location.replace("/services");
}
// useEffect(() => {
// setLOGIN(true);
// }, [loginStorage])
//--UserFullInfo---------------------
const [ActiveUserFullInfo, setActiveUserFullInfo] = useState(false);
const [UserFullInfoData, setUserFullInfoData] = useState(buyPackagesData);
const showUserFullInfo = (data) => {
console.log(data);
setActiveUserFullInfo(true);
setUserFullInfoData(data);
};
const hideUserFullInfo = () => {
setActiveUserFullInfo(false);
};
return (
<Provider store={store}>
<div>
<Router>
<div className="App">
{LOGIN && <Header logOut={logOut} />}
{LOGIN && <Nav />}
<Routes>
<Route
path="/"
element={
LOGIN ? (
window.innerWidth <= 1024 && (
<Dashboard
ActiveUserFullInfo={ActiveUserFullInfo}
UserFullInfoData={UserFullInfoData}
showUserFullInfo={showUserFullInfo}
hideUserFullInfo={hideUserFullInfo}
/>
)
) : (
<LoginSignUp activeLogin={activeLogin} />
)
}
/>
<Route
path="/myServices"
element={
LOGIN ? (
window.innerWidth>1000 ?<MyServices /> : <MobileMyServices/>
) : (
<LoginSignUp activeLogin={activeLogin} />
)
}
/>
{LOGIN ? (
<>
<Route
path="/buy-packages/:id"
element={
<Dashboard2
ActiveUserFullInfo={ActiveUserFullInfo}
UserFullInfoData={UserFullInfoData}
showUserFullInfo={showUserFullInfo}
hideUserFullInfo={hideUserFullInfo}
/>
}
/>
<Route path="/adminpanel" element={<AdminPanel />} />
<Route
path="/adminpanel/add-product"
element={<AddProduct />}
/>
<Route path="/adminpanel/add-exam" element={<AddExam />} />
<Route
path="/register"
element={<Register activeLogin={activeLogin} />}
/>
<Route path="/accounting" element={<Accounting />} />
<Route path="/messages" element={<Messages />} />
<Route path="/messages/:id" element={<ChatPage />} />
<Route path="/services" element={<Services />} />
<Route path="shoppingCart" element={<ShoppingCart />} />
{/* <Route path="/dashboard" element={ <Dashboard
ActiveUserFullInfo={ActiveUserFullInfo}
UserFullInfoData={UserFullInfoData}
showUserFullInfo={showUserFullInfo}
hideUserFullInfo={hideUserFullInfo}
/>} /> */}
<Route path="/callBack" element={<CallBack />} />
<Route path="/contacts" element={<ContactUs />} />
<Route
exact
path="/azmoon_list/enter_exam/:id"
element={<ENTER_EXAM />}
/>
<Route
exact
path="/dashboard/azmoon_list/exam/:id"
element={<EXAM />}
/>
</>
) : (
<Route
path="*"
element={<LoginSignUp activeLogin={activeLogin} />}
/>
)}
</Routes>
</div>
</Router>
<ToastContainer
position="top-right"
theme="colored"
autoClose={5000}
hideProgressBar={false}
newestOnTop={true}
closeOnClick
rtl={true}
pauseOnFocusLoss
draggable
pauseOnHover
/>
</div>
</Provider>
);
}
export default App;