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] pull and display all plants #2

Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
12f9970
create supabase client
kylezryr Sep 30, 2024
b268565
added Plant type
kylezryr Sep 30, 2024
5df8089
created PlantList type and getPlantSeasonality query
kylezryr Sep 30, 2024
923fbae
run prettier
kylezryr Sep 30, 2024
c28c283
[chore] create supabse client (#3)
ccatherinetan Sep 30, 2024
a679504
added Plant type
kylezryr Sep 30, 2024
b5f78aa
adding img prop to Plant
kylezryr Oct 14, 2024
ccb3e71
Merge branch 'kyleramachandran/tg-11-pull-and-display-plants-unstyled…
kylezryr Oct 14, 2024
4934aa8
resolving lockfile issues
kylezryr Oct 14, 2024
8fe8603
[feat] User Auth: Created a simple login page that supports sign up a…
rachaelch3n Oct 15, 2024
e3caa76
schema changes, adding water_frequency, weed_frequency, sunlight, dif…
kylezryr Oct 16, 2024
d0d3fe2
change weed_frequency to weeding_frequency
kylezryr Oct 16, 2024
e5eacf7
added Plant type
kylezryr Sep 30, 2024
2f2a3b0
adding img prop to Plant
kylezryr Oct 14, 2024
4c83471
added Plant type
kylezryr Sep 30, 2024
07029fa
resolving lockfile issues
kylezryr Oct 14, 2024
be7cb70
schema changes, adding water_frequency, weed_frequency, sunlight, dif…
kylezryr Oct 16, 2024
b7e6596
change weed_frequency to weeding_frequency
kylezryr Oct 16, 2024
641fe9b
change table name in pull all plants query
kylezryr Oct 17, 2024
70fa068
Merge branch 'kyleramachandran/tg-11-pull-and-display-plants-unstyled…
kylezryr Oct 20, 2024
620832b
change state to us_state in schema
kylezryr Oct 20, 2024
ec6060f
added seasonal-planting-guide route for testing PlantList
kylezryr Oct 20, 2024
8f1630b
fix es-lint errors (unused variables)
kylezryr Oct 20, 2024
2f034e2
fix es-lint errors
kylezryr Oct 20, 2024
caafb88
prettier fix
ccatherinetan Oct 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions api/supabase/createClient.ts
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;
14 changes: 14 additions & 0 deletions api/supabase/queries/plantSeasonality.ts
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;
}
24 changes: 24 additions & 0 deletions components/PlantList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { useEffect, useState } from 'react';
Copy link
Collaborator

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 the PlantList component?

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>
);
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
},
"dependencies": {
"next": "^14.2.10",
"@supabase/supabase-js": "^2.45.4",
"dotenv": "^16.4.5",
"react": "^18",
"react-dom": "^18",
"styled-components": "^6.1.13"
Expand Down
Loading