Skip to content

Commit ad0bffb

Browse files
list of blos for admin
1 parent c9845c9 commit ad0bffb

File tree

11 files changed

+139
-22
lines changed

11 files changed

+139
-22
lines changed

client/actions/blog.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const singleBlog = slug =>{
4040
}).then(response=>{
4141
return response.json()
4242
}).catch(err => console.log(err))
43-
}
43+
};
4444

4545
export const blogListRelated = (blog) => {
4646
return fetch(`${API}/api/bloglists/related`, {
@@ -54,3 +54,43 @@ export const blogListRelated = (blog) => {
5454
return response.json();
5555
}).catch(error => console.log(error));
5656
};
57+
58+
export const listingTheBlog = slug =>{
59+
return fetch(`${API}/api/bloglists`,{
60+
method: 'GET'
61+
}).then(response=>{
62+
return response.json()
63+
}).catch(err => console.log(err))
64+
};
65+
66+
export const removingTheBlog = (slug,token) => {
67+
return fetch(`${API}/api/blog/${slug}`, {
68+
method: 'DELETE',
69+
headers: {
70+
Accept: 'application/json',
71+
'Content-Type': 'application/json',
72+
Authorization:`Bearer ${token}`
73+
74+
},
75+
})
76+
.then(response => {
77+
return response.json();
78+
})
79+
.catch(error => console.log(error));
80+
};
81+
82+
export const updatingTheBlog = (blog,token,slug) => {
83+
return fetch(`${API}/api/blog/${slug}`, {
84+
method: 'PUT',
85+
headers: {
86+
Accept: 'application/json',
87+
Authorization:`Bearer ${token}`
88+
89+
},
90+
body: blog
91+
})
92+
.then(response => {
93+
return response.json();
94+
})
95+
.catch(error => console.log(error));
96+
};

client/components/Header.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import DashboardIcon from '@material-ui/icons/Dashboard';
2525
import VpnKeyIcon from '@material-ui/icons/VpnKey';
2626
import PersonAddIcon from '@material-ui/icons/PersonAdd';
2727
import ComputerIcon from '@material-ui/icons/Computer';
28-
import Typical from 'react-typical'
28+
import Typical from 'react-typical';
2929

3030

3131
Router.onRouteChangeStart = url => NProgress.start();
@@ -43,9 +43,9 @@ const Header = (props) => {
4343
<>
4444
<Navbar style={{boxShadow:"inset 0 0 2000px rgba(204, 255, 204, 0.4)",filter:"blur(0.4px)"}} light expand="md">
4545
{/* <ComputerIcon style={{color:"teal"}}/> */}
46-
<NavLink href="/" className="font-weight-bold">
47-
<Typical steps={['TECH', 1000,'BLOG', 500,'SITE', 500,'TECHBLOGSITE', 500]} loop={Infinity} wrapper="p"/>
48-
</NavLink>
46+
<Link href="/" className="font-weight-bold">
47+
<a className="pl-3 pt-3 h3" style={{color:"white"}}><Typical steps={['TECH', 1000,'BLOG', 500,'SITE', 500,'TECHBLOGSITE', 500]} loop={Infinity} wrapper="p"/></a>
48+
</Link>
4949
<NavbarToggler onClick={toggle} />
5050
<Collapse isOpen={isOpen} navbar>
5151
<Nav className="ml-auto" navbar>

client/components/blog/Card/Card.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const Card =({blog})=>{
5454
<div className="col-md-8">
5555
<section>
5656
<div className="pb-3">{renderHTML(blog.excerpt)}</div>
57-
<Link href={`/blogs/${blog.slug}`}><a className="btn btn-info pt-2" target="_blank">Read more<MoreIcon/></a></Link>
57+
<Link href={`/blogs/${blog.slug}`}><a className="btn btn-info pt-2" target="_blank">Read more <MoreIcon/></a></Link>
5858
</section>
5959
</div>
6060
</div>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Link from "next/link";
2+
import React,{useState,useEffect} from "react";
3+
import Router from "next/router";
4+
// importing actions
5+
import {getCookie,isAuthenticated} from "../../actions/authentication";
6+
import {listingTheBlog,removingTheBlog,updatingTheBlog} from "../../actions/blog";
7+
import PublishIcon from '@material-ui/icons/Publish';
8+
import {ReactQuillModules,ReactQuillFormats} from "../../helpers/ReactQuill";
9+
10+
const ReadNewBlog = () => {
11+
return (
12+
<>
13+
<p>Update Blogs</p>
14+
</>
15+
)
16+
}
17+
18+
export default ReadNewBlog;

client/components/update/UpdateNewBlog.js

Whitespace-only changes.

client/pages/adminDashboard/index.js

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import Layout from "../../components/Layout";
22
import Admin from "../../components/authentication/Admin";
33
import Link from "next/link";
4+
import LabelIcon from '@material-ui/icons/Label';
5+
import CategoryIcon from '@material-ui/icons/Category';
6+
import BookIcon from '@material-ui/icons/Book';
7+
8+
49

510

611
const AdminIndex =() =>{
@@ -10,35 +15,47 @@ const AdminIndex =() =>{
1015
<div className="container-fluid">
1116
<div className="row">
1217
<div className="col-md-12">
13-
<h2>Admin Dashboard</h2>
18+
<h2 className="text-center pt-4 display-4">Admin Dashboard</h2>
1419
</div>
15-
<div className="col-md-4 pt-5 pb-5">
16-
<ul className="list-group">
20+
<div className="row">
21+
{/* <ul className="list-group"> */}
1722
{/* // new category */}
18-
<li className="list-group-item">
23+
{/* <li className="list-group-item"> */}
24+
<div className="pt-5 pl-5 pb-5">
1925
<Link href="/adminDashboard/update/category-tag">
20-
<a>Create new category</a>
26+
<button className="pt-5 pb-5 pl-5 pr-5 btn btn-success"><div className="h4">Create new category <CategoryIcon/></div></button>
2127
</Link>
22-
</li>
28+
</div>
29+
{/* </li> */}
2330

2431
{/* // new tag */}
25-
<li className="list-group-item">
32+
{/* <li className="list-group-item"> */}
33+
<div className="pt-5 pl-5 pb-5">
2634
<Link href="/adminDashboard/update/category-tag">
27-
<a>Create new tag</a>
35+
<button className="pt-5 pb-5 pl-5 pr-5 btn btn-info"><div className="h4">Create new tag <LabelIcon/></div></button>
2836
</Link>
29-
</li>
37+
</div>
38+
{/* </li> */}
3039

3140
{/* // new blog */}
32-
<li className="list-group-item">
41+
{/* <li className="list-group-item"> */}
42+
<div className="pt-5 pl-5 pb-5">
3343
<Link href="/adminDashboard/update/blog">
34-
<a>Create new blog</a>
44+
<button className="pt-5 pb-5 pl-5 pr-5 btn btn-warning"><div className="h4">Create new blog <BookIcon/></div></button>
3545
</Link>
36-
</li>
37-
</ul>
46+
</div>
47+
{/* </li> */}
48+
{/* </ul> */}
49+
50+
<div className="pt-5 pl-5 pb-5">
51+
<Link href="/adminDashboard/update/editBlog">
52+
<button className="pt-5 pb-5 pl-5 pr-5 btn btn-success"><div className="h4">Update blogs <BookIcon/></div></button>
53+
</Link>
54+
</div>
3855
</div>
39-
<div className="col-md-8 pt-5 pb-5">
56+
{/* <div className="col-md-8 pt-5 pb-5">
4057
Right
41-
</div>
58+
</div> */}
4259
</div>
4360
</div>
4461
</Admin>

client/pages/adminDashboard/update/add-category.js

Whitespace-only changes.

client/pages/adminDashboard/update/add-tag.js

Whitespace-only changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import Layout from "../../../components/Layout";
2+
import Admin from "../../../components/authentication/Admin";
3+
import ReadNewBlog from "../../../components/update/ReadNewBlog";
4+
5+
import Link from "next/link";
6+
import CategoryIcon from '@material-ui/icons/Category';
7+
import AddIcon from '@material-ui/icons/Add';
8+
import LocalOfferIcon from '@material-ui/icons/LocalOffer';
9+
import BookIcon from '@material-ui/icons/Book';
10+
import PostAddIcon from '@material-ui/icons/PostAdd';
11+
// import MenuIcon from "@material-ui/icons/Menu";
12+
// import BigMenu from "@material-ui/icons/MenuIcons";
13+
14+
15+
16+
const Editblog =() =>{
17+
return(
18+
<Layout>
19+
<Admin>
20+
<div className="container-fluid">
21+
<div className="row">
22+
<div className="col-md-12">
23+
<h1 className="text-center">
24+
<PostAddIcon style={{"color":"pink"}}/>
25+
Create a new blog
26+
<BookIcon style={{"color":"teal"}}/>
27+
</h1>
28+
</div>
29+
<div className="col-md-12">
30+
<ReadNewBlog/>
31+
</div>
32+
</div>
33+
</div>
34+
</Admin>
35+
</Layout>
36+
);
37+
}
38+
39+
export default Editblog;

client/pages/blogs/[slug].js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ const SingleBlog = ({blog,query})=>{
124124
<div className="container pb-5">
125125
<h4 className="text-center pb-5 pt-5 h2">Related Blogs</h4>
126126
<hr/>
127-
<p>Show Related Blogs</p>
127+
{/* <p>Show Related Blogs</p> */}
128128
{/* {JSON.stringify(showBlogRelated)} */}
129129
<div className="row">
130130
{showingRelatedBlogs()}

0 commit comments

Comments
 (0)