popular-magentaP
Refine2y ago
10 replies
popular-magenta

how to send created by

"use client";

import { Box, TextField } from "@mui/material";
import { Create } from "@refinedev/mui";
import { useForm } from "@refinedev/react-hook-form";
import dynamic from "next/dynamic";
import { useState } from "react";

const MDEditor = dynamic(() => import("@uiw/react-md-editor"), { ssr: false });

export default function NewsCreate() {
const {
saveButtonProps,
refineCore: { formLoading },
register,
setValue,
formState: { errors },
} = useForm({});

const [description, setDescription] = useState("");

return (
<Create isLoading={formLoading} saveButtonProps={saveButtonProps}>
<Box
component="form"
sx={{ display: "flex", flexDirection: "column" }}
autoComplete="off"
>
<TextField
{...register("title", {
required: "This field is required",
})}
error={!!(errors as any)?.title}
helperText={(errors as any)?.title?.message}
margin="normal"
fullWidth
InputLabelProps={{ shrink: true }}
type="text"
label={"Title"}
name="title"
/>
<TextField
{...register("sub_heading", {
required: "This field is required",
})}
error={!!(errors as any)?.sub_heading}
helperText={(errors as any)?.sub_heading?.message}
margin="normal"
fullWidth
InputLabelProps={{ shrink: true }}
multiline
label={"Sub Heading"}
name="sub_heading"
/>
<MDEditor
value={description}
onChange={(value) => {
setDescription(value ""); // Ensure value is a string
}}
data-color-mode="light"
/>
</Box>
</Create>
);
}


here i want to make a field "created_by" and send the uuid of the user logged in
Was this page helpful?