-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] implement remove plant functionality & style PlantPages (#53)
Co-authored-by: Catherine Tan <[email protected]>
- Loading branch information
1 parent
d84231b
commit ea231e2
Showing
23 changed files
with
548 additions
and
215 deletions.
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.