Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I26 create a home page #91

Merged
merged 105 commits into from Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
9274057
basic files
chayG5 Jul 2, 2022
d5a7c1e
home page layout and top nav
LisonLau Jul 2, 2022
fcc12db
minor changes
LisonLau Jul 2, 2022
5faaa9f
fixed red line, better quality logo and centre elements of summary da…
chayG5 Jul 2, 2022
86c100c
summary dashboard and button fixed/centred
chayG5 Jul 2, 2022
a9da7d8
test commit
LisonLau Jul 3, 2022
9767375
change font size, added modal
LisonLau Jul 3, 2022
24f1bb7
when click on start or stop update form. Also, a dog picture when vis…
chayG5 Jul 4, 2022
e657016
react-hook-form
chayG5 Jul 5, 2022
18b1529
adding type of visit and distance covered
chayG5 Jul 8, 2022
2ee3d36
multi select drop down, installed react select
chayG5 Jul 9, 2022
f6be041
fix drop down
chayG5 Jul 9, 2022
20226c5
update modal forms
LisonLau Jul 13, 2022
fa19620
formatting changes
LisonLau Jul 13, 2022
616b38d
formatting changes
LisonLau Jul 13, 2022
ab0c097
firebase document init
LisonLau Jul 13, 2022
3f27c02
up to date with main
LisonLau Jul 13, 2022
a9e333e
remove commented code
chayG5 Jul 14, 2022
69b302d
added labels for visit form
LisonLau Jul 15, 2022
77680ca
added colour, changed position of button
LisonLau Jul 15, 2022
679ef01
making font smaller
LisonLau Jul 15, 2022
d8b976f
separated form selectors into components, fixed type error
LisonLau Jul 16, 2022
beb5187
up to date with main
LisonLau Jul 16, 2022
4991ed3
fixed top nav
LisonLau Jul 16, 2022
1b40bf8
added new form fields, changed font size, modal size, etc.
LisonLau Jul 16, 2022
f138869
added dog image and positioning
JadeynFeng Jul 16, 2022
da86837
Merge branch 'i26-create_a_home_page' of https://github.com/codersfor…
JadeynFeng Jul 16, 2022
110f54b
Added form field component
LisonLau Jul 16, 2022
a04c3b1
fix visit form width
chayG5 Jul 17, 2022
6582786
stop button functionality and cancel button
chayG5 Jul 17, 2022
8fa1f64
Got rid of line breaks
LisonLau Jul 17, 2022
57506ad
DOG IMAGE
JadeynFeng Jul 19, 2022
939f79e
Merge branch 'i26-create_a_home_page' of https://github.com/codersfor…
JadeynFeng Jul 19, 2022
fa8dcdf
Fix all css
LisonLau Jul 20, 2022
6692669
Merge branch 'main' into i26-create_a_home_page
LisonLau Jul 20, 2022
a65aa0f
up to date with main
LisonLau Jul 20, 2022
a761053
Fixing css on home page
LisonLau Jul 20, 2022
89c5efb
Change type of visit options
LisonLau Jul 20, 2022
b20e465
scrollability
JadeynFeng Jul 20, 2022
c7a422a
Merge branch 'i26-create_a_home_page' of https://github.com/codersfor…
JadeynFeng Jul 20, 2022
f1e48e0
fix visit form positioning
chayG5 Jul 20, 2022
86cb660
"padding of visit page"
chayG5 Jul 20, 2022
3c71fe5
fixed bug
JadeynFeng Jul 20, 2022
e4f3942
Merge branch 'i26-create_a_home_page' of https://github.com/codersfor…
JadeynFeng Jul 20, 2022
8878fe9
Change pets to clients
LisonLau Jul 20, 2022
ef11ef9
scrollability works now and picture works too
JadeynFeng Jul 20, 2022
d983d5a
scrollability works now and picture works too
JadeynFeng Jul 20, 2022
5e6d43d
prettier styling
JadeynFeng Jul 20, 2022
6f67478
Merge branch 'main' into i26-create_a_home_page
JadeynFeng Jul 20, 2022
882c1d5
Fix tailwind css and removed imports
LisonLau Jul 22, 2022
c3c87ef
change type to CSSObjectWithLabel
chayG5 Jul 22, 2022
bc442bb
fix types
chayG5 Jul 22, 2022
0629541
fix top nav height
LisonLau Jul 23, 2022
7a97b77
Merge branch 'main' into i26-create_a_home_page
LisonLau Jul 23, 2022
baa558b
fix type options
LisonLau Jul 23, 2022
aeed2b5
add alert on button click
chayG5 Jul 23, 2022
58f25bc
dog image fix
JadeynFeng Jul 23, 2022
16c9e15
Fixed TopNav not showing with Alert
skyheat Jul 23, 2022
14dc313
Merge branch 'i26-create_a_home_page' of https://github.com/codersfor…
skyheat Jul 23, 2022
f5fa1c1
alert and fix top nav
chayG5 Jul 23, 2022
3c75ec6
Fixed type error
skyheat Jul 23, 2022
f16736c
Merge branch 'i26-create_a_home_page' of github.com:codersforcauses/p…
chayG5 Jul 23, 2022
b473e26
Fix form and added stopwatch
LisonLau Jul 23, 2022
c1c9790
fix type error for interval
chayG5 Jul 23, 2022
0e87832
Fix stopwatch display
LisonLau Jul 23, 2022
cb06850
Removed stopwatch file
LisonLau Jul 23, 2022
8e70e84
add disabled button component and fix reset timer
LisonLau Jul 23, 2022
7549670
refactoring for conditions
LisonLau Jul 23, 2022
0682091
confirmation is read only
LisonLau Jul 24, 2022
522df00
changed modal title
LisonLau Jul 24, 2022
8c9c232
fix imports
LisonLau Jul 24, 2022
6cbbd13
rebase
LisonLau Jul 24, 2022
d1fae43
fix to better alternative for disabled buttons
LisonLau Jul 24, 2022
a1b191f
timer in h:m:s format
JadeynFeng Jul 24, 2022
e4c1fde
Merge branch 'main' into i26-create_a_home_page
LisonLau Jul 24, 2022
e58759a
client field is not single select, fix bottom alert
LisonLau Jul 25, 2022
6a992f9
change overall layout of page
chayG5 Jul 25, 2022
b9fd654
make start time field
chayG5 Jul 25, 2022
6ab5e11
Added duration selector, fix form submit
LisonLau Jul 25, 2022
2415535
fix duration condition
chayG5 Jul 26, 2022
f4d6782
reset some fields after submit form
chayG5 Jul 26, 2022
dc6b8d1
fix selects and removed files
LisonLau Jul 26, 2022
2a7f8d7
change minute limit to 45
chayG5 Jul 26, 2022
7b0fe16
fix form outlines
LisonLau Jul 27, 2022
64e748a
move duration type to 'types'
chayG5 Jul 27, 2022
fa6849e
fix type error
chayG5 Jul 27, 2022
a33ca6d
trial number forms
LisonLau Jul 27, 2022
47824e8
implemented numpad if input is for numbers
LisonLau Jul 27, 2022
6d9b80a
rebase
LisonLau Jul 27, 2022
0a8aa54
fix top nav height
LisonLau Jul 27, 2022
0c4afac
duration buttons
LisonLau Jul 27, 2022
dd086bf
fix type errors
chayG5 Jul 27, 2022
19c7bfc
trigger submit only when duration values filled
chayG5 Jul 27, 2022
e80264d
fix duration form css
LisonLau Jul 27, 2022
173347b
fix duration form css
LisonLau Jul 27, 2022
e1901d1
ok surely this time
LisonLau Jul 27, 2022
2826c69
Merge remote-tracking branch 'origin/i75-add_alert_component' into i2…
LisonLau Jul 30, 2022
3066f7f
rebase
chayG5 Jul 30, 2022
3c225e4
Top Nav stuff
LisonLau Jul 30, 2022
981afac
Merge branch 'i26-create_a_home_page' of https://github.com/codersfor…
LisonLau Jul 30, 2022
61c0c49
Fixed top nav
LisonLau Jul 30, 2022
ef7417e
update duration dropdowns
LisonLau Jul 30, 2022
bcc82b0
Fix type errors
LisonLau Jul 30, 2022
6d18981
rebase
chayG5 Jul 30, 2022
a6369ea
Merge branch 'main' of https://github.com/codersforcauses/poops into …
NicholasChoong Aug 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19,765 changes: 19,765 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -35,10 +35,11 @@
"@heroicons/react": "^1.0.6",
"babel-plugin-macros": "^3.1.0",
"clsx": "^1.1.1",
"firebase": "^9.8.4",
"firebase": "^9.9.0",
"next": "^12.1.6",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-hook-form": "^7.33.1",
"react-icons": "^4.4.0",
"react-select": "^5.4.0",
"sharp": "^0.30.7",
Expand Down
Binary file added public/images/dog-home.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/dog.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions src/components/Home/clientSelector.tsx
@@ -0,0 +1,49 @@
import { Dispatch, SetStateAction, useState } from 'react'
import { default as ReactSelect } from 'react-select'
import { MultiValue } from 'react-select'

import multiStyles from '@/components/Home/multiStyles'

const clientOptions = [
{ value: 'Jeffrey', label: 'Jeffrey' },
{ value: 'George', label: 'George' },
{ value: 'Nancy', label: 'Nancy' },
{ value: 'Michelle', label: 'Michelle' }
]

type Props = {
clients: Array<string>
setClients: Dispatch<SetStateAction<Array<string>>>
}

type MyOption = { value: string; label: string }

function ClientSelector({ setClients }: Props) {
const [clientSelected, setClientSelected] = useState<MultiValue<MyOption>>()

const handleChange = (selected: MultiValue<MyOption>) => {
setClientSelected(selected)
setClients(Object.values(selected).map((val) => val.value))
}

return (
<div className='flex flex-col p-1'>
<label htmlFor='clients'>
<span className='text-primary'>*</span>
<b>Select Clients</b>
</label>
<ReactSelect
name='clients'
options={clientOptions}
closeMenuOnSelect={false}
value={clientSelected}
isMulti
hideSelectedOptions={false}
onChange={handleChange}
styles={multiStyles}
/>
</div>
)
}

export default ClientSelector
48 changes: 48 additions & 0 deletions src/components/Home/commuteSelector.tsx
@@ -0,0 +1,48 @@
import { Dispatch, SetStateAction, useState } from 'react'
import { default as ReactSelect } from 'react-select'
import { SingleValue } from 'react-select'

import singleStyles from '@/components/Home/singleStyles'

const commuteOptions = [
{ value: 'Walk', label: 'Walk' },
{ value: 'Drive', label: 'Drive' },
{ value: 'Public Transport', label: 'Public Transport' },
{ value: 'Other', label: 'Other' }
]

type Props = {
commute: string
setCommute: Dispatch<SetStateAction<string>>
}

type MyOption = { value: string; label: string }

function CommuteSelector({ setCommute }: Props) {
const [commuteSelected, setCommuteSelected] =
useState<SingleValue<MyOption>>()

const handleChange = (selected: SingleValue<MyOption>) => {
setCommuteSelected(selected)
if (selected == null) return
setCommute(selected.value)
}

return (
<div className='flex flex-col p-1'>
<label htmlFor='commute'>
<span className='text-primary'>*</span>
<b>Commute Method</b>
</label>
<ReactSelect
name='commute'
options={commuteOptions}
value={commuteSelected}
onChange={handleChange}
styles={singleStyles}
/>
</div>
)
}

export default CommuteSelector
123 changes: 123 additions & 0 deletions src/components/Home/modal.tsx
@@ -0,0 +1,123 @@
import React from 'react'
LisonLau marked this conversation as resolved.
Show resolved Hide resolved
import { useState } from 'react'

import ClientSelector from '@/components/Home/clientSelector'
import CommuteSelector from '@/components/Home/commuteSelector'
import TextForm from '@/components/Home/textForm'
import TypeSelector from '@/components/Home/typeSelector'

function Modal() {
const [modalIsOpen, setModalOpen] = useState(false)
const [commute, setCommute] = useState('')
const [clients, setClients] = useState<string[]>([])
const [type, setType] = useState('')
const [walkDistance, setWalkDistance] = useState(0)
const [other, setOther] = useState('')
const [commuteDistance, setCommuteDistance] = useState(0)

function formIsFilled() {
return (
commuteDistance > 0 &&
(commute == 'Walk' ||
commute == 'Drive' ||
commute == 'Public Transport' ||
(commute == 'Other' && other != '')) &&
(type == 'Vet' || (type == 'Walk' && walkDistance > 0)) &&
clients.length > 0
)
}

return (
<div className='text-center'>
{/* If modal is closed, display start button */}
{!modalIsOpen && (
<button
className='relative h-[30px] w-[120px] rounded-lg bg-dark-red text-lg font-semibold text-white'
onClick={() => {
setModalOpen(true)
}}
>
START VISIT
</button>
)}

{/* Displays modal */}
{modalIsOpen && (
<div className='rounded-lg bg-zinc-200 py-4 px-5 text-center shadow-lg sm:py-4'>
<h1 className='mb-2 text-xl text-dark-red'>
<b>Visit Details</b>
</h1>
<hr className='mb-3 h-0.5 border-dark-red bg-dark-red text-dark-red' />

{/* Visit Form */}
<form>
NicholasChoong marked this conversation as resolved.
Show resolved Hide resolved
{/* Commute Distance Form */}
<TextForm
id='commuteDistance'
type='text'
placeholder='Enter...'
label='Commute Distance (in km)'
isRequired={true}
onChange={(e) => setCommuteDistance(Number(e.target.value))}
/>

{/* Commute Selector Form */}
<CommuteSelector commute={commute} setCommute={setCommute} />

{/* Other Form if commute is 'Other' */}
{commute == 'Other' && (
<TextForm
id='other'
type='text'
placeholder='Enter...'
label='Other Commute Method'
isRequired={true}
onChange={(e) => setOther(String(e.target.value))}
/>
)}

{/* Pet Selector Form */}
<ClientSelector clients={clients} setClients={setClients} />

{/* Type Selector Form */}
<TypeSelector type={type} setType={setType} />

{/* Distance Form if type is 'Walk' */}
{type == 'Walk' && (
<TextForm
id='walkDistance'
type='text'
placeholder='Enter...'
label='Walk Distance (in km)'
isRequired={true}
onChange={(e) => setWalkDistance(Number(e.target.value))}
/>
)}
</form>
</div>
)}
<br />
<div className='text-center'>
{/* If modal is opened, display cancel button. Once all information has been filled display stop button*/}
{modalIsOpen && (
<button
className='relative h-[30px] w-[120px] rounded-lg bg-dark-red text-lg font-semibold text-white'
onClick={() => {
setModalOpen(false),
setClients([]),
setType(''),
setCommute(''),
setWalkDistance(0),
setOther(''),
setCommuteDistance(0)
}}
>
{formIsFilled() ? 'STOP VISIT' : 'CANCEL'}
</button>
)}
</div>
</div>
)
}

export default Modal
41 changes: 41 additions & 0 deletions src/components/Home/multiStyles.tsx
@@ -0,0 +1,41 @@
import { GroupBase, StylesConfig } from 'react-select'

type OptionType = {
label: string
value: string
}

const singleStyles: StylesConfig<OptionType, true, GroupBase<OptionType>> = {
control: () => ({
marginTop: '4px',
marginBottom: '8px',
display: 'flex',
borderRadius: '4px',
backgroundColor: '#fff',
borderColor: '#6b7280',
border: '1px solid #6b7280'
}),
input: (provided: Record<string, unknown>) => ({
LisonLau marked this conversation as resolved.
Show resolved Hide resolved
...provided,
paddingTop: '0.1em',
paddingBottom: '0.1em',
color: 'black'
}),
placeholder: (provided: Record<string, unknown>) => ({
...provided,
color: '#6b7280'
}),
dropdownIndicator: () => ({
display: 'flex',
transition: '',
padding: '8px',
color: '#6b7280'
}),
valueContainer: (provided: Record<string, unknown>) => ({
...provided,
border: 'black',
transition: ''
})
}

export default singleStyles
42 changes: 42 additions & 0 deletions src/components/Home/singleStyles.tsx
@@ -0,0 +1,42 @@
import { GroupBase, StylesConfig } from 'react-select'

type OptionType = {
label: string
value: string
}

const singleStyles: StylesConfig<OptionType, false, GroupBase<OptionType>> = {
control: () => ({
marginTop: '4px',
marginBottom: '8px',
display: 'flex',
borderRadius: '4px',
backgroundColor: '#fff',
borderColor: '#6b7280',
border: '1px solid #6b7280',
height: '36px'
}),
chayG5 marked this conversation as resolved.
Show resolved Hide resolved
input: (provided: Record<string, unknown>) => ({
...provided,
paddingTop: '0.1em',
paddingBottom: '0.1em',
color: 'black'
}),
placeholder: (provided: Record<string, unknown>) => ({
...provided,
color: '#6b7280'
}),
dropdownIndicator: () => ({
display: 'flex',
transition: '',
padding: '8px',
color: '#6b7280'
}),
valueContainer: (provided: Record<string, unknown>) => ({
...provided,
border: 'black',
transition: ''
})
}

export default singleStyles
17 changes: 17 additions & 0 deletions src/components/Home/statistics.tsx
@@ -0,0 +1,17 @@
import React from 'react'
LisonLau marked this conversation as resolved.
Show resolved Hide resolved

interface SummaryStatistics {
title: string
data: string
}

function Statistics(props: SummaryStatistics) {
return (
<div>
<p className='mt-2 text-lg'>{props.title}</p>
<p className='text-3xl text-dark-red'>{props.data}</p>
</div>
)
}

export default Statistics
33 changes: 33 additions & 0 deletions src/components/Home/summary.tsx
@@ -0,0 +1,33 @@
import React from 'react'

import Statistics from '@/components/Home/statistics'

const dummyVisitData = '12'
const dummyDistanceData = '6.5'

function Summary() {
return (
<div className='rounded-lg bg-zinc-200 py-4 px-5 text-center shadow-lg sm:py-4'>
<h1 className='mb-2 text-xl text-dark-red'>
<b>Summary Dashboard</b>
</h1>
<hr className='h-0.5 border-dark-red bg-dark-red text-dark-red' />
<div>
<table className='w-full'>
<tbody>
<tr>
<td>
<Statistics title='Number of Visits' data={dummyVisitData} />
</td>
<td>
<Statistics title='Distance Walked' data={dummyDistanceData} />
</td>
</tr>
</tbody>
</table>
</div>
</div>
)
}

export default Summary