Skip to content

Commit

Permalink
feat: introduce server action to form submission
Browse files Browse the repository at this point in the history
  • Loading branch information
julianastahelin committed Nov 7, 2023
1 parent fceaf13 commit 0f80fb6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions components/core/contact-form/action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use server'
import { FormSchema } from "./schema"


export async function SendContactForm(data: FormSchema) {
console.log(data)
return "Thanks for the message!"
}
6 changes: 4 additions & 2 deletions components/core/contact-form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Input } from '@/components/ui/input'
import { Textarea } from '@/components/ui/textarea'

import { formSchema, FormSchema } from './schema'
import { SendContactForm } from './action'


export default function ContactForm() {
Expand All @@ -31,8 +32,9 @@ export default function ContactForm() {
},
})

function onSubmit(values: FormSchema) {
console.log(values)
async function onSubmit(values: FormSchema) {
const returnedValues = await SendContactForm(values)
alert(returnedValues)
}

return (
Expand Down
Empty file.

0 comments on commit 0f80fb6

Please sign in to comment.