diff --git a/src/components/Resources/ResourceTable.tsx b/src/components/Resources/ResourceTable.tsx index d049638..fa9cff4 100644 --- a/src/components/Resources/ResourceTable.tsx +++ b/src/components/Resources/ResourceTable.tsx @@ -2,8 +2,9 @@ import TagSection from '@/components/TagSection.tsx' import client from '@/database/client' import { Tooltip } from 'flowbite-react' import { useEffect, useState } from 'react' -import { FaHeart } from 'react-icons/fa' +import { FaHeart, FaSun } from 'react-icons/fa' import { useLoaderData } from 'react-router-dom' +import SessionWrapper from '../Auth/SessionWrapper' export interface Resource { id: number @@ -36,6 +37,17 @@ export default function ResourceTable() { } }, [tableData.length, data.length]) + const favorite = async (row: Resource) => { + const new_helped = row.num_helped + 1 + const idx = data.map((o) => o.id).indexOf(row.id) + const temp = [...data] + temp[idx].num_helped = new_helped + setTableData([...temp]) + await client + .from('resources') + .update({ num_helped: new_helped }) + .eq('id', row.id) + } return (
|
- + |
+
+ )}
+
+ |