From f1ad4d9fbbff2a9bc29249f06040f9d46d2bcc13 Mon Sep 17 00:00:00 2001 From: "Dusan Mijatovic (PC2020)" Date: Tue, 15 Aug 2023 19:42:03 +0200 Subject: [PATCH] feat: add verified organisation badge and claim organisation button --- .../home/rsd/OrganisationSignUp.tsx | 163 ++--------------- .../home/rsd/OrganisationSignUpButton.tsx | 34 ++++ .../home/rsd/OrganisationSignUpDialog.tsx | 164 ++++++++++++++++++ .../overview/card/OrganisationCard.tsx | 89 ++++++---- .../overview/card/TenantBadge.tsx | 71 ++++++++ .../overview/card/TenantStatus.tsx | 32 ---- .../overview/cards/ProjectDuration.tsx | 4 +- 7 files changed, 340 insertions(+), 217 deletions(-) create mode 100644 frontend/components/home/rsd/OrganisationSignUpButton.tsx create mode 100644 frontend/components/home/rsd/OrganisationSignUpDialog.tsx create mode 100644 frontend/components/organisation/overview/card/TenantBadge.tsx delete mode 100644 frontend/components/organisation/overview/card/TenantStatus.tsx diff --git a/frontend/components/home/rsd/OrganisationSignUp.tsx b/frontend/components/home/rsd/OrganisationSignUp.tsx index 4ea8a972d..7adb6b2e5 100644 --- a/frontend/components/home/rsd/OrganisationSignUp.tsx +++ b/frontend/components/home/rsd/OrganisationSignUp.tsx @@ -6,161 +6,28 @@ // SPDX-License-Identifier: Apache-2.0 import {useState} from 'react' -import useTheme from '@mui/material/styles/useTheme' -import useMediaQuery from '@mui/material/useMediaQuery' -import Dialog from '@mui/material/Dialog' -import MailOutlineOutlined from '@mui/icons-material/MailOutlineOutlined' -import {config,organisationSignUp} from './config' -import useRsdSettings from '~/config/useRsdSettings' -import {useForm} from 'react-hook-form' - -type SignUpOrganisation = { - name: string, - organisation: string, - role: string, - description: string -} - -const inputClasses='mb-4 placeholder:text-base-500 outline-0 p-2 w-full text-sm bg-transparent text-base-100 border border-base-600 rounded-sm' +import {config} from './config' +import OrganisationSignUpButton from './OrganisationSignUpButton' +import OrganisationSignUpDialog from './OrganisationSignUpDialog' export default function OrganisationSignUp({minWidth = '9rem'}:{minWidth:string}) { - const theme = useTheme() - const fullScreen = useMediaQuery(theme.breakpoints.down('sm')) - const {host} = useRsdSettings() const [open, setOpen] = useState(false) - const {register, watch, reset} = useForm({ - mode: 'onChange', - defaultValues: { - name:'', - organisation: '', - role:'', - description: '' - } - }) - - const [name,organisation,role,description] = watch(['name','organisation','role','description']) - - // console.group('Organisation Sing Up') - // console.log('name...', name) - // console.log('organisation...', organisation) - // console.log('description...', description) - // console.groupEnd() - - function mailBody(): string | undefined { - return encodeURIComponent(`Hi RSD team, - - I would like to add my organisation to RSD! - - ------------------------- - Name: ${name} - Organisation: ${organisation} - Professional role: ${role} - ------------------------- - - ${description} - `) - } - - function closeAndReset() { - setOpen(false) - // reset form after all processes settled - // we need to wait for mailBody function - setTimeout(() => { - reset() - },0) - } - return ( <> - - setOpen(false)} - aria-labelledby="responsive-dialog-title" - > -
-
-
- {config.button.register.label} -
-
- You can find more information about registering your organisation in our documentation. -
- {/* INPUTS */} - - - - - {/* NOTIFICATIONS */} -
- {organisationSignUp.notification[0]}
- {organisationSignUp.notification[1]} -
- {/* NAVIGATION */} -
- - - Create email * - -
-
-
-
+ + {open && + setOpen(false)} + open={open} + /> + } ) } diff --git a/frontend/components/home/rsd/OrganisationSignUpButton.tsx b/frontend/components/home/rsd/OrganisationSignUpButton.tsx new file mode 100644 index 000000000..b57689dba --- /dev/null +++ b/frontend/components/home/rsd/OrganisationSignUpButton.tsx @@ -0,0 +1,34 @@ +// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center) +// SPDX-FileCopyrightText: 2023 Netherlands eScience Center +// +// SPDX-License-Identifier: Apache-2.0 + +type OrganisationSignUpButtonProps = { + onClick: (open: boolean) => void + minWidth: string + label: string +} + +export default function OrganisationSignUpButton({onClick,minWidth,label}:OrganisationSignUpButtonProps) { + return ( + + ) +} diff --git a/frontend/components/home/rsd/OrganisationSignUpDialog.tsx b/frontend/components/home/rsd/OrganisationSignUpDialog.tsx new file mode 100644 index 000000000..32adcfd66 --- /dev/null +++ b/frontend/components/home/rsd/OrganisationSignUpDialog.tsx @@ -0,0 +1,164 @@ +// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center) +// SPDX-FileCopyrightText: 2023 Netherlands eScience Center +// +// SPDX-License-Identifier: Apache-2.0 + +import Dialog from '@mui/material/Dialog' +import useTheme from '@mui/material/styles/useTheme' +import useMediaQuery from '@mui/material/useMediaQuery' + +import {useForm} from 'react-hook-form' + +import {config,organisationSignUp} from './config' +import useRsdSettings from '~/config/useRsdSettings' +import MailOutlineOutlined from '@mui/icons-material/MailOutlineOutlined' + +type OrganisationSignUpDialogProps = { + title: string + reason?: string + open: boolean + onClose: () => void + initOrg?: string +} + +type SignUpOrganisation = { + name: string, + organisation: string, + role: string, + description: string +} + +const inputClasses='mb-4 placeholder:text-base-500 outline-0 p-2 w-full text-sm bg-transparent text-base-100 border border-base-600 rounded-sm' + +export default function OrganisationSignUpDialog({ + title, open, onClose, initOrg, + reason='I would like to add my organisation to RSD!' +}: OrganisationSignUpDialogProps) { + const theme = useTheme() + const fullScreen = useMediaQuery(theme.breakpoints.down('sm')) + const {host} = useRsdSettings() + + const {register, watch, reset} = useForm({ + mode: 'onChange', + defaultValues: { + name:'', + organisation: initOrg ?? '', + role:'', + description: '' + } + }) + + const [name,organisation,role,description] = watch(['name','organisation','role','description']) + + function mailBody(): string | undefined { + return encodeURIComponent(`Hi RSD team, + + ${reason} + + ------------------------- + Name: ${name} + Organisation: ${organisation} + Professional role: ${role} + ------------------------- + + ${description} + `) + } + + + function closeAndReset() { + onClose() + // reset form after all processes settled + // we need to wait for mailBody function + setTimeout(() => { + reset() + },0) + } + + + return ( + { + if (reason === 'backdropClick' || reason === 'escapeKeyDown') { + // console.log('do nothing') + } else { + closeAndReset() + } + }} + disableEscapeKeyDown + aria-labelledby="responsive-dialog-title" + > +
+
+
+ {title} +
+
+ You can find more information about registering your organisation in our documentation. +
+ {/* INPUTS */} + + + + + {/* NOTIFICATIONS */} +
+ {organisationSignUp.notification[0]}
+ {organisationSignUp.notification[1]} +
+ {/* NAVIGATION */} + +
+
+
+ ) +} diff --git a/frontend/components/organisation/overview/card/OrganisationCard.tsx b/frontend/components/organisation/overview/card/OrganisationCard.tsx index b26296cf9..e32246de6 100644 --- a/frontend/components/organisation/overview/card/OrganisationCard.tsx +++ b/frontend/components/organisation/overview/card/OrganisationCard.tsx @@ -14,7 +14,7 @@ import ImageWithPlaceholder from '~/components/layout/ImageWithPlaceholder' import CardImageFrame from '~/components/cards/CardImageFrame' import CardContentFrame from '~/components/cards/CardContentFrame' import CountryLabel from './CountryLabel' -import TenantStatus from './TenantStatus' +import TenantBadge from './TenantBadge' export type OrganisationCardProps = { id: string, @@ -31,40 +31,59 @@ export type OrganisationCardProps = { export default function OrganisationCard({organisation}: { organisation: OrganisationCardProps }) { return ( - - {/* Organization card content */} -
- - - - - -
- - -
-
- + +
+ + -
- -
- + + +
+ + +
+
+ + {/* if is not tenant we render the placeholder here and TenantBadge outside the Link */} + {organisation.is_tenant === false ? +
+ : + + } +
+ +
+ + {/* if is not the tenant TenantBadge needs to be outside organisation link for email link to work */} + {organisation.is_tenant === false ? +
+ +
+ : null + } +
) } diff --git a/frontend/components/organisation/overview/card/TenantBadge.tsx b/frontend/components/organisation/overview/card/TenantBadge.tsx new file mode 100644 index 000000000..71c710df5 --- /dev/null +++ b/frontend/components/organisation/overview/card/TenantBadge.tsx @@ -0,0 +1,71 @@ +// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center) +// SPDX-FileCopyrightText: 2023 Netherlands eScience Center +// +// SPDX-License-Identifier: Apache-2.0 + +import {useState} from 'react' +import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline' +import IconButton from '@mui/material/IconButton' +import Tooltip from '@mui/material/Tooltip' +import UnpublishedIcon from '@mui/icons-material/Unpublished' + +import OrganisationSignUpDialog from '~/components/home/rsd/OrganisationSignUpDialog' + +type TenantBadgeProps = { + is_tenant: boolean + organisation: string +} + +export default function TenantBadge({is_tenant,organisation}: TenantBadgeProps) { + const [modal,setModal]=useState(false) + + // console.group('TenantBadge') + // console.log('is_tenant...', is_tenant) + // console.log('modal...', modal) + // console.log('organisation...', organisation) + // console.groupEnd() + + if (is_tenant === true) { + return ( +
+ + + +
+ ) + } + + return ( +
+ + { + setModal(true) + e.preventDefault() + }}> + + + + {modal && + setModal(false)} + open={modal} + initOrg={organisation } + /> + } +
+ ) +} diff --git a/frontend/components/organisation/overview/card/TenantStatus.tsx b/frontend/components/organisation/overview/card/TenantStatus.tsx deleted file mode 100644 index f82d6e761..000000000 --- a/frontend/components/organisation/overview/card/TenantStatus.tsx +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center) -// SPDX-FileCopyrightText: 2023 Netherlands eScience Center -// -// SPDX-License-Identifier: Apache-2.0 - -type TenantStatusProps = { - is_tenant: boolean - width?: string - borderRadius?: string - letterSpacing?: string -} - -export default function TenantStatus({ - is_tenant, - width = '6rem', - borderRadius = '0 0rem 3rem 0', - letterSpacing = '0.125rem' -}: TenantStatusProps) { - - if (is_tenant===true) { - return ( -
- Verified -
- ) - } - - return null -} diff --git a/frontend/components/projects/overview/cards/ProjectDuration.tsx b/frontend/components/projects/overview/cards/ProjectDuration.tsx index 2f1a28ab1..1e85a2b8e 100644 --- a/frontend/components/projects/overview/cards/ProjectDuration.tsx +++ b/frontend/components/projects/overview/cards/ProjectDuration.tsx @@ -15,9 +15,9 @@ type ProjectDurationProps = { export default function ProjectDuration({date_start,date_end}:ProjectDurationProps) { return (
- {date_start ? getMonthYearDate(date_start) : 'N/S'} + {date_start ? getMonthYearDate(date_start) : 'N/A'}  -  - {date_end ? getMonthYearDate(date_end) : 'N/S'} + {date_end ? getMonthYearDate(date_end) : 'N/A'}
) }