add option de texte
This commit is contained in:
@@ -3,11 +3,18 @@ import { useParams, useNavigate } from "react-router-dom";
|
|||||||
import { getPostById, updatePost, uploadImageFromUrl } from "../wordpress"; // utilise uploadImageFromUrl
|
import { getPostById, updatePost, uploadImageFromUrl } from "../wordpress"; // utilise uploadImageFromUrl
|
||||||
import { getToken } from "../auth";
|
import { getToken } from "../auth";
|
||||||
import {
|
import {
|
||||||
Box, Container, Typography, TextField, Button, Paper
|
Box,
|
||||||
|
Container,
|
||||||
|
Typography,
|
||||||
|
TextField,
|
||||||
|
Button,
|
||||||
|
Paper,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { ArrowBack, Publish } from "@mui/icons-material";
|
import { ArrowBack, Height, Publish } from "@mui/icons-material";
|
||||||
import ImageUploaderCloudinary from "./ImageUploaderCloudinary";
|
import ImageUploaderCloudinary from "./ImageUploaderCloudinary";
|
||||||
import CloudinaryGallerySelector from "./CloudinaryGallerySelector";
|
import CloudinaryGallerySelector from "./CloudinaryGallerySelector";
|
||||||
|
import ReactQuill from "react-quill";
|
||||||
|
import "react-quill/dist/quill.snow.css";
|
||||||
|
|
||||||
function EditPost() {
|
function EditPost() {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
@@ -65,19 +72,50 @@ function EditPost() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ minHeight: "100vh", display: "flex", justifyContent: "center", alignItems: "center" }}>
|
<Box
|
||||||
|
sx={{
|
||||||
|
minHeight: "100vh",
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Container maxWidth="sm">
|
<Container maxWidth="sm">
|
||||||
<Paper elevation={6} sx={{ p: 4, borderRadius: 3 }}>
|
<Paper elevation={6} sx={{ p: 4, borderRadius: 3 }}>
|
||||||
<Button onClick={() => navigate("/admin/gestion-articles")} variant="outlined" startIcon={<ArrowBack />}>
|
<Button
|
||||||
|
onClick={() => navigate("/admin/gestion-articles")}
|
||||||
|
variant="outlined"
|
||||||
|
startIcon={<ArrowBack />}
|
||||||
|
>
|
||||||
Retour
|
Retour
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Typography variant="h4" align="center" sx={{ mb: 3 }}>Modifier l'article</Typography>
|
<Typography variant="h4" align="center" sx={{ mb: 3 }}>
|
||||||
|
Modifier l'article
|
||||||
|
</Typography>
|
||||||
|
|
||||||
<form onSubmit={handleUpdate}>
|
<form onSubmit={handleUpdate}>
|
||||||
<TextField label="Titre" fullWidth value={title} onChange={(e) => setTitle(e.target.value)} sx={{ mb: 2 }} />
|
<TextField
|
||||||
<TextField label="Contenu" multiline rows={4} fullWidth value={content} onChange={(e) => setContent(e.target.value)} sx={{ mb: 2 }} />
|
label="Titre"
|
||||||
|
fullWidth
|
||||||
|
value={title}
|
||||||
|
onChange={(e) => setTitle(e.target.value)}
|
||||||
|
sx={{ mb: 2 }}
|
||||||
|
/>
|
||||||
|
<Typography
|
||||||
|
variant="body1"
|
||||||
|
sx={{ mt: 2, mb: 2, fontWeight: "bold" }}
|
||||||
|
>
|
||||||
|
Contenu de l'article :
|
||||||
|
</Typography>
|
||||||
|
<Box sx={{ height: 250, mb: 7 }}>
|
||||||
|
<ReactQuill
|
||||||
|
theme="snow"
|
||||||
|
value={content}
|
||||||
|
onChange={setContent}
|
||||||
|
style={{ height: "100%" }}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
<Typography fontWeight="bold">Image depuis ton ordi :</Typography>
|
<Typography fontWeight="bold">Image depuis ton ordi :</Typography>
|
||||||
<ImageUploaderCloudinary
|
<ImageUploaderCloudinary
|
||||||
onUploadSuccess={(url) => {
|
onUploadSuccess={(url) => {
|
||||||
@@ -86,7 +124,9 @@ function EditPost() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Typography fontWeight="bold" sx={{ mt: 3 }}>Ou choisir une image déjà envoyée :</Typography>
|
<Typography fontWeight="bold" sx={{ mt: 3 }}>
|
||||||
|
Ou choisir une image déjà envoyée :
|
||||||
|
</Typography>
|
||||||
<CloudinaryGallerySelector
|
<CloudinaryGallerySelector
|
||||||
onSelect={async (url) => {
|
onSelect={async (url) => {
|
||||||
setImageUrl(url);
|
setImageUrl(url);
|
||||||
@@ -98,11 +138,26 @@ function EditPost() {
|
|||||||
{imageUrl && (
|
{imageUrl && (
|
||||||
<Box sx={{ mt: 2 }}>
|
<Box sx={{ mt: 2 }}>
|
||||||
<Typography variant="body2">Aperçu :</Typography>
|
<Typography variant="body2">Aperçu :</Typography>
|
||||||
<img src={imageUrl} style={{ width: "100%", borderRadius: 6, maxHeight: 200, objectFit: "cover" }} alt="preview" />
|
<img
|
||||||
|
src={imageUrl}
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
borderRadius: 6,
|
||||||
|
maxHeight: 200,
|
||||||
|
objectFit: "cover",
|
||||||
|
}}
|
||||||
|
alt="preview"
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Button type="submit" variant="contained" fullWidth sx={{ mt: 3 }} startIcon={<Publish />}>
|
<Button
|
||||||
|
type="submit"
|
||||||
|
variant="contained"
|
||||||
|
fullWidth
|
||||||
|
sx={{ mt: 3 }}
|
||||||
|
startIcon={<Publish />}
|
||||||
|
>
|
||||||
Mettre à jour
|
Mettre à jour
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
@@ -112,4 +167,4 @@ function EditPost() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default EditPost;
|
export default EditPost;
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import {
|
|||||||
import { ArrowBack, Publish } from "@mui/icons-material";
|
import { ArrowBack, Publish } from "@mui/icons-material";
|
||||||
import ImageUploaderCloudinary from "../ImageUploaderCloudinary";
|
import ImageUploaderCloudinary from "../ImageUploaderCloudinary";
|
||||||
import CloudinaryGallerySelector from "../CloudinaryGallerySelector";
|
import CloudinaryGallerySelector from "../CloudinaryGallerySelector";
|
||||||
|
import ReactQuill from "react-quill";
|
||||||
|
import "react-quill/dist/quill.snow.css";
|
||||||
|
|
||||||
function CreatePost() {
|
function CreatePost() {
|
||||||
const [title, setTitle] = useState("");
|
const [title, setTitle] = useState("");
|
||||||
@@ -85,7 +87,8 @@ function CreatePost() {
|
|||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextField
|
<Box sx={{ height: 250, mb: 7 }}>
|
||||||
|
<ReactQuill
|
||||||
label="Contenu"
|
label="Contenu"
|
||||||
fullWidth
|
fullWidth
|
||||||
margin="normal"
|
margin="normal"
|
||||||
@@ -95,7 +98,9 @@ function CreatePost() {
|
|||||||
value={content}
|
value={content}
|
||||||
onChange={(e) => setContent(e.target.value)}
|
onChange={(e) => setContent(e.target.value)}
|
||||||
required
|
required
|
||||||
|
style={{height:"100%"}}
|
||||||
/>
|
/>
|
||||||
|
</Box>
|
||||||
|
|
||||||
{/* Upload via Cloudinary */}
|
{/* Upload via Cloudinary */}
|
||||||
<Box sx={{ mt: 3 }}>
|
<Box sx={{ mt: 3 }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user