diff --git a/package-lock.json b/package-lock.json index 7ef275d..96947db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "eslint-config-react-app": "^7.0.1", "formik": "^2.2.9", "jsonwebtoken": "^9.0.0", + "moment": "^2.29.4", "react": "^18.2.0", "react-dom": "^18.2.0", "react-hot-toast": "^2.4.0", @@ -12087,6 +12088,14 @@ "mkdirp": "bin/cmd.js" } }, + "node_modules/moment": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "engines": { + "node": "*" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", diff --git a/package.json b/package.json index c2e2499..1b69b34 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "eslint-config-react-app": "^7.0.1", "formik": "^2.2.9", "jsonwebtoken": "^9.0.0", + "moment": "^2.29.4", "react": "^18.2.0", "react-dom": "^18.2.0", "react-hot-toast": "^2.4.0", diff --git a/src/components/Login/index.jsx b/src/components/Login/index.jsx index 44278b9..e587366 100644 --- a/src/components/Login/index.jsx +++ b/src/components/Login/index.jsx @@ -1,5 +1,4 @@ import { useState } from "react"; -import { useNavigate, useLocation } from "react-router-dom"; import useAuth from "../../hooks/useAuth"; import axios from "axios"; @@ -12,9 +11,8 @@ const Signin = () => { const { setAuth } = useAuth(); - const location = useLocation(); - const navigate = useNavigate(); - const from = location.state?.from?.pathname || "/"; + + const handleChange = ({ currentTarget: input }) => { setData({ ...data, [input.name]: input.value }); @@ -30,7 +28,7 @@ const Signin = () => { setAuth({ roles, token }); console.log(roles); - navigate(from, { replace: true }); + window.location= "/homeuser" } catch (error) { if ( error.response && @@ -68,7 +66,7 @@ const Signin = () => {
Sign in to access your account diff --git a/src/components/Navbar/Navbar.jsx b/src/components/Navbar/Navbar.jsx index 827680d..f9e5ed3 100644 --- a/src/components/Navbar/Navbar.jsx +++ b/src/components/Navbar/Navbar.jsx @@ -1,60 +1,72 @@ import React, { useState } from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faSignOutAlt } from '@fortawesome/free-solid-svg-icons'; +import { Link } from 'react-router-dom'; - - - - const Navbar = () => { - const handleLogout = ()=> { +const Navbar = () => { + const handleLogout = () => { localStorage.removeItem("token"); window.location.reload("/login"); - } + }; + const [open, setOpen] = useState(true); const toggleMenu = () => { setOpen(!open); }; - - - - return ( - -
Unsupported file type
; + } +} export function PostCard({ post }) { const { deletePost } = usePosts(); const navigate = useNavigate(); + const normalDate = moment(post.createdAt).format("DD/MM/YYYY"); + const handleDelete = (id) => { toast( (t) => ( @@ -49,14 +75,14 @@ export function PostCard({ post }) {- {post.createdAt} + {normalDate}
{post.description}
diff --git a/src/components/PostCardUser.jsx b/src/components/PostCardUser.jsx index 8130285..f5fcc8c 100644 --- a/src/components/PostCardUser.jsx +++ b/src/components/PostCardUser.jsx @@ -1,32 +1,49 @@ - - - +import moment from "moment"; +import { insertMedia } from "./PostCard"; export function PostCardUser({ post }) { - + const normalDate = moment(post.createdAt).format("DD/MM/YYYY"); return ( -{post.createdAt}
++ {" "} + {normalDate} +
{post.description}