Open nthnluu opened 3 years ago
Here is the code you need to execute in order to call the createBusiness
Cloud Function:
const addBusiness = fb.functions().httpsCallable('createBusiness');
addBusiness({
"name": "Brightside Barbershop",
"address": "10277 University Ave",
"city": "San Diego",
"state": "CA",
"zipCode": "90210",
"created_by": "12",
"lat": -12.7,
"long": 97.2
})
.then(() => {
console.log("done!")
})
.catch(error => console.log(error))
I've setup the form to have a more logical flow, I'll work on implementing the Cloud Function while you work on the Google Location API.
I made a function called setBusiness that handles the reference to the createBusiness
cloud function.
We need to create a page that walks businesses through the process of adding their business to Hollar.
Docs
Overview
This page will be a similar layout to the onboarding page we have currently. Each step on the onboarding flow is focused on a particular piece of info we need: we want to avoid showing too many fields on one page since long forms tend to overwhelm users.
We want to make use of built-in browser form validation while also keeping track of the user data for each step. Therefore, each step of the onboarding flow will have its own form component.
In the top-level page component...
formData
in a useState() hook.formData
state will be initialized with the following object:{ "name":"", "street_address":"", "city":"", "state":"", "zipCode":"" }
There will be a field in this object representing the values all the text fields. We initialize the form with blank values, but as the user updates the text fields, this object will change. This object allows us to hold the user's inputs across multiple forms and serves as a single source of truth for the onboarding flow.
For each step...
formData
formData
accordinglyOnboarding steps
1. What is the name of your business?
2. Choose the category that fits your business best
3. Add a location
4. Verify info
Notes
I already started work on the AddressAutocomplete component, but it needs work.
You should use the data-driven UI approach I've used in the past. It helps reduce redundancy and ensures consistency. For example, you could model the onboarding flow as such:
const onboardingSteps = [{ title: "What is the name of your business?", form: <StepOneFormComponent formData={formData} setFormData={setFormData}/> }]
and use
onboardingSteps.map((step, index) => <div key={index}> ... </div>)
to render the UI.Each TextInput's value corresponds with a value in
formData
. Whenever we change the value, we should update the respective field informData
by callingsetFormData().
Check out this CodePen for an example of how this works. Here is a drawing showing an overview of how to implement this.Submitting a form will run built-in browser validation (it'll alert users if something is required, an email isn't formatted correctly, etc.) and if it passes, we can navigate the user forward.
Use the TextInput component from
/components/forms
for text fields.TextInput Props:
event.target.value
and should update a respective field informData.