Skip to content

Commit

Permalink
Merge pull request #3 from GHanamaAhmed/main
Browse files Browse the repository at this point in the history
pull
  • Loading branch information
Abellache-Rabah authored May 29, 2023
2 parents adb0a44 + 81409ba commit c1b25cc
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 266 deletions.
22 changes: 14 additions & 8 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useLayoutEffect, useState } from "react";
import Navbar from "./navbar/navbar";
import Header from "./header/header";
import ListHeader from "./components/listHeader";
import { BrowserRouter, Navigate, Route, Routes, useNavigate } from "react-router-dom";
import { BrowserRouter, Navigate, Route, Routes, useNavigate, useLocation } from "react-router-dom";
import Dashboard from "./Dashboard/dashboard";
import Rooms from "./rooms/rooms";
import CreateRoom from "./createRoom/createRoom";
Expand All @@ -15,11 +15,12 @@ import OurTeam from "./OurTeam/ourTeam";
import { setAcount } from "./redux/accountReducer";
import axios from "axios";
function App() {
const location = useLocation()
const account = useSelector(state => state.account)
const navigate = useNavigate()
const dispatch = useDispatch()
const store = useSelector(state => state.account)
const [show,setShow]=useState(false)
const [show, setShow] = useState(false)
useEffect(() => {
dispatch(fetchRooms(store))
}, [account])
Expand All @@ -29,10 +30,15 @@ function App() {
useEffect(() => {
let email = localStorage.getItem("email")
let password = localStorage.getItem("password")
if (email && password) {
send(email, password)
} else {
navigate("/Student-Attendance/sign/signin");
console.log(location.pathname== "/Student-Attendance/sign/signup" );
if (location.pathname == "/Student-Attendance/sign/signup" || location.pathname == "/Student-Attendance/sign/signin") {

}else{
if (email && password) {
send(email, password)
} else {
navigate("/Student-Attendance/sign/signin");
}
}
setShow(true)
}, [account])
Expand Down Expand Up @@ -73,8 +79,8 @@ function App() {
path="/*"
element={
<>
<Header />
<div className="md:grid md:grid-cols-4 md:grid-rows-1 pb-16 overflow-y-auto h-full">
<div className="md:grid md:grid-cols-4 mb-10 md:mb-0 md:grid-rows-1 overflow-y-auto h-full">
<Header />
<ListHeader
className={"hidden md:block w-fit col-start-1 h-full col-end-2"}
/>
Expand Down
8 changes: 4 additions & 4 deletions src/Dashboard/dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ export default memo(function Dashboard() {
setShearchInp(e.target.value)
}
return (
<div className='col-start-2 col-end-5 max-h-screen h-screen overflow-y-auto'>
<div className='flex justify-center items-center gap-2 w-full flex-col'>
<div className='col-start-2 col-end-5 mb-8 max-h-screen h-full overflow-y-auto'>
<div className='flex justify-center items-center gap-2 w-full flex-col overflow-y-auto'>
<Nav />
<div className='w-5/6 flex flex-col md:flex-row gap-2 justify-around items-center'>
<div className='w-5/6 flex flex-col md:flex-row gap-2 justify-around items-center overflow-y-auto'>
<div className='border-border-color bg-white w-full border-4 flex flex-col gap-y-2 px-10 py-4'>
<p>Welcome </p>
<p className='font-semibold'>{account?.firstName} {account?.lastName}</p>
Expand All @@ -159,7 +159,7 @@ export default memo(function Dashboard() {
</div>
</div>
<MyCharts />
<div className='w-full bg-white pb-10 pt-4 px-4'>
<div className='w-full bg-white pb-10 pt-4 px-4 overflow-y-auto'>
<div className='w-full flex flex-col md:flex-row items-center mb-3 gap-2 justify-between'>
<div className='flex items-center flex-col md:flex-row gap-5'>
<div className='flex flex-col gap-2'>
Expand Down
2 changes: 1 addition & 1 deletion src/Dashboard/tabel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default function Tabel({ seassions, students, currentModule, account, roo
})
}
return (
<div className="relative overflow-x-auto shadow-md sm:rounded-lg">
<div className="relative overflow-auto shadow-md sm:rounded-lg">
<table className="w-full text-sm text-left text-gray-500 dark:text-gray-400">
<thead className="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
<tr>
Expand Down
273 changes: 81 additions & 192 deletions src/OurTeam/ourTeam.jsx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/listHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default memo(function ListHeader({ className }) {
className="h-full w-full"
aria-label="Sidebar"
>
<div className="h-screen w-full px-3 py-4 overflow-y-auto flex flex-col justify-between bg-gray-50 dark:bg-gray-800">
<div className="h-full w-full px-3 py-4 overflow-y-auto flex flex-col justify-between bg-gray-50 dark:bg-gray-800">

<ul className="space-y-2 font-medium">
<div className='p-2'>
Expand Down
2 changes: 1 addition & 1 deletion src/header/header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default memo(function Header() {
<img src="../img/Line.svg" alt="" onClick={toggleMenu} />
</div>
</div>
<ListHeader className={`duration-300 absolute top-0 ${showMenu ? "translate-x-0" : "-translate-x-full"}`} />
<ListHeader className={`duration-300 h-full absolute top-0 ${showMenu ? "translate-x-0" : "-translate-x-full"}`} />
</>
)
}
Expand Down
10 changes: 5 additions & 5 deletions src/rooms/allRooms/allRooms.jsx → src/rooms/allRooms.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { useEffect, useLayoutEffect, useState } from 'react'
import { Dropdown, Pagination } from 'flowbite-react'
import axios from 'axios';
import { useDispatch, useSelector } from 'react-redux';
import { setRooms } from '../../redux/roomsReducer';
import { fetchSeassions } from '../../redux/seassion';
import RoomParam from '../roomParam';
import { setRooms } from '../redux/roomsReducer';
import { fetchSeassions } from '../redux/seassion';
import RoomParam from './roomParam';
import { useNavigate } from 'react-router-dom';
export default function AllRooms() {
const navigate = useNavigate()
Expand Down Expand Up @@ -114,9 +114,9 @@ export default function AllRooms() {
<input type="text" placeholder='shearch' onChange={handle} className='w-1/2 border-none placeholder:opacity-50 bg-transparent focus:ring-0 py-2' />
</div>
</div>
<div className='w-full h-full flex justify-center items-center'>
<div className='w-full h-full flex justify-center items-start'>
<div className='w-full flex items-center flex-col' >
{!rooms.isloading && <div className="w-11/12 bg-transparent shadow-none relative overflow-x-auto sm:rounded-lg">
{!rooms.isloading && <div className="w-11/12 bg-transparent shadow-none relative overflow-auto sm:rounded-lg">
<table className="w-full h-full rounded-3xl shadow-sm text-sm text-left text-gray-500 dark:text-gray-400">
<thead className="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
<tr>
Expand Down
4 changes: 2 additions & 2 deletions src/rooms/rooms.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import Nav from '../nav/nav';
import { Navigate, Route, Routes} from 'react-router-dom';
import Room from './room';
import RoomPrev from './roomPrev';
import AllRooms from './allRooms/allRooms';
import AllRooms from './allRooms';
export default function Rooms() {
return (
<div className='col-start-2 col-end-6 gap-y-2 overflow-y-auto pb-10 flex flex-col items-center'>
<div className='col-start-2 col-end-6 gap-y-2 mb-8 overflow-y-auto pb-10 flex flex-col items-center'>
<Nav />
<Routes>
<Route path='/*' element={<AllRooms/>} />
Expand Down
2 changes: 1 addition & 1 deletion src/signin/signin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default function Signin() {
<input
type={"email"}
ref={emailuser}
onChange={handle}
onBlur={handle}
name="floating_email"
id="floating_email"
className={`block py-2.5 px-0 w-full text-sm bg-transparent border-0 border-b-2 ${state.invalidinpute} appearance-none focus:outline-none focus:ring-0 peer`}
Expand Down
84 changes: 33 additions & 51 deletions src/signin/signup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import axios from "axios";
import { toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import { useDispatch } from "react-redux";
import {setAcount} from '../redux/accountReducer'
import { setAcount } from '../redux/accountReducer'
export default function Signup(params) {
const [spE, setSpE] = useState([])
const dispatch = useDispatch();
const [isLoading,setIsLoading]=useState(false)
const [isLoading, setIsLoading] = useState(false)
const [state, setState] = useState({
validateusername: [
"border-gray-300 text-gray-900 dark:text-white dark:border-gray-600 dark:focus:border-blue-500 focus:outline-none focus:ring-0 focus:border-blue-600",
Expand Down Expand Up @@ -60,7 +60,7 @@ export default function Signup(params) {
const wait = toast.loading("Please wait...")
let res;
let req = { email: email.current.value };
if (validateEmail(email.current.value) && validateName(sp.current.value) && validateName(fname.current.value) && validatepassword(p.current.value) && validateName(lname.current.value)) {
if (validateEmail(email.current.value) && sp.current.value != "" && company.current.value != "" && validateName(fname.current.value) && validatepassword(p.current.value) && validateName(lname.current.value) && p.current.value == rp.current.value) {
res = await axios.post(
"https://simpleapi-p29y.onrender.com/teacher/auth",
req,
Expand All @@ -69,16 +69,20 @@ export default function Signup(params) {
"Content-Type": "application/x-www-form-urlencoded",
},
}
);
if (res.data.res) {
toast.update(wait, { render: "Send code", type: "success", isLoading: false,autoClose:2000})
setIshedden((prevValue) => !prevValue)
} else {
toast.update(wait, { render: res.data.msg, type: "error", isLoading: false, data: 2000 ,autoClose:2000})
}
).then(res=>{
if (res.data.res) {
toast.update(wait, { render: "Send code", type: "success", isLoading: false, autoClose: 2000 })
setIshedden((prevValue) => !prevValue)
} else {
toast.update(wait, { render: res.data.mes, type: "error", isLoading: false, data: 2000, autoClose: 2000 })
}
}).catch(err=>{
toast.update(wait, { render: err, type: "error", isLoading: false, data: 2000, autoClose: 2000 })
});

} else {
await new Promise((resolve) => setTimeout(resolve, 1000))
toast.update(wait, { render: "chek your information", type: "error", isLoading: false, data: 2000,autoClose:2000})
toast.update(wait, { render: "chek your information", type: "error", isLoading: false, data: 2000, autoClose: 2000 })
}
setIsLoading(false)
}
Expand All @@ -99,7 +103,7 @@ export default function Signup(params) {
async function send() {
const wait = toast.loading("Please wait...")
let res;

let req = {
firstname: fname.current.value,
lastname: lname.current.value,
Expand All @@ -118,17 +122,19 @@ export default function Signup(params) {
"Content-Type": "application/x-www-form-urlencoded",
},
}
);
if (res.data.res) {
dispatch(setAcount(res.data.data))
toast.update(wait, { render: "Success", type: "success", isLoading: false, autoClose: true });
await new Promise((resolve) => setTimeout(resolve, 1000))
navigate("/Student-Attendance/Dashboard/");
} else {
toast.error(res.data.mes, {
position: toast.POSITION.TOP_RIGHT,
});
}
).then(async res => {
if (res.data.res) {
dispatch(setAcount(res.data?.data))
toast.update(wait, { render: "Success", type: "success", isLoading: false, autoClose: true });
await new Promise((resolve) => setTimeout(resolve, 1000))
navigate("/Student-Attendance/Dashboard/");
} else {
toast.update(wait, { render: res.data?.mes, type: "error", isLoading: false, autoClose: true });
}
}).catch(err => {
toast.update(wait, { render: err, type: "error", isLoading: false, autoClose: true });
});

}
}
function validateEmail(email) {
Expand Down Expand Up @@ -339,31 +345,8 @@ export default function Signup(params) {
</div>
</div>
<div className={`w-5/6 md:w-3/5 ${isHidden ? "" : "hidden"}`}>
<div
className={`${state.err.hidden} flex p-4 text-sm text-yellow-700 bg-yellow-100 rounded-lg dark:bg-yellow-200 dark:text-yellow-800`}
role="alert"
>
<svg
aria-hidden="true"
className="flex-shrink-0 inline w-5 h-5 mr-3"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z"
clipRule="evenodd"
></path>
</svg>
<span className="sr-only">Info</span>
<div>
<span className="font-medium">Warring!</span>{" "}
{state.err.msg.map((e) => e + ",")}.
</div>
</div>
<div className="mb-3 dark:text-white">
<img className="my-4" src="../img/LogoQr.svg" alt="" />
<img className="my-4" src="../img/LogoQr.svg" alt="" />
<p className="text-zinc-500 mt-3 font-serif">
Welcome,please enter details.
</p>
Expand All @@ -375,7 +358,6 @@ export default function Signup(params) {
name="floating_email"
ref={email}
onBlur={handle}
onChange={handle}
id="floating_email"
className={`block py-2.5 px-0 w-full text-sm bg-transparent border-0 border-b-2 ${state.validateemail[0]} appearance-none focus:outline-none focus:ring-0 peer`}
placeholder=" "
Expand Down Expand Up @@ -472,17 +454,17 @@ export default function Signup(params) {
<div className="relative z-0 mb-3 w-full group">

<select name="speaciality" defaultValue={""} ref={sp} id="speaciality" className='block py-2.5 px-0 w-full text-sm text-gray-500 bg-transparent border-0 border-b-2 border-gray-200 appearance-none dark:text-gray-400 dark:border-gray-700 focus:outline-none focus:ring-0 focus:border-gray-200 peer'>
<option value={""} disabled>specialist</option>
<option value={""} disabled>specialist</option>
{spE && spE.map((e, i) => {
return (<option key={i} value={e.specialist}>{e.specialist}</option>)
})}
</select>

</div>
</div>
<div>

<select ref={company} id="underline_select" defaultValue={""} className="block py-2.5 px-0 w-full text-sm text-gray-500 bg-transparent border-0 border-b-2 border-gray-200 appearance-none dark:text-gray-400 dark:border-gray-700 focus:outline-none focus:ring-0 focus:border-gray-200 peer">
<option value={""} disabled>Male Or Female</option>
<option value={""} disabled>Male Or Female</option>
<option value="Male">Male</option>
<option value="Fimale">Female</option>
</select>
Expand Down

1 comment on commit c1b25cc

@vercel
Copy link

@vercel vercel bot commented on c1b25cc May 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.