Skip to content

Commit 28a6455

Browse files
authored
Merge pull request #174 from CivicDataLab/171-restructure-dashboard-to-reuse-organization-features-for-dataspace
171 restructure dashboard to reuse organization features for dataspace
2 parents 65b8461 + d69741a commit 28a6455

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+490
-203
lines changed

app/[locale]/(user)/categories/[categorySlug]/page.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
'use client';
22

3+
import { useEffect, useReducer, useState } from 'react';
4+
import Image from 'next/image';
5+
import { useRouter } from 'next/navigation';
36
import GraphqlPagination from '@/app/[locale]/dashboard/components/GraphqlPagination/graphqlPagination';
47
import { fetchDatasets } from '@/fetch';
58
import { graphql } from '@/gql';
69
import { useQuery } from '@tanstack/react-query';
7-
import Image from 'next/image';
8-
import { useRouter } from 'next/navigation';
910
import { Pill, SearchInput, Select, Text } from 'opub-ui';
10-
import { useEffect, useReducer, useState } from 'react';
1111

12+
import { GraphQL } from '@/lib/api';
1213
import BreadCrumbs from '@/components/BreadCrumbs';
1314
import { ErrorPage } from '@/components/error';
1415
import { Loading } from '@/components/loading';
15-
import { GraphQL } from '@/lib/api';
1616
import Card from '../../datasets/components/Card';
1717
import Filter from '../../datasets/components/FIlter/Filter';
1818

@@ -171,7 +171,13 @@ const CategoryDetailsPage = ({ params }: { params: { categorySlug: any } }) => {
171171
isLoading: boolean;
172172
isError: boolean;
173173
} = useQuery([`get_category_details_${params.categorySlug}`], () =>
174-
GraphQL(categoryQueryDoc, { filters: { slug: params.categorySlug } })
174+
GraphQL(
175+
categoryQueryDoc,
176+
{
177+
// Entity Headers if present
178+
},
179+
{ filters: { slug: params.categorySlug } }
180+
)
175181
);
176182

177183
const [facets, setFacets] = useState<{

app/[locale]/(user)/categories/page.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'use client';
22

3-
import { graphql } from '@/gql';
4-
import { useQuery } from '@tanstack/react-query';
53
import Image from 'next/image';
64
import Link from 'next/link';
5+
import { graphql } from '@/gql';
6+
import { useQuery } from '@tanstack/react-query';
77
import { Text } from 'opub-ui';
88

9+
import { GraphQL } from '@/lib/api';
910
import BreadCrumbs from '@/components/BreadCrumbs';
1011
import { ErrorPage } from '@/components/error';
1112
import { Loading } from '@/components/loading';
12-
import { GraphQL } from '@/lib/api';
1313

1414
const categoriesListQueryDoc: any = graphql(`
1515
query CategoriesList {
@@ -30,7 +30,13 @@ const CategoriesListingPage = () => {
3030
error: any;
3131
isError: boolean;
3232
} = useQuery([`categories_list_page`], () =>
33-
GraphQL(categoriesListQueryDoc, [])
33+
GraphQL(
34+
categoriesListQueryDoc,
35+
{
36+
// Entity Headers if present
37+
},
38+
[]
39+
)
3440
);
3541

3642
return (

app/[locale]/(user)/datasets/[datasetIdentifier]/components/AccessModels/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,15 @@ const AccessModels = () => {
124124
const { data, error, isLoading } = useQuery(
125125
[`accessmodel_${params.datasetIdentifier}`],
126126
() =>
127-
GraphQL(accessModelResourcesQuery, {
128-
datasetId: params.datasetIdentifier,
129-
})
127+
GraphQL(
128+
accessModelResourcesQuery,
129+
{
130+
// Entity Headers if present
131+
},
132+
{
133+
datasetId: params.datasetIdentifier,
134+
}
135+
)
130136
);
131137

132138
return (

app/[locale]/(user)/datasets/[datasetIdentifier]/components/Details/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@ const Details = () => {
4545
}: { data: any; isLoading: boolean; refetch: any } = useQuery(
4646
[`chartdata_${params.datasetIdentifier}`],
4747
() =>
48-
GraphQL(charts, {
49-
datasetId: params.datasetIdentifier,
50-
})
48+
GraphQL(
49+
charts,
50+
{
51+
// Entity Headers if present
52+
},
53+
{
54+
datasetId: params.datasetIdentifier,
55+
}
56+
)
5157
);
5258

5359
return (

app/[locale]/(user)/datasets/[datasetIdentifier]/components/Resources/index.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { useState, useEffect, useRef } from 'react';
3+
import { useEffect, useRef, useState } from 'react';
44
import Link from 'next/link';
55
import { useParams } from 'next/navigation';
66
import { graphql } from '@/gql';
@@ -49,12 +49,21 @@ const Resources = () => {
4949

5050
const { data, isLoading } = useQuery(
5151
[`resources_${params.datasetIdentifier}`],
52-
() => GraphQL(datasetResourceQuery, { datasetId: params.datasetIdentifier })
52+
() =>
53+
GraphQL(
54+
datasetResourceQuery,
55+
{
56+
// Entity Headers if present
57+
},
58+
{ datasetId: params.datasetIdentifier }
59+
)
5360
);
5461

5562
// Use an object to manage the expanded state for each resource individually
5663
const [showMore, setShowMore] = useState<{ [key: number]: boolean }>({});
57-
const [isDescriptionLong, setIsDescriptionLong] = useState<{ [key: number]: boolean }>({});
64+
const [isDescriptionLong, setIsDescriptionLong] = useState<{
65+
[key: number]: boolean;
66+
}>({});
5867

5968
const descriptionRefs = useRef<(HTMLDivElement | null)[]>([]);
6069

@@ -70,7 +79,8 @@ const Resources = () => {
7079
useEffect(() => {
7180
descriptionRefs.current.forEach((descriptionElement, index) => {
7281
if (descriptionElement) {
73-
const isLong = descriptionElement.scrollHeight > descriptionElement.clientHeight;
82+
const isLong =
83+
descriptionElement.scrollHeight > descriptionElement.clientHeight;
7484
setIsDescriptionLong((prevState) => ({
7585
...prevState,
7686
[index]: isLong,
@@ -90,11 +100,11 @@ const Resources = () => {
90100
<Text variant="bodyLg" className="mx-6 lg:mx-0">
91101
Downloadable Resources
92102
</Text>
93-
<div className="mx-6 lg:mx-0 mt-5 flex flex-col gap-8 bg-surfaceDefault p-6">
103+
<div className="mx-6 mt-5 flex flex-col gap-8 bg-surfaceDefault p-6 lg:mx-0">
94104
{data?.datasetResources.map((item: any, index: number) => (
95105
<div key={index} className="flex flex-wrap justify-between gap-4">
96106
<div className="gap flex flex-col lg:w-4/5">
97-
<div className="item flex gap-2 items-center">
107+
<div className="item flex items-center gap-2">
98108
<Text variant="headingMd">{item.name}</Text>
99109
<Tag>{item.fileDetails.format}</Tag>
100110
</div>

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ const DatasetDetailsPage = () => {
5555
const params = useParams();
5656

5757
const { data, isLoading } = useQuery([`${params.datasetIdentifier}`], () =>
58-
GraphQL(datasetQuery, { filters: { id: params.datasetIdentifier } })
58+
GraphQL(
59+
datasetQuery,
60+
{
61+
// Entity Headers if present
62+
},
63+
{ filters: { id: params.datasetIdentifier } }
64+
)
5965
);
6066

6167
return (

app/[locale]/dashboard/organization/[organizationId]/consumers/page.tsx renamed to app/[locale]/dashboard/[entityType]/[entitySlug]/consumers/page.tsx

File renamed without changes.

app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/access/page.tsx renamed to app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/access/page.tsx

File renamed without changes.

app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/charts/components/ChartsImage.tsx renamed to app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/charts/components/ChartsImage.tsx

File renamed without changes.

app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/charts/components/ChartsList.tsx renamed to app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/charts/components/ChartsList.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,15 @@ const ChartsList: React.FC<ChartsListProps> = ({
5353
}: { data: any; isLoading: boolean; refetch: any } = useQuery(
5454
[`chartDetails_${params.id}`],
5555
() =>
56-
GraphQL(chartDetailsQuery, {
57-
datasetId: params.id,
58-
})
56+
GraphQL(
57+
chartDetailsQuery,
58+
{
59+
// Entity Headers if present
60+
},
61+
{
62+
datasetId: params.id,
63+
}
64+
)
5965
);
6066

6167
const [filteredRows, setFilteredRows] = useState<any[]>([]);
@@ -68,7 +74,14 @@ const ChartsList: React.FC<ChartsListProps> = ({
6874
}, [data, type]);
6975

7076
const { mutate, isLoading: deleteLoading } = useMutation(
71-
(data: { chartId: UUID }) => GraphQL(deleteResourceChart, data),
77+
(data: { chartId: UUID }) =>
78+
GraphQL(
79+
deleteResourceChart,
80+
{
81+
// Entity Headers if present
82+
},
83+
data
84+
),
7285
{
7386
onSuccess: () => {
7487
toast('Chart Deleted Successfully');

0 commit comments

Comments
 (0)