-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Kyle Ramachandran <[email protected]>
- Loading branch information
1 parent
4ce630a
commit c28c283
Showing
6 changed files
with
866 additions
and
1,844 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
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.