Skip to content

Commit eee3e65

Browse files
Merge pull request #343 from CivicDataLab/update/dependencies
Nextjs, react, and opub-ui updated
2 parents 9418f46 + f4da28d commit eee3e65

File tree

38 files changed

+9397
-7842
lines changed

38 files changed

+9397
-7842
lines changed

.eslintrc.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/[locale]/(user)/collaboratives/[collaborativeSlug]/page.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ const CollaborativeInfoQuery = graphql(`
2626
export async function generateMetadata({
2727
params,
2828
}: {
29-
params: { collaborativeSlug: string };
29+
params: Promise<{ collaborativeSlug: string }>;
3030
}): Promise<Metadata> {
31+
const { collaborativeSlug } = await params;
3132
try {
32-
const data = await GraphQLPublic(CollaborativeInfoQuery, {}, { pk: params.collaborativeSlug });
33+
const data = await GraphQLPublic(
34+
CollaborativeInfoQuery,
35+
{},
36+
{ pk: collaborativeSlug }
37+
);
3338
const Collaborative = data?.collaborative;
3439

3540
return generatePageMetadata({
@@ -41,7 +46,7 @@ export async function generateMetadata({
4146
openGraph: {
4247
type: 'article',
4348
locale: 'en_US',
44-
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/collaboratives/${params.collaborativeSlug}`,
49+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/collaboratives/${collaborativeSlug}`,
4550
title: `${Collaborative?.title} | Collaborative Data | CivicDataSpace`,
4651
description:
4752
Collaborative?.summary ||
@@ -59,7 +64,7 @@ export async function generateMetadata({
5964
openGraph: {
6065
type: 'article',
6166
locale: 'en_US',
62-
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/collaboratives/${params.collaborativeSlug}`,
67+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/collaboratives/${collaborativeSlug}`,
6368
title: `Collaborative Details | CivicDataSpace`,
6469
description: `Explore open data and curated datasets in this collaborative.`,
6570
siteName: 'CivicDataSpace',

app/[locale]/(user)/components/ListingComponent.tsx

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
'use client'
1+
'use client';
22

3-
import GraphqlPagination from '@/app/[locale]/dashboard/components/GraphqlPagination/graphqlPagination';
3+
import React, { useEffect, useReducer, useRef, useState } from 'react';
44
import Image from 'next/image';
55
import { useRouter } from 'next/navigation';
6+
import GraphqlPagination from '@/app/[locale]/dashboard/components/GraphqlPagination/graphqlPagination';
7+
import { fetchData } from '@/fetch';
68
import {
79
Button,
810
ButtonGroup,
@@ -14,52 +16,52 @@ import {
1416
Text,
1517
Tray,
1618
} from 'opub-ui';
17-
import React, { useEffect, useReducer, useRef, useState } from 'react';
1819

20+
import { cn, formatDate } from '@/lib/utils';
1921
import BreadCrumbs from '@/components/BreadCrumbs';
2022
import { Icons } from '@/components/icons';
2123
import { Loading } from '@/components/loading';
22-
import { fetchData } from '@/fetch';
23-
import { cn, formatDate } from '@/lib/utils';
2424
import Filter from '../datasets/components/FIlter/Filter';
2525
import Styles from '../datasets/dataset.module.scss';
2626

2727
// Helper function to strip markdown and HTML tags for card preview
2828
const stripMarkdown = (markdown: string): string => {
2929
if (!markdown) return '';
30-
return markdown
31-
// Remove code blocks first (before other replacements)
32-
.replace(/```[\s\S]*?```/g, '')
33-
// Remove inline code
34-
.replace(/`([^`]+)`/g, '$1')
35-
// Remove images
36-
.replace(/!\[([^\]]*)\]\([^)]+\)/g, '$1')
37-
// Remove links
38-
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')
39-
// Remove headers
40-
.replace(/^#{1,6}\s+/gm, '')
41-
// Remove bold
42-
.replace(/\*\*([^*]+)\*\*/g, '$1')
43-
.replace(/__([^_]+)__/g, '$1')
44-
// Remove italic
45-
.replace(/\*([^*]+)\*/g, '$1')
46-
.replace(/_([^_]+)_/g, '$1')
47-
// Remove strikethrough
48-
.replace(/~~([^~]+)~~/g, '$1')
49-
// Remove blockquotes
50-
.replace(/^\s*>\s+/gm, '')
51-
// Remove horizontal rules
52-
.replace(/^(-{3,}|_{3,}|\*{3,})$/gm, '')
53-
// Remove list markers
54-
.replace(/^\s*[-*+]\s+/gm, '')
55-
.replace(/^\s*\d+\.\s+/gm, '')
56-
// Remove HTML tags
57-
.replace(/<[^>]*>/g, '')
58-
// Remove extra whitespace and newlines
59-
.replace(/\n\s*\n/g, '\n')
60-
.replace(/\n/g, ' ')
61-
.replace(/\s+/g, ' ')
62-
.trim();
30+
return (
31+
markdown
32+
// Remove code blocks first (before other replacements)
33+
.replace(/```[\s\S]*?```/g, '')
34+
// Remove inline code
35+
.replace(/`([^`]+)`/g, '$1')
36+
// Remove images
37+
.replace(/!\[([^\]]*)\]\([^)]+\)/g, '$1')
38+
// Remove links
39+
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')
40+
// Remove headers
41+
.replace(/^#{1,6}\s+/gm, '')
42+
// Remove bold
43+
.replace(/\*\*([^*]+)\*\*/g, '$1')
44+
.replace(/__([^_]+)__/g, '$1')
45+
// Remove italic
46+
.replace(/\*([^*]+)\*/g, '$1')
47+
.replace(/_([^_]+)_/g, '$1')
48+
// Remove strikethrough
49+
.replace(/~~([^~]+)~~/g, '$1')
50+
// Remove blockquotes
51+
.replace(/^\s*>\s+/gm, '')
52+
// Remove horizontal rules
53+
.replace(/^(-{3,}|_{3,}|\*{3,})$/gm, '')
54+
// Remove list markers
55+
.replace(/^\s*[-*+]\s+/gm, '')
56+
.replace(/^\s*\d+\.\s+/gm, '')
57+
// Remove HTML tags
58+
.replace(/<[^>]*>/g, '')
59+
// Remove extra whitespace and newlines
60+
.replace(/\n\s*\n/g, '\n')
61+
.replace(/\n/g, ' ')
62+
.replace(/\s+/g, ' ')
63+
.trim()
64+
);
6365
};
6466

6567
// Interfaces
@@ -266,7 +268,7 @@ const ListingComponent: React.FC<ListingProps> = ({
266268
if (variables) {
267269
const currentFetchId = ++latestFetchId.current;
268270

269-
fetchData(type,variables)
271+
fetchData(type, variables)
270272
.then((res) => {
271273
// Only set if this is the latest call
272274
if (currentFetchId === latestFetchId.current) {
@@ -325,7 +327,7 @@ const ListingComponent: React.FC<ListingProps> = ({
325327
label: bucket.key,
326328
value: bucket.key,
327329
}));
328-
}
330+
}
329331
// Handle key-value object format (current backend format)
330332
else if (value && typeof value === 'object' && !Array.isArray(value)) {
331333
acc[key] = Object.entries(value).map(([label, count]) => ({
@@ -528,14 +530,14 @@ const ListingComponent: React.FC<ListingProps> = ({
528530
: item?.organization?.logo
529531
? `${process.env.NEXT_PUBLIC_BACKEND_URL}/${item.organization.logo}`
530532
: '/org.png';
531-
532-
const geographies = item.geographies && item.geographies.length > 0
533-
? item.geographies
534-
: null;
535533

536-
const sdgs = item.sdgs && item.sdgs.length > 0
537-
? item.sdgs
538-
: null;
534+
const geographies =
535+
item.geographies && item.geographies.length > 0
536+
? item.geographies
537+
: null;
538+
539+
const sdgs =
540+
item.sdgs && item.sdgs.length > 0 ? item.sdgs : null;
539541

540542
const MetadataContent = [
541543
{
@@ -569,7 +571,9 @@ const ListingComponent: React.FC<ListingProps> = ({
569571

570572
if (sdgs && sdgs.length > 0) {
571573
// Format SDGs for display
572-
const sdgDisplay = sdgs.map((sdg: any) => `${sdg.code} - ${sdg.name}`).join(', ');
574+
const sdgDisplay = sdgs
575+
.map((sdg: any) => `${sdg.code} - ${sdg.name}`)
576+
.join(', ');
573577

574578
MetadataContent.push({
575579
icon: Icons.target,

app/[locale]/(user)/datasets/[datasetIdentifier]/page.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ const datasetMetaQuery: any = graphql(`
2121
export async function generateMetadata({
2222
params,
2323
}: {
24-
params: { datasetIdentifier: string };
24+
params: Promise<{ datasetIdentifier: string }>;
2525
}) {
26+
const { datasetIdentifier } = await params;
2627
try {
2728
const res: any = await GraphQL(
2829
datasetMetaQuery,
2930
{},
30-
{ datasetId: params.datasetIdentifier }
31+
{ datasetId: datasetIdentifier }
3132
);
3233

3334
const dataset = res?.getDataset;
@@ -38,7 +39,7 @@ export async function generateMetadata({
3839
openGraph: {
3940
type: 'dataset',
4041
locale: 'en_US',
41-
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/datasets/${params.datasetIdentifier}`,
42+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/datasets/${datasetIdentifier}`,
4243
title: dataset?.title,
4344
description: dataset?.description,
4445
siteName: 'CivicDataSpace',
@@ -51,10 +52,12 @@ export async function generateMetadata({
5152
}
5253
}
5354

54-
export default function Page({
55+
export default async function Page({
5556
params,
5657
}: {
57-
params: { datasetIdentifier: string };
58+
params: Promise<{ datasetIdentifier: string }>;
5859
}) {
59-
return <DatasetDetailsPage datasetId={params.datasetIdentifier} />;
60+
const { datasetIdentifier } = await params;
61+
62+
return <DatasetDetailsPage datasetId={datasetIdentifier} />;
6063
}

app/[locale]/(user)/publishers/[publisherSlug]/page.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ const userInfo = graphql(`
2121
export async function generateMetadata({
2222
params,
2323
}: {
24-
params: { publisherSlug: string };
24+
params: Promise<{ publisherSlug: string }>;
2525
}): Promise<Metadata> {
26+
const { publisherSlug } = await params;
2627
const data = await GraphQL(
2728
userInfo,
2829
{},
29-
{ userId: extractPublisherId(params.publisherSlug) }
30+
{ userId: extractPublisherId(publisherSlug) }
3031
);
3132

3233
const user = data.userById;
@@ -49,7 +50,7 @@ export async function generateMetadata({
4950
user?.bio || 'Explore datasets and use cases by this publisher.',
5051
type: 'profile',
5152
siteName: 'CivicDataSpace',
52-
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/publishers/${params.publisherSlug}`,
53+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/publishers/${publisherSlug}`,
5354
image: user?.profilePicture?.url
5455
? `${process.env.NEXT_PUBLIC_BACKEND_URL}/${user.profilePicture.url}`
5556
: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/og.png`,
@@ -58,14 +59,13 @@ export async function generateMetadata({
5859
});
5960
}
6061

61-
export default function PublisherPage({
62+
export default async function PublisherPage({
6263
params,
6364
}: {
64-
params: { publisherSlug: string };
65+
params: Promise<{ publisherSlug: string }>;
6566
}) {
67+
const { publisherSlug } = await params;
6668
return (
67-
<PublisherPageClient
68-
publisherSlug={extractPublisherId(params.publisherSlug)}
69-
/>
69+
<PublisherPageClient publisherSlug={extractPublisherId(publisherSlug)} />
7070
);
7171
}

app/[locale]/(user)/publishers/organization/[organizationSlug]/page.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ const orgDataQuery = graphql(`
2121
export async function generateMetadata({
2222
params,
2323
}: {
24-
params: { organizationSlug: string };
24+
params: Promise<{ organizationSlug: string }>;
2525
}): Promise<Metadata> {
26+
const { organizationSlug } = await params;
2627
const data = await GraphQL(
2728
orgDataQuery,
2829
{},
29-
{ id: extractPublisherId(params.organizationSlug) }
30+
{ id: extractPublisherId(organizationSlug) }
3031
);
3132

3233
const org = data.organization;
@@ -49,7 +50,7 @@ export async function generateMetadata({
4950
org?.description || 'Explore datasets and use cases by this publisher.',
5051
type: 'profile',
5152
siteName: 'CivicDataSpace',
52-
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/publishers/${params.organizationSlug}`,
53+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/publishers/${organizationSlug}`,
5354
image: org?.logo?.url
5455
? `${process.env.NEXT_PUBLIC_BACKEND_URL}/${org.logo.url}`
5556
: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/og.png`,
@@ -58,14 +59,15 @@ export async function generateMetadata({
5859
});
5960
}
6061

61-
export default function OrgPage({
62+
export default async function OrgPage({
6263
params,
6364
}: {
64-
params: { organizationSlug: string };
65+
params: Promise<{ organizationSlug: string }>;
6566
}) {
67+
const { organizationSlug } = await params;
6668
return (
6769
<OrgPageClient
68-
organizationSlug={extractPublisherId(params.organizationSlug)}
70+
organizationSlug={extractPublisherId(organizationSlug)}
6971
/>
7072
);
7173
}

app/[locale]/(user)/sectors/[sectorSlug]/page.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ const sectorQueryDoc = graphql(`
2020
export async function generateMetadata({
2121
params,
2222
}: {
23-
params: { sectorSlug: string };
23+
params: Promise<{ sectorSlug: string }>;
2424
}) {
25+
const { sectorSlug } = await params;
2526
const data = await GraphQL(
2627
sectorQueryDoc,
2728
{},
28-
{ filters: { slug: params.sectorSlug } }
29+
{ filters: { slug: sectorSlug } }
2930
);
3031
const sector = data?.sectors?.[0];
3132

@@ -38,7 +39,7 @@ export async function generateMetadata({
3839
openGraph: {
3940
type: 'article',
4041
locale: 'en_US',
41-
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/sectors/${params.sectorSlug}`,
42+
url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/sectors/${sectorSlug}`,
4243
title: `${sector?.name} | Sector Data | CivicDataSpace`,
4344
description:
4445
sector?.description ||
@@ -52,12 +53,13 @@ export async function generateMetadata({
5253
const SectorDetailsPage = async ({
5354
params,
5455
}: {
55-
params: { sectorSlug: string };
56+
params: Promise<{ sectorSlug: string }>;
5657
}) => {
58+
const { sectorSlug } = await params;
5759
const data = await GraphQL(
5860
sectorQueryDoc,
5961
{},
60-
{ filters: { slug: params.sectorSlug } }
62+
{ filters: { slug: sectorSlug } }
6163
);
6264
const sector = data?.sectors?.[0];
6365

0 commit comments

Comments
 (0)