From 35a0fc5ad59776a52189677e47f3ab0abce07653 Mon Sep 17 00:00:00 2001 From: spham21 Date: Thu, 7 May 2026 20:01:00 -0700 Subject: [PATCH 1/4] integration to membership portal --- pages/index.tsx | 47 +++++++++++++++++++++++++++++------------------ utils/index.ts | 2 +- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index 9011d08..02abbd2 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,21 +1,32 @@ -import { GetStaticProps } from 'next'; -import React from 'react'; +import React, { useEffect, useState } from 'react'; import Layout from '../components/Layout'; -import { fetchLinks, PageProps } from '../utils'; +import { fetchLinks, Link } from '../utils'; +import { supabase } from '../utils/supabase'; -export default function Home({ pageName, links, pages }: PageProps): JSX.Element { - return ( - - ); -} +export default function Home(): JSX.Element { + const [links, setLinks] = useState([]); + + useEffect(() => { + // Initial data fetch on mount + fetchLinks().then(setLinks); + + // Subscribe to any INSERT, UPDATE, or DELETE on the links table + const channel = supabase + .channel('links-realtime') + .on( + 'postgres_changes', + { event: '*', schema: 'public', table: 'links' }, + () => { + // Re-fetch all links to stay in sync with the latest state + fetchLinks().then(setLinks); + } + ) + .subscribe(); -export const getStaticProps: GetStaticProps = async () => { - const links = await fetchLinks(); - return { - props: { - pageName: '', - links, - pages: [], - }, - }; -}; + return () => { + supabase.removeChannel(channel); + }; + }, []); + + return ; +} diff --git a/utils/index.ts b/utils/index.ts index b8b947b..3d4518d 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -29,5 +29,5 @@ export async function fetchLinks(): Promise { displayName: row.display_name, url: row.url, redirect_path: row.redirect_path, - })); + })).reverse(); } \ No newline at end of file From 54477730c420b1f66578809a0de04e84bc039c51 Mon Sep 17 00:00:00 2001 From: spham21 Date: Thu, 7 May 2026 20:35:16 -0700 Subject: [PATCH 2/4] linting issues --- pages/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index 02abbd2..265ac9e 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -8,7 +8,7 @@ export default function Home(): JSX.Element { useEffect(() => { // Initial data fetch on mount - fetchLinks().then(setLinks); + void fetchLinks().then(setLinks); // Subscribe to any INSERT, UPDATE, or DELETE on the links table const channel = supabase @@ -18,13 +18,13 @@ export default function Home(): JSX.Element { { event: '*', schema: 'public', table: 'links' }, () => { // Re-fetch all links to stay in sync with the latest state - fetchLinks().then(setLinks); - } + void fetchLinks().then(setLinks); + }, ) .subscribe(); return () => { - supabase.removeChannel(channel); + void supabase.removeChannel(channel); }; }, []); From f704c97aee260b966dbbff10f800b6380b2897cc Mon Sep 17 00:00:00 2001 From: spham21 Date: Fri, 8 May 2026 17:37:01 -0700 Subject: [PATCH 3/4] update positions --- utils/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/index.ts b/utils/index.ts index 3d4518d..cfaa5cd 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -18,7 +18,9 @@ export async function fetchLinks(): Promise { const { supabase } = await import('./supabase'); const { data, error } = await supabase .from('links') - .select('display_name, url, redirect_path'); + .select('display_name, url, redirect_path, position, created_at') + .order('position', { ascending: true, nullsFirst: true }) + .order('created_at', { ascending: false }); if (error) { console.error('Supabase error:', error); @@ -29,5 +31,5 @@ export async function fetchLinks(): Promise { displayName: row.display_name, url: row.url, redirect_path: row.redirect_path, - })).reverse(); + })); } \ No newline at end of file From 7de3e36a9d51d977156813f11c8fe6a3be4d0e51 Mon Sep 17 00:00:00 2001 From: spham21 Date: Mon, 11 May 2026 17:19:17 -0700 Subject: [PATCH 4/4] fixing order --- utils/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/index.ts b/utils/index.ts index cfaa5cd..52e11da 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -19,8 +19,7 @@ export async function fetchLinks(): Promise { const { data, error } = await supabase .from('links') .select('display_name, url, redirect_path, position, created_at') - .order('position', { ascending: true, nullsFirst: true }) - .order('created_at', { ascending: false }); + .order('position', { ascending: false }); if (error) { console.error('Supabase error:', error);