ngiad / ProjectSaydeo

0 stars 0 forks source link

fix authen #1

Open hahuyhungdev opened 2 years ago

hahuyhungdev commented 2 years ago

nafy laf header `import React, { useEffect, useState } from "react"; import "./Header.css"; import vi from "../../img/vi.png"; import en from "../../img/en.png"; import logo from "../../img/logo.jpg"; import { AuthContext } from "../../contexts/AuthContext"; import { AiFillPhone } from "react-icons/ai"; import { GoLocation } from "react-icons/go"; import { BsFillCartCheckFill } from "react-icons/bs"; import { BsSearch } from "react-icons/bs"; import { Link, useNavigate } from "react-router-dom"; import { useDispatch, useSelector } from "react-redux"; import { update } from "../../Redux/Slice"; import { useContext } from "react";

const Header = () => { const { setLogin, LoginSuccect } = useContext(AuthContext); const Dispatch = useDispatch(); const Navigate = useNavigate();

const Products = useSelector((state) => state.Cart); const [inputValue, setInputvalue] = useState("");

const [amount, setAmount] = useState(0); // const InputSearch = useSelector((state) => state.Search) const HandleSearch = (e) => { e.preventDefault(); Dispatch(update(inputValue)); const result = inputValue.split(" ").join("").toLowerCase(); Navigate(/search?title=${result}); setInputvalue(""); }; const handleChange = (e) => { setInputvalue(e.target.value); };

useEffect(() => { if (Products !== undefined) { setAmount(Products.reduce((total, product) => total + product.amount, 0)); } }, [Products]);

return (

0962673018{" "} Dẹ 1 - Văn miếu - Thanh Sơn - Phú thọ

  • GIỚI THIỆU
  • LIÊN HỆ
  • img
  • img
img
{amount === 0 ? null : {amount}}
  • TRANG CHỦ
  • GIỚI THIỆU
  • SẢN PHẨM
  • HƯỚNG DẪN MUA HÀNG
  • TIN TỨC
  • LIÊN HỆ
  • {LoginSuccect && (
  • ADMIN
  • )} {/* setLogin */}
  • setLogin(true)} > {LoginSuccect ?
  • dang nhap roi nha
  • :
  • dang nhap
  • } {console.log(LoginSuccect)}

); };

export default Header;

`

ngiad commented 2 years ago

Cảm ơn ông, nhiệt tính quá =))

cái nayd tôi hỏi thì t thử test 1 chút thì thấy thắc mắc ở đâu r , đơn giản chỉ là t viết cái router ở trên thanh url thì cái app của t nó reset nên nó gán lại thành false thôi. cảm ơn ông rất nhiều nhé :v ngáo quá bh để ý mới mình ngáo

Reply to this email directly, view it on GitHub https://github.com/ngiad/ProjectSaydeo/issues/1#issuecomment-1275603524, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZB3NGQAVFQ55UK77TZPH43WCZDBXANCNFSM6AAAAAARC5GBJI .

You are receiving this because you are subscribed to this thread.Message ID: @.***>

ngiad commented 2 years ago

Vào Th 4, 12 thg 10, 2022 lúc 12:24 phuong nguyen @.***> đã viết:

nếu bh t thêm cái usúeefect như ông mà vẫn vào router bằng cách viết trên

url của tôi thì nó vẫn là false và sẽ vẫn vào rou là search thôi @@

Reply to this email directly, view it on GitHub https://github.com/ngiad/ProjectSaydeo/issues/1#issuecomment-1275603524, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZB3NGQAVFQ55UK77TZPH43WCZDBXANCNFSM6AAAAAARC5GBJI .

You are receiving this because you are subscribed to this thread.Message ID: @.***>

hahuyhungdev commented 2 years ago

oke ông haha

Vào Th 4, 12 thg 10, 2022 vào lúc 12:26 Tran Dai Nghia < @.***> đã viết:

Vào Th 4, 12 thg 10, 2022 lúc 12:24 phuong nguyen @.***> đã viết:

nếu bh t thêm cái usúeefect như ông mà vẫn vào router bằng cách viết trên

url của tôi thì nó vẫn là false và sẽ vẫn vào rou là search thôi @@

Reply to this email directly, view it on GitHub < https://github.com/ngiad/ProjectSaydeo/issues/1#issuecomment-1275603524>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AZB3NGQAVFQ55UK77TZPH43WCZDBXANCNFSM6AAAAAARC5GBJI

.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/ngiad/ProjectSaydeo/issues/1#issuecomment-1275607461, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT72JMK7GH4HYO3K3PHFVVDWCZDY7ANCNFSM6AAAAAARC5GBJI . You are receiving this because you authored the thread.Message ID: @.***>

ngiad commented 2 years ago

Vào Th 4, 12 thg 10, 2022 lúc 12:32 hà huy hùng @.***> đã viết:

cảm ơn ông nhiều nhé, nhiệt tình quá tôi mà làm con gái chao thân luôn đấy =)))

Vào Th 4, 12 thg 10, 2022 vào lúc 12:26 Tran Dai Nghia < @.***> đã viết:

Vào Th 4, 12 thg 10, 2022 lúc 12:24 phuong nguyen @.***> đã viết:

nếu bh t thêm cái usúeefect như ông mà vẫn vào router bằng cách viết trên

url của tôi thì nó vẫn là false và sẽ vẫn vào rou là search thôi @@

Reply to this email directly, view it on GitHub < https://github.com/ngiad/ProjectSaydeo/issues/1#issuecomment-1275603524 , or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AZB3NGQAVFQ55UK77TZPH43WCZDBXANCNFSM6AAAAAARC5GBJI

.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub <https://github.com/ngiad/ProjectSaydeo/issues/1#issuecomment-1275607461 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AT72JMK7GH4HYO3K3PHFVVDWCZDY7ANCNFSM6AAAAAARC5GBJI

. You are receiving this because you authored the thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/ngiad/ProjectSaydeo/issues/1#issuecomment-1275610981, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZB3NGUQITL4NKGOU6BYTNDWCZENLANCNFSM6AAAAAARC5GBJI . You are receiving this because you commented.Message ID: @.***>