+ {/* if it's a new user, then
+ render onboarding for all pages */}
+ { newUser && !initOnboarding
+ ?
+ : {children}
+ }
+
+ )
+}
diff --git a/src/pages/Dashboard.jsx b/src/pages/Dashboard.jsx
index c2d73f5..0d1f490 100644
--- a/src/pages/Dashboard.jsx
+++ b/src/pages/Dashboard.jsx
@@ -1,7 +1,7 @@
import React from 'react'
import FlexBox from '../components/FlexBox'
-
+import PageWrapper from '../components/PageWrapper'
import CustomBarChart from '../components/Charts/CustomBarChart'
import CustomPieChart from '../components/Charts/CustomPieChart'
@@ -22,23 +22,25 @@ const FormatsData = [
export default function Dashboard() {
return (
-
- {/*
Dashboard
*/}
-
-
-
-
-
- Book Genre distribution
+
+ { GenresData && FormatsData &&
+
+
+
+
+
+ Book Genre distribution
-
-
-
-
- Book Format distribution
+
+
+
+
+ Book Format distribution
-
-
+
+
+
+ }
@@ -46,6 +48,6 @@ export default function Dashboard() {
Number of books read each month over the past year
-
+
)
}
diff --git a/src/pages/ItemProfile.jsx b/src/pages/ItemProfile.jsx
index e39c666..0f8e4e7 100644
--- a/src/pages/ItemProfile.jsx
+++ b/src/pages/ItemProfile.jsx
@@ -3,7 +3,7 @@ import React, {useEffect, useState} from 'react'
import BookData from '../components/ItemsProfiles/BookData'
// future: import JournalData from '../components/ItemsProfiles/JournalData'
-import DropDown from '../components/DropDown'
+import DropDown from '../components/Dropdown'
import Editor from '../components/Editor'
import FlexBox from '../components/FlexBox'
diff --git a/src/pages/Onboarding/Steps/One.jsx b/src/pages/Onboarding/Steps/One.jsx
new file mode 100644
index 0000000..4f1005a
--- /dev/null
+++ b/src/pages/Onboarding/Steps/One.jsx
@@ -0,0 +1,40 @@
+import React from 'react'
+
+import Button from '../../../components/Button'
+import Dropdown from '../../../components/Dropdown'
+
+import PeopleReading from '../../../assets/img/people-reading.svg'
+
+export default function One() {
+
+ const servicesOptions = ["Pick a service", "Goodreads", "Google Books"]
+
+ // TO DO: implement picking an option
+ // pass the option and data back to the parent
+ const handleOptionPick = (option, data = {}) => {
+ switch (option) {
+ case "dropdown":
+ break
+ case "button":
+ break
+ default:
+ break
+ }
+ }
+
+ // TO DO: refactor into components
+ return (
+ <>
+
+
Welcome to Leaf!
+
Let's track your reading activity together
+
Pick a service you want to pull your reading data from or add a new item manually
+
+ handleOptionPick("dropdown", {service: ''})} />
+
+
+
+ >
+ )
+}
\ No newline at end of file
diff --git a/src/pages/Onboarding/index.jsx b/src/pages/Onboarding/index.jsx
new file mode 100644
index 0000000..0e7b3eb
--- /dev/null
+++ b/src/pages/Onboarding/index.jsx
@@ -0,0 +1,135 @@
+import React, { useEffect, useState } from 'react'
+import { useLocation } from 'react-router-dom'
+import { useToasts } from 'react-toast-notifications'
+
+import { authorizeProvider } from '../../provider/apiRequests'
+
+import { OnboardingContainer } from '../../provider/containers'
+
+import Button from '../../components/Button'
+import Dropdown from '../../components/Dropdown'
+
+import One from './Steps/One'
+
+
+/*
+ Onboarding steps:
+ 1.1. User picks a service to connect or
+ 2.1. Adds an item manually
+
+ -- 1.1. User picks a service to connect
+ 1.2. User gets forwared for OAuth w/ two outcomes:
+ a) they approve release of personal data -> yay, go to step 3
+ b) they don't approve or there is an error -> ah, please try again step 2
+
+ 1.3. Show loading progress while we make a request to the back-end to fetch
+ user's reading library from the chosen service and calculate their stats
+ When finished loading, save their reading library and statistics in the app's
+ state and show `All Set` last onboarding screen
+ When user clicks `Done`, populate the dashboard with their statistics
+
+ -- 2.1 Manually adding an item
+ 2.2. Render the form for adding item properties
+ 2.3. Do a form validation for the entered fields, send it to the back-end, and
+ save it in the app's state
+ 2.4. Populate the dashboard with statistics and watch out for empty fields since only 1 item
+ would be entered at this time
+
+*/
+
+// const handleNextStep = async (service, onboardingContainer, stepContents) => {
+
+// const {
+// initOnboarding, setInitOnboarding,
+// onboardingStep, setOnboardingStep,
+// } = onboardingContainer
+
+// // increment step
+
+// const OAuthRedirect = await authorizeProvider(service)
+// if (OAuthRedirect === undefined) {
+
+// }
+// try {
+// let OAuthRedirectUrl = new URL(OAuthRedirect)
+// } catch (e) {
+// console.log("invalid url", OAuthRedirect)
+// }
+// // var win = window.open(OAuthRedirectUrl, '_blank');
+// }
+
+export default function Onboarding() {
+ const { addToast } = useToasts()
+
+ const authResult = useLocation().search.replace("?", "")
+ const onboardingContainer = OnboardingContainer.useContainer()
+
+ const {
+ initOnboarding, setInitOnboarding,
+ onboardingStep, setOnboardingStep,
+ incrementStep,
+ } = onboardingContainer
+
+ // TO DO: pull the service value from the state
+ const service = "goodreads"
+ const [stepContents, setStepContents] = useState(<>>)
+
+ const configureStepContents = async (onboardingStep) => {
+ // different behavior depending on step number
+ switch (onboardingStep) {
+ // initialize onboarding
+ // picking a service or adding an item manually
+ case 1:
+ setStepContents(