Skip to content

Commit

Permalink
initial interview template, add interviews/tools to userpostsid query
Browse files Browse the repository at this point in the history
  • Loading branch information
GraemeFulton committed Jun 7, 2024
1 parent bc394a4 commit f5cbc59
Show file tree
Hide file tree
Showing 12 changed files with 799 additions and 12 deletions.
11 changes: 10 additions & 1 deletion components/Editor/editorHooks/libs/getCreatePostData.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import {
getContent,
getLegacyFeaturedImage,
uid,
getPostRelation
} from "./helpers/editorDataFormatter";

export const getCreatePostData = ({
editor,
forReview,
postObject,
user
user,
relatedPost
}) => {
const html = editor.getHTML();
const json = editor.getJSON()?.content;
Expand All @@ -25,6 +27,9 @@ export const getCreatePostData = ({
//create post slug - just use a unique id and the date
const slug = `${uid()}--${user?.profile?.id}`;

const postRelation = getPostRelation({ relatedPost, postObject });


let entry = {
type: "article",
status: forReview ? "pending" : "draft",
Expand All @@ -38,6 +43,10 @@ export const getCreatePostData = ({
user: user?.profile?.id,
};

if(postRelation) {
entry.tools = [postRelation];
}

//change the date on save only if postStatus==draft or postStatus==pending publish
if (postObject?.status !== "publish") {
entry.date = new Date();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,9 @@ export const getPostDate = ({ postObject }) => {
export const uid = function () {
return Date.now().toString(36) + Math.random().toString(36).substr(2);
};


export const getPostRelation = ({ postObject, relatedPost }) => {

return relatedPost;
};
Loading

0 comments on commit f5cbc59

Please sign in to comment.