-
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.
fixed styling and displayed card based on backend call
- Loading branch information
1 parent
f243253
commit 87bcf03
Showing
6 changed files
with
87 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,58 @@ | ||
'use client'; | ||
|
||
import { useEffect, useState } from 'react'; | ||
import { UUID } from 'crypto'; | ||
import { getPlantById } from '@/api/supabase/queries/plant_by_id'; | ||
import PlantCard from '@/components/PlantCard/PlantCard'; | ||
import { Plant } from '@/types/schema'; | ||
|
||
export default function Home() { | ||
const plant: Plant = { | ||
id: '3067b896-ba05-45b0-bb5c-e09277cf1e68', | ||
plant_name: 'tomato', | ||
state: 'tennessee', | ||
harvest_season: 'SPRING', | ||
water_num_times_per_week: 7, | ||
plant_seed_indoors_start: 'January', | ||
plant_seed_indoors_end: 'February', | ||
plant_seed_outdoors_start: 'March', | ||
plant_seed_outdoors_end: 'April', | ||
plant_transplant_start: 'April', | ||
plant_transplant_end: 'May', | ||
harvest_start: 'April', | ||
harvest_end: 'May', | ||
water_inches_per_week: 7, | ||
harvest_days_after_plant: 5, | ||
sunlight_required: 'Yes', | ||
beginner_friendly: true, | ||
plant_tips: 'aerg', | ||
}; | ||
return <PlantCard {...plant}></PlantCard>; | ||
const [result, setResult] = useState<Plant>(); | ||
async function fetchPlant(state: string, id: UUID) { | ||
const plant = await getPlantById(state, id); | ||
console.log(plant); | ||
return plant; | ||
} | ||
// const plant: Plant = { | ||
// id: '3067b896-ba05-45b0-bb5c-e09277cf1e68', | ||
// plant_name: 'tomato', | ||
// state: 'tennessee', | ||
// harvest_season: 'SPRING', | ||
// water_num_times_per_week: 7, | ||
// plant_seed_indoors_start: 'January', | ||
// plant_seed_indoors_end: 'February', | ||
// plant_seed_outdoors_start: 'March', | ||
// plant_seed_outdoors_end: 'April', | ||
// plant_transplant_start: 'April', | ||
// plant_transplant_end: 'May', | ||
// harvest_start: 'April', | ||
// harvest_end: 'May', | ||
// water_inches_per_week: 7, | ||
// harvest_days_after_plant: 5, | ||
// sunlight_required: 'Yes', | ||
// beginner_friendly: true, | ||
// plant_tips: 'aerg', | ||
// }; | ||
useEffect(() => { | ||
const getData = async () => { | ||
const testState: string = 'Tennessee'; | ||
const testUUID: UUID = '43c19f80-8205-4d03-b323-05c220550bf0'; | ||
const plant2 = await fetchPlant(testState, testUUID); | ||
setResult(plant2); // Set the result to state | ||
}; | ||
|
||
getData(); // Call the async function when the component mounts | ||
}, []); | ||
if (result === undefined) { | ||
return <div>Loading...</div>; | ||
} else { | ||
return <PlantCard plant={result} />; | ||
} | ||
// return ( | ||
// <div> | ||
|
||
// <PlantCard plant={plant}/> | ||
// | ||
// </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
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.