starter code

This commit is contained in:
Hunter Johnston 2023-02-04 20:52:22 -05:00
parent b15148ca19
commit 17bfc2a6d0
4 changed files with 18 additions and 28 deletions

View File

@ -10,10 +10,9 @@ export const load: PageServerLoad = async () => {
export const actions: Actions = { export const actions: Actions = {
createArticle: async ({ request }) => { createArticle: async ({ request }) => {
const { title, content } = Object.fromEntries(await request.formData()) as { const { title, content } = Object.fromEntries(
title: string await request.formData(),
content: string ) as Record<string, string>
}
try { try {
await prisma.article.create({ await prisma.article.create({

View File

@ -22,10 +22,9 @@ export const load: PageServerLoad = async ({ params }) => {
export const actions: Actions = { export const actions: Actions = {
updateArticle: async ({ request, params }) => { updateArticle: async ({ request, params }) => {
const { title, content } = Object.fromEntries(await request.formData()) as { const { title, content } = Object.fromEntries(
title: string await request.formData(),
content: string ) as Record<string, string>
}
try { try {
await prisma.article.update({ await prisma.article.update({

View File

@ -1,13 +1,13 @@
<form> <form method="POST">
<hgroup> <hgroup>
<h2>Login</h2> <h2>Login</h2>
<h3>Welcome back!</h3> <h3>Welcome back!</h3>
</hgroup> </hgroup>
<label for="email">Email address</label> <label for="username">Username</label>
<input type="email" id="email" name="email" required /> <input type="text" id="username" name="username" required />
<label for="email">Password</label> <label for="password">Password</label>
<input type="email" id="email" name="password" required /> <input type="password" id="password" name="password" required />
<button type="submit">Login</button> <button type="submit">Login</button>
</form> </form>

View File

@ -1,25 +1,17 @@
<form> <form method="POST">
<hgroup> <hgroup>
<h2>Register</h2> <h2>Register</h2>
<h3>To post articles, you'll need an account.</h3> <h3>To post articles, you'll need an account.</h3>
</hgroup> </hgroup>
<div class="grid">
<label for="firstname">
First name
<input type="text" id="firstname" name="firstname" required />
</label>
<label for="lastname"> <label for="name">Name</label>
Last name <input type="text" id="name" name="name" required />
<input type="text" id="lastname" name="lastname" required />
</label>
</div>
<label for="email">Email address</label> <label for="username">Username</label>
<input type="email" id="email" name="email" required /> <input type="text" id="username" name="username" required />
<label for="email">Password</label> <label for="password">Password</label>
<input type="email" id="email" name="password" required /> <input type="password" id="password" name="password" required />
<button type="submit">Register</button> <button type="submit">Register</button>
</form> </form>