Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 18 additions & 9 deletions app/[locale]/dashboard/[entityType]/[entitySlug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { InProgress } from '@/components/in-progress';

export default async function Page({ params }: { params: { id: string } }) {
return (
<>
<InProgress />
</>
);
}
'use client';

import { useEffect } from 'react';
import { useRouter } from 'next/navigation';

export default function Page({
params,
}: {
params: { entityType: string; entitySlug: string };
}) {
const router = useRouter();

useEffect(() => {
router.push(`/dashboard/${params.entityType}/${params.entitySlug}/dataset?tab=drafts`);
}, [params, router]);

return null; // prevent rendering anything before redirect
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,26 +116,36 @@ const OrgProfile = () => {
);

const handleSave = () => {
// Create mutation input with only changed fields
const inputData: OrganizationInputPartial = {
name: formData.name,
contactEmail: formData.contactEmail,
organizationTypes: formData.organizationTypes,
homepage: formData.homepage,
description: formData.description,
id: formData.id,
linkedinProfile: formData.linkedinProfile,
githubProfile: formData.githubProfile,
twitterProfile: formData.twitterProfile,
location: formData.location,
};
const formValidation =
formData.name &&
formData.contactEmail &&
formData.description &&
formData.logo;

// Only add logo if it has changed
if (formData.logo instanceof File) {
inputData.logo = formData.logo;
}
if (!formValidation) {
toast('Please fill all the required fields');
return;
} else {
const inputData: OrganizationInputPartial = {
name: formData.name,
contactEmail: formData.contactEmail,
organizationTypes: formData.organizationTypes,
homepage: formData.homepage,
description: formData.description,
id: formData.id,
linkedinProfile: formData.linkedinProfile,
githubProfile: formData.githubProfile,
twitterProfile: formData.twitterProfile,
location: formData.location,
};

// Only add logo if it has changed
if (formData.logo instanceof File) {
inputData.logo = formData.logo;
}

mutate({ input: inputData });
mutate({ input: inputData });
}
};

return (
Expand All @@ -147,7 +157,7 @@ const OrgProfile = () => {
<div className="flex flex-wrap gap-6 lg:flex-nowrap">
<div className="w-full">
<TextField
label="Name"
label="Name *"
name="name"
value={formData.name}
onChange={(e) => setFormData({ ...formData, name: e })}
Expand All @@ -156,7 +166,7 @@ const OrgProfile = () => {

<div className="w-full">
<TextField
label="Email"
label="Email *"
name="email"
value={formData.contactEmail}
onChange={(e) => setFormData({ ...formData, contactEmail: e })}
Expand Down Expand Up @@ -234,7 +244,7 @@ const OrgProfile = () => {
<div className="flex flex-wrap gap-6 lg:flex-nowrap">
<div className="w-full">
<TextField
label="Description"
label="Description *"
name="description"
multiline={6}
value={formData.description}
Expand All @@ -243,7 +253,7 @@ const OrgProfile = () => {
</div>
<div className="w-full">
<DropZone
label={'Upload Organization Logo'}
label={'Upload Organization Logo *'}
onDrop={(e) => setFormData({ ...formData, logo: e[0] })}
name={'Logo'}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,34 @@ const UserProfile = () => {

const handleSave = () => {
// Create mutation input with only changed fields
const inputData: UpdateUserInput = {
firstName: formData.firstName,
lastName: formData.lastName,
bio: formData.bio,
email: formData.email,
githubProfile: formData.githubProfile,
linkedinProfile: formData.linkedinProfile,
twitterProfile: formData.twitterProfile,
location: formData.location,
};

// Only add logo if it has changed
if (formData.profilePicture instanceof File) {
inputData.profilePicture = formData.profilePicture;
const formValidation =
formData.firstName &&
formData.lastName &&
formData.email &&
formData.bio &&
formData.location;

if (!formValidation) {
toast('Please fill all the required fields');
return;
} else {
const inputData: UpdateUserInput = {
firstName: formData.firstName,
lastName: formData.lastName,
bio: formData.bio,
email: formData.email,
githubProfile: formData.githubProfile,
linkedinProfile: formData.linkedinProfile,
twitterProfile: formData.twitterProfile,
location: formData.location,
};

// Only add logo if it has changed
if (formData.profilePicture instanceof File) {
inputData.profilePicture = formData.profilePicture;
}
mutate({ input: inputData });
}
mutate({ input: inputData });
};

return (
Expand All @@ -129,15 +141,15 @@ const UserProfile = () => {
<div className="flex w-full flex-wrap gap-6 md:flex-nowrap lg:flex-nowrap">
<div className="w-full">
<TextField
label="First Name"
label="First Name *"
name="firstName"
value={formData.firstName}
onChange={(e) => setFormData({ ...formData, firstName: e })}
/>
</div>
<div className="w-full">
<TextField
label="Last Name"
label="Last Name *"
name="lastName"
value={formData.lastName}
onChange={(e) => setFormData({ ...formData, lastName: e })}
Expand All @@ -147,7 +159,7 @@ const UserProfile = () => {

<div className="w-full">
<TextField
label="Email"
label="Email *"
name="email"
value={formData.email}
onChange={(e) => setFormData({ ...formData, email: e })}
Expand Down Expand Up @@ -189,7 +201,7 @@ const UserProfile = () => {
<div className="flex w-full flex-col gap-4 lg:flex-row">
<div className="w-full">
<TextField
label="Bio"
label="Bio *"
name="bio"
multiline={6}
value={formData.bio}
Expand All @@ -198,7 +210,7 @@ const UserProfile = () => {
</div>
<div className="w-full">
<DropZone
label={'Upload Profile Picture'}
label={'Upload Profile Picture *'}
onDrop={(e) => setFormData({ ...formData, profilePicture: e[0] })}
name={'Profile Picture'}
>
Expand Down
46 changes: 29 additions & 17 deletions app/[locale]/dashboard/[entityType]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use client';

import { useState } from 'react';
import Image from 'next/image';
import Link from 'next/link';
import { notFound, useParams, usePathname } from 'next/navigation';
import {
ApiOrganizationOrganizationTypesEnum,
OrganizationInput,
} from '@/gql/generated/graphql';
import { useOrganizationTypes } from '@/hooks/useOrganizationTypes';
import { useMutation } from '@tanstack/react-query';
import Image from 'next/image';
import Link from 'next/link';
import { notFound, useParams, usePathname } from 'next/navigation';
import {
Button,
Dialog,
Expand All @@ -17,16 +18,15 @@ import {
Select,
Text,
TextField,
toast
toast,
} from 'opub-ui';
import { useState } from 'react';

import BreadCrumbs from '@/components/BreadCrumbs';
import { Icons } from '@/components/icons';
import { Loading } from '@/components/loading';
import { useDashboardStore } from '@/config/store';
import { GraphQL } from '@/lib/api';
import { cn } from '@/lib/utils';
import BreadCrumbs from '@/components/BreadCrumbs';
import { Icons } from '@/components/icons';
import { Loading } from '@/components/loading';
import styles from './../components/styles.module.scss';
import { organizationCreationMutation } from './schema';

Expand Down Expand Up @@ -90,7 +90,20 @@ const Page = () => {
if (params.entityType !== 'organization') {
return notFound();
}

const handleSave = () => {
const formValidation =
formData.name &&
formData.description &&
formData.logo &&
formData.contactEmail;

if (!formValidation) {
toast('Please fill all the required fields');
return;
} else {
mutate({ input: formData });
}
};
return (
<>
<BreadCrumbs
Expand All @@ -109,7 +122,8 @@ const Page = () => {
]}
/>
<div className="m-auto flex w-11/12 flex-col">
{allEntityDetails?.organizations.length < 0 || allEntityDetails === null ? (
{allEntityDetails?.organizations.length < 0 ||
allEntityDetails === null ? (
<Loading />
) : (
<div className="container mb-40 ">
Expand Down Expand Up @@ -154,7 +168,7 @@ const Page = () => {
<div className="flex flex-col gap-6">
<div>
<TextField
label="Organization Name"
label="Organization Name *"
name="name"
value={formData.name}
onChange={(e) =>
Expand All @@ -164,7 +178,7 @@ const Page = () => {
</div>
<div>
<TextField
label="Description"
label="Description *"
multiline={4}
name="description"
value={formData.description}
Expand Down Expand Up @@ -204,7 +218,7 @@ const Page = () => {
</div>
<div>
<TextField
label="Contact Email"
label="Contact Email *"
name="contactEmail"
type="email"
value={formData.contactEmail}
Expand All @@ -214,7 +228,7 @@ const Page = () => {
/>
</div>
<DropZone
label={'Upload Logo'}
label={'Upload Logo *'}
onDrop={(e) =>
setFormData({ ...formData, logo: e[0] })
}
Expand Down Expand Up @@ -257,9 +271,7 @@ const Page = () => {
setFormData({ ...formData, location: e })
}
/>
<Button onClick={() => mutate({ input: formData })}>
Save
</Button>
<Button onClick={handleSave}>Save</Button>
</div>
</>
</Dialog.Content>
Expand Down
Binary file added public/1org.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/1profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/org.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.