Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
d871ba9
add overflow properties to Main for better layout control
sanjaypinna Jun 12, 2025
a7ca87e
add clear functionality to search input in ResourceListView
sanjaypinna Jun 12, 2025
30a5f22
add hidefooter in preview table
sanjaypinna Jun 12, 2025
4d6c50c
refactor: move chart rendering logic to a new position in Details com…
sanjaypinna Jun 12, 2025
4b220ae
fix: remove unnecessary semicolon in SimilarDatasets component
sanjaypinna Jun 12, 2025
e8d6240
refactor: remove EditDistribution component and associated logic
sanjaypinna Jun 12, 2025
6a58815
refactor: update file types and increase maximum file size limit in R…
sanjaypinna Jun 12, 2025
8704578
feat: add PDF preview functionality and conditionally render resource…
sanjaypinna Jun 12, 2025
44a4ef3
refactor: remove unused isPreview prop and simplify PreviewData compo…
sanjaypinna Jun 12, 2025
f81b2b8
feat: add PDF preview functionality and conditionally render preview …
sanjaypinna Jun 12, 2025
f842b9b
fix: update import path for PdfPreview component to correct location
sanjaypinna Jun 12, 2025
b7b752d
feat: add PdfPreview component to display PDF previews from a given URL
sanjaypinna Jun 12, 2025
6f66a57
fix preview
sanjaypinna Jun 13, 2025
0c1222d
fix gap
sanjaypinna Jun 13, 2025
3439ffa
feat: enhance UseCaseDetailPage layout and add Dashboards component
sanjaypinna Jun 16, 2025
23de1ea
feat: add Dashboards component to display linked dashboards for use c…
sanjaypinna Jun 16, 2025
fb0ce16
fix: update heading styles for GEOGRAPHIES and Summary sections
sanjaypinna Jun 16, 2025
988f2ec
feat: add Dashboards tab to Use Case editing layout
sanjaypinna Jun 16, 2025
7abd1b5
feat: implement Dashboard management with add, update, and delete fun…
sanjaypinna Jun 16, 2025
28de114
feat: add refetch capability for tags list on metadata update
sanjaypinna Jun 18, 2025
d893fdb
feat: disable email field in organization and user profile forms
sanjaypinna Jun 18, 2025
2d1af3c
feat: reorder Contributors tab in Use Case editing layout
sanjaypinna Jun 18, 2025
aa2a5e0
feat: refactor Publish component to integrate new Assign, Contributor…
sanjaypinna Jun 18, 2025
7df4136
feat: add Assign, Contributors, Dashboards, and Details components fo…
sanjaypinna Jun 18, 2025
48ee9bc
fix tooltip and truncation
sanjaypinna Jun 23, 2025
0b257ff
add tooltips for sectors and sdgs
sanjaypinna Jun 23, 2025
ff4dceb
add tooltip and update date format
sanjaypinna Jun 23, 2025
6114dd9
add tooltip
sanjaypinna Jun 23, 2025
7cda110
Add accepted file types
sanjaypinna Jun 23, 2025
28d2f74
add search feature
sanjaypinna Jun 23, 2025
09e758d
add pagination
sanjaypinna Jun 23, 2025
a4d0445
update completedOn field logic based on runningStatus values
sanjaypinna Jun 23, 2025
ed57275
add organization details to orgPublishedUseCases query
sanjaypinna Jun 23, 2025
93cd544
fix: update layout for tags display in PrimaryData component
sanjaypinna Jun 23, 2025
6448a8c
add user details to orgPublishedUseCases query
sanjaypinna Jun 23, 2025
82d29f3
add a conditional link in drafts
sanjaypinna Jun 23, 2025
205c46c
add allorg query
sanjaypinna Jun 23, 2025
e7d081d
update org query
sanjaypinna Jun 23, 2025
5e0a6cd
fix ui
sanjaypinna Jun 23, 2025
80728c7
update mutation to show proper errors
sanjaypinna Jun 24, 2025
3c4bb3f
remove empty values
sanjaypinna Jun 24, 2025
2d8fff6
add entity headers in every graphql call on provider side
sanjaypinna Jun 25, 2025
75c654a
add description in schema preview
sanjaypinna Jun 25, 2025
360cc66
refactor ResourceSchema: clean up unused format cell and improve erro…
sanjaypinna Jun 25, 2025
c171d9d
remove unused resetSchema mutation from query.ts
sanjaypinna Jun 25, 2025
3f49c92
refactor EditResource: remove unused resetSchema mutation and clean u…
sanjaypinna Jun 25, 2025
960c5eb
fix(EditMetadata): improve error handling in metadata update mutation
sanjaypinna Jun 25, 2025
9e1b6fc
refactor(UseCaseDetailPage): adjust layout and improve styling for da…
sanjaypinna Jun 25, 2025
af1dd03
refactor(EntitySelection): enhance button styling and improve label d…
sanjaypinna Jun 25, 2025
cedba50
refactor(Dashboards): improve conditional rendering and enhance user …
sanjaypinna Jun 25, 2025
0c7148a
refactor(ListingComponent): implement fetch call optimization using u…
sanjaypinna Jun 25, 2025
bad8f40
chore: update opub-ui dependency to version 0.3.88
sanjaypinna Jun 26, 2025
2a38275
refactor(ListingComponent): streamline metadata and footer content st…
sanjaypinna Jun 26, 2025
0edbf2b
refactor(TitleBar): reorganize imports and enhance title display for …
sanjaypinna Jun 26, 2025
f8b16ae
add truncate to breadcrumbs
sanjaypinna Jun 26, 2025
37119c3
refactor(ListingComponent): add Geography metadata to MetadataContent…
sanjaypinna Jun 26, 2025
78d9613
add truncate
sanjaypinna Jun 26, 2025
2f7db13
Merge branch 'dev' into 273-add-preview-for-pdf-files
sanjaypinna Jun 27, 2025
281a87a
update mutation response
sanjaypinna Jun 27, 2025
4e77097
Merge pull request #275 from CivicDataLab/273-add-preview-for-pdf-files
sanjaypinna Jun 27, 2025
5cadee7
add platformUrl field to UseCaseDetails query
sanjaypinna Jun 27, 2025
c1703ec
fetch and display website title for platform URLs in Metadata and Det…
sanjaypinna Jun 27, 2025
51786e4
add platformUrl field to UpdateUseCaseMutation and FetchUseCase query…
sanjaypinna Jun 27, 2025
8f77890
add created field to UseCasedetails query
sanjaypinna Jun 27, 2025
1f8cc77
refactor: improve styling across various components
sanjaypinna Jun 28, 2025
d584178
add SVG files for Coastal and Gender sectors
sanjaypinna Jun 30, 2025
19b7e71
fix: update stroke color and clipPath in chart-bar.svg
sanjaypinna Jun 30, 2025
4edcefb
fix: adjust top positioning and padding in BreadCrumbs component
sanjaypinna Jun 30, 2025
ceed033
refactor: reorganize imports and adjust padding in MainNav component
sanjaypinna Jun 30, 2025
dc74ea5
refactor: improve layout and styling in Details, Resources, and UseCa…
sanjaypinna Jun 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 67 additions & 26 deletions app/[locale]/(user)/components/ListingComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useReducer, useState } from 'react';
import React, { useEffect, useReducer, useRef, useState } from 'react';
import Image from 'next/image';
import { useRouter } from 'next/navigation';
import GraphqlPagination from '@/app/[locale]/dashboard/components/GraphqlPagination/graphqlPagination';
Expand Down Expand Up @@ -219,12 +219,18 @@ const ListingComponent: React.FC<ListingProps> = ({
const datasetDetails = facets?.results ?? [];

useUrlParams(queryParams, setQueryParams, setVariables);
const latestFetchId = useRef(0);

useEffect(() => {
if (variables) {
const currentFetchId = ++latestFetchId.current;

fetchDatasets(variables)
.then((res) => {
setFacets(res);
// Only set if this is the latest call
if (currentFetchId === latestFetchId.current) {
setFacets(res);
}
})
.catch((err) => {
console.error(err);
Expand Down Expand Up @@ -471,36 +477,71 @@ const ListingComponent: React.FC<ListingProps> = ({
: item?.organization?.logo
? `${process.env.NEXT_PUBLIC_BACKEND_URL}/${item.organization.logo}`
: '/org.png';
const Geography = item.metadata.filter(
(item: any) => item.metadata_item.label === 'Geography'
)[0]?.value;

const MetadataContent = [
{
icon: Icons.calendar,
label: 'Date',
value: formatDate(item.modified),
tooltip: 'Date',
},
{
icon: Icons.download,
label: 'Download',
value: item.download_count.toString(),
tooltip: 'Download',
},
];
if (Geography) {
MetadataContent.push({
icon: Icons.globe,
label: 'Geography',
value: Geography,
tooltip: 'Geography',
});
}

if (item.has_charts && view === 'expanded') {
MetadataContent.push({
icon: Icons.chart,
label: '',
value: 'With Charts',
tooltip: 'Charts',
});
}

const FooterContent = [
{
icon: `/Sectors/${item.sectors[0]}.svg`,
label: 'Sectors',
tooltip: `${item.sectors[0]}`,
},
...(item.has_charts && view !== 'expanded'
? [
{
icon: `/chart-bar.svg`,
label: 'Charts',
tooltip: 'Charts',
},
]
: []),
{
icon: image,
label: 'Published by',
tooltip: `${item.is_individual_dataset ? item.user?.name : item.organization?.name}`,
},
];

const commonProps = {
title: item.title,
description: item.description,
metadataContent: [
{
icon: Icons.calendar,
label: 'Date',
value: formatDate(item.modified),
},
{
icon: Icons.download,
label: 'Download',
value: item.download_count.toString(),
},
{
icon: Icons.globe,
label: 'Geography',
value: 'India',
},
],
metadataContent: MetadataContent,
tag: item.tags,
formats: item.formats,
footerContent: [
{
icon: `/Sectors/${item.sectors[0]}.svg`,
label: 'Sectors',
},
{ icon: image, label: 'Published by' },
],
footerContent: FooterContent,
};

return (
Expand Down
48 changes: 48 additions & 0 deletions app/[locale]/(user)/components/PdfPreview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use client';

import { useEffect, useState } from 'react';

interface PdfPreviewProps {
url: string;
}

export default function PdfPreview({ url }: PdfPreviewProps) {
const [previewUrl, setPreviewUrl] = useState<string | null>(null);

useEffect(() => {
const fetchPdf = async () => {
try {
const response = await fetch(url);
const blobData = await response.blob();

// Manually set MIME type to PDF (in case it's sent as octet-stream)
const pdfBlob = new Blob([blobData], { type: 'application/pdf' });
const objectUrl = URL.createObjectURL(pdfBlob);
setPreviewUrl(objectUrl);
} catch (error) {
console.error('Failed to load PDF:', error);
}
};

fetchPdf();

return () => {
if (previewUrl) {
URL.revokeObjectURL(previewUrl);
}
};
}, [url]);

if (!previewUrl) return <p>Loading PDF preview...</p>;

return (
<object
data={previewUrl}
type="application/pdf"
width="100%"
height="500px"
>
<p>PDF preview not available</p>
</object>
);
}
2 changes: 1 addition & 1 deletion app/[locale]/(user)/components/Sectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const Sectors = () => {
<div className="mt-12 grid w-full grid-cols-1 gap-6 px-4 md:grid-cols-2 md:px-12 lg:grid-cols-3 lg:px-12">
{data?.sectors.map((sectors: any) => (
<Link
href={`/sectors/${sectors.slug}?sectors=${capitalizeWords(sectors.slug)}`}
href={`/sectors/${sectors.slug}?size=9&page=1&sort=recent&sectors=${capitalizeWords(sectors.slug)}`}
key={sectors.id}
>
<div className="flex w-full items-center gap-5 rounded-4 bg-surfaceDefault p-7 shadow-card">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ const DetailsQuery: any = graphql(`
}
`);

interface DetailsProps {
setShowcharts: (vars: boolean) => void;
}

const Details: React.FC<DetailsProps> = ({ setShowcharts }) => {
const Details: React.FC = () => {
const params = useParams();
const chartRef = useRef<ReactECharts>(null);

Expand All @@ -62,12 +58,6 @@ const Details: React.FC<DetailsProps> = ({ setShowcharts }) => {
() => GraphQL(DetailsQuery, {}, { datasetId: params.datasetIdentifier })
);

useEffect(() => {
if (data && data?.getChartData.length <= 0) {
setShowcharts(false);
}
}, [data]);

const renderChart = (item: any) => {
if (item.chartType === 'ASSAM_DISTRICT' || item.chartType === 'ASSAM_RC') {
// Register the map
Expand All @@ -84,35 +74,20 @@ const Details: React.FC<DetailsProps> = ({ setShowcharts }) => {
const toggleDescription = () => setIsexpanded(!isexpanded);

return (
<div className=" flex w-full flex-col gap-4 p-2">
<>
{isLoading ? (
<div className=" mt-8 flex justify-center">
<Spinner />
</div>
) : data?.getChartData?.length > 0 ? (
<>
<div className=" flex w-full flex-col gap-4 py-10">
<div className="relative w-full ">
<Carousel className="w-full">
<div className=" px-12">
<CarouselContent className="flex-grow">
{data?.getChartData.map((item: any, index: any) => (
<CarouselItem key={index} className="m-auto">
<div className="w-full border-2 border-solid border-baseGraySlateSolid4 bg-surfaceDefault p-6 text-center shadow-basicLg max-sm:p-2">
<div className="lg:p-10">
{item.__typename === 'TypeResourceChart' &&
item?.chart?.options ? (
renderChart(item)
) : (
<Image
src={`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/download/chart_image/${item.id}`}
alt={''}
width={300}
height={300}
unoptimized
/>
)}
{/* Call the renderChart function */}
</div>
<div className="flex items-center justify-between gap-2 max-sm:flex-wrap">
<div className="flex flex-col gap-1 py-2 text-start">
<Text className="font-semi-bold">{item.name}</Text>
Expand All @@ -133,13 +108,6 @@ const Details: React.FC<DetailsProps> = ({ setShowcharts }) => {
</Text>
</div>
<div className="flex gap-2">
<Button kind="secondary" className="p-2">
<Icon
source={Icons.diagonal}
size={20}
color="default"
/>
</Button>
<Link
href={`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/download/chart/${item.id}`}
target="_blank"
Expand All @@ -155,6 +123,22 @@ const Details: React.FC<DetailsProps> = ({ setShowcharts }) => {
</Link>
</div>
</div>
<div className="p-4 lg:p-10">
{item.__typename === 'TypeResourceChart' &&
item?.chart?.options ? (
renderChart(item)
) : (
<Image
src={`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/download/chart_image/${item.id}`}
alt={''}
width={100}
height={100}
unoptimized
className=" h-full w-full object-contain"
/>
)}
{/* Call the renderChart function */}
</div>
</div>
</CarouselItem>
))}
Expand All @@ -168,11 +152,11 @@ const Details: React.FC<DetailsProps> = ({ setShowcharts }) => {
</div>
</Carousel>
</div>
</>
</div>
) : (
''
)}
</div>
</>
);
};

Expand Down
Loading