diff --git a/frontend/src/Admin/AdminCourses.jsx b/frontend/src/Admin/AdminCourses.jsx index d7b71f2..d623600 100644 --- a/frontend/src/Admin/AdminCourses.jsx +++ b/frontend/src/Admin/AdminCourses.jsx @@ -12,14 +12,25 @@ import { deleteProduct, getProduct, patchProduct } from '../redux/AdminReducer/a const AdminCourses = () => { const dispatch=useDispatch(); -const courses=useSelector((store)=>{ - return store.AdminReducer.data -}) - -console.log("course",courses); - +// const courses=useSelector((store)=>{ +// return store.AdminReducer.data +// }) +const[courses,getCourses] =useState([]) +// console.log("course",courses); +let user=JSON.parse(localStorage.getItem('user')); useEffect(()=>{ dispatch(getProduct()) + fetch("https://energetic-wasp-hose.cyclic.cloud/courses",{ + headers:{ + "Authorization":`Bearer ${user.token}` + } + }).then((res)=>{ + return res.json() + }).then((res)=>{ + console.log(res) + getCourses(res.Courses + ) + }) },[]) diff --git a/frontend/src/Admin/AdminNavbar.jsx b/frontend/src/Admin/AdminNavbar.jsx index b0720e2..d28c3f7 100644 --- a/frontend/src/Admin/AdminNavbar.jsx +++ b/frontend/src/Admin/AdminNavbar.jsx @@ -7,6 +7,21 @@ import styled from "styled-components"; export const AdminNavbar = () => { let user=JSON.parse(localStorage.getItem("user")); console.log(user.user); +const navigate= useNavigate(); + +const handleChange=(e)=>{ + + // localStorage.setItem("user",null) + if(e.target.value=="2"){ + localStorage.clear(); + }else if(e.target.value=="3"){ + navigate("/admin") + }else if(e.target.value=="1"){ + navigate("/dashboard") + } + +} + return (
@@ -25,8 +40,20 @@ console.log(user.user); - - {user.user} + {user.user} + {/*
+ +
*/}
); @@ -85,4 +112,7 @@ const DIV = styled.div` padding-top: 7px; border-radius: 2px; } + select{ + color: black; + } `; diff --git a/frontend/src/Admin/AdminUsers.jsx b/frontend/src/Admin/AdminUsers.jsx index 7807f87..16359f0 100644 --- a/frontend/src/Admin/AdminUsers.jsx +++ b/frontend/src/Admin/AdminUsers.jsx @@ -10,14 +10,28 @@ import { deleteUsers, getUser } from '../redux/AdminReducer/action'; import { patchUser } from '../redux/AdminReducer/action'; const AdminUsers = () => { - + let user=JSON.parse(localStorage.getItem('user')); const dispatch=useDispatch(); -const users=useSelector((store)=>{ - return store.AdminReducer.users -}) +// const users=useSelector((store)=>{ +// return store.AdminReducer.users +// }) +const [users,setUsers]=useState([]) + console.log(users); useEffect(()=>{ dispatch(getUser()) + fetch("https://energetic-wasp-hose.cyclic.cloud/users",{ + headers:{ + "Authorization":`Bearer ${user.token}` + } + }).then((res)=>{ + return res.json() + }).then((res)=>{ + console.log(res) + setUsers(res.users + ) + }) + },[]) diff --git a/frontend/src/Admin/CourseForm.jsx b/frontend/src/Admin/CourseForm.jsx index 64d1cd7..62c7cab 100644 --- a/frontend/src/Admin/CourseForm.jsx +++ b/frontend/src/Admin/CourseForm.jsx @@ -42,12 +42,30 @@ const CourseForm = () => { - const courses=useSelector((store)=>{ - return store.AdminReducer.data - }) + // const courses=useSelector((store)=>{ + // return store.AdminReducer.data + // }) const dispatch=useDispatch(); - + const[courses,getCourses] =useState([]) + // console.log("course",courses); + let user=JSON.parse(localStorage.getItem('user')); + useEffect(()=>{ + dispatch(getProduct()) + fetch("https://energetic-wasp-hose.cyclic.cloud/courses",{ + headers:{ + "Authorization":`Bearer ${user.token}` + } + }).then((res)=>{ + return res.json() + }).then((res)=>{ + console.log(res) + getCourses(res.Courses + ) + }) + + },[]) + useEffect(()=>{ diff --git a/frontend/src/Admin/UserEdit.jsx b/frontend/src/Admin/UserEdit.jsx index 6d8953a..670fbc6 100644 --- a/frontend/src/Admin/UserEdit.jsx +++ b/frontend/src/Admin/UserEdit.jsx @@ -21,9 +21,29 @@ const UserEdit = () => { const {id}= useParams() // let id="64eb6860527fb0c018fed42c" - const users=useSelector((store)=>{ - return store.AdminReducer.users - }) + // const users=useSelector((store)=>{ + // return store.AdminReducer.users + // }) + let user=JSON.parse(localStorage.getItem('user')); + const [users,setUsers]=useState([]) + + console.log(users); + useEffect(()=>{ + dispatch(getUser()) + fetch("https://energetic-wasp-hose.cyclic.cloud/users",{ + headers:{ + "Authorization":`Bearer ${user.token}` + } + }).then((res)=>{ + return res.json() + }).then((res)=>{ + console.log(res) + setUsers(res.users + ) + }) + + },[]) + console.log(users); const dispatch=useDispatch(); useEffect(()=>{ diff --git a/frontend/src/components/Footer.jsx b/frontend/src/components/Footer.jsx index 4fc7c12..0b1ae4f 100644 --- a/frontend/src/components/Footer.jsx +++ b/frontend/src/components/Footer.jsx @@ -1,11 +1,17 @@ -import React from 'react'; -import styled from 'styled-components'; -import { FaFacebookF, FaTwitter, FaLinkedin, FaInstagram, FaYoutube } from 'react-icons/fa'; +import React from "react"; +import styled from "styled-components"; +import { + FaFacebookF, + FaTwitter, + FaLinkedin, + FaInstagram, + FaYoutube, +} from "react-icons/fa"; const Footer = () => { return ( -
+

Learn Something New

    @@ -47,50 +53,68 @@ const Footer = () => {
  • Meta Front-End Developer
-
-
-

Connect with Us

- - +
+
+

Connect with Us

+ -

© 2023 Skillvintage Inc. All rights reserved.

- + ); }; export default Footer; const FooterContainer = styled.footer` -width: 100%; -align-self:center; -/* border: 1px solid red; */ + width: 100%; + align-self: center; + /* border: 1px solid red; */ background-color: #333; color: white; padding: 20px 0; @@ -99,73 +123,67 @@ align-self:center; width: 150%; } - #social{ -/* border:1px solid white; */ - list-style: none; - display: flex; - justify-content:center; - align-items:center; -text-align: center; - /* margin-left: 33%; */ - padding: 0; - li { - margin: 0 10px; -align-self:center; -/* border-bottom: 1px solid; */ - a { - color: white; - font-size: 1.5rem; - - &:hover { - color: #66ccff; /* Change color on hover */ + #social { + /* border:1px solid white; */ + list-style: none; + display: flex; + justify-content: center; + align-items: center; + text-align: center; + /* margin-left: 33%; */ + padding: 0; + li { + margin: 0 10px; + align-self: center; + /* border-bottom: 1px solid; */ + a { + color: white; + font-size: 1.5rem; + + &:hover { + color: #66ccff; /* Change color on hover */ + } + } } } -} - -} - + .footer-section { + display: flex; + /* border: 1px solid red; */ + justify-content: space-around; + width: 100%; + /* margin: 0 auto; */ + @media only screen and (max-width: 576px) { + flex-direction: column; + margin-left: 20px; + } + } + .footer-column { + ul { + list-style: none; + padding-left: 0; + } -.footer-section { - display: flex; - /* border: 1px solid red; */ - justify-content: space-around; - width: 100%; - /* margin: 0 auto; */ - @media only screen and (max-width: 576px) { - flex-direction: column; -margin-left:20px; - + li { + margin: 5px 0; + } } -} -.footer-column { - ul { - list-style: none; - padding-left: 0; + h3 { + font-size: 1.2rem; + margin-bottom: 10px; + text-align: center; } - li { - margin: 5px 0; + .footer-bottom { + width: 100%; + text-align: center; + margin-top: 20px; } -} - -h3 { - font-size: 1.2rem; - margin-bottom: 10px; - text-align:center; -} - -.footer-bottom { -width: 100%; - text-align: center; - margin-top: 20px; -} -@media only screen and (min-width: 577px) and (max-width: 768px) { + @media only screen and (min-width: 577px) and (max-width: 768px) { /* Additional styling for small screens */ width: 150%; } - -`; \ No newline at end of file +`; diff --git a/frontend/src/components/Login.jsx b/frontend/src/components/Login.jsx index a29c23e..e29eafd 100644 --- a/frontend/src/components/Login.jsx +++ b/frontend/src/components/Login.jsx @@ -26,7 +26,7 @@ const Login = () => { const emailbox = useRef(null); const passwordInput = useRef(null); const passwordbox = useRef(null); - const [form, setForm] = useState({ email: "", password: "" }); + const [form, setForm] = useState({ email: "shashi@gmail.com", password: "shashi" }); const userStore = useSelector((store) => store.UserReducer); const dispatch = useDispatch(); @@ -74,7 +74,7 @@ const Login = () => { function handleLogin() { console.log(form); dispatch(loginFetch(form)).then((res) => { - setForm({ email: "", password: "" }); + // setForm({ email: "", password: "" }); navigate("/dashboard") }); @@ -98,13 +98,13 @@ const Login = () => { - - - Log in to your Account + + + Log in to your Account {/* 2nd box */} diff --git a/frontend/src/components/Navbar.jsx b/frontend/src/components/Navbar.jsx index 79bebaf..ea8454d 100644 --- a/frontend/src/components/Navbar.jsx +++ b/frontend/src/components/Navbar.jsx @@ -5,9 +5,13 @@ import logo from "../homeImg/logo2.jpg"; import { Link } from 'react-router-dom'; import { BsPersonCircle } from "react-icons/bs"; import { useNavigate } from 'react-router-dom'; +import { useSelector } from "react-redux"; const Navbar = () => { + const userStore = useSelector((store) => store.UserReducer); +console.log("userStore",userStore); + const navigate= useNavigate(); const user = JSON.parse(localStorage.getItem("user")) || {} diff --git a/frontend/src/components/Signup.jsx b/frontend/src/components/Signup.jsx index 5d41ec6..8e3b47b 100644 --- a/frontend/src/components/Signup.jsx +++ b/frontend/src/components/Signup.jsx @@ -1,36 +1,374 @@ -import React, { useRef, useState } from "react"; +// import React, { useRef, useState } from "react"; import Navbar from "./Navbar"; +// import { +// Box, +// Button, +// Flex, +// Heading, +// Input, +// Spinner, +// Text, +// Toast, +// keyframes, +// useToast, +// } from "@chakra-ui/react"; +// import { AiOutlineEyeInvisible, AiFillEye } from "react-icons/ai"; + +// import { useDispatch, useSelector } from "react-redux"; + +// import { Link, useNavigate } from "react-router-dom"; +// import { signUpFetch } from "../redux/UserReducer/action"; +// import {BiError} from 'react-icons/bi' +// import { actionsingUpError } from "../redux/UserReducer/actionType"; + +// const SignUp = () => { +// const emailInput = useRef(null); +// const backgroundRef = useRef(null); +// const emailbox = useRef(null); +// const passwordInput = useRef(null); +// const passwordbox = useRef(null); +// const nameInput = useRef(null); +// const namebox = useRef(null); +// const confirmPasswordInput = useRef(null); +// const confirmPasswordbox = useRef(null); +// const [form, setForm] = useState({ +// email: "", +// password: "", +// confirmPassword: "", +// name: "", +// isPromotion: false, +// }); + +// const userStore = useSelector((store) => store.UserReducer); +// const dispatch = useDispatch(); +// const navigate = useNavigate(); +// const [isChecked, setIsChecked] = useState(false); +// const [eyeclose, seteyeMoment] = useState(false); +// const toast = useToast() +// const [toastkey,setToastKey] = useState(true) + +// // will show the input element when click on element +// function showInput(e) { +// const ele = e.target.id; +// if (ele === "email") { +// emailInput.current.style.display = "block"; +// emailInput.current.focus(); +// emailbox.current.style.padding = "5px 20px"; +// } else if (ele === "password") { +// passwordInput.current.style.display = "block"; +// passwordInput.current.focus(); +// passwordbox.current.style.padding = "5px 20px"; +// } else if (ele === "name") { +// nameInput.current.style.display = "block"; +// nameInput.current.focus(); +// namebox.current.style.padding = "5px 20px"; +// } else if (ele === "confirmPassword") { +// confirmPasswordInput.current.style.display = "block"; +// confirmPasswordInput.current.focus(); +// confirmPasswordbox.current.style.padding = "5px 20px"; +// } +// } + +// // will block the input element when click on backgrond +// function blockInput(event) { +// if (event.target === backgroundRef.current && !form.email) { +// emailInput.current.style.display = "none"; +// emailbox.current.style.padding = "20px"; +// } +// if (event.target === backgroundRef.current && !form.password) { +// passwordInput.current.style.display = "none"; +// passwordbox.current.style.padding = "20px"; +// } +// if (event.target === backgroundRef.current && !form.confirmPassword) { +// confirmPasswordInput.current.style.display = "none"; +// confirmPasswordbox.current.style.padding = "20px"; +// } + +// if (event.target === backgroundRef.current && !form.name) { +// nameInput.current.style.display = "none"; +// namebox.current.style.padding = "20px"; +// } +// } + +// // form management + +// function handleInput(e) { +// const { value, name } = e.target; +// setForm({ ...form, [name]: value }); +// } + +// // see password; + +// function showPassword() { +// seteyeMoment(!eyeclose); +// passwordInput.current.type === "password" +// ? (passwordInput.current.type = "text") +// : (passwordInput.current.type = "password"); +// } + +// // handle promotion +// const handleCheckboxChange = () => { +// setIsChecked(!isChecked); +// setForm({ ...form, isPromotion: !isChecked }); +// }; + +// // Error toast +// const showToast = () => { +// toast({ +// position: 'top-right', +// top:'100px', +// render: () => ( +// +// {/* {userStore.isError} */} +// +// ), +// }); +// }; + +// // Sucess Toast +// const showSucessToast = () => { +// toast({ +// position: 'top-right', +// top:'100px', +// render: () => ( +// +// Sign Up Sucess +// +// ), +// }); +// }; + +// if(userStore.isError && toastkey){ +// showToast(); +// setToastKey(false) +// } + +// // SignUp function +// function handleSignUp() { +// setToastKey(true); +// const { email, password, confirmPassword, name } = form; +// if (!email || !password || !confirmPassword || !name) { +// dispatch(actionsingUpError('All fields are required')); +// return; +// } +// console.log("signUpData",form); +// if (confirmPassword !== password) { +// dispatch(actionsingUpError('Password does not match')); +// return; +// } + +// dispatch(signUpFetch(form)) +// .then((res) => { +// setForm({ email: '', password: '', confirmPassword: '', name: '' }); +// showSucessToast(); +// }) +// } + +// return ( +// +// +// +// +// +// +// +// Sign up And Start Learning +// +// {/* 2nd box */} +// +// {/* name */} +// +// +// +// Name +// +// +// +// +// +// +// {/* email */} +// +// +// +// Email +// +// +// +// +// +// +// {/* password */} +// +// +// +// +// Password +// +// +// +// {eyeclose ? ( +// +// ) : ( +// +// )} +// +// +// +// +// +// +// {/* confirm password */} +// +// +// +// Confirm Password +// +// +// +// +// +// + +// +// +// +// +// +// +// Send me special offers, personalized recommendations, and +// learning tips. +// +// +// + +// {/* button */} +// +// + +// Already Resistered Login Here +// +// +// +// +// +// ); +// }; + +// export default SignUp; + +import React, { useState } from "react"; import { - Box, + Input, + Checkbox, Button, - Flex, + Box, Heading, - Input, - Spinner, - Text, Toast, - keyframes, useToast, + Text, } from "@chakra-ui/react"; -import { AiOutlineEyeInvisible, AiFillEye } from "react-icons/ai"; - -import { useDispatch, useSelector } from "react-redux"; - -import { useNavigate } from "react-router-dom"; +import { Link, useNavigate } from "react-router-dom"; import { signUpFetch } from "../redux/UserReducer/action"; -import {BiError} from 'react-icons/bi' import { actionsingUpError } from "../redux/UserReducer/actionType"; - -const SignUp = () => { - const emailInput = useRef(null); - const backgroundRef = useRef(null); - const emailbox = useRef(null); - const passwordInput = useRef(null); - const passwordbox = useRef(null); - const nameInput = useRef(null); - const namebox = useRef(null); - const confirmPasswordInput = useRef(null); - const confirmPasswordbox = useRef(null); +import { useDispatch, useSelector } from "react-redux"; +const Signup = () => { + const dispatch = useDispatch(); + const navigate = useNavigate(); const [form, setForm] = useState({ email: "", password: "", @@ -39,85 +377,38 @@ const SignUp = () => { isPromotion: false, }); - const userStore = useSelector((store) => store.UserReducer); - const dispatch = useDispatch(); - const navigate = useNavigate(); - const [isChecked, setIsChecked] = useState(false); - const [eyeclose, seteyeMoment] = useState(false); - const toast = useToast() - const [toastkey,setToastKey] = useState(true) - - // will show the input element when click on element - function showInput(e) { - const ele = e.target.id; - if (ele === "email") { - emailInput.current.style.display = "block"; - emailInput.current.focus(); - emailbox.current.style.padding = "5px 20px"; - } else if (ele === "password") { - passwordInput.current.style.display = "block"; - passwordInput.current.focus(); - passwordbox.current.style.padding = "5px 20px"; - } else if (ele === "name") { - nameInput.current.style.display = "block"; - nameInput.current.focus(); - namebox.current.style.padding = "5px 20px"; - } else if (ele === "confirmPassword") { - confirmPasswordInput.current.style.display = "block"; - confirmPasswordInput.current.focus(); - confirmPasswordbox.current.style.padding = "5px 20px"; - } - } - - // will block the input element when click on backgrond - function blockInput(event) { - if (event.target === backgroundRef.current && !form.email) { - emailInput.current.style.display = "none"; - emailbox.current.style.padding = "20px"; - } - if (event.target === backgroundRef.current && !form.password) { - passwordInput.current.style.display = "none"; - passwordbox.current.style.padding = "20px"; - } - if (event.target === backgroundRef.current && !form.confirmPassword) { - confirmPasswordInput.current.style.display = "none"; - confirmPasswordbox.current.style.padding = "20px"; - } - - if (event.target === backgroundRef.current && !form.name) { - nameInput.current.style.display = "none"; - namebox.current.style.padding = "20px"; - } - } - - // form management + const [showPassword, setShowPassword] = useState(false); + const [focusedInput, setFocusedInput] = useState(null); - function handleInput(e) { - const { value, name } = e.target; + const handleInputChange = (e) => { + const { name, value } = e.target; setForm({ ...form, [name]: value }); - } + }; - // see password; + const togglePasswordVisibility = () => { + setShowPassword(!showPassword); + }; - function showPassword() { - seteyeMoment(!eyeclose); - passwordInput.current.type === "password" - ? (passwordInput.current.type = "text") - : (passwordInput.current.type = "password"); - } + const handleCheckboxChange = (e) => { + const { name, checked } = e.target; + setForm({ ...form, [name]: checked }); + }; + const handleFocus = (name) => { + setFocusedInput(name); + }; - // handle promotion - const handleCheckboxChange = () => { - setIsChecked(!isChecked); - setForm({ ...form, isPromotion: !isChecked }); + const handleBlur = () => { + setFocusedInput(null); }; -// Error toast + const [toastkey, setToastKey] = useState(true); + const toast = useToast(); + // Error toast const showToast = () => { toast({ - position: 'top-right', - top:'100px', + position: "top-right", + top: "100px", render: () => ( {/* {userStore.isError} */} @@ -129,8 +420,8 @@ const SignUp = () => { // Sucess Toast const showSucessToast = () => { toast({ - position: 'top-right', - top:'100px', + position: "top-right", + top: "100px", render: () => ( Sign Up Sucess @@ -139,215 +430,109 @@ const SignUp = () => { }); }; - if(userStore.isError && toastkey){ - showToast(); - setToastKey(false) - } + const handleSubmit = (e) => { + e.preventDefault(); + console.log(form); - // SignUp function - function handleSignUp() { setToastKey(true); const { email, password, confirmPassword, name } = form; if (!email || !password || !confirmPassword || !name) { - dispatch(actionsingUpError('All fields are required')); + dispatch(actionsingUpError("All fields are required")); return; } - + console.log("signUpData", form); if (confirmPassword !== password) { - dispatch(actionsingUpError('Password does not match')); + dispatch(actionsingUpError("Password does not match")); return; } - - - dispatch(signUpFetch(form)) - .then((res) => { - setForm({ email: '', password: '', confirmPassword: '', name: '' }); - showSucessToast(); - }) - } - + dispatch(signUpFetch(form)).then((res) => { + setForm({ email: "", password: "", confirmPassword: "", name: "" }); + showSucessToast(); + navigate("/login"); + }); + }; return ( - - - - - - - Sign up And Start Learning + + + Register + + +
+ + handleFocus("name")} + onBlur={handleBlur} + placeholder="Name" + isReadOnly={focusedInput !== "name"} + /> - {/* 2nd box */} - - {/* name */} - - - - Name - - - - - - - {/* email */} - - - - Email - - - - - - - {/* password */} - - - - - Password - - - - {eyeclose ? ( - - ) : ( - - )} - - - - - - - {/* confirm password */} - + handleFocus("email")} + onBlur={handleBlur} + placeholder="Email" + isReadOnly={focusedInput !== "email"} + /> + + + handleFocus("password")} + onBlur={handleBlur} + placeholder="Password" + isReadOnly={focusedInput !== "password"} + onClick={togglePasswordVisibility} + /> + + + handleFocus("confirmPassword")} + onBlur={handleBlur} + placeholder="Confirm Password" + isReadOnly={focusedInput !== "confirmPassword"} + onClick={togglePasswordVisibility} + /> + + + - - - Confirm Password - - - - - - - - - - - - - - Send me special offers, personalized recommendations, and - learning tips. - - - - - {/* button */} - - - + Subscribe to promotions + - + + + Already Registered?{" "} + + Click Here + + +
); }; -export default SignUp; +export default Signup; diff --git a/frontend/src/pages/Dashboard.jsx b/frontend/src/pages/Dashboard.jsx index 66040df..e81835a 100644 --- a/frontend/src/pages/Dashboard.jsx +++ b/frontend/src/pages/Dashboard.jsx @@ -6,21 +6,37 @@ import Footer from '../components/Footer' import axios from 'axios' import { useDispatch, useSelector } from 'react-redux' import { getCourses } from '../redux/UserReducer/action' +import { useNavigate } from 'react-router-dom' +import { getProduct } from '../redux/AdminReducer/action'; const Dashboard = () => { + + // const data=useSelector((store)=>{ + // return store.AdminReducer.data + // }) + + // console.log("course",data); + + // useEffect(()=>{ + // dispatch(getProduct()) + + // },[]) + +const navigate=useNavigate() const [showAll, setShowAll] = useState(false); const [data,setData]=useState([]) - - - + let user=JSON.parse(localStorage.getItem('user')); +if(!user){ + navigate("/login") +} const dispatch=useDispatch() @@ -33,7 +49,7 @@ const Dashboard = () => { fetch("https://energetic-wasp-hose.cyclic.cloud/courses",{ headers:{ - "Authorization":`Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySUQiOiI2NGU4ZjI5MGVhZWRhNjFjZTJmOTliMWUiLCJ1c2VyTmFtZSI6InNoYXNoaSIsInJvbGUiOiJhZG1pbiIsImlhdCI6MTY5MzEyODY1MCwiZXhwIjoxNjkzNzMzNDUwfQ.tAXBywpDLMOdIMRVbptGjStLb1t2IoQqjUBeL83pN3Y` + "Authorization":`Bearer ${user?.token}` } }).then((res)=>{ return res.json() @@ -44,7 +60,7 @@ const Dashboard = () => { }) - dispatch(getCourses()) + // dispatch(getCourses()) @@ -86,7 +102,7 @@ const Dashboard = () => {

Earn Your Degree

- {data.slice(0, showAll ? data.length : 4).map((course, index) => ( + {data?.slice(0, showAll ? data.length : 4)?.map((course, index) => ( {

Most Popular Certificates

- {data.reverse().slice(0, showAll ? data.length : 4).map((course, index) => ( + {data?.slice(0, showAll ? data.length : 4)?.map((course, index) => ( {

- {data.slice(0, showAll ? data.length : 4).map((course, index) => ( + {data?.slice(0, showAll ? data.length : 4)?.map((course, index) => ( diff --git a/frontend/src/pages/Homepage.jsx b/frontend/src/pages/Homepage.jsx index 696e37b..d1a7c01 100644 --- a/frontend/src/pages/Homepage.jsx +++ b/frontend/src/pages/Homepage.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect } from "react"; import Navbar from "../components/Navbar"; import Footer from "../components/Footer"; import BannerSlider from "../components/BannerSlider"; @@ -7,7 +7,23 @@ import banner from "../homeImg/b3.png"; import banner1 from "../homeImg/b5.png"; import { styled } from "styled-components"; import CategoryList from "../components/CategoryList"; + +import { useDispatch, useSelector } from 'react-redux' +import { getProduct, } from '../redux/AdminReducer/action'; + const Homepage = () => { +const dispatch = useDispatch() + // const courses=useSelector((store)=>{ + // return store.UserReducer.token + // }) + + // console.log("token",courses); + + useEffect(()=>{ + dispatch(getProduct()) + + },[]) + return (
diff --git a/frontend/src/pages/Payment.css b/frontend/src/pages/Payment.css index d905c8e..6389cca 100644 --- a/frontend/src/pages/Payment.css +++ b/frontend/src/pages/Payment.css @@ -172,7 +172,9 @@ #pay:hover { background-color: #00bcd4; } - + .container1 input{ + border: 1px solid black; + } .container2 { width: 35%; /* height: 800px; */ diff --git a/frontend/src/pages/SingleCoursePage.jsx b/frontend/src/pages/SingleCoursePage.jsx index 40c7254..33e32ee 100644 --- a/frontend/src/pages/SingleCoursePage.jsx +++ b/frontend/src/pages/SingleCoursePage.jsx @@ -9,7 +9,7 @@ import { useNavigate } from "react-router-dom"; const SingleCoursePage = () => { const [singleData, setSingleData] = useState(null); - + let user=JSON.parse(localStorage.getItem('user')); const { id } = useParams() @@ -17,7 +17,7 @@ const SingleCoursePage = () => { try { const response = await fetch(`https://energetic-wasp-hose.cyclic.cloud/courses`, { headers: { - "Authorization": `Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySUQiOiI2NGU4ZjI5MGVhZWRhNjFjZTJmOTliMWUiLCJ1c2VyTmFtZSI6InNoYXNoaSIsInJvbGUiOiJhZG1pbiIsImlhdCI6MTY5MzEyODY1MCwiZXhwIjoxNjkzNzMzNDUwfQ.tAXBywpDLMOdIMRVbptGjStLb1t2IoQqjUBeL83pN3Y` + "Authorization":`Bearer ${user.token}` } }); const data = await response.json(); diff --git a/frontend/src/redux/AdminReducer/action.js b/frontend/src/redux/AdminReducer/action.js index d0aa6a0..3e501bd 100644 --- a/frontend/src/redux/AdminReducer/action.js +++ b/frontend/src/redux/AdminReducer/action.js @@ -1,8 +1,8 @@ import axios from "axios" import { ADD_PRODUCT_SUCCESS, ADD_User_SUCCESS, GET_PRODUCT_SUCCESS, GET_User_SUCCESS, PATCH_PRODUCT_SUCCESS, PATCH_User_SUCCESS, PRODUCT_FAILURE, PRODUCT_REQUEST } from "./actionType" -// const token = JSON.parse(localStorage.getItem('user'))?.token || ""; -const token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySUQiOiI2NGU4ZjI5MGVhZWRhNjFjZTJmOTliMWUiLCJ1c2VyTmFtZSI6InNoYXNoaSIsInJvbGUiOiJhZG1pbiIsImlhdCI6MTY5MzEyNTg1MSwiZXhwIjoxNjkzNzMwNjUxfQ.BlugfQEtyCNBJtBe3xSFgrZSK_d6t3oyx1UEXvFYTvU" +const token = JSON.parse(localStorage.getItem('user'))?.token || ""; +// const token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySUQiOiI2NGU4ZjI5MGVhZWRhNjFjZTJmOTliMWUiLCJ1c2VyTmFtZSI6InNoYXNoaSIsInJvbGUiOiJhZG1pbiIsImlhdCI6MTY5MzEyNTg1MSwiZXhwIjoxNjkzNzMwNjUxfQ.BlugfQEtyCNBJtBe3xSFgrZSK_d6t3oyx1UEXvFYTvU" const BaseURL="https://energetic-wasp-hose.cyclic.cloud"; diff --git a/frontend/src/redux/UserReducer/action.js b/frontend/src/redux/UserReducer/action.js index 65b17dd..658b6ab 100644 --- a/frontend/src/redux/UserReducer/action.js +++ b/frontend/src/redux/UserReducer/action.js @@ -13,6 +13,7 @@ import { } from "./actionType"; let baseURL = "https://energetic-wasp-hose.cyclic.cloud/"; +let user=localStorage.getItem('user'); // export const loginFetch = (value) => (dispatch) => { // dispatch(actionLoginLoading()); @@ -45,7 +46,7 @@ export const loginFetch = (value) => (dispatch) => { "user", JSON.stringify({token: res.data.token,isAuth: true,user:value.password}) ); - console.log(res); + console.log("loginres",res); }) .catch((err) => { dispatch(actionLoginError(err.message)); @@ -86,7 +87,7 @@ export const getCourses=()=>(dispatch)=>{ fetch("https://energetic-wasp-hose.cyclic.cloud/courses",{ headers:{ - "Authorization":`Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySUQiOiI2NGU4ZjI5MGVhZWRhNjFjZTJmOTliMWUiLCJ1c2VyTmFtZSI6InNoYXNoaSIsInJvbGUiOiJhZG1pbiIsImlhdCI6MTY5MzEyODY1MCwiZXhwIjoxNjkzNzMzNDUwfQ.tAXBywpDLMOdIMRVbptGjStLb1t2IoQqjUBeL83pN3Y` + "Authorization":`Bearer ${user.token}` } }).then((res)=>{ return res.json()