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

[feat] implement remove plant functionality & style PlantPages #53

Merged

Conversation

SashankBalusu
Copy link
Contributor

@SashankBalusu SashankBalusu commented Nov 22, 2024

What's new in this PR 🧑‍🌾

Description

  • styled the general and user plant page
    • consolidates styling to /plant-pages/styles.ts. Both Plant Pags are also under the plant-page directory.
  • allow user to remove plant from their plants
    • this actually means we update the date_removed; we don't actually delete the row from the db
  • also made edits to the plantpage components in order to match the styles
  • updated UserPlant type to include date_removed rather than date_harvested. also, planting_type is now PlantingTypeEnum type.

Screenshots

Previously:
Screenshot 2024-11-22 at 1 51 10 AM
Screenshot 2024-11-22 at 1 50 42 AM
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
Screen Shot 2024-12-07 at 1 46 33 AM

UserPlantPage
Screen Shot 2024-12-07 at 1 46 45 AM

How to review

  • can view both the general and user plant pages, test back button and remove button

Next steps

  • create the SeasonColorKey and use it in the PlantPages (maybe create a new component, PlantingTimeline, since both PlantPages use it)
  • on the issue of whether we should actually delete rows when "Removing Plants": POC wants a Retool workflow to filter out plants that have been removed a season ago.
  • fix /add-details handling of "SELECT" value, which is now invalid as a planting_type

Relevant links

Online sources

Related PRs

CC: @ccatherinetan

@SashankBalusu SashankBalusu linked an issue Nov 22, 2024 that may be closed by this pull request
@ccatherinetan ccatherinetan changed the title styled plantpages + remove functionality [feat] implement remove plant functionality & style PlantPages Nov 25, 2024
Copy link
Collaborator

@ccatherinetan ccatherinetan left a 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

  1. nit: all styling files should be plural, i.e. styles.ts rather than style.ts
  2. 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)
  3. 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.

Comment on lines 53 to 74
if (error) {
console.error('Error deleting row:', error);
return null;
}
Copy link
Collaborator

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

router.push(`/view-plants`);
}}
>
Copy link
Collaborator

@ccatherinetan ccatherinetan Nov 25, 2024

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??

border-radius: 5px;
cursor: pointer;
font-size: 0.75rem;
font-style: inherit;
Copy link
Collaborator

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!

`;

export const StyledIcon = styled.div`
color: ${COLORS.shrub};
display: flex;
align-items: center;
`;

export const StyledHeading = styled(H3)`
font-size: 16px;
Copy link
Collaborator

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

@@ -18,12 +36,52 @@ export default function GeneralPlantPage() {
getPlant();
}, [plantId]);
return (
<div>
<Container>
{currentPlant && (
Copy link
Collaborator

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

export const TitleWrapper = styled.div`
display: flex;
flex-direction: row;
gap: 2px;
Copy link
Collaborator

@ccatherinetan ccatherinetan Nov 26, 2024

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?

Copy link
Collaborator

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

Copy link
Collaborator

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.

Comment on lines 4 to 6
export const Container = styled.div`
padding: 20px;
`;
Copy link
Collaborator

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


export const NameWrapper = styled.div`
display: flex;
justify-content: flex-start;
Copy link
Collaborator

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

gap: 2px;
justify-content: space-between;
`;
export const AddPlant = styled.button`
Copy link
Collaborator

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) {
Copy link
Collaborator

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

@ccatherinetan ccatherinetan force-pushed the 49-style-plantpage-and-add-remove-plant-functionality branch from e9b8121 to db325e4 Compare December 7, 2024 09:42
@ccatherinetan ccatherinetan merged commit ea231e2 into main Dec 7, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Style PlantPage and Add Remove Plant Functionality
2 participants