-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a951e3
commit 9a52f7a
Showing
35 changed files
with
18,765 additions
and
22,958 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import axios from "axios"; | ||
import { checkSessionExpired } from "../account/checkSessionExpired"; | ||
|
||
export const createPost = async ({ entry, user }) => { | ||
|
||
//check if jwt is expired | ||
const sessionExpired = checkSessionExpired(user?.jwt); | ||
if (sessionExpired) { | ||
alert("Your sessions has expired. Please log in again."); | ||
return false; | ||
} | ||
|
||
console.log('user',user) | ||
let createData = false; | ||
|
||
let newPostData = { | ||
type: "article", | ||
status: entry.status, | ||
title: entry.title, | ||
content: entry.content, | ||
draft_title: entry.versioned_title, | ||
draft_content: entry.versioned_content, | ||
slug: entry.slug, | ||
esES: false, | ||
date: new Date(), | ||
user: user?.id, | ||
publishedAt: null, | ||
tools: entry.relation, | ||
}; | ||
|
||
console.log('newPostData',newPostData) | ||
try { | ||
createData = await axios({ | ||
method: "post", | ||
url: `${process.env.NEXT_PUBLIC_API_URL}/api/posts`, | ||
headers: { | ||
Authorization: `Bearer ${user?.jwt}`, | ||
}, | ||
|
||
data: { | ||
data: { | ||
...newPostData, | ||
}, | ||
}, | ||
}) | ||
.then(async function (response) { | ||
return response?.data?.data; | ||
}) | ||
.catch(function (error) { | ||
console.log(error); | ||
return false; | ||
}); | ||
if (createData?.id) { | ||
let postObject = {id:createData.id, ...createData.attributes}; | ||
|
||
postObject.versioned_title = entry.draft_title; | ||
postObject.versioned_content = entry.draft_content; | ||
|
||
return postObject; | ||
} else { | ||
return false; | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
return false; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { UserCircle, Article, CircleWavyCheck } from "@/components/icons" | ||
|
||
export const loggedInMenu = { | ||
show:true, | ||
items: [ | ||
{ | ||
link: user => | ||
user?.profile?.approved | ||
? `/people/${user?.profile?.slug}` | ||
: `/account/profile`, | ||
icon: <UserCircle size={26} className="opacity-80 mr-3" />, | ||
label: "Profile", | ||
}, | ||
{ separator: true }, | ||
{ | ||
link: "/dashboard/drafts", | ||
icon: <Article size={26} className="opacity-80 mr-3" />, | ||
label: "Posts", | ||
}, | ||
{ | ||
condition: user => user?.profile?.onboardComplete !== true, | ||
items: [ | ||
{ separator: true }, | ||
{ | ||
link: "/onboard?onboard=true", | ||
icon: <CircleWavyCheck size={26} className="opacity-80 mr-3" />, | ||
label: "Setup", | ||
}, | ||
], | ||
}, | ||
{ separator: true }, | ||
{ | ||
link: "/account", | ||
label: "Edit profile", | ||
}, | ||
], | ||
adminMenu: [ | ||
{ separator: true }, | ||
{ | ||
link: "/admin/drafts", | ||
label: "👩✈️ Admin", | ||
}, | ||
{ | ||
link: "https://api.prototypr.io/admin/content-manager/collectionType/api::post.post?page=1&pageSize=10&sort=date:DESC&plugins[i18n][locale]=en", | ||
label: "👾 Strapi", | ||
}, | ||
], | ||
businessMenu: [ | ||
{ separator: true }, | ||
{ | ||
link: "/dashboard/partner", | ||
label: "Business hub", | ||
}, | ||
], | ||
} |
Oops, something went wrong.