From 9a531d252b043b4f1338184dda00761a05961489 Mon Sep 17 00:00:00 2001 From: David Boyne Date: Tue, 29 Oct 2024 16:40:25 +0000 Subject: [PATCH] feat(core): added ability to embed discovery table (#923) * feat(core): added ability to embed discovery table * Create angry-cycles-arrive.md --- .changeset/angry-cycles-arrive.md | 5 +++++ src/components/Tables/Table.tsx | 14 +++++++++++++- src/layouts/DiscoverLayout.astro | 11 +---------- src/layouts/VerticalSideBarLayout.astro | 6 +++++- 4 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 .changeset/angry-cycles-arrive.md diff --git a/.changeset/angry-cycles-arrive.md b/.changeset/angry-cycles-arrive.md new file mode 100644 index 00000000..4e47630a --- /dev/null +++ b/.changeset/angry-cycles-arrive.md @@ -0,0 +1,5 @@ +--- +"@eventcatalog/core": patch +--- + +feat(core): added ability to embed discovery table diff --git a/src/components/Tables/Table.tsx b/src/components/Tables/Table.tsx index 26a60ea2..bc04825a 100644 --- a/src/components/Tables/Table.tsx +++ b/src/components/Tables/Table.tsx @@ -15,7 +15,7 @@ import type { CollectionEntry } from 'astro:content'; import DebouncedInput from './DebouncedInput'; import { getColumnsByCollection } from './columns'; -import { useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import type { CollectionTypes } from '@types'; declare module '@tanstack/react-table' { @@ -40,6 +40,18 @@ export const Table = ({ const [data, _setData] = useState(initialData); const [columnFilters, setColumnFilters] = useState([]); + useEffect(() => { + console.log(window.location.pathname); + }, []); + + useEffect(() => { + const urlParams = new URLSearchParams(window.location.search); + const id = urlParams.get('id'); + if (id) { + setColumnFilters([{ id: 'name', value: id }]); + } + }, []); + const columns = useMemo(() => getColumnsByCollection(collection), [collection]); const table = useReactTable({ diff --git a/src/layouts/DiscoverLayout.astro b/src/layouts/DiscoverLayout.astro index 620c744d..769bcd3f 100644 --- a/src/layouts/DiscoverLayout.astro +++ b/src/layouts/DiscoverLayout.astro @@ -76,16 +76,7 @@ const tabs = [
-
- +