-
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] pull and display all plants #2
Merged
ccatherinetan
merged 25 commits into
main
from
kyleramachandran/tg-11-pull-and-display-plants-unstyled-from-plant_seasonality
Oct 21, 2024
Merged
Changes from 9 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
12f9970
create supabase client
kylezryr b268565
added Plant type
kylezryr 5df8089
created PlantList type and getPlantSeasonality query
kylezryr 923fbae
run prettier
kylezryr c28c283
[chore] create supabse client (#3)
ccatherinetan a679504
added Plant type
kylezryr b5f78aa
adding img prop to Plant
kylezryr ccb3e71
Merge branch 'kyleramachandran/tg-11-pull-and-display-plants-unstyled…
kylezryr 4934aa8
resolving lockfile issues
kylezryr 8fe8603
[feat] User Auth: Created a simple login page that supports sign up a…
rachaelch3n e3caa76
schema changes, adding water_frequency, weed_frequency, sunlight, dif…
kylezryr d0d3fe2
change weed_frequency to weeding_frequency
kylezryr e5eacf7
added Plant type
kylezryr 2f2a3b0
adding img prop to Plant
kylezryr 4c83471
added Plant type
kylezryr 07029fa
resolving lockfile issues
kylezryr be7cb70
schema changes, adding water_frequency, weed_frequency, sunlight, dif…
kylezryr b7e6596
change weed_frequency to weeding_frequency
kylezryr 641fe9b
change table name in pull all plants query
kylezryr 70fa068
Merge branch 'kyleramachandran/tg-11-pull-and-display-plants-unstyled…
kylezryr 620832b
change state to us_state in schema
kylezryr ec6060f
added seasonal-planting-guide route for testing PlantList
kylezryr 8f1630b
fix es-lint errors (unused variables)
kylezryr 2f034e2
fix es-lint errors
kylezryr caafb88
prettier fix
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createClient } from '@supabase/supabase-js'; | ||
import dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
|
||
if ( | ||
!process.env.NEXT_PUBLIC_SUPABASE_URL || | ||
!process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY | ||
) { | ||
throw new Error( | ||
'No Supabase environment variables detected, please make sure they are in place!', | ||
); | ||
} | ||
|
||
const supabase = createClient( | ||
process.env.NEXT_PUBLIC_SUPABASE_URL, | ||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY, | ||
); | ||
|
||
export default supabase; |
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,14 @@ | ||
import { Plant } from '@/types/schema'; | ||
import supabase from '../createClient'; | ||
|
||
export async function getPlantSeasonality( | ||
input_state: string, | ||
): Promise<Plant[]> { | ||
const { data, error } = await supabase | ||
.from('plant_seasonality') | ||
.select('*') | ||
.eq('state', input_state); | ||
if (error) | ||
throw new Error(`Error fetching plant seasonality: ${error.message}`); | ||
return data; | ||
} |
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,24 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { getPlantSeasonality } from '@/api/supabase/queries/plantSeasonality'; | ||
import { Plant } from '@/types/schema'; | ||
|
||
export const PlantList = () => { | ||
const [plants, setPlants] = useState<Plant[]>([]); | ||
|
||
useEffect(() => { | ||
const fetchPlantSeasonality = async () => { | ||
const plantList = await getPlantSeasonality('Tennessee'); | ||
setPlants(plantList); | ||
}; | ||
|
||
fetchPlantSeasonality(); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
{plants.map((plant, key) => ( | ||
<div key={key}>{plant.plant_name}</div> | ||
))} | ||
</div> | ||
); | ||
}; |
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
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.
this looks great! sorry for the change, but is it possible to create the
seasonal-planting-guide
page (route:app/seasonal-planting-guide
) that uses thePlantList
component?