-
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
Merged
ccatherinetan
merged 14 commits into
main
from
49-style-plantpage-and-add-remove-plant-functionality
Dec 7, 2024
+548
−215
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
19c670b
styled plantpages + remove functionality
SashankBalusu 6ba281c
fixed background grey
SashankBalusu e4c3025
fixed background stretch
SashankBalusu a587c20
fix styling for gardening tips
ccatherinetan da08e76
finalize PlantCare styling; add Sunlight helper funcs
ccatherinetan b56029f
fix SunlightEnum helper func abstraction
ccatherinetan 9df0d6a
style YourPlantDetails; make planting_type a PlantingTypeEnum
ccatherinetan 8461cbe
refactor PlantCareDescription
ccatherinetan 85e0a78
refactor YourPlantDetails with DetailRow
ccatherinetan 80a2a12
create upsertUserPlant query
ccatherinetan 1620f61
use upsertUserPlant in userPlantPage
ccatherinetan db325e4
consolidate styling between plantpages in /plant-page route
ccatherinetan 6d4e128
fix imgheader padding
ccatherinetan 6162cae
change String to string
ccatherinetan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
'use client'; | ||
|
||
import { useEffect, useState } from 'react'; | ||
import { useParams, useRouter } from 'next/navigation'; | ||
import { UUID } from 'crypto'; | ||
import { getPlantById } from '@/api/supabase/queries/plants'; | ||
import DifficultyLevelBar from '@/components/DifficultyLevelBar'; | ||
import GardeningTips from '@/components/GardeningTips'; | ||
import PlantCalendarRow from '@/components/PlantCalendarRow'; | ||
import PlantCareDescription from '@/components/PlantCareDescription'; | ||
import { Flex } from '@/styles/containers'; | ||
import { H4 } from '@/styles/text'; | ||
import { Plant } from '@/types/schema'; | ||
import { | ||
BackButton, | ||
ButtonWrapper, | ||
ComponentWrapper, | ||
Content, | ||
ImgHeader, | ||
NameWrapper, | ||
PlantImage, | ||
PlantName, | ||
} from '../../style'; | ||
import { AddPlant } from './style'; | ||
|
||
export default function GeneralPlantPage() { | ||
const router = useRouter(); | ||
|
||
const params = useParams(); | ||
const plantId: UUID = params.plantId as UUID; | ||
const [currentPlant, setCurrentPlant] = useState<Plant>(); | ||
useEffect(() => { | ||
const getPlant = async () => { | ||
const plant = await getPlantById(plantId); | ||
setCurrentPlant(plant); | ||
}; | ||
getPlant(); | ||
}, [plantId]); | ||
return currentPlant ? ( | ||
<> | ||
<ImgHeader> | ||
<ButtonWrapper> | ||
<BackButton | ||
onClick={() => { | ||
router.push(`/view-plants`); | ||
}} | ||
> | ||
← | ||
</BackButton> | ||
</ButtonWrapper> | ||
<PlantImage src={currentPlant.img} alt={currentPlant.plant_name} /> | ||
</ImgHeader> | ||
<Content> | ||
<Flex $justify="between" $align="center" $mb="36px"> | ||
<NameWrapper> | ||
<PlantName>{currentPlant.plant_name}</PlantName> | ||
<DifficultyLevelBar | ||
difficultyLevel={currentPlant.difficulty_level} | ||
/> | ||
</NameWrapper> | ||
<AddPlant>Add +</AddPlant> | ||
</Flex> | ||
<ComponentWrapper> | ||
<GardeningTips | ||
plantName={currentPlant.plant_name} | ||
plantTips={currentPlant.plant_tips} | ||
/> | ||
|
||
<PlantCareDescription | ||
waterFreq={currentPlant.water_frequency} | ||
weedingFreq={currentPlant.weeding_frequency} | ||
sunlightMaxHours={currentPlant.sunlight_max_hours} | ||
sunlightMinHours={currentPlant.sunlight_min_hours} | ||
/> | ||
<Flex $direction="column" $gap="8px"> | ||
<H4>Planting Timeline</H4> | ||
{/*add SeasonalColorKey here */} | ||
<PlantCalendarRow | ||
harvestStart={currentPlant.harvest_start} | ||
harvestEnd={currentPlant.harvest_end} | ||
transplantStart={currentPlant.transplant_start} | ||
transplantEnd={currentPlant.transplant_end} | ||
indoorsStart={currentPlant.indoors_start} | ||
indoorsEnd={currentPlant.indoors_end} | ||
outdoorsStart={currentPlant.outdoors_start} | ||
outdoorsEnd={currentPlant.outdoors_end} | ||
/> | ||
</Flex> | ||
</ComponentWrapper> | ||
</Content> | ||
</> | ||
) : ( | ||
<>Loading</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import styled from 'styled-components'; | ||
import COLORS from '@/styles/colors'; | ||
|
||
export const Container = styled.div` | ||
padding: 20px; | ||
`; | ||
|
||
export const Header = styled.div` | ||
background-color: ${COLORS.backgroundGrey}; | ||
margin: -28px -28px 24px -28px; | ||
padding: 12px 20px; | ||
padding-bottom: 27px; | ||
`; | ||
|
||
export const HeaderContent = styled.div` | ||
position: relative; | ||
max-width: 100%; | ||
`; | ||
|
||
export const ButtonWrapper = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
width: 100%; | ||
padding-top: 24px; | ||
`; | ||
|
||
export const BackButton = styled.button` | ||
background: none; | ||
border: none; | ||
font-size: 1.125rem; | ||
cursor: pointer; | ||
padding: 0; | ||
`; | ||
|
||
export const PlantImage = styled.img` | ||
max-width: 150px; | ||
height: auto; | ||
margin: 9px auto 0; | ||
display: block; | ||
`; | ||
|
||
export const Content = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 20px; | ||
`; | ||
|
||
export const NameWrapper = styled.div` | ||
display: flex; | ||
justify-content: flex-start; | ||
align-items: center; | ||
gap: 8.5px; | ||
`; | ||
|
||
export const PlantName = styled.h1` | ||
text-align: center; | ||
font-size: 1.5rem; | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: normal; | ||
margin: 0; | ||
`; | ||
|
||
export const TitleWrapper = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
gap: 2px; | ||
justify-content: space-between; | ||
`; | ||
export const AddPlant = styled.button` | ||
background-color: ${COLORS.shrub}; | ||
color: white; | ||
padding: 8px 16px; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
font-size: 0.75rem; | ||
font-style: inherit; | ||
font-weight: 400; | ||
line-height: normal; | ||
`; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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