Skip to content

Commit

Permalink
fix: admin api intergration #513
Browse files Browse the repository at this point in the history
completed api intergration in admin page
  • Loading branch information
jasurobo committed Nov 23, 2021
2 parents 74e3cf2 + 0531c3e commit e7edc42
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 27 deletions.
7 changes: 7 additions & 0 deletions component/layout/SiteHeader/SiteHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ export default function HomeSpotlight() {
</a>
</Link>
</li>
<li>
<Link href="/events">
<a onClick={() => setMenu(true)} className="w-full font-semibold">
Events
</a>
</Link>
</li>
<li>
<Link href="/code-of-conduct">
<a onClick={() => setMenu(true)} className="w-full font-semibold">
Expand Down
5 changes: 3 additions & 2 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ const postsUrl = `${apiVerUrl}/posts`;
const allPostsUrl = "api/posts";
const postUser = `${apiVerUrl}/posts-by-user`;
const eventsUrl = `${apiVerUrl}/events`;
const createEventUrl = `${apiVerUrl}/admin/event`;
const eventIdUrl = `${apiVerUrl}/event`;
const createEventUrl = `${apiVerUrl}/admin/event`;
const changeStatusUrl = "api/user/post";
const subscribeUrl = "api/subscribe";
const loginUrl = `${apiVerUrl}/signin`;
const signUpUrl = `${apiVerUrl}/user`;
const userUrl = `${apiVerUrl}/user`;
const usersUrl = `${apiVerUrl}/users`;
const adminUrl = "api/admin";
const adminUrl = `${apiVerUrl}/admin`;
const tagUrl = `${apiVerUrl}/tags`;
const postTagUrl = `${apiVerUrl}/post-tag`;
const postTagsUrl = `${apiVerUrl}/post-tags`;
Expand Down Expand Up @@ -57,6 +57,7 @@ const configVars = {
createEventUrl,
eventIdUrl,
changeStatusUrl,
createEventUrl,
subscribeUrl,
editorUrl,
userUrl,
Expand Down
1 change: 0 additions & 1 deletion pages/events/[event_id].js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export async function getServerSideProps(context) {
try {
const eid = context.params.event_id;
const response = await EventService.getEventById(eid);

if (!response?.data) {
return {
redirect: {
Expand Down
10 changes: 6 additions & 4 deletions pages/events/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ export async function getServerSideProps() {
sort_field: "event_time",
order: "ASC",
limit: limit,
status: "drafted",
page: 1,
with_table: "users, tags"
};
const responseEvents = await EventService.getLatestEvents(postParams);
if (responseEvents.events.length > 0) {
if (responseEvents.count > 0) {
return {
props: {
events: responseEvents.events,
Expand All @@ -34,7 +35,8 @@ export async function getServerSideProps() {
return {
props: {
events: [],
count: 0
count: 0,
limit: 0
}
};
}
Expand All @@ -47,7 +49,6 @@ export async function getServerSideProps() {
}

export default function EventListing({ events, count, limit }) {

const [newEvents, setNewEvents] = useState(events);

const currentCount = (count) => {
Expand All @@ -59,6 +60,7 @@ export default function EventListing({ events, count, limit }) {
sort_field: "published_at",
order: "ASC",
limit: limit,
status: "drafted",
page: 1,
with_table: "users, tags"
};
Expand Down Expand Up @@ -121,7 +123,7 @@ export default function EventListing({ events, count, limit }) {
/>
) : (
<div className="flex items-center justify-center m-9 font-semibold">
There's no published blogs yet!
There's no events yet!
</div>
)}
<SectionSwag />
Expand Down
11 changes: 6 additions & 5 deletions pages/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,12 @@ export default function SignUp({ referer }) {
// .catch((err) => {
// console.log(err.message);
// });
if (referer) {
router.back();
} else {
router.push("/");
}
// console.log(referer , 'here')
// if (referer) {
// router.back();
// } else {
// router.push("/");
// }
} else {
setIsLoading(false);
if (!fName) {
Expand Down
19 changes: 9 additions & 10 deletions pages/whats-new.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,35 @@ export async function getServerSideProps(context) {
if (tag) {
searchArray = ["whats-new", tag];
}
const { posts, count } = await PostService.getPostsByMultipleTags(
searchArray,
0
);
const {
data: { posts, count }
} = await PostService.getPostByTags(searchArray, 0);
return {
props: {
blogs: posts
}
};
} catch (err) {
notify(err?.response?.data?.message ?? err?.message, 'error');
notify(err?.response?.data?.message ?? err?.message, "error");

return {
props: {
blogs: []
}
}
};
}
}

export default function whatsNew({blogs}) {
console.log(blogs)
export default function whatsNew({ blogs }) {
console.log(blogs);
return (
<>
<Head>
<title> What's new | Nullcast</title>
</Head>
<SiteHeader />
<WhatsNewSpotlight />
{blogs?.length > 0 && <WhatsNewPosts blogs={blogs} />}
{blogs?.length > 0 && <WhatsNewPosts blogs={blogs} />}
<SectionSwag />
<SiteFooter />
</>
Expand Down
8 changes: 3 additions & 5 deletions services/EventService.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ async function getEventById(eventId) {

async function createNewEvent(userCookie, eventData) {
try {
const response = await axios.post(
`${baseUrl}/${createEventUrl}`,
eventData
);
return response;
const response = await axios.post(`${baseUrl}/${createEventUrl}` , eventData)
console.log(response);
return response
} catch (err) {
console.log(err);
throw err;
Expand Down

0 comments on commit e7edc42

Please sign in to comment.