From 99363c5e41efe8f17b826181133df4877681a5d8 Mon Sep 17 00:00:00 2001 From: Abi Date: Mon, 18 Dec 2023 17:21:22 -0500 Subject: [PATCH 1/8] Updated table with buttons --- src/components/Resources/ResourceTable.tsx | 63 ++++++++++++++++++++-- 1 file changed, 58 insertions(+), 5 deletions(-) diff --git a/src/components/Resources/ResourceTable.tsx b/src/components/Resources/ResourceTable.tsx index a7e1a4c..298c911 100644 --- a/src/components/Resources/ResourceTable.tsx +++ b/src/components/Resources/ResourceTable.tsx @@ -2,8 +2,9 @@ import { useEffect, useState } from 'react' import { QueryData } from '@supabase/supabase-js' import client from '@/database/client.tsx' import TagSection from '@/components/TagSection.tsx' -import { FaHeart } from 'react-icons/fa' +import { FaHeart, FaSun } from 'react-icons/fa' import { Tooltip } from 'flowbite-react' +import SessionWrapper from '../Auth/SessionWrapper' export default function ResourceTable() { const resourcesQuery = client.from('resources').select() @@ -18,7 +19,32 @@ export default function ResourceTable() { setData(resources) } fetchData() + + // Listen for updates + client + .channel('schema-db-changes') + .on( + 'postgres_changes', + { event: 'UPDATE', schema: 'public', table: 'resources' }, + (payload) => { + data.splice( + data.map((o) => o.id).indexOf(payload.new.id), + 1, + payload.new + ) + setData(data.sort((a, b) => a.num_helped - b.num_helped)) + } + ) + .subscribe() }, []) + + const favorite = async (id: number, count: number) => { + await client + .from('resources') + .update({ num_helped: count + 1 }) + .eq('id', id) + } + return ( @@ -48,9 +74,13 @@ export default function ResourceTable() { - From 2547107acba4f279985be288605da8c4483bb796 Mon Sep 17 00:00:00 2001 From: Abi Date: Mon, 18 Dec 2023 19:59:23 -0500 Subject: [PATCH 2/8] wip --- src/components/Resources/ResourceTable.tsx | 37 +++++++++++++++++----- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/components/Resources/ResourceTable.tsx b/src/components/Resources/ResourceTable.tsx index 69a247c..44993fb 100644 --- a/src/components/Resources/ResourceTable.tsx +++ b/src/components/Resources/ResourceTable.tsx @@ -6,6 +6,15 @@ import { FaHeart, FaSun } from 'react-icons/fa' import { Tooltip } from 'flowbite-react' import SessionWrapper from '../Auth/SessionWrapper' +type SingleResource = { + created_at: Date + description: string + id: number + in_review: boolean + link: string + name: string + num_helped: number +} export default function ResourceTable() { const resourcesQuery = client.from('resources').select() type ResourcesType = QueryData @@ -16,6 +25,7 @@ export default function ResourceTable() { const { data, error } = await resourcesQuery if (error) throw error const resources: ResourcesType = data + resources.sort((a, b) => a.num_helped - b.num_helped) setData(resources) } fetchData() @@ -26,18 +36,29 @@ export default function ResourceTable() { .on( 'postgres_changes', { event: 'UPDATE', schema: 'public', table: 'resources' }, - (payload) => { - data.splice( - data.map((o) => o.id).indexOf(payload.new.id), - 1, - payload.new - ) - setData(data.sort((a, b) => a.num_helped - b.num_helped)) - } + (payload) => updateRow(payload.new) ) .subscribe() }, []) + const updateRow = (newResource) => { + { + const temp = data.slice( + 0, + data.map((o) => o.id).indexOf(newResource.id) - 1 + ) + temp.push(newResource) + temp.push( + ...data.slice( + data.map((o) => o.id).indexOf(newResource.id) + 1, + data.length + ) + ) + temp.sort((a, b) => a.num_helped - b.num_helped) + setData(temp) + } + } + const favorite = async (id: number, count: number) => { await client .from('resources') From 908fb8e4262d069ce208bec0adb6b1a0ea691e27 Mon Sep 17 00:00:00 2001 From: Abi Date: Tue, 19 Dec 2023 11:53:50 -0500 Subject: [PATCH 3/8] pushing for xue --- src/components/Resources/ResourceTable.tsx | 23 ++++++++-------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/components/Resources/ResourceTable.tsx b/src/components/Resources/ResourceTable.tsx index 44993fb..198e13c 100644 --- a/src/components/Resources/ResourceTable.tsx +++ b/src/components/Resources/ResourceTable.tsx @@ -42,21 +42,14 @@ export default function ResourceTable() { }, []) const updateRow = (newResource) => { - { - const temp = data.slice( - 0, - data.map((o) => o.id).indexOf(newResource.id) - 1 - ) - temp.push(newResource) - temp.push( - ...data.slice( - data.map((o) => o.id).indexOf(newResource.id) + 1, - data.length - ) - ) - temp.sort((a, b) => a.num_helped - b.num_helped) - setData(temp) - } + const temp = JSON.parse(JSON.stringify(data)) + temp.splice( + data.map((o) => o.id).indexOf(newResource.id), + 1, + newResource + ) + temp.sort((a, b) => a.num_helped - b.num_helped) + setData(temp) } const favorite = async (id: number, count: number) => { From 76e8526bd5d060c3e97fbc3abb80a484acfae855 Mon Sep 17 00:00:00 2001 From: Abi Date: Tue, 19 Dec 2023 12:23:49 -0500 Subject: [PATCH 4/8] Updated to static instead of realtime --- src/components/Resources/ResourceTable.tsx | 37 ++++++---------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/src/components/Resources/ResourceTable.tsx b/src/components/Resources/ResourceTable.tsx index 198e13c..a233aec 100644 --- a/src/components/Resources/ResourceTable.tsx +++ b/src/components/Resources/ResourceTable.tsx @@ -31,32 +31,18 @@ export default function ResourceTable() { fetchData() // Listen for updates - client - .channel('schema-db-changes') - .on( - 'postgres_changes', - { event: 'UPDATE', schema: 'public', table: 'resources' }, - (payload) => updateRow(payload.new) - ) - .subscribe() }, []) - const updateRow = (newResource) => { - const temp = JSON.parse(JSON.stringify(data)) - temp.splice( - data.map((o) => o.id).indexOf(newResource.id), - 1, - newResource - ) - temp.sort((a, b) => a.num_helped - b.num_helped) - setData(temp) - } - - const favorite = async (id: number, count: number) => { + const favorite = async (row: SingleResource) => { + 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 + setData([...temp]) await client .from('resources') - .update({ num_helped: count + 1 }) - .eq('id', id) + .update({ num_helped: new_helped }) + .eq('id', row.id) } return ( @@ -118,11 +104,8 @@ export default function ResourceTable() { - favorite( - d.id, - d.num_helped - ) + onClick={async () => + await favorite(d) } > From ec845f54eb873c7475a450b869aaba7957c492a6 Mon Sep 17 00:00:00 2001 From: Abi Date: Tue, 19 Dec 2023 14:32:38 -0500 Subject: [PATCH 5/8] updated width --- src/components/Resources/ResourceTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Resources/ResourceTable.tsx b/src/components/Resources/ResourceTable.tsx index 9bd178e..b6b0b9c 100644 --- a/src/components/Resources/ResourceTable.tsx +++ b/src/components/Resources/ResourceTable.tsx @@ -61,7 +61,7 @@ export default function ResourceTable() { -
+ - {d.num_helped} - + + {d.num_helped ? ( + `Helped ${d.num_helped}` + ) : ( +
+ {' '} + New! +
+ )} +
+ + favorite( + d.id, + d.num_helped + ) + } + > + + + } + notSession={<>} + />
+ Date: Tue, 19 Dec 2023 14:34:45 -0500 Subject: [PATCH 6/8] messed up my branch --- .editorconfig | 12 ++++++++ .git-blame-ignore-revs | 3 ++ .github/workflows/eslint.yml | 54 +++++++++++++++++++++++++++++++++++ .prettierrc.cjs | 10 +++++++ public/logo.png | Bin 0 -> 15266 bytes vercel.json | 8 ++++++ 6 files changed, 87 insertions(+) create mode 100644 .editorconfig create mode 100644 .git-blame-ignore-revs create mode 100644 .github/workflows/eslint.yml create mode 100644 .prettierrc.cjs create mode 100644 public/logo.png create mode 100644 vercel.json diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..01c91ca --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Use spaces instead of tabs +[*] +indent_style = space + +# Insert new line at the end of files +[*] +insert_final_newline = true diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..29ad4bc --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,3 @@ +# .git-blame-ignore-revs +# Ignore changes in git blame for specific revisions +4f8e868bd796996bc91e1b6139a77427ac97a30e # Add prettier plugin for tailwind css sort classes diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml new file mode 100644 index 0000000..09d929c --- /dev/null +++ b/.github/workflows/eslint.yml @@ -0,0 +1,54 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# ESLint is a tool for identifying and reporting on patterns +# found in ECMAScript/JavaScript code. +# More details at https://github.com/eslint/eslint +# and https://eslint.org + +name: Eslint and Prettier + +on: + push: + branches: [ "main" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "main" ] + +jobs: + eslint: + name: Run eslint scanning + runs-on: ubuntu-latest + permissions: + contents: read + security-events: write + actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install ESLint + run: | + npm install eslint@8.55.0 + npm install @microsoft/eslint-formatter-sarif@2.1.7 + + - name: Run ESLint + run: npx eslint . + --config .eslintrc.cjs + --ext .js,.jsx,.ts,.tsx + --format @microsoft/eslint-formatter-sarif + --output-file eslint-results.sarif + continue-on-error: true + + - name: Upload analysis results to GitHub + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: eslint-results.sarif + wait-for-processing: true + + - name: Run Prettier + run: npx prettier src/ + --check + --config .prettierrc.cjs + continue-on-error: false diff --git a/.prettierrc.cjs b/.prettierrc.cjs new file mode 100644 index 0000000..56061f9 --- /dev/null +++ b/.prettierrc.cjs @@ -0,0 +1,10 @@ +// prettier.config.js, .prettierrc.js, prettier.config.mjs, or .prettierrc.mjs + +/** @type {import("prettier").Config} */ +module.exports = { + plugins: ['prettier-plugin-tailwindcss'], + trailingComma: 'es5', + tabWidth: 4, + semi: false, + singleQuote: true, +} diff --git a/public/logo.png b/public/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..68adb310fa7125a9db23378582090fbb5d07ec10 GIT binary patch literal 15266 zcmdtJcT|&K*ESeXic}Q=1p!3_=}3!o6zL$nNa#rKCG?JfQk53zy@UXf5_(5OKw1dB zcL=?P&V=8yp68oy-gmzB{WELL46MBp?%eF`bI!i^+56hp`KtOsmXwHw2mk<(%FDf1 z2LN#9Z-o#ad&LjcoQVD7v$d3zs=SocGba~E3u`-b0N~Ykzwcsl9g=+Zdq(IVSX=*wwO;P) zjUo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y7q~zC)SmHKZHTtiYEcq^gA~2&bes|#&DI_pa>F9BOn7da<|6Ti#PufuJx#6j<(@$ zuuV0qN6)fOx;P=2Nuo={pSr=_QRlOQb!IDOvr0@^h{edk=OTM)2 z8%7{)s#42T;H6_=Ub77*SH}VND0u04?_lv-lLZn0CFi+fhM32(sT*QC%eE&mqZpN|>9J>6{?Aq5|2NKl z0rfY>;2xU?l#d=+VVkMHL1-WBxvVf=+#<5x$5=48+G>cg@>BQ2{JcD?WAq5U#?F^7 zgq>Yon_;vLgIRAw9#K%3c`5wUPwnpRR!~;fGBL@PMb-S*PRqFWEk60oNlf6In1Iv0 zPuRE_w5b-fRT`xD?2f~q#~t%w9pmL@(M(~kQt#h?{#a=d4J|$Q-z=?(YH5)G`#J1k zFhIwq<0KQ%C*z`~pva%osMWqy=;y Date: Tue, 19 Dec 2023 14:37:05 -0500 Subject: [PATCH 7/8] I think it's working now --- src/components/Resources/ResourceTable.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/components/Resources/ResourceTable.tsx b/src/components/Resources/ResourceTable.tsx index b6b0b9c..12b182b 100644 --- a/src/components/Resources/ResourceTable.tsx +++ b/src/components/Resources/ResourceTable.tsx @@ -30,6 +30,19 @@ export default function ResourceTable() { } fetchData() }, [resourcesQuery]) + + const favorite = async (row: SingleResource) => { + 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 + setData([...temp]) + await client + .from('resources') + .update({ num_helped: new_helped }) + .eq('id', row.id) + } + return ( From 20117ed4d848e3c72c2aa8efaf67d41a1abfd741 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 19 Dec 2023 17:20:50 -0500 Subject: [PATCH 8/8] ran linting --- src/components/Resources/ResourceTable.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Resources/ResourceTable.tsx b/src/components/Resources/ResourceTable.tsx index 12b182b..fdf443c 100644 --- a/src/components/Resources/ResourceTable.tsx +++ b/src/components/Resources/ResourceTable.tsx @@ -42,7 +42,7 @@ export default function ResourceTable() { .update({ num_helped: new_helped }) .eq('id', row.id) } - + return (
@@ -74,7 +74,7 @@ export default function ResourceTable() { -
+