-
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] implement remove plant functionality & style PlantPages #53
[feat] implement remove plant functionality & style PlantPages #53
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.
looking great, tysm sashank! a couple comments
- nit: all styling files should be plural, i.e.
styles.ts
rather thanstyle.ts
- we might want to consolidate the shared styles between UserPlantPage and GeneralPlantPage. one way to do this is to move both components under the view-plants route and add a
shared/styles.ts
file (see my comment) - let's avoid using negative margins if it's not for overlapping components. I will push some global styles that will address the white space issue; see my comment about changing styles for Container, Header, and Content.
api/supabase/queries/userPlants.ts
Outdated
if (error) { | ||
console.error('Error deleting row:', error); | ||
return null; | ||
} |
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.
note: honestly i'm down to generally throw errors in queries, but that would require us to catch the error wherever the query is used. this allows us to use the error message + do more specific/custom error-handling. this is fine for now, but if we do want to do custom error-handling, we might consider changing it to throwing an error later
app/all-plants/[plantId]/page.tsx
Outdated
router.push(`/view-plants`); | ||
}} | ||
> | ||
← |
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.
note: this is good for now! we might want to export the arrow icon from figma eventually??
app/all-plants/[plantId]/style.ts
Outdated
border-radius: 5px; | ||
cursor: pointer; | ||
font-size: 0.75rem; | ||
font-style: inherit; |
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.
styles are inherited by default so we can remove this line!
components/YourPlantDetails/style.ts
Outdated
`; | ||
|
||
export const StyledIcon = styled.div` | ||
color: ${COLORS.shrub}; | ||
display: flex; | ||
align-items: center; | ||
`; | ||
|
||
export const StyledHeading = styled(H3)` | ||
font-size: 16px; |
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.
font sizes should be in rem! 16px = 1 rem
Also, note: if this is a H3, it should inherit the sizing from H3, so you wouldn't need to re-define it here. Kyrene is working on making everything consistent, so you can keep the font-size for now
app/all-plants/[plantId]/page.tsx
Outdated
@@ -18,12 +36,52 @@ export default function GeneralPlantPage() { | |||
getPlant(); | |||
}, [plantId]); | |||
return ( | |||
<div> | |||
<Container> | |||
{currentPlant && ( |
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.
note: maybe we should add a spinner if it's loading in the future? let's discuss in worksesh
app/all-plants/[plantId]/style.ts
Outdated
export const TitleWrapper = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
gap: 2px; |
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.
is this necessary? can we remove the gap?
app/my-garden/[userPlantId]/style.ts
Outdated
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.
nit: styling folders should be plural: this file should be renamed styles.ts
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.
also, since there are so many shared styles between GeneralPlantPage and UserPlantPage, we should just have them share styles rather than duplicate the styles, as this will reduce redundancy make it easier for us to keep styling consistent between pages.
One way to do is this is to restructure the directories like so:
UserPlantPage → app/view-plants/my-garden/[userPlantId]/page.tsx
[userPlantId]/styles.ts
if there are any custom styles that aren't shared with GeneralPlantPage
GeneralPlantPage → app/view-plants/all-plants/[plantId]/page.tsx
[plantId]/styles.ts
if there are any custom styles that aren't shared with userPlantPage
Shared Styles → app/view-plants/shared/styles.ts
- should include Container, Header, HeaderContainer, PlantImage, Content, NameWrapper etc.
app/all-plants/[plantId]/style.ts
Outdated
export const Container = styled.div` | ||
padding: 20px; | ||
`; |
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.
we should remove the padding from Container and instead include margin: 24px;
in Content
app/all-plants/[plantId]/style.ts
Outdated
|
||
export const NameWrapper = styled.div` | ||
display: flex; | ||
justify-content: flex-start; |
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.
nit: i think this is the default so we don't have to include this line here
app/all-plants/[plantId]/style.ts
Outdated
gap: 2px; | ||
justify-content: space-between; | ||
`; | ||
export const AddPlant = styled.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.
note: kyrene said this button style may change, so let's just leave this for now, and i'll update it later
@@ -44,3 +44,15 @@ export async function getCurrentUserPlantsByUserId( | |||
} | |||
return data; | |||
} | |||
export async function removeUserPlantById(id: UUID) { |
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.
omg i just realized that we actually don't want to delete the plants from their lists, but instead include date_removed, so that it is no longer fetched
e9b8121
to
db325e4
Compare
What's new in this PR 🧑🌾
Description
plant-page
directory.date_removed
; we don't actually delete the row from the dbUserPlant
type to include date_removed rather than date_harvested. also, planting_type is now PlantingTypeEnum type.Screenshots
Previously:
Note that the images of plants were hard coded for proof of concept, if you were to pull and run you will not see the image
Now:
GeneralPlantPage
UserPlantPage
How to review
Next steps
PlantingTimeline
, since both PlantPages use it)planting_type
Relevant links
Online sources
Related PRs
CC: @ccatherinetan