-
Notifications
You must be signed in to change notification settings - Fork 2
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
[feat] implements add plant details #18
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhh so amazing, tysm sashank! plz see my comments
- we should merge in ur previous pr (All Plants + My Plants tab) + rebase this branch after that's merged
- there is 1 big logic fix for accessing the input values for each plants.
- let's try to add comments esp in the
move
func to explain the logic!
{currentIndex != plants.length + 1 && ( | ||
<div> | ||
<PlantDetails plant={plants[currentIndex - 1]}></PlantDetails> | ||
<button onClick={() => move(-1)}>Back</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Design question @kyrenetam: do we want to hide (or rename) the "Back" button on the first add plant screen page? I feel like it's misleading, unless we plan to allow users to route back to view-plants
a8340cd
to
4f8e04a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking great so far! the final change is to change planting_type
to type PlantingTypeEnum
in UserPlants
. This will cause some type errors which should be resolved by passing in plantingType/setPlantingType or dateInput/setDateInput to PlantDetails
plant_id: UUID; | ||
date_added: string; | ||
date_harvested: string; | ||
planting_type: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be PlantingTypeEnum
you should also have
export type PlantingTypeEnum = 'INDOORS' | 'OUTDOORS' | 'TRANSPLANT'
import { Plant, UserPlants } from '@/types/schema'; | ||
|
||
export default function PlantDetails({ | ||
detail, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should take in setDate
and setPlant
See Kyle's FilterDropdown in components/FilterDropdown.tsx
for an example of how to pass in setState react hooks
if (currentIndex != plants.length + 1) { | ||
const updatedDetails = [...details]; | ||
const plantID = plants[currentIndex - 1]['id']; | ||
const date = (document.getElementById('date')! as HTMLInputElement).value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of doing document.getElementById
we can use a useState to track the dateInput and plantingType, i.e.
const [dateInput, setDateInput] = useState<Date | null>(null);
const [plantingType, setPlantingType] = useState<PlantingTypeEnum | null>(null);
(you might be able to handle the null cases differently, but this is just a suggestion)
And then, pass the value and the setValue func (e.g. plantingType, setPlantingType) into PlantDetails
(see the later comment)
).value; | ||
updatedDetails[currentIndex - 1] = { | ||
date_added: date, | ||
planting_type: plant_type, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will cause a type error once we change planting_type
to PlantingTypeEnum
(instead of string
) in schema.d.ts
. Hopefully the additional value/setValue handling (see other comments) will resolve the the type error
What's new in this PR 🧑🌾
Description
Screenshots
How to review
Next steps
Relevant links
Online sources
Related PRs
CC: @ccatherinetan