Skip to content

Commit 74f351a

Browse files
authored
Merge pull request #272 from CivicDataLab/270-fix-bugs
270 fix bugs
2 parents 808b8c2 + 4b269f7 commit 74f351a

File tree

8 files changed

+111
-68
lines changed

8 files changed

+111
-68
lines changed
Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
import { InProgress } from '@/components/in-progress';
2-
3-
export default async function Page({ params }: { params: { id: string } }) {
4-
return (
5-
<>
6-
<InProgress />
7-
</>
8-
);
9-
}
1+
'use client';
2+
3+
import { useEffect } from 'react';
4+
import { useRouter } from 'next/navigation';
5+
6+
export default function Page({
7+
params,
8+
}: {
9+
params: { entityType: string; entitySlug: string };
10+
}) {
11+
const router = useRouter();
12+
13+
useEffect(() => {
14+
router.push(`/dashboard/${params.entityType}/${params.entitySlug}/dataset?tab=drafts`);
15+
}, [params, router]);
16+
17+
return null; // prevent rendering anything before redirect
18+
}

app/[locale]/dashboard/[entityType]/[entitySlug]/profile/orgProfile.tsx

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -116,26 +116,36 @@ const OrgProfile = () => {
116116
);
117117

118118
const handleSave = () => {
119-
// Create mutation input with only changed fields
120-
const inputData: OrganizationInputPartial = {
121-
name: formData.name,
122-
contactEmail: formData.contactEmail,
123-
organizationTypes: formData.organizationTypes,
124-
homepage: formData.homepage,
125-
description: formData.description,
126-
id: formData.id,
127-
linkedinProfile: formData.linkedinProfile,
128-
githubProfile: formData.githubProfile,
129-
twitterProfile: formData.twitterProfile,
130-
location: formData.location,
131-
};
119+
const formValidation =
120+
formData.name &&
121+
formData.contactEmail &&
122+
formData.description &&
123+
formData.logo;
132124

133-
// Only add logo if it has changed
134-
if (formData.logo instanceof File) {
135-
inputData.logo = formData.logo;
136-
}
125+
if (!formValidation) {
126+
toast('Please fill all the required fields');
127+
return;
128+
} else {
129+
const inputData: OrganizationInputPartial = {
130+
name: formData.name,
131+
contactEmail: formData.contactEmail,
132+
organizationTypes: formData.organizationTypes,
133+
homepage: formData.homepage,
134+
description: formData.description,
135+
id: formData.id,
136+
linkedinProfile: formData.linkedinProfile,
137+
githubProfile: formData.githubProfile,
138+
twitterProfile: formData.twitterProfile,
139+
location: formData.location,
140+
};
141+
142+
// Only add logo if it has changed
143+
if (formData.logo instanceof File) {
144+
inputData.logo = formData.logo;
145+
}
137146

138-
mutate({ input: inputData });
147+
mutate({ input: inputData });
148+
}
139149
};
140150

141151
return (
@@ -147,7 +157,7 @@ const OrgProfile = () => {
147157
<div className="flex flex-wrap gap-6 lg:flex-nowrap">
148158
<div className="w-full">
149159
<TextField
150-
label="Name"
160+
label="Name *"
151161
name="name"
152162
value={formData.name}
153163
onChange={(e) => setFormData({ ...formData, name: e })}
@@ -156,7 +166,7 @@ const OrgProfile = () => {
156166

157167
<div className="w-full">
158168
<TextField
159-
label="Email"
169+
label="Email *"
160170
name="email"
161171
value={formData.contactEmail}
162172
onChange={(e) => setFormData({ ...formData, contactEmail: e })}
@@ -234,7 +244,7 @@ const OrgProfile = () => {
234244
<div className="flex flex-wrap gap-6 lg:flex-nowrap">
235245
<div className="w-full">
236246
<TextField
237-
label="Description"
247+
label="Description *"
238248
name="description"
239249
multiline={6}
240250
value={formData.description}
@@ -243,7 +253,7 @@ const OrgProfile = () => {
243253
</div>
244254
<div className="w-full">
245255
<DropZone
246-
label={'Upload Organization Logo'}
256+
label={'Upload Organization Logo *'}
247257
onDrop={(e) => setFormData({ ...formData, logo: e[0] })}
248258
name={'Logo'}
249259
>

app/[locale]/dashboard/[entityType]/[entitySlug]/profile/userProfile.tsx

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,34 @@ const UserProfile = () => {
100100

101101
const handleSave = () => {
102102
// Create mutation input with only changed fields
103-
const inputData: UpdateUserInput = {
104-
firstName: formData.firstName,
105-
lastName: formData.lastName,
106-
bio: formData.bio,
107-
email: formData.email,
108-
githubProfile: formData.githubProfile,
109-
linkedinProfile: formData.linkedinProfile,
110-
twitterProfile: formData.twitterProfile,
111-
location: formData.location,
112-
};
113-
114-
// Only add logo if it has changed
115-
if (formData.profilePicture instanceof File) {
116-
inputData.profilePicture = formData.profilePicture;
103+
const formValidation =
104+
formData.firstName &&
105+
formData.lastName &&
106+
formData.email &&
107+
formData.bio &&
108+
formData.location;
109+
110+
if (!formValidation) {
111+
toast('Please fill all the required fields');
112+
return;
113+
} else {
114+
const inputData: UpdateUserInput = {
115+
firstName: formData.firstName,
116+
lastName: formData.lastName,
117+
bio: formData.bio,
118+
email: formData.email,
119+
githubProfile: formData.githubProfile,
120+
linkedinProfile: formData.linkedinProfile,
121+
twitterProfile: formData.twitterProfile,
122+
location: formData.location,
123+
};
124+
125+
// Only add logo if it has changed
126+
if (formData.profilePicture instanceof File) {
127+
inputData.profilePicture = formData.profilePicture;
128+
}
129+
mutate({ input: inputData });
117130
}
118-
mutate({ input: inputData });
119131
};
120132

121133
return (
@@ -129,15 +141,15 @@ const UserProfile = () => {
129141
<div className="flex w-full flex-wrap gap-6 md:flex-nowrap lg:flex-nowrap">
130142
<div className="w-full">
131143
<TextField
132-
label="First Name"
144+
label="First Name *"
133145
name="firstName"
134146
value={formData.firstName}
135147
onChange={(e) => setFormData({ ...formData, firstName: e })}
136148
/>
137149
</div>
138150
<div className="w-full">
139151
<TextField
140-
label="Last Name"
152+
label="Last Name *"
141153
name="lastName"
142154
value={formData.lastName}
143155
onChange={(e) => setFormData({ ...formData, lastName: e })}
@@ -147,7 +159,7 @@ const UserProfile = () => {
147159

148160
<div className="w-full">
149161
<TextField
150-
label="Email"
162+
label="Email *"
151163
name="email"
152164
value={formData.email}
153165
onChange={(e) => setFormData({ ...formData, email: e })}
@@ -189,7 +201,7 @@ const UserProfile = () => {
189201
<div className="flex w-full flex-col gap-4 lg:flex-row">
190202
<div className="w-full">
191203
<TextField
192-
label="Bio"
204+
label="Bio *"
193205
name="bio"
194206
multiline={6}
195207
value={formData.bio}
@@ -198,7 +210,7 @@ const UserProfile = () => {
198210
</div>
199211
<div className="w-full">
200212
<DropZone
201-
label={'Upload Profile Picture'}
213+
label={'Upload Profile Picture *'}
202214
onDrop={(e) => setFormData({ ...formData, profilePicture: e[0] })}
203215
name={'Profile Picture'}
204216
>

app/[locale]/dashboard/[entityType]/page.tsx

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

3+
import { useState } from 'react';
4+
import Image from 'next/image';
5+
import Link from 'next/link';
6+
import { notFound, useParams, usePathname } from 'next/navigation';
37
import {
48
ApiOrganizationOrganizationTypesEnum,
59
OrganizationInput,
610
} from '@/gql/generated/graphql';
711
import { useOrganizationTypes } from '@/hooks/useOrganizationTypes';
812
import { useMutation } from '@tanstack/react-query';
9-
import Image from 'next/image';
10-
import Link from 'next/link';
11-
import { notFound, useParams, usePathname } from 'next/navigation';
1213
import {
1314
Button,
1415
Dialog,
@@ -17,16 +18,15 @@ import {
1718
Select,
1819
Text,
1920
TextField,
20-
toast
21+
toast,
2122
} from 'opub-ui';
22-
import { useState } from 'react';
2323

24-
import BreadCrumbs from '@/components/BreadCrumbs';
25-
import { Icons } from '@/components/icons';
26-
import { Loading } from '@/components/loading';
2724
import { useDashboardStore } from '@/config/store';
2825
import { GraphQL } from '@/lib/api';
2926
import { cn } from '@/lib/utils';
27+
import BreadCrumbs from '@/components/BreadCrumbs';
28+
import { Icons } from '@/components/icons';
29+
import { Loading } from '@/components/loading';
3030
import styles from './../components/styles.module.scss';
3131
import { organizationCreationMutation } from './schema';
3232

@@ -90,7 +90,20 @@ const Page = () => {
9090
if (params.entityType !== 'organization') {
9191
return notFound();
9292
}
93-
93+
const handleSave = () => {
94+
const formValidation =
95+
formData.name &&
96+
formData.description &&
97+
formData.logo &&
98+
formData.contactEmail;
99+
100+
if (!formValidation) {
101+
toast('Please fill all the required fields');
102+
return;
103+
} else {
104+
mutate({ input: formData });
105+
}
106+
};
94107
return (
95108
<>
96109
<BreadCrumbs
@@ -109,7 +122,8 @@ const Page = () => {
109122
]}
110123
/>
111124
<div className="m-auto flex w-11/12 flex-col">
112-
{allEntityDetails?.organizations.length < 0 || allEntityDetails === null ? (
125+
{allEntityDetails?.organizations.length < 0 ||
126+
allEntityDetails === null ? (
113127
<Loading />
114128
) : (
115129
<div className="container mb-40 ">
@@ -154,7 +168,7 @@ const Page = () => {
154168
<div className="flex flex-col gap-6">
155169
<div>
156170
<TextField
157-
label="Organization Name"
171+
label="Organization Name *"
158172
name="name"
159173
value={formData.name}
160174
onChange={(e) =>
@@ -164,7 +178,7 @@ const Page = () => {
164178
</div>
165179
<div>
166180
<TextField
167-
label="Description"
181+
label="Description *"
168182
multiline={4}
169183
name="description"
170184
value={formData.description}
@@ -204,7 +218,7 @@ const Page = () => {
204218
</div>
205219
<div>
206220
<TextField
207-
label="Contact Email"
221+
label="Contact Email *"
208222
name="contactEmail"
209223
type="email"
210224
value={formData.contactEmail}
@@ -214,7 +228,7 @@ const Page = () => {
214228
/>
215229
</div>
216230
<DropZone
217-
label={'Upload Logo'}
231+
label={'Upload Logo *'}
218232
onDrop={(e) =>
219233
setFormData({ ...formData, logo: e[0] })
220234
}
@@ -257,9 +271,7 @@ const Page = () => {
257271
setFormData({ ...formData, location: e })
258272
}
259273
/>
260-
<Button onClick={() => mutate({ input: formData })}>
261-
Save
262-
</Button>
274+
<Button onClick={handleSave}>Save</Button>
263275
</div>
264276
</>
265277
</Dialog.Content>

public/1org.png

7.28 KB
Loading

public/1profile.png

7.3 KB
Loading

public/org.png

-3.3 KB
Loading

public/profile.png

-3.36 KB
Loading

0 commit comments

Comments
 (0)