add function creatPost and login wp

This commit is contained in:
sebvtl728
2025-01-31 08:22:48 +01:00
parent 81ac3d831e
commit 841161cb9b
16 changed files with 1177 additions and 355 deletions
+34
View File
@@ -0,0 +1,34 @@
import { useState } from "react";
import { updatePost } from "../wordpress";
function EditPost({ post }) {
const [title, setTitle] = useState(post.title.rendered);
const [content, setContent] = useState(post.content.rendered);
const handleUpdate = async () => {
const success = await updatePost(post.id, title, content);
if (success) {
alert("Article mis à jour !");
} else {
alert("Échec de la mise à jour.");
}
};
return (
<div>
<h1>Modifier larticle</h1>
<input
type="text"
value={title}
onChange={(e) => setTitle(e.target.value)}
/>
<textarea
value={content}
onChange={(e) => setContent(e.target.value)}
/>
<button onClick={handleUpdate}>Mettre à jour</button>
</div>
);
}
export default EditPost;