Skip to content

Commit

Permalink
fix(*): update files
Browse files Browse the repository at this point in the history
  • Loading branch information
HoseaCodes committed Feb 19, 2024
1 parent af3d4b6 commit 9db71a5
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 81 deletions.
68 changes: 25 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"react-markdown": "^7.0.0",
"react-masonry-css": "^1.0.16",
"react-router-dom": "^5.2.0",
"react-scripts": "5.0.0",
"react-scripts": "4.0.3",
"react-spring": "^8.0.27",
"react-sticky-state": "^2.1.9",
"react-twitter-widgets": "^1.10.0",
Expand Down
9 changes: 5 additions & 4 deletions src/API/UserAPI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ function UserAPI(token) {
const [cookies] = useCookies(["cookie-name"]);

useEffect(() => {
if (!cookies.accesstoken) setIsLoggedIn(true);
if (token) {
if (cookies.accesstoken) setIsLoggedIn(true);
if (token || isLoggedIn || cookies.accesstoken) {
const getUser = async () => {
const accesstoken = token ? token : cookies.accesstoken;
try {
const res = await axios.get("/api/user/info", {
headers: { Authorization: token }
headers: { Authorization: accesstoken }
});
console.log(res, "huh");
setIsLoggedIn(true);
Expand All @@ -46,7 +47,7 @@ function UserAPI(token) {
};
getUser();
}
}, [token, cookies, user]);
}, [token, cookies]);

const addCart = async product => {
if (!isLoggedIn) return alert("Please login to continue buying");
Expand Down
7 changes: 5 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ const App = () => {
<Route path="/project/:id" exact={true} component={ProjectItem} />
{/* Showcase */}
{/* UserManagement */}
<PrivateRoute type={"login"} path="/profile" exact={true} element={Profile} />
<PrivateRoute type={"login"} path="/profile" exact={true} element={Profile} >
<Profile />
</PrivateRoute>
{/* <PrivateRoute type={"login"} path="/profile" exact={true} element={Profile} /> */}
<PrivateRoute type={"login"} path="/profile/edit" exact={true} element={Editprofile} />
{/* UserManagement */}
{/* AdminManagement */}
Expand All @@ -79,7 +82,7 @@ const App = () => {
<PrivateRoute type={"login"} path="/shop/cart" exact={true} element={Checkout} />
{/* Shop */}
{/* 404 */}
<Route path="*" component={Error} />
{/* <Route component={Error} /> */}
{/* 404 */}
</Layout>
</DataProvider>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/NavBar/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const NavBar = () => {
id="navdrop" role="button" data-toggle="dropdown"
data-hover="dropdown">Blog</a>
<div className="dropdown-menu" aria-labelledby="navdrop">
<Link to={"/blog/new"} className="dropdown-item nav-link">Create Post</Link>
<Link to={"/admin/blog/new"} className="dropdown-item nav-link">Create Post</Link>
<Link to={"/blog"} rel="noopener noreferrer"
className="dropdown-item nav-link">View Blogs</Link>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/NavBar/SideBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const SideBar = () => {
<MdBookmarkBorder onClick={handleSave} style={{marginBottom: '5rem'}}/>
<ArticleHr/>
{isAdmin ?
<Link to="/blog/new"><HiOutlinePencilAlt style={{marginBottom: '5rem'}}/></Link>
<Link to="/admin/blog/new"><HiOutlinePencilAlt style={{marginBottom: '5rem'}}/></Link>
:
<HiOutlinePencilAlt onClick={handleUnauthorized} style={{marginBottom: '5rem'}}/>
}
Expand Down
32 changes: 15 additions & 17 deletions src/Pages/Articles/CreateArticle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GlobalState } from "../../GlobalState";
import Loading from "../../Loading";
import { useHistory, useParams } from "react-router-dom";
import axios from "axios";
import "./CreateArticle.css";
// import "./CreateArticle.css";
import marked from "marked";
import { v4 as uuidv4 } from "uuid";
import Error401 from "../Error/Error401";
Expand Down Expand Up @@ -213,14 +213,14 @@ function CreatArticle() {
<div className="panel-body">
<form className="row g-3" onSubmit={handleSubmit}>
<div className="col-md-6">
<div id="div_p_name" className="form-group required">
<div id="div_p_name" className=" required">
<label
for="p_name"
className="control-label requiredField"
>
Title<span className="asteriskField">*</span>
</label>
<div className="controls">
{/* <div className="controls"> */}
<input
className="input-md emailinput form-control"
placeholder="Enter Article Title Name"
Expand All @@ -231,11 +231,11 @@ function CreatArticle() {
onChange={handleChangeInput}
disabled={onEdit}
/>
</div>
{/* </div> */}
</div>
</div>
<div className="col-md-6">
<div id="div_p_name" className="form-group required">
<div id="div_p_name" className=" required">
<label
for="p_name"
className="control-label requiredField"
Expand All @@ -257,7 +257,7 @@ function CreatArticle() {
</div>
</div>
<div className="col-md-6">
<div id="div_p_id" className="form-group required">
<div id="div_p_id" className=" required">
<label
for="p_id"
className="control-label requiredField"
Expand All @@ -276,11 +276,11 @@ function CreatArticle() {
</div>
</div>
<div className="col-md-6 mb-0">
<div id="div_p_id" className="form-group required">
<div id="div_p_id" className=" required">
<label
for="tags"
className="control-label"
requiredfield
requiredField
>
{" "}
Article Language Tag
Expand All @@ -300,7 +300,7 @@ function CreatArticle() {
</div>
</div>
<div className="col-md-6">
<div id="div_description" className="form-group required">
<div id="div_description" className=" required">
<label
for="p_name"
className="control-label requiredField"
Expand Down Expand Up @@ -361,7 +361,7 @@ function CreatArticle() {
<label
for="markdown"
className="control-label"
requiredfield
requiredField
>
Article Template
<span className="asteriskField">*</span>
Expand Down Expand Up @@ -393,13 +393,13 @@ function CreatArticle() {
<div className="col-md-6">
<div
id="div_id_downloads"
className="form-group required"
className="required"
>
<div className="controls">
<label
for="markdown"
className="control-label"
requiredfield
requiredField
>
Publish To Dev
<span className="pr-1 asteriskField">*</span>
Expand All @@ -414,13 +414,13 @@ function CreatArticle() {
</div>
<div
id="div_id_downloads"
className="form-group required"
className=" required"
>
<div className="controls">
<label
for="markdown"
className="control-label"
requiredfield
requiredField
>
Publish To Medium
<span className="pr-1 asteriskField">*</span>
Expand Down Expand Up @@ -460,7 +460,7 @@ function CreatArticle() {
<div className="col-lg-12 col-md-6 pb-5">
<div
id="div_description"
className="form-group required row"
className=" required row"
>
<label
for="p_name"
Expand Down Expand Up @@ -499,8 +499,6 @@ function CreatArticle() {
<StyledButton type="reset">
<a href="/blog">Cancel</a>
</StyledButton>
{/* <button className="personal-btn" type="submit">Add Article</button> */}
{/* <button className="personal-btn" type="reset"><a href="/blog">Cancel</a> </button> */}
</div>
</div>
</form>
Expand Down
8 changes: 2 additions & 6 deletions src/Pages/Auth/login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ const Login = () => {
const state = useContext(GlobalState);
const [user, setUser] = state.userAPI.user;
const [isLoggedIn, setIsLoggedIn] = state.userAPI.isLoggedIn;
console.log(state, "state");
console.log(state.userAPI, "state");
console.log(state.userAPI.isLoggedIn, "state");
console.log(state.userAPI.isLoggedIn[0], "state");
console.log(state.userAPI.isLoggedIn[1], "state");

const [pass, setPass] = useState(false);
const [initialPress, setInitialPress] = useState(0);
const [rememberMe, setRememberMe] = useState(false);
Expand Down Expand Up @@ -82,7 +78,7 @@ const Login = () => {
<h2>Log In</h2>
</div>
<div className="row login-row">
<form onSubmit={loginSubmit} className="form-group">
<form onSubmit={loginSubmit} className="">
<div className="row login-row">
<input
className="form__input"
Expand Down
Loading

0 comments on commit 9db71a5

Please sign in to comment.