Skip to content

Commit

Permalink
displaying summaries
Browse files Browse the repository at this point in the history
  • Loading branch information
angelinetu committed Oct 9, 2024
1 parent 529b1c0 commit 833a7e4
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions src/SeekHelp/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
import { Text } from 'react-native';
import React, { useEffect, useState } from 'react';
import { Button, Text, View } from 'react-native';
import supabase from '../supabase/createClient';

interface Resource {
summary: string;
[key: string]: any;
}

export default function SeekHelp() {
return <Text>SEEK HELP!</Text>;
const [summaries, setSummaries] = useState<Resource[]>([]);

useEffect(() => {
fetchData();
}, []);

const fetchData = async () => {
try {
const { data, error } = await supabase
.from('state_resources')
.select('*')
.in('state', ['California', 'National']);

if (error) {
console.error('Error fetching resources:', error);
return;
}

setSummaries(data as Resource[]);
} catch (error) {
console.error('Error fetching data:', error);
}
};

return (
<View>
<Button title="Fetch Data" onPress={fetchData} />
{summaries.length > 0 ? (
summaries.map((resource, index) => (
<Text key={index}>{resource.summary}</Text>
))
) : (
<Text>Loading...</Text>
)}
</View>
);
}

0 comments on commit 833a7e4

Please sign in to comment.