diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..fc4f842 --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +DATABASE_URL= +AUTH_SECRET= +AUTH_GOOGLE_ID= +AUTH_GOOGLE_SECRET= +ENFORCEADMIN= +SEED_ACCOUNT_PASSWORD= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5ef6a52..4077f37 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,18 @@ yarn-error.log* # env files (can opt-in for committing if needed) .env* +!.env.example + +# ai stuff +/.agents/ +/.claude/ +/.windsurf/ +/skills-lock.json + + +# regenerated by setup commands +/lib/generated/prisma/ +/generated/prisma # vercel .vercel diff --git a/README.md b/README.md index e215bc4..3f31f63 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,28 @@ You can check out [the Next.js GitHub repository](https://github.com/vercel/next The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. + +# CMS README - Archie McCulloch + +### Setup Instructions +- copy `.env.example` to `.env` and fill in values +- ENFORCEADMIN is checked against "true" to determine whether to expose /users + +- `npm install` +- `npx prisma validate --config ./prisma7.config.ts` +- `npx prisma migrate dev --name init --config prisma7.config.ts` +- `npx prisma generate --config prisma7.config.ts` +- `npx tsx prisma/seed.ts` +- `npm run dev` +- seeded login details: "seededTest@test.test" + password defined in .env +- + +### Authentication Approach +- Registation is done by a custom registration endpoint that creates uses in the database with hashed passwords using bcrypt +- Email and passwod login is done with Auth.js Credentials provider which check against stored user and password hash +- Google login is done with Auth.js Google provider, a database account is created if not already existing linked to their Google account by their Google ID +- Routes access control is controlled by the proxy +- Newsletter actions check for ownership using logged in user's ID +- Auth.js signOut() endpoint clears the session and redirects to login page +- Front end uses SessionProvider to gain access to session data which is fed by Auth.js +- Auth.js uses JWT to store session information with http only cookies, a callback is used to append user.id to session diff --git a/app/(auth)/layout.tsx b/app/(auth)/layout.tsx new file mode 100644 index 0000000..b410880 --- /dev/null +++ b/app/(auth)/layout.tsx @@ -0,0 +1,11 @@ +export default function AuthLayout({ children }: { children: React.ReactNode }) { + return ( +
+
+
+ {children} +
+
+
+ ) + } \ No newline at end of file diff --git a/app/(auth)/login/AuthLoginForm.tsx b/app/(auth)/login/AuthLoginForm.tsx new file mode 100644 index 0000000..21ca08e --- /dev/null +++ b/app/(auth)/login/AuthLoginForm.tsx @@ -0,0 +1,95 @@ +"use client" + +import { signIn } from "next-auth/react"; // client function +import { useState } from "react"; +import { useRouter } from "next/navigation"; +import Link from "next/link"; + +export default function AuthLoginForm() { + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [error, setError] = useState(""); + const [isSubmitting, setIsSubmitting] = useState(false); + + const router = useRouter(); + + const handleSubmit = async (e: React.SubmitEvent) => { // event object from form element + e.preventDefault(); // stops default submission to send through the js instead + setError(""); // clear state + setIsSubmitting(true); + + try { + const res = await signIn("credentials", { // sends to auth.js server endpoint selecting credentials provider and supplies obj argument which it passes into authorize function, returns the user + email, + password, + redirect: false, // prevents auto redirect + }); + + if (res.error || !res) { + setError("Sign in failed"); + } else { + router.push("/"); // if signin function doesnt error + } + } catch { + setError("Unable to sign in. Please try again.") + } finally { + setIsSubmitting(false); + } + + } + + return ( + <> +
+ {error && ( +
+ {error} +
+ )} + {" "} +
+ + setEmail(e.target.value)} + required + /> +
+
+ + setPassword(e.target.value)} + required + /> +
+
+ +
+
+
OR
+

+ Don't have an account?{" "} + + Sign Up + +

+ + ); +} \ No newline at end of file diff --git a/app/(auth)/login/SigninButton.tsx b/app/(auth)/login/SigninButton.tsx new file mode 100644 index 0000000..a010cba --- /dev/null +++ b/app/(auth)/login/SigninButton.tsx @@ -0,0 +1,24 @@ +export default function SigninButton({ + text, + style, + callback, + formAction +}: { + text: string; + style: string; + callback?: () => void; + formAction?: any; +}) { + return ( +
+ +
+ ); +}; \ No newline at end of file diff --git a/app/(auth)/login/page.tsx b/app/(auth)/login/page.tsx new file mode 100644 index 0000000..a33a36e --- /dev/null +++ b/app/(auth)/login/page.tsx @@ -0,0 +1,60 @@ +"use client"; + +import { Suspense, useState, useEffect } from "react"; +import AuthLoginForm from "./AuthLoginForm" +import SigninButton from "./SigninButton"; +import { handleGoogleLogin } from "@/app/actions/GoogleAction"; +import { useSearchParams } from "next/navigation"; + +function LoginContent() { + const [elogin, setElogin] = useState(false); + const showEmailLogin = () => { // lets you toggle on and off showEmailLogin which is used to decide if the authloginform is shown + setElogin(!elogin); + }; + + const searchParams = useSearchParams(); + const isJustRegisted = searchParams.get("registered") === "true"; // if redirected with reigstered = true + + useEffect(() => { + if (isJustRegisted) { + setElogin(true); + } + }, [isJustRegisted]); + + return ( + <> +

Please Sign In

+
+ {isJustRegisted && ( // display if redirect with search param +
+ Account created successfully. You can now sign in. +
+ )} + + +
+ +
+
{elogin ? : ""}
+ + ) +} + +export default function LoginPage() { // displays fallback while url dependent content loads (searchparams), errors if it tries to prepare page in advance + return ( + <> + Loading login..

}> + +
+ + + ); +} \ No newline at end of file diff --git a/app/(auth)/register/page.tsx b/app/(auth)/register/page.tsx new file mode 100644 index 0000000..af7fab0 --- /dev/null +++ b/app/(auth)/register/page.tsx @@ -0,0 +1,124 @@ +'use client'; + +import Link from "next/link"; +import { useState, useEffect } from "react"; +import { register } from "../../lib/client/register"; +import { useRouter } from "next/navigation" + +export default function RegisterPage() { + const [name, setName] = useState(""); // creating state objects and getting setters + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [confirmPassword, setConfirmPassword] = useState(""); + const [error, setError] = useState(""); + const [isSubmitting, setIsSubmitting] = useState(false); + + const router = useRouter(); + + const handleSubmit = async (e: React.SubmitEvent) => { // event object from form element + e.preventDefault(); // stops default submission to send through the js instead + setError(""); // clear state + + if (password !== confirmPassword) { + setError("Passwords do not match") + return; + } + + if (password.length < 16 || password === password.toLowerCase() || password === password.toUpperCase()) { // rejects password if its not 16+ characters or if its all in the same case + setError("Password must be at least 16 characters and a mix of lower and upper case. To keep your account secure also include special characters and dont use predictable phrases.") + return; + } + + setIsSubmitting(true); // once password is valid + + try { + await register({ email, password, name }) + router.push("/login?registered=true") + } catch (error) { + setError(error instanceof Error ? error.message : "Registration failed") + } finally { + setIsSubmitting(false); + } + } + + // useEffect(() => { // on page load + // if (!isLoading && isAuthenticated) { + // router.push("/") + // } + // },[isLoading, isAuthenticated, router]) + + return ( + <> + +

Create Account

+
+ {error && ( +
+ {error} +
+ )} + {" "} +
+ + setName(e.target.value)} + /> +
+
+ + setEmail(e.target.value)} + required + /> +
+
+ + setPassword(e.target.value)} + required + /> +
+
+ + setConfirmPassword(e.target.value)} + required + /> +
+
+ +
+
+ + ) +}; diff --git a/app/actions/GoogleAction.ts b/app/actions/GoogleAction.ts new file mode 100644 index 0000000..01b6429 --- /dev/null +++ b/app/actions/GoogleAction.ts @@ -0,0 +1,19 @@ +"use server"; + +import { auth, signIn, signOut } from "@/auth"; + +export async function handleGoogleLogin() { + await signIn("google", {redirectTo: "/"}) + +} + +export async function checkGoogleSession() { + const session = await auth(); + return session; +} + +export async function handleGoogleLogout() { + await signOut({redirectTo: "/login"}) +} + +// creates our functions to check session, login, logout using functions we exported from auth's nextauth functions \ No newline at end of file diff --git a/app/actions/NewsletterActions.ts b/app/actions/NewsletterActions.ts new file mode 100644 index 0000000..bc9e036 --- /dev/null +++ b/app/actions/NewsletterActions.ts @@ -0,0 +1,276 @@ +"use server"; + +import { prisma } from "../lib/prisma"; +import { revalidatePath } from "next/cache"; +import { auth } from "@/auth"; +import { NewsletterStatus } from "@/lib/generated/prisma/enums"; + +async function getAuthorId() { + const session = await auth(); // returns valid session object + + if (!session?.user?.id) { // if no session, user, or id + throw new Error("You must be logged in"); + } + + return session.user.id; +} + +export async function getPubNewsletters() { + return await prisma.newsletters.findMany({ + where: { + status: "Sent", + }, + orderBy: { + createdAt: "desc", + }, + include: { // includes author + author: { + select: { + name: true, // only takes authors name not private info + }, + }, + }, + }); +} + +export async function getPubNewsletter(id: string) { // single pub newsletter + return await prisma.newsletters.findUnique({ + where: { + id, + status: "Sent", + }, + include: { + author: { + select: { + name: true, + }, + }, + }, + }); +} + +export async function getUserNewsletters() { + + const authorID = await getAuthorId(); + + return await prisma.newsletters.findMany({ + where: { + authorID, + }, + orderBy: { + createdAt: "desc", // newest first + }, + include: { // includes author + author: { + select: { + name: true, // only takes authors name not private info + }, + }, + }, + }); +} + +export async function getUserNewsletter(id: string) { + const authorID = await getAuthorId(); + + return await prisma.newsletters.findUnique({ + where: { + id, + authorID, + }, + }); +} + +export async function publishNewsletter(id: string) { + try { + const authorID = await getAuthorId(); + + const newsletter = await prisma.newsletters.update({ + where: { + id, + authorID, // if it was called with a post id that doesnt belong to that author it wont be found + }, + data: { + status: "Sent", + }, + }); + + revalidatePath("/dashboard"); + revalidatePath("/newsletters"); + revalidatePath(`/newsletters/${id}`); + revalidatePath(`/dashboard/${id}`); + + return { success: true, newsletter }; + } catch (error) { + console.error("Error publishing newsletter:", error); + return { success: false, error: "Failed to publish newsletter" }; + } +} + +export async function unPublishNewsletter(id: string) { + try { + const authorID = await getAuthorId(); + + const newsletter = await prisma.newsletters.update({ + where: { + id, + authorID, // if it was called with a post id that doesnt belong to that author it wont be found + }, + data: { + status: "Draft", + }, + }); + + revalidatePath("/dashboard"); + revalidatePath("/newsletters"); + revalidatePath(`/newsletters/${id}`); + revalidatePath(`/dashboard/${id}`); + + return { success: true, newsletter }; + } catch (error) { + console.error("Error unpublishing newsletter:", error); + return { success: false, error: "Failed to unpublish newsletter" }; + } +} + +export async function scheduleNewsletter(id: string) { + try { + const authorID = await getAuthorId(); + + const newsletter = await prisma.newsletters.update({ + where: { + id, + authorID, // if it was called with a post id that doesnt belong to that author it wont be found + }, + data: { + status: "Schedule", + }, + }); + + revalidatePath("/dashboard"); + revalidatePath("/newsletters"); + revalidatePath(`/newsletters/${id}`); + revalidatePath(`/dashboard/${id}`); + + return { success: true, newsletter }; + } catch (error) { + console.error("Error publishing newsletter:", error); + return { success: false, error: "Failed to publish newsletter" }; + } +} + +// export async function likeNewsletter(id: string) { +// try { +// const authorID = await getAuthorId(); + +// const newsletter = await prisma.newsletters.update({ +// where: { +// id, +// authorID, // if it was called with a post id that doesnt belong to that author it wont be found +// }, +// data: { +// status: "Sent", +// }, +// }); + +// revalidatePath("/dashboard"); +// revalidatePath("/newsletters"); +// revalidatePath(`/newsletters/${id}`); +// revalidatePath(`/dashboard/${id}`); + +// return { success: true, newsletter }; +// } catch (error) { +// console.error("Error publishing newsletter:", error); +// return { success: false, error: "Failed to publish newsletter" }; +// } +// } + +export async function addNewsletter(data: { + title: string; + imageUrl: string; + content: string; +} +) { + try { + const authorID = await getAuthorId(); + + const newNewsletter = await prisma.newsletters.create({ + data: { + title: data.title.trim(), + imageUrl: data.imageUrl.trim(), + content: data.content, // keep spaces + authorID, + } + }) + + revalidatePath("/newsletters"); + revalidatePath("/dashboard"); + + return { success: true, newsletter: newNewsletter }; + } catch (error) { + console.error("Error adding newsletter:", error); + return { success: false, error: "Failed to add newsletter" }; + } + +} + +export async function editNewsletter( + id: string, + data: { + title: string; + imageUrl: string; + content: string; + }, +) { + try { + const authorID = await getAuthorId(); + + const updatedNewsletter = await prisma.newsletters.update({ + where: { + id, // find target newsletter + authorID, // thats also owned by current session owner + status: { + not: "Sent" + } + }, + data: { + title: data.title.trim(), + imageUrl: data.imageUrl.trim(), + content: data.content, + }, + }); + + revalidatePath("/newsletters"); + revalidatePath("/dashboard"); + revalidatePath(`/newsletters/${id}`); + revalidatePath(`/dashboard/${id}`); + + return { success: true, newsletter: updatedNewsletter }; + } catch (error) { + console.error("Error editing newsletter:", error); + return { success: false, error: "Failed to edit newsletter" }; + } +} + +export async function removeNewsletter(id: string) { + try { + const authorID = await getAuthorId(); + + const deletedNewsletter = await prisma.newsletters.delete({ + where: { + id, + authorID, + }, + }); + + revalidatePath("/newsletters"); + revalidatePath("/dashboard"); + revalidatePath(`/newsletters/${id}`); + revalidatePath(`/dashboard/${id}`); + + return { success: true, newsletter: deletedNewsletter }; + } catch (error) { + console.error("Error deleting newsletter:", error); + return { success: false, error: "Failed to delete newsletter" }; + } +} \ No newline at end of file diff --git a/app/actions/UserAction.ts b/app/actions/UserAction.ts new file mode 100644 index 0000000..4c16045 --- /dev/null +++ b/app/actions/UserAction.ts @@ -0,0 +1,72 @@ +"use server"; + +import { prisma } from "../lib/prisma"; +import { revalidatePath } from "next/cache"; + +export async function addUser(data: { + name?: string; + email: string; + pass: string; +}) { + try { + const newUser = await prisma.users.create({ // creates a new user from parameter object data + data: { + name: data.name, + email: data.email, + passwordHash: data.pass, + }, + }); + revalidatePath("/users"); // next function informs changes made to page so refreshes cached data + return { success: true, user: newUser }; // returns object containing status and object returned from prisma.users.create + } catch (error) { // if it fails return error + console.error("Error adding user:", error); + return { success: false, error: "Failed to add user" }; + } +} + +export async function editUser( + id: string, + data: { + name?: string; + email?: string; + pass?: string; + }, +) { + try { + const updatedUser = await prisma.users.update({ + where: { id }, // shorthand for where: { id: id } - finds user by id in table matching id parameter + data: { + ...(data.name && { name: data.name }), // if data.name exists then update name to data.name + ...(data.email && { email: data.email }), // likely as prisma cant update a field with an object it must be a property value of data object + ...(data.pass && { passwordHash: data.pass }), //. if data.name is empty (false) the expression is false and spread will crteate an empty object which will not update the name field in the database + }, + }); + + revalidatePath("/users"); + return { success: true, user: updatedUser }; + } catch (error) { + console.error("Error editing user:", error); + return { success: false, error: "Failed to edit user" }; + } +} + +export async function removeUser(id: string) { // this should be clear from the above explanations + try { + const deletedUser = await prisma.users.delete({ + where: { id }, + }); + revalidatePath("/users"); + revalidatePath("/newsletters"); + revalidatePath("/dashboard"); + return { success: true, user: deletedUser }; + } catch (error) { + console.error("Error deleting user:", error); + return { success: false, error: "Failed to delete user" }; + } +} + +export async function getUsers() { + return await prisma.users.findMany({ + orderBy: { createdAt: "desc" } // changed from lab code as my id's are string - newest first + }); // returns all users in the table in descending order of id +} diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts new file mode 100644 index 0000000..0eebb94 --- /dev/null +++ b/app/api/auth/[...nextauth]/route.ts @@ -0,0 +1,2 @@ +import { handlers } from "@/auth" +export const { GET, POST } = handlers \ No newline at end of file diff --git a/app/api/auth/register/route.ts b/app/api/auth/register/route.ts new file mode 100644 index 0000000..96d8e7e --- /dev/null +++ b/app/api/auth/register/route.ts @@ -0,0 +1,59 @@ +import { NextRequest, NextResponse } from "next/server"; +import { prisma } from "../../../lib/prisma"; +import { hashPassword } from "../../../lib/auth"; + +export async function POST(request: NextRequest) { // handles post request to /api/auth/register endpoint + try { + const body = await request.json(); // converts json req to obj, request.json reads only the req body + const { email, password, name } = body; // breaks down the body obj into variables + + if (!email || !password) { // checks required variables + return NextResponse.json( + { error: "Email and password are required" }, + { status: 400 } + ) + }; + + const existingUser = await prisma.users.findUnique({ // checks whether that email is already registered + where: { email } + }); + + if (existingUser) { + return NextResponse.json( + { error: "User with this email already exists" }, + { status: 409 } + ) + } + + const hashedPassword = await hashPassword(password); + const user = await prisma.users.create({ // creates new user with hashed password + data: { + email, + passwordHash: hashedPassword, + name + } + }); + + const response = NextResponse.json( // crafts the response with a message and user obj thats just been added + { + message: "User reigseted successfully", + user: { + id: user.id, + email: user.email, + name: user.name + } + }, + { status: 201} + ); + + return response; // returns the crafted response + + } catch (error) { + console.error("Registration error:", error); + return NextResponse.json( + { error: "Internal server error" }, + { status: 500 } + ); + } + +} diff --git a/app/components/ExternalNewsletters.tsx b/app/components/ExternalNewsletters.tsx new file mode 100644 index 0000000..a8ec8b9 --- /dev/null +++ b/app/components/ExternalNewsletters.tsx @@ -0,0 +1,62 @@ +type ExternalNewsletter = { + title: string; + description: string; + url: string; +}; + +export default async function ExternalNewsletters() { + try { + const response = await fetch( + "https://us-rse.org/api/newsletters.json", // can go to url to see the response body + { + signal: AbortSignal.timeout(5000), // errors after 5s to stop loading and go to catch + } + ); + + const numNewsletters = 5; // probably dont want a massively page I also dk how many newsletters the api is gonna return + + if (!response.ok) { // display status if not succeeded + throw new Error(`Feed request failed: ${response.status}`); + } + + const newsletters: ExternalNewsletter[] = await response.json(); // converts api response body into a list of objects of our type + return ( +
+

+ {/* I am assuming when I pick the first five its the latest 5 */} + Latest from US-RSE +

+ +
    + {newsletters.slice(0, numNewsletters).map((newsletter) => ( // slice out varnum from 0 and map them to list items +
  • +

    + + {newsletter.title} + +

    + +

    + {newsletter.description} +

    +
  • + ))} +
+
+ ); + } catch (error) { + console.error("External newsletter feed failed:", error); + + return ( +

+ This source is currently unavailable. +

+ ); + } +} \ No newline at end of file diff --git a/app/components/NavBar.tsx b/app/components/NavBar.tsx new file mode 100644 index 0000000..c84e837 --- /dev/null +++ b/app/components/NavBar.tsx @@ -0,0 +1,69 @@ +"use client"; + +import {Links} from "./navbarData"; +import Link from "next/link"; +import { usePathname } from "next/navigation"; +import { useSession, signOut } from "next-auth/react"; + +export default function NavBar( { enforceAdmin } : { enforceAdmin: boolean; } ) { + const pathname = usePathname(); + const { data: session} = useSession(); + const visibleLinks = Links.filter( // check each link + (link) => (link.url !== "/dashboard" || session?.user) && (link.url !== "/users" || !enforceAdmin) + // keep link if its not dashboard or if theres a session (logged in) (only keep dashboard if logged in) + // and keep link if its not users or if enforceadmin is false + ); + + return ( +
+
+
+
+ +
+
    + {visibleLinks.map((link) => ( // below highlights the active link +
  • + {link.text} +
  • + ))} +
+
+ Secure CMS +
+
+
    + {visibleLinks.map((link) => ( +
  • + {link.text} +
  • + ))} +
+
+
+ {session?.user ? ( + <> + {session.user.name || session.user.email || "Account"} + + + ) : ( + <> + + Login + + + Sign Up + + + )} + +
+
+ + ); +} + diff --git a/app/components/Providers.tsx b/app/components/Providers.tsx new file mode 100644 index 0000000..48bfc9f --- /dev/null +++ b/app/components/Providers.tsx @@ -0,0 +1,12 @@ +"use client"; + +import { SessionProvider } from "next-auth/react"; + +export function Providers({ children }: { children: React.ReactNode }) { + return ( + {children} + + ) +} + +// surrounds page content to give children access to auth context and functions \ No newline at end of file diff --git a/app/components/navbarData.tsx b/app/components/navbarData.tsx new file mode 100644 index 0000000..22e9e8b --- /dev/null +++ b/app/components/navbarData.tsx @@ -0,0 +1,28 @@ +interface Link { + id: number; + url: string; + text: string; +} + +export const Links: Link[] = [ + { + id: 1, + url: "/", + text: "Home", + }, + { + id: 2, + url: "/users", + text: "Users", + }, + { + id: 3, + url: "/dashboard", + text: "Dashboard", + }, + { + id: 4, + url: "/newsletters", + text: "Newsletters", + }, +] \ No newline at end of file diff --git a/app/dashboard/CreateNewsletterFrom.tsx b/app/dashboard/CreateNewsletterFrom.tsx new file mode 100644 index 0000000..c7da254 --- /dev/null +++ b/app/dashboard/CreateNewsletterFrom.tsx @@ -0,0 +1,119 @@ +"use client" + +import { addNewsletter, } from "@/app/actions/NewsletterActions"; +import { useState } from "react"; +import { useRouter } from "next/navigation" + +export default function CreateNewsletterForm() { + const [title, setTitle] = useState(""); + const [imageUrl, setImageUrl] = useState(""); + const [content, setContent] = useState(""); + const [error, setError] = useState(""); + const [isSubmitting, setIsSubmitting] = useState(false); + const [isCreated, setIsCreated] = useState(false); + + const router = useRouter(); + + const handleSubmit = async (e: React.SubmitEvent) => { + e.preventDefault(); // stops default submission to send through the js instead + setError(""); // clear state + setIsSubmitting(true); + setIsCreated(false) + + try { + if ( + typeof title !== "string" || + typeof imageUrl !== "string" || + typeof content !== "string" || + !title.trim() || + !content.trim() + ) { + throw new Error("Please provide a title and content"); + } + + const result = await addNewsletter({ + title, + imageUrl, + content, + }); + + if (!result.success) { + throw new Error(result.error); + } else { + setTitle(""); + setContent(""); + setImageUrl(""); + setIsCreated(true) + + // if (result.newsletter) { router.push(`/dashboard/${result.newsletter.id}`); }; + } + } catch { + setError("Unable to create newsletter. Please try again.") + } finally { + setIsSubmitting(false); + } + + } + + return ( +
+ {error && ( +
+ {error} +
+ )} + {isCreated && ( // display if redirect with search param +
+ Newsletter sucessfully created +
+ )} + {" "} +
+ + setTitle(e.target.value)} + required + /> +
+
+ + setImageUrl(e.target.value)} + /> +
+
+ +