Update forms

This commit is contained in:
Fede Álvarez 2022-06-16 00:14:44 +02:00
parent f3beefb6d5
commit 36e055acca
6 changed files with 4 additions and 99 deletions

2
.gitignore vendored
View File

@ -33,3 +33,5 @@ yarn-error.log*
# vercel
.vercel
trash

View File

@ -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),

View File

@ -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),

View File

@ -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
})

View File

@ -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)
}
}

View File

@ -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)
}
}