This project was bootstrapped with Create React App.
It is a single page app in React with a serverless backend currently being served by Netlify.
- Request access to this repo, Airtable, SendGrid, and Netlify
- Add API keys to your local
.env
file - Run
yarn
,yarn start
, andyarn start:api
to install dependencies and start the app
Ask someone with access to invite you to the USDR Food Airtable workspace. Once you have access:
Airtable API Key
Create an Airtable account and copy your personal API key at https://airtable.com/account.
Airtable Base ID
To get a base ID, go to https://airtable.com/api and click on any USDR Food base e.g. Storefront Demo.
The app ID begins with app
. You can either grab the ID from the url https://airtable.com/[some_key_beginning_with_app]/api/
or it will be displayed in the Introduction section: The ID of this base is [some_key_beginning_with_app].
Note: It is recommended that you clone the Storefront Demo base and use this copy while developing. This way you can test schema changes without worrying about breaking other instances of the app.
There are two Stripe API keys, a main Stripe key and a donation Stripe key. Both are located in the Config
table of any USDR Food Airtable base under the stripe_donation_public_api_key
and stripe_main_public_api_key
fields.
Check the Netlify config for the site you're working on to get the SENDGRID_API_KEY. More Details
Create a .env
file in the repo's root directory using a copy of .example.env
and add your keys:
AIRTABLE_API_KEY=
AIRTABLE_BASE_ID=
STRIPE_MAIN_PRIVATE_API_KEY=
STRIPE_DONATION_PRIVATE_API_KEY=
SENDGRID_API_KEY=
These keys will be used when you run yarn start:api
in the next section.
We use yarn for managing packages instead of npm. You may run into this issue if you use npm: /bin/sh: react-scripts: command not found
View yarn's docs for how to install in your OS.
yarn
yarn start:api
Runs a proxy for the serverless API in development.
If you run yarn start
without setting up your API keys or running yarn start:api
, the app will render but calls to the backend will return 500s.
yarn start
Runs the app in development mode.
By default it will serve the app at http://localhost:3000 which you can view in your browser. The port number is configurable by setting PORT=your_port_number
in your .env
file.
The page will reload when you make edits. You're ready to start contributing!
yarn build
Note: Netlify automates our deploy process and this step is not normally required
Builds a minified and optimized version of the app for production to the build
folder. Your app is ready to be deployed!
See the section about deployment or Create React App's docs for more information.
Ask someone on the team for an invitation to the team SendGrid account. Once you have access:
You can grab the API key at https://app.sendgrid.com/settings/api_keys or have someone send it to you.
Add the SendGrid API key to your .env
file:
SENDGRID_API_KEY=
In the Config
table of your Airtable base, set the email_from_address
to [email protected]
.
Restart the app. You should now be able to receive emails sent by the app (e.g. order confirmation email).
We use Netlify to manage deploys. Here are the steps you will need to deploy a new site:
- Have someone with access invite you to the app.
- Have someone give you access to this git repo (usdigitalresponse/storefront).
- Sign up/Log in, ideally with your Github.
- Click "New site from Git", choose Github as the provider.
- Change the user to
usdigitalresponse
and you should see the option to choosestorefront
. - Enter
build
into thepublish directory
field. - Hit show advanced, and add the same variables as another site. You can find variables by clicking on a site, navigating to
Build & deploy
and thenEnvironment
. Generally, there should be 6 variables with the following keys (hint: hittingedit
will allow you to see and copy the full key/value):
AIRTABLE_API_KEY
AIRTABLE_BASE_ID
MASTER_AIRTABLE_API_KEY
MASTER_AIRTABLE_BASE_ID
STRIPE_DONATION_PRIVATE_API_KEY
STRIPE_MAIN_PRIVATE_API_KEY
SENDGRID_API_KEY
AIRTABLE_BASE_ID
corresponds to the Airtable base for this project. You can find the id in the URL of your base after going to api.airtable.com. You will need to obtain the Stripe and Sendgrid api keys from the partner after they have set up their respective Stripe and Sendgrid accounts.
All merges to master will deploy to every connected Netlify site. It will take a bit of time, but you'll be able to see the latest version within minutes.
Use the card number 4242 4242 4242 4242 with any expiration date and any 3 digit code.