Skip to content

Commit a4a8a67

Browse files
committed
add feedback api
1 parent 5b17be2 commit a4a8a67

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
ALGOLIA_APP_ID=***
22
ALGOLIA_SEARCH_KEY=***
33
ALGOLIA_ADMIN_KEY=***
4+
AIRTABLE_API_KEY=***
45
MAILCHIMP_ADDRESS=***
56
HUBSPOT_TEAMS_FORM_ID =***
67
HUBSPOT_PORTAL_ID =***

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@tinacms/git-client": "^0.6.7",
2929
"@types/react-instantsearch-dom": "^5.2.6",
3030
"@types/styled-components": "^4.4.2",
31+
"airtable": "^0.9.0",
3132
"algoliasearch": "^4.0.0",
3233
"axios": "^0.19.2",
3334
"btoa": "^1.2.1",

pages/api/feedback.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Airtable from 'airtable'
2+
3+
interface FeedbackRecord {
4+
Date: string
5+
Comment: string
6+
Review: 'Good' | 'Bad'
7+
Email?: string
8+
}
9+
10+
export default function feedback(req, res) {
11+
const base = Airtable.base('appmrIEGfi6XWeXaY')
12+
13+
const fields: FeedbackRecord = {
14+
Date: new Date().toDateString(),
15+
Comment: 'What a wonderful world.',
16+
Review: 'Good',
17+
18+
}
19+
20+
base('Site Feedback').create([{ fields }], function(err, records) {
21+
if (err) {
22+
console.error(err)
23+
res.json({ message: 'Uh oh spagehtti-o' })
24+
return
25+
}
26+
27+
res.json({ message: 'Thanks for your feedback!' })
28+
})
29+
}

yarn.lock

+21-1
Original file line numberDiff line numberDiff line change
@@ -2379,13 +2379,18 @@ abab@^2.0.0:
23792379
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.3.tgz#623e2075e02eb2d3f2475e49f99c91846467907a"
23802380
integrity sha512-tsFzPpcttalNjFBCFMqsKYQcWxxen1pgJR56by//QwvJc4/OUS3kPOOttx2tSIfjsylB0pYu7f5D3K1RCxUnUg==
23812381

2382-
2382+
[email protected], abort-controller@^3.0.0:
23832383
version "3.0.0"
23842384
resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392"
23852385
integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==
23862386
dependencies:
23872387
event-target-shim "^5.0.0"
23882388

2389+
abortcontroller-polyfill@^1.4.0:
2390+
version "1.5.0"
2391+
resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.5.0.tgz#2c562f530869abbcf88d949a2b60d1d402e87a7c"
2392+
integrity sha512-O6Xk757Jb4o0LMzMOMdWvxpHWrQzruYBaUruFaIOfAQRnWFxfdXYobw12jrVHGtoXk6WiiyYzc0QWN9aL62HQA==
2393+
23892394
accepts@~1.3.5, accepts@~1.3.7:
23902395
version "1.3.7"
23912396
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd"
@@ -2446,6 +2451,16 @@ aggregate-error@^3.0.0:
24462451
clean-stack "^2.0.0"
24472452
indent-string "^4.0.0"
24482453

2454+
airtable@^0.9.0:
2455+
version "0.9.0"
2456+
resolved "https://registry.yarnpkg.com/airtable/-/airtable-0.9.0.tgz#2fc170891593b0f5a40ecb36e00adcd862be4ee8"
2457+
integrity sha512-8gSNSSkS5RgqgEDbWDSZSkF/a1vy4RsT8Z0YPVr+YeoF8m8v+0FScflR+z6HiPW11dKeNym3T2wNLVIpg52X2Q==
2458+
dependencies:
2459+
abort-controller "^3.0.0"
2460+
abortcontroller-polyfill "^1.4.0"
2461+
lodash "4.17.15"
2462+
node-fetch "^2.6.0"
2463+
24492464
ajv-errors@^1.0.0:
24502465
version "1.0.1"
24512466
resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.1.tgz#f35986aceb91afadec4102fbd85014950cefa64d"
@@ -6758,6 +6773,11 @@ lodash.uniq@^4.5.0:
67586773
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
67596774
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
67606775

6776+
6777+
version "4.17.15"
6778+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
6779+
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
6780+
67616781
lodash@^4.0.1, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.19:
67626782
version "4.17.19"
67636783
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"

0 commit comments

Comments
 (0)