mirror of
https://github.com/LaconicNetwork/laconic.com.git
synced 2026-02-28 19:54:09 +00:00
Update forms
This commit is contained in:
parent
f3beefb6d5
commit
36e055acca
2
.gitignore
vendored
2
.gitignore
vendored
@ -33,3 +33,5 @@ yarn-error.log*
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
trash
|
||||
@ -59,7 +59,7 @@ const CustomForm = ({ data }: FormProps) => {
|
||||
inquiry: selectedOption.value
|
||||
}
|
||||
|
||||
await fetch('/api/contact', {
|
||||
await fetch(`${process.env.NEXT_PUBLIC_API}/api/contact`, {
|
||||
method: 'POST',
|
||||
mode: 'no-cors',
|
||||
body: JSON.stringify(data),
|
||||
|
||||
@ -78,7 +78,7 @@ const CustomForm = ({ data }: FormProps) => {
|
||||
role: role
|
||||
}
|
||||
|
||||
await fetch('/api/inquiry', {
|
||||
await fetch(`${process.env.NEXT_PUBLIC_API}/api/inquiry`, {
|
||||
method: 'POST',
|
||||
mode: 'no-cors',
|
||||
body: JSON.stringify(data),
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
import { Client } from '@notionhq/client'
|
||||
|
||||
export const notion = new Client({
|
||||
auth: process.env.NOTION_TOKEN
|
||||
})
|
||||
|
||||
export const notionAlt = new Client({
|
||||
auth: process.env.NOTION_TOKEN_ALT
|
||||
})
|
||||
@ -1,33 +0,0 @@
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
|
||||
import { internalServerError, success } from '../../lib/api-responses'
|
||||
import { notion } from '../../lib/notion'
|
||||
|
||||
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
try {
|
||||
const { email, message, inquiry } = JSON.parse(req.body)
|
||||
await notion.pages.create({
|
||||
parent: {
|
||||
database_id: '03c225f0469d436db60bd1b225deffef' as string
|
||||
},
|
||||
properties: {
|
||||
Email: {
|
||||
email,
|
||||
type: 'email'
|
||||
},
|
||||
Message: {
|
||||
type: 'rich_text',
|
||||
rich_text: [{ text: { content: message }, type: 'text' }]
|
||||
},
|
||||
'Type of inquiry': {
|
||||
type: 'select',
|
||||
select: { name: inquiry }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
success(res)
|
||||
} catch (error) {
|
||||
internalServerError(res, error)
|
||||
}
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
|
||||
import { internalServerError, success } from '../../lib/api-responses'
|
||||
import { notionAlt } from '../../lib/notion'
|
||||
|
||||
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
try {
|
||||
const { name, email, message, inquiry, role, company, jurisdiction } =
|
||||
JSON.parse(req.body)
|
||||
await notionAlt.pages.create({
|
||||
parent: {
|
||||
database_id: '90a7d71e342f4b91b7ca263a14d839ea' as string
|
||||
},
|
||||
properties: {
|
||||
Name: {
|
||||
title: [
|
||||
{
|
||||
text: {
|
||||
content: name
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
Email: {
|
||||
email,
|
||||
type: 'email'
|
||||
},
|
||||
Message: {
|
||||
type: 'rich_text',
|
||||
rich_text: [{ text: { content: message }, type: 'text' }]
|
||||
},
|
||||
Role: {
|
||||
type: 'rich_text',
|
||||
rich_text: [{ text: { content: role }, type: 'text' }]
|
||||
},
|
||||
Company: {
|
||||
type: 'rich_text',
|
||||
rich_text: [{ text: { content: company }, type: 'text' }]
|
||||
},
|
||||
'Legal jurisdiction': {
|
||||
type: 'rich_text',
|
||||
rich_text: [{ text: { content: jurisdiction }, type: 'text' }]
|
||||
},
|
||||
Inquiry: {
|
||||
type: 'select',
|
||||
select: { name: inquiry }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
success(res)
|
||||
} catch (error) {
|
||||
internalServerError(res, error)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user