MCPcopy Create free account
hub / github.com/OpenSIST/OpenSIST.github.io / action

Function action

src/Components/Modify/Post/AddModifyPost.jsx:110–129  ·  view source on GitHub ↗
({request, params})

Source from the content-addressed store, hash-verified

108}
109
110export async function action({request, params}) {
111 const formData = await request.formData();
112 const title = formData.get("Title");
113 const content = formData.get("Content");
114 const actionType = formData.get("ActionType");
115 const requestBody = {
116 content: {
117 Title: title,
118 Content: content
119 }
120 }
121 if (actionType === 'new') {
122 requestBody.content.type = 'post';
123 } else if (actionType === 'edit') {
124 requestBody.PostID = decodePathParam(params.postId);
125 }
126
127 await addModifyPost(requestBody, actionType);
128 return redirect(actionType === 'edit' ? postsPostPath(params.postId) : "/posts");
129}
130
131export default function AddModifyPost({type}) {
132 const mode = type === "new" ? "添加" : "编辑";

Callers

nothing calls this directly

Calls 3

decodePathParamFunction · 0.90
addModifyPostFunction · 0.90
postsPostPathFunction · 0.90

Tested by

no test coverage detected