Skip to content

Commit e1bc24a

Browse files
Merge pull request #218 from CivicDataLab/217-update-categories-to-sectors
Update categories to sectors
2 parents ed1d653 + d1c70d5 commit e1bc24a

File tree

9 files changed

+65
-65
lines changed

9 files changed

+65
-65
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const MetadataComponent: React.FC<MetadataProps> = ({ data, setOpen }) => {
9191
variant="bodyLg"
9292
fontWeight="medium"
9393
>
94-
{data.categories[0].name}
94+
{data.sectors[0].name}
9595
</Text>
9696
</div>
9797
{Metadata.map((item, index) => (
@@ -110,10 +110,10 @@ const MetadataComponent: React.FC<MetadataProps> = ({ data, setOpen }) => {
110110
<div className="flex flex-col gap-4">
111111
<Text variant="bodyMd">Description</Text>
112112
<Text variant="bodyMd">
113-
{data.description.length > 260 && !isexpanded
113+
{data.description?.length > 260 && !isexpanded
114114
? `${data.description.slice(0, 260)}...`
115115
: data.description}
116-
{data.description.length > 260 && (
116+
{data.description?.length > 260 && (
117117
<Button
118118
kind="tertiary"
119119
size="slim"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const datasetQuery = graphql(`
4949
slug
5050
id
5151
}
52-
categories {
52+
sectors {
5353
name
5454
}
5555
formats

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface Dataset {
1818
id: string;
1919
metadata: MetadataEntry[];
2020
tags: string[];
21-
categories: string[];
21+
sectors: string[];
2222
formats: string[];
2323
has_charts: boolean,
2424
title: string;
@@ -161,9 +161,9 @@ const Cards = ({ data }: { data: Dataset }) => {
161161
{data.has_charts && <Icon source={Icons.chart} size={20} />}
162162
</div>
163163

164-
{data?.categories.length > 0 && (
164+
{data?.sectors.length > 0 && (
165165
<span className="flex flex-wrap gap-2 py-1 pr-2">
166-
{data?.categories.map((category, index) => (
166+
{data?.sectors.map((category, index) => (
167167
<div
168168
key={index}
169169
className="rounded-1 border-1 px-2 py-1 text-75"

app/[locale]/(user)/categories/[categorySlug]/page.tsx renamed to app/[locale]/(user)/sectors/[sectorSlug]/page.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import { Loading } from '@/components/loading';
1616
import Card from '../../datasets/components/Card';
1717
import Filter from '../../datasets/components/FIlter/Filter';
1818

19-
const categoryQueryDoc: any = graphql(`
20-
query CategoryDetails($filters: CategoryFilter) {
21-
categories(filters: $filters) {
19+
const sectorQueryDoc: any = graphql(`
20+
query CategoryDetails($filters: SectorFilter) {
21+
sectors(filters: $filters) {
2222
id
2323
name
2424
description
@@ -165,14 +165,14 @@ const useUrlParams = (
165165
}, [queryParams, setVariables, router]);
166166
};
167167

168-
const CategoryDetailsPage = ({ params }: { params: { categorySlug: any } }) => {
168+
const SectorDetailsPage = ({ params }: { params: { categorySlug: any } }) => {
169169
const getCategoryDetails: {
170170
data: any;
171171
isLoading: boolean;
172172
isError: boolean;
173173
} = useQuery([`get_category_details_${params.categorySlug}`], () =>
174174
GraphQL(
175-
categoryQueryDoc,
175+
sectorQueryDoc,
176176
{
177177
// Entity Headers if present
178178
},
@@ -243,11 +243,11 @@ const CategoryDetailsPage = ({ params }: { params: { categorySlug: any } }) => {
243243
<BreadCrumbs
244244
data={[
245245
{ href: '/', label: 'Home' },
246-
{ href: '/categories', label: 'Categories' },
246+
{ href: '/sectors', label: 'Sectors' },
247247
{
248248
href: '#',
249249
label:
250-
getCategoryDetails.data?.categories[0].name ||
250+
getCategoryDetails.data?.sectors[0].name ||
251251
params.categorySlug,
252252
},
253253
]}
@@ -275,14 +275,14 @@ const CategoryDetailsPage = ({ params }: { params: { categorySlug: any } }) => {
275275
// className="text-baseIndigoAlpha4"
276276
fontWeight="bold"
277277
>
278-
{getCategoryDetails.data?.categories[0].name ||
278+
{getCategoryDetails.data?.sectors[0].name ||
279279
params.categorySlug}
280280
</Text>
281281
<Text variant="bodyLg">
282-
{getCategoryDetails.data?.categories[0].datasetCount} Datasets
282+
{getCategoryDetails.data?.sectors[0].datasetCount} Datasets
283283
</Text>
284284
<Text variant="bodyMd">
285-
{getCategoryDetails.data?.categories[0].description ||
285+
{getCategoryDetails.data?.sectors[0].description ||
286286
'No description available.'}
287287
</Text>
288288
</div>
@@ -399,4 +399,4 @@ const CategoryDetailsPage = ({ params }: { params: { categorySlug: any } }) => {
399399
);
400400
};
401401

402-
export default CategoryDetailsPage;
402+
export default SectorDetailsPage;
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import BreadCrumbs from '@/components/BreadCrumbs';
1111
import { ErrorPage } from '@/components/error';
1212
import { Loading } from '@/components/loading';
1313

14-
const categoriesListQueryDoc: any = graphql(`
15-
query CategoriesList {
16-
categories {
14+
const sectorsListQueryDoc: any = graphql(`
15+
query SectorsList {
16+
sectors {
1717
id
1818
name
1919
description
@@ -23,15 +23,15 @@ const categoriesListQueryDoc: any = graphql(`
2323
}
2424
`);
2525

26-
const CategoriesListingPage = () => {
27-
const getCategoriesList: {
26+
const SectorsListingPage = () => {
27+
const getSectorsList: {
2828
data: any;
2929
isLoading: boolean;
3030
error: any;
3131
isError: boolean;
32-
} = useQuery([`categories_list_page`], () =>
32+
} = useQuery([`sectors_list_page`], () =>
3333
GraphQL(
34-
categoriesListQueryDoc,
34+
sectorsListQueryDoc,
3535
{
3636
// Entity Headers if present
3737
},
@@ -44,43 +44,43 @@ const CategoriesListingPage = () => {
4444
<BreadCrumbs
4545
data={[
4646
{ href: '/', label: 'Home' },
47-
{ href: '#', label: 'Categories' },
47+
{ href: '#', label: 'Sectors' },
4848
]}
4949
/>
5050
<>
51-
{getCategoriesList.isLoading ? (
51+
{getSectorsList.isLoading ? (
5252
<Loading />
53-
) : getCategoriesList.data?.categories.length > 0 ? (
53+
) : getSectorsList.data?.sectors.length > 0 ? (
5454
<>
5555
<div className="flex h-screen w-full flex-col gap-2 px-28 pt-10">
5656
<Text variant="heading3xl" as="h1">
57-
Categories
57+
Sectors
5858
</Text>
5959
<div className="flex flex-wrap justify-between pt-8">
60-
{getCategoriesList.data?.categories.map((category: any) => (
61-
<Link href={`/categories/${category.slug}`} key={category.id}>
60+
{getSectorsList.data?.sectors.map((sectors: any) => (
61+
<Link href={`/sectors/${sectors.slug}`} key={sectors.id}>
6262
<div className="md::w-72 mb-7 flex flex-row items-center gap-3 rounded-2 border-borderDefault bg-basePureWhite p-3 shadow-basicLg sm:w-72 lg:w-72 xl:w-72">
6363
<div className="flex items-center justify-center rounded-1 bg-baseGraySlateSolid2 p-2">
6464
<Image
6565
src={'/obi.jpg'}
6666
width={40}
6767
height={40}
68-
alt={'Category Logo'}
68+
alt={'Sectors Logo'}
6969
/>
7070
</div>
7171
<div className="flex flex-col gap-1">
7272
<Text variant="bodyMd" fontWeight="semibold">
73-
{category.name}
73+
{sectors.name}
7474
</Text>
75-
<Text>{category.datasetCount} Dataset(s)</Text>
75+
<Text>{sectors.datasetCount} Dataset(s)</Text>
7676
</div>
7777
</div>
7878
</Link>
7979
))}
8080
</div>
8181
</div>
8282
</>
83-
) : getCategoriesList.isError ? (
83+
) : getSectorsList.isError ? (
8484
<ErrorPage />
8585
) : (
8686
<></>
@@ -90,4 +90,4 @@ const CategoriesListingPage = () => {
9090
);
9191
};
9292

93-
export default CategoriesListingPage;
93+
export default SectorsListingPage;

app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/components/EditMetadata.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import { graphql } from '@/gql';
44
import {
5-
TypeCategory,
65
TypeDataset,
76
TypeMetadata,
7+
TypeSector,
88
TypeTag,
99
UpdateMetadataInput
1010
} from '@/gql/generated/graphql';
@@ -28,9 +28,9 @@ import { GraphQL } from '@/lib/api';
2828
import { useEffect, useState } from 'react';
2929
import DatasetLoading from '../../../components/loading-dataset';
3030

31-
const categoriesListQueryDoc: any = graphql(`
32-
query CategoryList {
33-
categories {
31+
const sectorsListQueryDoc: any = graphql(`
32+
query SectorList {
33+
sectors {
3434
id
3535
name
3636
}
@@ -56,7 +56,7 @@ const datasetMetadataQueryDoc: any = graphql(`
5656
id
5757
value
5858
}
59-
categories {
59+
sectors {
6060
id
6161
name
6262
}
@@ -139,10 +139,10 @@ export function EditMetadata({ id }: { id: string }) {
139139
}
140140
);
141141

142-
const getCategoriesList: { data: any; isLoading: boolean; error: any } =
143-
useQuery([`categories_list_query`], () =>
142+
const getSectorsList: { data: any; isLoading: boolean; error: any } =
143+
useQuery([`sectors_list_query`], () =>
144144
GraphQL(
145-
categoriesListQueryDoc,
145+
sectorsListQueryDoc,
146146
{
147147
[params.entityType]: params.entitySlug,
148148
},
@@ -230,11 +230,11 @@ export function EditMetadata({ id }: { id: string }) {
230230

231231
defaultVal['description'] = dataset?.description || '';
232232

233-
defaultVal['categories'] =
234-
dataset?.categories?.map((category: TypeCategory) => {
233+
defaultVal['sectors'] =
234+
dataset?.sectors?.map((sector: TypeSector) => {
235235
return {
236-
label: category.name,
237-
value: category.id,
236+
label: sector.name,
237+
value: sector.id,
238238
};
239239
}) || [];
240240

@@ -289,7 +289,7 @@ export function EditMetadata({ id }: { id: string }) {
289289
...Object.keys(transformedValues)
290290
.filter(
291291
(valueItem) =>
292-
!['categories', 'description', 'tags'].includes(valueItem)
292+
!['sectors', 'description', 'tags'].includes(valueItem)
293293
)
294294
.map((key) => {
295295
return {
@@ -300,8 +300,8 @@ export function EditMetadata({ id }: { id: string }) {
300300
],
301301
description: updatedData.description || '',
302302
tags: updatedData.tags?.map((item: any) => item.label) || [],
303-
categories:
304-
updatedData.categories?.map((item: any) => item.value) || [],
303+
sectors:
304+
updatedData.sectors?.map((item: any) => item.value) || [],
305305
},
306306
});
307307
}
@@ -427,7 +427,7 @@ export function EditMetadata({ id }: { id: string }) {
427427
return (
428428
<>
429429
{!getTagsList?.isLoading &&
430-
!getCategoriesList?.isLoading &&
430+
!getSectorsList?.isLoading &&
431431
!getDatasetMetadata.isLoading ? (
432432
<Form
433433

@@ -484,16 +484,16 @@ export function EditMetadata({ id }: { id: string }) {
484484
<div className="w-full py-4 pr-4 sm:w-1/2 md:w-1/2 lg:w-1/2 xl:w-1/2">
485485
<Combobox
486486
displaySelected
487-
label="Categories"
488-
list={getCategoriesList.data?.categories?.map(
489-
(item: TypeCategory) => {
487+
label="Sectors"
488+
list={getSectorsList.data?.sectors?.map(
489+
(item: TypeSector) => {
490490
return { label: item.name, value: item.id };
491491
}
492492
)}
493-
name="categories"
493+
name="sectors"
494494
onChange={(value) => {
495-
handleChange('categories', value);
496-
handleSave({ ...formData, categories: value }); // Save on change
495+
handleChange('sectors', value);
496+
handleSave({ ...formData, sectors: value }); // Save on change
497497
}}
498498
/>
499499
</div>

app/[locale]/dashboard/[entityType]/[entitySlug]/usecases/edit/[id]/assign/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const FetchUseCaseDetails: any = graphql(`
2020
id
2121
title
2222
modified
23-
categories {
23+
sectors {
2424
name
2525
}
2626
}
@@ -72,7 +72,7 @@ const Assign = () => {
7272
return {
7373
title: item.title,
7474
id: item.id,
75-
category: item.categories[0]?.name || 'N/A', // Safeguard in case of missing category
75+
category: item.sectors[0]?.name || 'N/A', // Safeguard in case of missing category
7676
modified: formatDate(item.modified),
7777
};
7878
});
@@ -101,7 +101,7 @@ const Assign = () => {
101101
return {
102102
title: item.title,
103103
id: item.id,
104-
category: item.categories[0],
104+
category: item.sectors[0],
105105
modified: formatDate(item.modified),
106106
};
107107
});

app/[locale]/dashboard/[entityType]/[entitySlug]/usecases/edit/[id]/publish/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const UseCaseDetails: any = graphql(`
3838
datasets {
3939
title
4040
id
41-
categories {
41+
sectors {
4242
name
4343
}
4444
modified
@@ -119,7 +119,7 @@ const Publish = () => {
119119

120120
const columns = [
121121
{ accessorKey: 'title', header: 'Title' },
122-
{ accessorKey: 'category', header: 'Category' },
122+
{ accessorKey: 'sector', header: 'Sector' },
123123
{ accessorKey: 'modified', header: 'Last Modified' },
124124
];
125125

@@ -147,7 +147,7 @@ const Publish = () => {
147147
return {
148148
title: item.title,
149149
id: item.id,
150-
category: item.categories[0]?.name,
150+
category: item.sectors[0]?.name,
151151
modified: formatDate(item.modified),
152152
};
153153
});

app/[locale]/dashboard/components/main-nav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function MainNav({ hideSearch = false }) {
6565
},
6666
{
6767
title: 'Sectors',
68-
href: '/categories',
68+
href: '/sectors',
6969
},
7070
{
7171
title: 'Use Cases',

0 commit comments

Comments
 (0)