From 95edfa1c7d71c25c49a36d124c092ff66feb0259 Mon Sep 17 00:00:00 2001 From: Pedro Martin Date: Mon, 20 Jan 2025 17:34:59 +0000 Subject: [PATCH 01/10] chore: get publications query --- .../memberships-partners/index.generated.tsx | 2 +- .../queries/publications/index.generated.tsx | 73 ++++++++ .../queries/publications/index.graphql | 29 ++++ website/src/graphql/types.ts | 157 ++++++++++++++++++ 4 files changed, 260 insertions(+), 1 deletion(-) create mode 100644 website/src/graphql/queries/publications/index.generated.tsx create mode 100644 website/src/graphql/queries/publications/index.graphql diff --git a/website/src/graphql/queries/memberships-partners/index.generated.tsx b/website/src/graphql/queries/memberships-partners/index.generated.tsx index e62ebe5..ef3d23a 100644 --- a/website/src/graphql/queries/memberships-partners/index.generated.tsx +++ b/website/src/graphql/queries/memberships-partners/index.generated.tsx @@ -9,7 +9,7 @@ export type GetMembershipPartnersQueryVariables = Types.Exact<{ }>; -export type GetMembershipPartnersQuery = { __typename?: 'Query', navigationList?: { __typename?: 'NavigationList', name?: string | null, linksCollection?: { __typename?: 'NavigationListLinksCollection', items: Array<{ __typename?: 'Link', href?: string | null, content?: string | null, referenceCollection?: { __typename?: 'LinkReferenceCollection', items: Array<{ __typename?: 'Accordion' } | { __typename?: 'Banner' } | { __typename?: 'BlogPage' } | { __typename?: 'BoardMember' } | { __typename?: 'Heading' } | { __typename?: 'HtmlHeadMetadata' } | { __typename?: 'Image', asset?: { __typename?: 'Asset', url?: string | null } | null } | { __typename?: 'Link' } | { __typename?: 'NavigationList' } | { __typename?: 'PageHeader' } | { __typename?: 'Paragraphs' } | { __typename?: 'Volunteer' } | null> } | null } | null> } | null } | null }; +export type GetMembershipPartnersQuery = { __typename?: 'Query', navigationList?: { __typename?: 'NavigationList', name?: string | null, linksCollection?: { __typename?: 'NavigationListLinksCollection', items: Array<{ __typename?: 'Link', href?: string | null, content?: string | null, referenceCollection?: { __typename?: 'LinkReferenceCollection', items: Array<{ __typename?: 'Accordion' } | { __typename?: 'Banner' } | { __typename?: 'BlogPage' } | { __typename?: 'BoardMember' } | { __typename?: 'Heading' } | { __typename?: 'HtmlHeadMetadata' } | { __typename?: 'Image', asset?: { __typename?: 'Asset', url?: string | null } | null } | { __typename?: 'Link' } | { __typename?: 'NavigationList' } | { __typename?: 'PageHeader' } | { __typename?: 'Paragraphs' } | { __typename?: 'Publication' } | { __typename?: 'Volunteer' } | null> } | null } | null> } | null } | null }; export const GetMembershipPartnersDocument = gql` diff --git a/website/src/graphql/queries/publications/index.generated.tsx b/website/src/graphql/queries/publications/index.generated.tsx new file mode 100644 index 0000000..20156dc --- /dev/null +++ b/website/src/graphql/queries/publications/index.generated.tsx @@ -0,0 +1,73 @@ +import * as Types from '../../types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type GetPublicationsQueryVariables = Types.Exact<{ [key: string]: never; }>; + + +export type GetPublicationsQuery = { __typename?: 'Query', patient?: { __typename?: 'PublicationCollection', items: Array<{ __typename?: 'Publication', title?: string | null, dateOfPublication?: any | null, link?: string | null, asset?: { __typename?: 'Asset', url?: string | null } | null } | null> } | null, gene?: { __typename?: 'PublicationCollection', items: Array<{ __typename?: 'Publication', title?: string | null, dateOfPublication?: any | null, link?: string | null, asset?: { __typename?: 'Asset', url?: string | null } | null } | null> } | null }; + + +export const GetPublicationsDocument = gql` + query GetPublications { + patient: publicationCollection( + where: {typeOfResearch: "Patient"} + order: dateOfPublication_DESC + ) { + items { + title + dateOfPublication + asset { + url + } + link + } + } + gene: publicationCollection( + where: {typeOfResearch: "Gene"} + order: dateOfPublication_DESC + ) { + items { + title + dateOfPublication + asset { + url + } + link + } + } +} + `; + +/** + * __useGetPublicationsQuery__ + * + * To run a query within a React component, call `useGetPublicationsQuery` and pass it any options that fit your needs. + * When your component renders, `useGetPublicationsQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useGetPublicationsQuery({ + * variables: { + * }, + * }); + */ +export function useGetPublicationsQuery(baseOptions?: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(GetPublicationsDocument, options); + } +export function useGetPublicationsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(GetPublicationsDocument, options); + } +export function useGetPublicationsSuspenseQuery(baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions) { + const options = baseOptions === Apollo.skipToken ? baseOptions : {...defaultOptions, ...baseOptions} + return Apollo.useSuspenseQuery(GetPublicationsDocument, options); + } +export type GetPublicationsQueryHookResult = ReturnType; +export type GetPublicationsLazyQueryHookResult = ReturnType; +export type GetPublicationsSuspenseQueryHookResult = ReturnType; +export type GetPublicationsQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/website/src/graphql/queries/publications/index.graphql b/website/src/graphql/queries/publications/index.graphql new file mode 100644 index 0000000..87c13e9 --- /dev/null +++ b/website/src/graphql/queries/publications/index.graphql @@ -0,0 +1,29 @@ +query GetPublications { + patient: publicationCollection( + where: { typeOfResearch: "Patient" } + order: dateOfPublication_DESC + ) { + items { + title + dateOfPublication + asset { + url + } + link + } + } + + gene: publicationCollection( + where: { typeOfResearch: "Gene" } + order: dateOfPublication_DESC + ) { + items { + title + dateOfPublication + asset { + url + } + link + } + } +} diff --git a/website/src/graphql/types.ts b/website/src/graphql/types.ts index 033a543..9e18d9b 100644 --- a/website/src/graphql/types.ts +++ b/website/src/graphql/types.ts @@ -304,6 +304,7 @@ export type AssetLinkingCollections = { htmlHeadMetadataCollection?: Maybe; imageCollection?: Maybe; pageHeaderCollection?: Maybe; + publicationCollection?: Maybe; }; @@ -362,6 +363,14 @@ export type AssetLinkingCollectionsPageHeaderCollectionArgs = { skip?: InputMaybe; }; + +export type AssetLinkingCollectionsPublicationCollectionArgs = { + limit?: InputMaybe; + locale?: InputMaybe; + preview?: InputMaybe; + skip?: InputMaybe; +}; + export enum AssetOrder { ContentTypeAsc = 'contentType_ASC', ContentTypeDesc = 'contentType_DESC', @@ -1941,6 +1950,135 @@ export enum ParagraphsOrder { SysPublishedVersionDesc = 'sys_publishedVersion_DESC' } +/** PDFs and links about NR2F1 research [See type definition](https://app.contentful.com/spaces/9j9d6tsmuyzl/content_types/publication) */ +export type Publication = Entry & _Node & { + __typename?: 'Publication'; + _id: Scalars['ID']['output']; + asset?: Maybe; + contentfulMetadata: ContentfulMetadata; + dateOfPublication?: Maybe; + link?: Maybe; + linkedFrom?: Maybe; + sys: Sys; + title?: Maybe; + typeOfResearch?: Maybe; +}; + + +/** PDFs and links about NR2F1 research [See type definition](https://app.contentful.com/spaces/9j9d6tsmuyzl/content_types/publication) */ +export type PublicationAssetArgs = { + locale?: InputMaybe; + preview?: InputMaybe; +}; + + +/** PDFs and links about NR2F1 research [See type definition](https://app.contentful.com/spaces/9j9d6tsmuyzl/content_types/publication) */ +export type PublicationDateOfPublicationArgs = { + locale?: InputMaybe; +}; + + +/** PDFs and links about NR2F1 research [See type definition](https://app.contentful.com/spaces/9j9d6tsmuyzl/content_types/publication) */ +export type PublicationLinkArgs = { + locale?: InputMaybe; +}; + + +/** PDFs and links about NR2F1 research [See type definition](https://app.contentful.com/spaces/9j9d6tsmuyzl/content_types/publication) */ +export type PublicationLinkedFromArgs = { + allowedLocales?: InputMaybe>>; +}; + + +/** PDFs and links about NR2F1 research [See type definition](https://app.contentful.com/spaces/9j9d6tsmuyzl/content_types/publication) */ +export type PublicationTitleArgs = { + locale?: InputMaybe; +}; + + +/** PDFs and links about NR2F1 research [See type definition](https://app.contentful.com/spaces/9j9d6tsmuyzl/content_types/publication) */ +export type PublicationTypeOfResearchArgs = { + locale?: InputMaybe; +}; + +export type PublicationCollection = { + __typename?: 'PublicationCollection'; + items: Array>; + limit: Scalars['Int']['output']; + skip: Scalars['Int']['output']; + total: Scalars['Int']['output']; +}; + +export type PublicationFilter = { + AND?: InputMaybe>>; + OR?: InputMaybe>>; + asset_exists?: InputMaybe; + contentfulMetadata?: InputMaybe; + dateOfPublication?: InputMaybe; + dateOfPublication_exists?: InputMaybe; + dateOfPublication_gt?: InputMaybe; + dateOfPublication_gte?: InputMaybe; + dateOfPublication_in?: InputMaybe>>; + dateOfPublication_lt?: InputMaybe; + dateOfPublication_lte?: InputMaybe; + dateOfPublication_not?: InputMaybe; + dateOfPublication_not_in?: InputMaybe>>; + link?: InputMaybe; + link_contains?: InputMaybe; + link_exists?: InputMaybe; + link_in?: InputMaybe>>; + link_not?: InputMaybe; + link_not_contains?: InputMaybe; + link_not_in?: InputMaybe>>; + sys?: InputMaybe; + title?: InputMaybe; + title_contains?: InputMaybe; + title_exists?: InputMaybe; + title_in?: InputMaybe>>; + title_not?: InputMaybe; + title_not_contains?: InputMaybe; + title_not_in?: InputMaybe>>; + typeOfResearch?: InputMaybe; + typeOfResearch_contains?: InputMaybe; + typeOfResearch_exists?: InputMaybe; + typeOfResearch_in?: InputMaybe>>; + typeOfResearch_not?: InputMaybe; + typeOfResearch_not_contains?: InputMaybe; + typeOfResearch_not_in?: InputMaybe>>; +}; + +export type PublicationLinkingCollections = { + __typename?: 'PublicationLinkingCollections'; + entryCollection?: Maybe; +}; + + +export type PublicationLinkingCollectionsEntryCollectionArgs = { + limit?: InputMaybe; + locale?: InputMaybe; + preview?: InputMaybe; + skip?: InputMaybe; +}; + +export enum PublicationOrder { + DateOfPublicationAsc = 'dateOfPublication_ASC', + DateOfPublicationDesc = 'dateOfPublication_DESC', + LinkAsc = 'link_ASC', + LinkDesc = 'link_DESC', + SysFirstPublishedAtAsc = 'sys_firstPublishedAt_ASC', + SysFirstPublishedAtDesc = 'sys_firstPublishedAt_DESC', + SysIdAsc = 'sys_id_ASC', + SysIdDesc = 'sys_id_DESC', + SysPublishedAtAsc = 'sys_publishedAt_ASC', + SysPublishedAtDesc = 'sys_publishedAt_DESC', + SysPublishedVersionAsc = 'sys_publishedVersion_ASC', + SysPublishedVersionDesc = 'sys_publishedVersion_DESC', + TitleAsc = 'title_ASC', + TitleDesc = 'title_DESC', + TypeOfResearchAsc = 'typeOfResearch_ASC', + TypeOfResearchDesc = 'typeOfResearch_DESC' +} + export type Query = { __typename?: 'Query'; _node?: Maybe<_Node>; @@ -1969,6 +2107,8 @@ export type Query = { pageHeaderCollection?: Maybe; paragraphs?: Maybe; paragraphsCollection?: Maybe; + publication?: Maybe; + publicationCollection?: Maybe; volunteer?: Maybe; volunteerCollection?: Maybe; }; @@ -2195,6 +2335,23 @@ export type QueryParagraphsCollectionArgs = { }; +export type QueryPublicationArgs = { + id: Scalars['String']['input']; + locale?: InputMaybe; + preview?: InputMaybe; +}; + + +export type QueryPublicationCollectionArgs = { + limit?: InputMaybe; + locale?: InputMaybe; + order?: InputMaybe>>; + preview?: InputMaybe; + skip?: InputMaybe; + where?: InputMaybe; +}; + + export type QueryVolunteerArgs = { id: Scalars['String']['input']; locale?: InputMaybe; From 7d8feb0d3a0bd447290b13bb330ec14baf601b4d Mon Sep 17 00:00:00 2001 From: Pedro Martin Date: Mon, 20 Jan 2025 18:07:09 +0000 Subject: [PATCH 02/10] refactor: abstract page body to a component --- .../[lang]/register-a-patient/page-body.tsx | 273 ++++++++---------- .../page-body/index.module.scss} | 0 website/src/components/page-body/index.tsx | 29 ++ 3 files changed, 156 insertions(+), 146 deletions(-) rename website/src/{app/[lang]/register-a-patient/page-body.module.scss => components/page-body/index.module.scss} (100%) create mode 100644 website/src/components/page-body/index.tsx diff --git a/website/src/app/[lang]/register-a-patient/page-body.tsx b/website/src/app/[lang]/register-a-patient/page-body.tsx index ff0cd68..e3957fc 100644 --- a/website/src/app/[lang]/register-a-patient/page-body.tsx +++ b/website/src/app/[lang]/register-a-patient/page-body.tsx @@ -1,8 +1,5 @@ -import styles from './page-body.module.scss'; - import Accordion from '@components/accordion'; -import PageContents from '@components/page-contents'; -import PageLatestNews from '@components/page-latest-news'; +import PageBody from '@components/page-body'; import SignupForm from '@components/signup-form'; import { documentToReactComponents } from '@contentful/rich-text-react-renderer'; import { getClient } from '@graphql/client'; @@ -102,148 +99,132 @@ const RegisterPageBody: React.FC = async ({ lang }) => { ]; return ( -
-
- -
- {documentToReactComponents(intro?.content?.json)} -
    -
  1. - - {registerWithUsHeading?.content} - -
  2. -
  3. - - {registerPatientRegistryHeading?.content} - -
  4. -
  5. - - {registerClinicalIdHeading?.content} - -
  6. -
-
-

- 1. {registerWithUsHeading?.content} -

- - {documentToReactComponents(registerWithUsContent?.content?.json)} - - -
-
-

- 2. {registerPatientRegistryHeading?.content} -

- - {documentToReactComponents( - registerPatientRegistryContent?.content?.json, - )} - - - {registerPatientRegistrySignUpLink?.content} - -

{alreadyRegister[lang]}

- - {registerPatientRegistryLoginLink?.content} - - - - - - - - -
- -
-

- 3. {registerClinicalIdHeading?.content} -

- - {documentToReactComponents( - registerClinicalIdContent?.content?.json, - )} - - - {registerContentIdLink?.content} - -
-
- -
-
+ + {documentToReactComponents(intro?.content?.json)} +
    +
  1. + + {registerWithUsHeading?.content} + +
  2. +
  3. + + {registerPatientRegistryHeading?.content} + +
  4. +
  5. + + {registerClinicalIdHeading?.content} + +
  6. +
+
+

+ 1. {registerWithUsHeading?.content} +

+ + {documentToReactComponents(registerWithUsContent?.content?.json)} + + +
+
+

+ 2. {registerPatientRegistryHeading?.content} +

+ + {documentToReactComponents( + registerPatientRegistryContent?.content?.json, + )} + + + {registerPatientRegistrySignUpLink?.content} + +

{alreadyRegister[lang]}

+ + {registerPatientRegistryLoginLink?.content} + + + + + + + + +
+ +
+

+ 3. {registerClinicalIdHeading?.content} +

+ + {documentToReactComponents(registerClinicalIdContent?.content?.json)} + + + {registerContentIdLink?.content} + +
+
); }; diff --git a/website/src/app/[lang]/register-a-patient/page-body.module.scss b/website/src/components/page-body/index.module.scss similarity index 100% rename from website/src/app/[lang]/register-a-patient/page-body.module.scss rename to website/src/components/page-body/index.module.scss diff --git a/website/src/components/page-body/index.tsx b/website/src/components/page-body/index.tsx new file mode 100644 index 0000000..a8d1430 --- /dev/null +++ b/website/src/components/page-body/index.tsx @@ -0,0 +1,29 @@ +import styles from './index.module.scss'; + +import PageContents from '@components/page-contents'; +import PageLatestNews from '@components/page-latest-news'; +import type { AvailableLocale } from '@i18n/locales'; + +interface PageBodyProps { + lang: AvailableLocale; + headings: string[]; + children: React.ReactNode; +} + +const PageBody: React.FC = ({ lang, headings, children }) => { + return ( +
+
+ +
{children}
+ +
+
+ ); +}; + +export default PageBody; From cda1e81932ce1747abecfced15117b6ccd1bf681 Mon Sep 17 00:00:00 2001 From: Pedro Martin Date: Tue, 21 Jan 2025 09:28:22 +0000 Subject: [PATCH 03/10] feat: add publications page header --- .../src/app/[lang]/publications/page-body.tsx | 231 ++++++++++++++++++ .../app/[lang]/publications/page-header.tsx | 57 +++++ website/src/app/[lang]/publications/page.tsx | 102 ++++++++ .../components/page-header/index.module.scss | 2 + website/src/models/page-header/index.ts | 1 + 5 files changed, 393 insertions(+) create mode 100644 website/src/app/[lang]/publications/page-body.tsx create mode 100644 website/src/app/[lang]/publications/page-header.tsx create mode 100644 website/src/app/[lang]/publications/page.tsx diff --git a/website/src/app/[lang]/publications/page-body.tsx b/website/src/app/[lang]/publications/page-body.tsx new file mode 100644 index 0000000..e3957fc --- /dev/null +++ b/website/src/app/[lang]/publications/page-body.tsx @@ -0,0 +1,231 @@ +import Accordion from '@components/accordion'; +import PageBody from '@components/page-body'; +import SignupForm from '@components/signup-form'; +import { documentToReactComponents } from '@contentful/rich-text-react-renderer'; +import { getClient } from '@graphql/client'; +import { + GetRegisterPatientPageDocument, + type GetRegisterPatientPageQuery, +} from '@graphql/queries/register-patient-page/index.generated'; +import type { AvailableLocale, LocalisedString } from '@i18n/locales'; +import { + matrixLanguagesAccordionId, + otherThanFillSurveysAccordionId, + whoCanTakePartAccordionId, + whoContactAccordionId, + whoWillHaveAccessAccordionId, +} from '@models/accordions'; +import { + registerClinicalIdHeadingId, + registerPatientRegistryHeadingId, + registerWithUsHeadingId, +} from '@models/headings'; +import { + registerContentIdLinkId, + registerPatientRegistryLoginLinkId, + registerPatientRegistrySignUpLinkId, +} from '@models/links'; +import { + introId, + registerClinicalIdContentId, + registerPatientRegistryContentId, + registerWithUsContentId, +} from '@models/paragraphs'; +import { createHashLink } from '@shared/utils/hash-links'; + +interface RegisterPageBodyProps { + lang: AvailableLocale; +} + +const { query } = getClient(); + +const alreadyRegister: LocalisedString = { + en: 'Already registered?', + es: '¿Ya estás registrado?', + fr: 'Déjà enregistré?', + de: 'Bereits registriert?', +}; + +const RegisterPageBody: React.FC = async ({ lang }) => { + const { + data: { + intro, + registerWithUsHeading, + registerPatientRegistryHeading, + registerClinicalIdHeading, + registerPatientRegistryLoginLink, + registerWithUsContent, + registerPatientRegistryContent, + registerPatientRegistrySignUpLink, + whoCanTakePartAccordion, + whoWillHaveAccessAccordion, + otherThanFillSurveysAccordion, + matrixLanguagesAccordion, + whoContactAccordion, + registerClinicalIdContent, + registerContentIdLink, + }, + error, + } = await query({ + query: GetRegisterPatientPageDocument, + variables: { + locale: lang, + introId, + registerWithUsHeadingId, + registerPatientRegistryHeadingId, + registerClinicalIdHeadingId, + registerPatientRegistryLoginLinkId, + registerWithUsContentId, + registerPatientRegistryContentId, + registerPatientRegistrySignUpLinkId, + whoCanTakePartAccordionId, + whoWillHaveAccessAccordionId, + otherThanFillSurveysAccordionId, + matrixLanguagesAccordionId, + whoContactAccordionId, + registerClinicalIdContentId, + registerContentIdLinkId, + }, + }); + + if (error) { + return null; + } + + const headings = [ + registerWithUsHeading?.content ?? '', + registerPatientRegistryHeading?.content ?? '', + registerClinicalIdHeading?.content ?? '', + ]; + + return ( + + {documentToReactComponents(intro?.content?.json)} +
    +
  1. + + {registerWithUsHeading?.content} + +
  2. +
  3. + + {registerPatientRegistryHeading?.content} + +
  4. +
  5. + + {registerClinicalIdHeading?.content} + +
  6. +
+
+

+ 1. {registerWithUsHeading?.content} +

+ + {documentToReactComponents(registerWithUsContent?.content?.json)} + + +
+
+

+ 2. {registerPatientRegistryHeading?.content} +

+ + {documentToReactComponents( + registerPatientRegistryContent?.content?.json, + )} + + + {registerPatientRegistrySignUpLink?.content} + +

{alreadyRegister[lang]}

+ + {registerPatientRegistryLoginLink?.content} + + + + + + + + +
+ +
+

+ 3. {registerClinicalIdHeading?.content} +

+ + {documentToReactComponents(registerClinicalIdContent?.content?.json)} + + + {registerContentIdLink?.content} + +
+
+ ); +}; + +export default RegisterPageBody; diff --git a/website/src/app/[lang]/publications/page-header.tsx b/website/src/app/[lang]/publications/page-header.tsx new file mode 100644 index 0000000..9ad0e70 --- /dev/null +++ b/website/src/app/[lang]/publications/page-header.tsx @@ -0,0 +1,57 @@ +import PageHeader from '@components/page-header'; +import { getClient } from '@graphql/client'; +import { + GetPageHeaderDocument, + type GetPageHeaderQuery, +} from '@graphql/queries/page-header/index.generated'; +import type { AvailableLocale } from '@i18n/locales'; +import { publicationsPageHeaderId } from '@models/page-header'; + +interface RegisterPageHeaderProps { + lang: AvailableLocale; +} + +const PublicationsPageHeader: React.FC = async ({ + lang, +}) => { + const { query } = getClient(); + + // TODO: Change query + const { data, error } = await query({ + query: GetPageHeaderDocument, + variables: { + locale: lang, + id: publicationsPageHeaderId, + }, + }); + + if ( + error || + !data.pageHeader || + !data.pageHeader.title || + !data.pageHeader.sectionTitle || + !data.pageHeader.lastUpdated || + !data.pageHeader.image + ) { + return null; + } + + const { + title, + sectionTitle, + lastUpdated, + image: { url }, + } = data.pageHeader; + + return ( + + ); +}; + +export default PublicationsPageHeader; diff --git a/website/src/app/[lang]/publications/page.tsx b/website/src/app/[lang]/publications/page.tsx new file mode 100644 index 0000000..2232276 --- /dev/null +++ b/website/src/app/[lang]/publications/page.tsx @@ -0,0 +1,102 @@ +import SupportBanner from '@components/support-banner'; +import { getClient } from '@graphql/client'; +import { + GetMetadataDocument, + type GetMetadataQuery, +} from '@graphql/queries/metadata/index.generated'; +import { registerPatientPageMetadataId } from '@models/metadata'; +import type { PagePropsWithLocale } from '@shared/types/page-with-locale-params'; +import type { Metadata, NextPage } from 'next'; +import type { Graph, MedicalStudy, WebPage, WithContext } from 'schema-dts'; +import RegisterPageBody from './page-body'; +import PublicationsPageHeader from './page-header'; + +const { query } = getClient(); + +const Page: NextPage = async ({ params }) => { + const { lang } = await params; + + // TODO: Change query + const { + data: { + // @ts-ignore + htmlHeadMetadata: { title, description }, + }, + } = await query({ + query: GetMetadataDocument, + variables: { + locale: lang, + id: registerPatientPageMetadataId, + }, + }); + + const medicalStudy: WithContext = { + '@context': 'https://schema.org', + '@type': 'MedicalStudy', + name: title, + description, + potentialAction: [ + { + '@type': 'RegisterAction', + target: `https://nr2f1.org/${lang}/register-patient`, + name: title, + }, + ], + }; + + // TODO: Change schema + const webPage: WithContext = { + '@context': 'https://schema.org', + '@type': 'WebPage', + url: `https://nr2f1.org/${lang}/register-a-patient`, + name: title, + inLanguage: lang, + }; + + const jsonLd: Graph = { + '@context': 'https://schema.org', + '@graph': [medicalStudy, webPage], + }; + + return ( + <> +