Skip to content

Commit 808b8c2

Browse files
authored
Merge pull request #271 from CivicDataLab/270-fix-bugs
270 fix bugs
2 parents f44eb84 + b054799 commit 808b8c2

File tree

23 files changed

+370
-268
lines changed

23 files changed

+370
-268
lines changed

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,14 @@ const ListingComponent: React.FC<ListingProps> = ({
232232
}
233233
}, [variables, fetchDatasets]);
234234

235+
const [hasMounted, setHasMounted] = useState(false);
236+
237+
useEffect(() => {
238+
setHasMounted(true);
239+
}, []);
240+
241+
if (!hasMounted) return <Loading />;
242+
235243
const handlePageChange = (newPage: number) => {
236244
setQueryParams({ type: 'SET_CURRENT_PAGE', payload: newPage });
237245
};
@@ -301,7 +309,11 @@ const ListingComponent: React.FC<ListingProps> = ({
301309
</Text>
302310
)}
303311

304-
<Text variant="headingLg" fontWeight="regular" className=' leading-3 '>
312+
<Text
313+
variant="headingLg"
314+
fontWeight="regular"
315+
className=" leading-3 "
316+
>
305317
{categoryDescription
306318
? categoryDescription
307319
: 'No Description Provided'}
@@ -440,7 +452,9 @@ const ListingComponent: React.FC<ListingProps> = ({
440452
</div>
441453
)}
442454

443-
{facets && datasetDetails?.length > 0 ? (
455+
{facets === null ? (
456+
<Loading />
457+
) : facets.results.length > 0 ? (
444458
<GraphqlPagination
445459
totalRows={count}
446460
pageSize={queryParams.pageSize}
@@ -503,7 +517,9 @@ const ListingComponent: React.FC<ListingProps> = ({
503517
})}
504518
</GraphqlPagination>
505519
) : (
506-
<Loading />
520+
<div className="flex h-screen items-center justify-center">
521+
<Text variant="heading2xl">No datasets found</Text>
522+
</div>
507523
)}
508524
</div>
509525
</div>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const useCasesListDoc: any = graphql(`
2525
$filters: UseCaseFilter
2626
$pagination: OffsetPaginationInput
2727
) {
28-
useCases(filters: $filters, pagination: $pagination) {
28+
publishedUseCases(filters: $filters, pagination: $pagination) {
2929
id
3030
title
3131
summary
@@ -123,8 +123,8 @@ const UseCasesListingPage = () => {
123123
) : (
124124
<CarouselContent className="p-4 ">
125125
{getUseCasesList &&
126-
getUseCasesList?.data?.useCases.length > 0 &&
127-
getUseCasesList?.data?.useCases.map((item: any, index: any) => (
126+
getUseCasesList?.data?.publishedUseCases.length > 0 &&
127+
getUseCasesList?.data?.publishedUseCases.map((item: any, index: any) => (
128128
<CarouselItem
129129
key={item.id}
130130
className={cn(

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,26 @@ const MetadataComponent: React.FC<MetadataProps> = ({ data, setOpen }) => {
125125
: data.organization.name}
126126
</Text>
127127
</div>
128-
<div className="flex items-center gap-2 ">
128+
<div className="flex gap-2 ">
129129
<Text className="min-w-[120px] basis-1/4 uppercase" variant="bodyMd">
130130
Sector
131131
</Text>
132-
<Text
133-
className="max-w-xs truncate "
134-
variant="bodyLg"
135-
fontWeight="medium"
136-
>
137-
{data.sectors[0].name}
138-
</Text>
132+
<div className="flex flex-wrap gap-2">
133+
{data.sectors.length > 0 ? (
134+
data.sectors.map((sector: any, index: number) => (
135+
<Image
136+
key={index}
137+
src={`/Sectors/${sector.name}.svg`}
138+
alt={sector.name || ''}
139+
width={52}
140+
height={52}
141+
className="border-1 border-solid border-greyExtralight p-1"
142+
/>
143+
))
144+
) : (
145+
<span>N/A</span>
146+
)}
147+
</div>
139148
</div>
140149
{Metadata.map((item: any, index: any) => (
141150
<div className="flex items-start gap-2 " key={index}>
@@ -152,7 +161,7 @@ const MetadataComponent: React.FC<MetadataProps> = ({ data, setOpen }) => {
152161
) : (
153162
<Link href={item.value} target="_blank">
154163
<Text className="underline" color="highlight">
155-
{sourceTitle?.trim() ? sourceTitle : 'Source'}
164+
{sourceTitle?.trim() ? sourceTitle : 'Visit Website'}
156165
</Text>
157166
</Link>
158167
)}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const SimilarDatasets: React.FC<Props> = ({ showCharts }) => {
149149
formats={item.formats}
150150
footerContent={[
151151
{
152-
icon: `/Sectors/${item.sectors[0].name}.svg`,
152+
icon: `/Sectors/${item.sectors[0]?.name}.svg`,
153153
label: 'Sectors',
154154
},
155155
{

app/[locale]/(user)/publishers/components/Datasets.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ const Datasets = ({ type }: { type: 'organization' | 'Publisher' }) => {
174174
formats={item.formats}
175175
footerContent={[
176176
{
177-
icon: `/Sectors/${item.sectors[0].name}.svg`,
177+
icon: `/Sectors/${item.sectors[0]?.name}.svg`,
178178
label: 'Sectors',
179179
},
180180
{

app/[locale]/(user)/usecases/[useCaseSlug]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ const UseCaseDetailPage = () => {
225225
href={`/datasets/${dataset.id}`}
226226
footerContent={[
227227
{
228-
icon: `/Sectors/${dataset.sectors[0].name}.svg`,
228+
icon: `/Sectors/${dataset.sectors[0]?.name}.svg`,
229229
label: 'Sectors',
230230
},
231231
{

app/[locale]/(user)/usecases/components/Details.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const PrimaryDetails = ({ data, isLoading }: { data: any; isLoading: any }) => {
7979
<div className="mt-6 lg:mt-10">
8080
<Text variant="heading2xl">Summary</Text>
8181
<div className="mt-4">
82-
<Text variant="headingLg" fontWeight="regular">
82+
<Text variant="headingMd" fontWeight="regular">
8383
{data.useCase.summary}
8484
</Text>
8585
</div>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Styles from '../page.module.scss';
1414

1515
const useCasesListQueryDoc: any = graphql(`
1616
query UseCasesList($filters: UseCaseFilter) {
17-
useCases(filters: $filters) {
17+
publishedUseCases(filters: $filters) {
1818
id
1919
title
2020
summary
@@ -129,8 +129,8 @@ const UseCasesListingPage = () => {
129129
)}
130130
>
131131
{getUseCasesList &&
132-
getUseCasesList?.data?.useCases.length > 0 &&
133-
getUseCasesList?.data?.useCases.map((item: any, index: any) => (
132+
getUseCasesList?.data?.publishedUseCases.length > 0 &&
133+
getUseCasesList?.data?.publishedUseCases.map((item: any, index: any) => (
134134
<Card
135135
title={item.title}
136136
key={index}

app/[locale]/dashboard/[entityType]/[entitySlug]/admin/addUser.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,13 @@ const AddUser = ({
136136

137137
const { mutate: updateMutate, isLoading: updateUserLoading } = useMutation(
138138
(input: { input: AssignOrganizationRoleInput }) =>
139-
GraphQL(updateUser, {
140-
[params.entityType]: params.entitySlug,
141-
}, input),
139+
GraphQL(
140+
updateUser,
141+
{
142+
[params.entityType]: params.entitySlug,
143+
},
144+
input
145+
),
142146
{
143147
onSuccess: (res: any) => {
144148
toast('User updated successfully');
@@ -172,6 +176,12 @@ const AddUser = ({
172176
const filteredOptions = Users.data?.searchUsers;
173177
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
174178
const value = e.target.value;
179+
if (value === '') {
180+
setFormData({
181+
userId: '',
182+
roleId: formData.roleId,
183+
});
184+
}
175185
setSearchValue(value);
176186
setIsDropdownOpen(true); // Keep dropdown open while typing
177187
Users.refetch(); // Refetch when search term changes
@@ -193,13 +203,13 @@ const AddUser = ({
193203
>
194204
<div className="m-auto mb-6 flex flex-col gap-6">
195205
<div className="relative w-full">
196-
<Label>Select User</Label>
206+
<Label>Select User *</Label>
197207
<input
198208
type="text"
199209
id="combobox"
200210
disabled={isEdit}
201211
value={searchValue}
202-
autoComplete='off'
212+
autoComplete="off"
203213
onChange={handleInputChange}
204214
className="border border-gray-100 placeholder:text-sm mt-1 block w-full px-3 py-1"
205215
placeholder={'Select user'}
@@ -229,7 +239,7 @@ const AddUser = ({
229239
label: toTitleCase(role.name),
230240
value: role.id,
231241
}))}
232-
label="Select a role"
242+
label="Select a role *"
233243
helpText={RolesList.data?.roles
234244
.filter((role: any) => role.id === formData.roleId)
235245
.map((role: any) => role.description)}
@@ -239,9 +249,12 @@ const AddUser = ({
239249
<Button
240250
kind="primary"
241251
className="m-auto"
252+
disabled={!formData.userId || !formData.roleId}
242253
onClick={() => {
243254
setIsOpen(false);
244-
isEdit ? updateMutate({ input: formData }) : mutate({ input: formData });
255+
isEdit
256+
? updateMutate({ input: formData })
257+
: mutate({ input: formData });
245258
}}
246259
>
247260
{isEdit ? 'Update' : 'Add'}

app/[locale]/dashboard/[entityType]/[entitySlug]/components/StepNavigation.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ interface StepNavigationProps {
1010
const StepNavigation = ({ steps }: StepNavigationProps) => {
1111
const pathname = usePathname(); // Get the current URL path
1212
const router = useRouter();
13-
console.log(pathname);
1413

1514
// Find the current step's index based on the pathname (without query params)
1615
const currentIndex = steps.findIndex((step) =>

0 commit comments

Comments
 (0)