Andrew 3 hafta önce
ebeveyn
işleme
d4b87967fd
4 değiştirilmiş dosya ile 21 ekleme ve 6 silme
  1. 2 2
      src/App.jsx
  2. 5 1
      src/Components/Player.jsx
  3. 14 3
      src/Login.jsx
  4. 0 0
      src/Player.jsx

+ 2 - 2
src/App.jsx

@@ -8,12 +8,12 @@ function App() {
   return (
     <div className="main">
       <Sidebar />
-      <Player className="top-video" video={"/assets/16_final.mp4"} information={{
+      <Player className="top-video" video={1} information={{
         title: "habibi habibi",
         description: "my name is john clapper. i clap everyone. i clap first at the cinema. no one else claps.",
         likes: "1.2M",
         dislikes: "1K",
-        comments: "1.2K",
+        comments: "1.1K",
         shares: "392",
         author: "John Clapper",
         authorAvatar: "https://i.imgur.com/4Z2b7aH.png",

+ 5 - 1
src/Components/Player.jsx

@@ -6,6 +6,8 @@ import Contact from "../icons/Contact.jsx"
 import ArrowRight from "../icons/ArrowRight.jsx"
 import ThreeDots from "../icons/ThreeDots.jsx"
 import Play from "../icons/Play.jsx"
+import { default as axios } from 'axios'
+import { config } from '../main.jsx'
 
 function Player(props) {
     const { video, information, top, className } = props;
@@ -16,7 +18,9 @@ function Player(props) {
         <>
             <div className={`container ${className}`} style={{ transform: `translateY(${top})` }}>
                 <div className="video-container">
-                    <video src={video} className="video-player" id="video-player" controls height={videoHeight} />
+                    <video className="video-player" id="video-player" controls height={videoHeight}>
+                        <source src={config.serverURL + "/video/" + video} type="video/mp4"></source>
+                    </video>
                     <div className="video-information">
                         <h1>{information.title}</h1>
                         <p>{information.description}</p>

+ 14 - 3
src/Login.jsx

@@ -1,12 +1,20 @@
 import './css/Login.css'
 import Sidebar from './Components/Sidebar'
-import { useState, useEffect } from 'react'
 import Cookies from 'js-cookie'
 import banner from "/src/assets/banner.png"
 import { default as axios } from 'axios'
 import { config } from './main'
+import { useNavigate } from 'react-router'
+import React, { useEffect } from 'react'
 
 function Login() {
+	let navigate = useNavigate();
+	if (Cookies.get("token") && Cookies.get("token").startsWith("HajeebToken ")) {
+		useEffect(() => {
+			return navigate("/");
+		}, [])
+	}
+
 	const handleSubmit = async (e) => {
 		e.preventDefault();
 		document.getElementById("submit").disabled = true;
@@ -17,11 +25,14 @@ function Login() {
 			password: formData.get("password")
 		})
 
-		if(response.data.error) {
+		if(response.data.error) { // Login unsuccessful
 			document.getElementById("submit").disabled = false;
 			return alert(`Login error: ${response.data.message}`);
 		}
-		Cookies.set("token", response.data.token);
+
+		// Login successful
+		Cookies.set("token", `HajeebToken ${response.data.token}`);
+		return navigate("/");
 	};
 
 	return (

+ 0 - 0
src/Player.jsx