Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(router): providerContactInfo field type should be a LocalizedObject #618

Merged
merged 4 commits into from
Jan 16, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { EventAttributes } from 'ics';
import { createEvent } from 'ics';
import { useTranslation } from 'next-i18next';
import React from 'react';
import { Link, SecondaryLink } from 'react-helsinki-headless-cms';
import { SecondaryLink } from 'react-helsinki-headless-cms';

import IconDirections from '../../../../assets/icons/IconDirections';
import InfoWithIcon from '../../../../components/infoWithIcon/InfoWithIcon';
Expand Down Expand Up @@ -249,28 +249,15 @@ const OtherInfo: React.FC<{
const { t } = useTranslation('event');
const locale = useLocale();

const { email, externalLinks, infoUrl, telephone, registrationUrl } =
const { externalLinks, infoUrl, registrationUrl, providerContactInfo } =
getEventFields(event, locale);

return (
<InfoWithIcon
icon={<IconInfoCircle aria-hidden />}
title={t('info.labelOtherInfo')}
>
{email && (
<div key={email}>
<Link className={styles.link} size="L" href={`mailto:${email}`}>
{email}
</Link>
</div>
)}
{telephone && (
<div key={telephone}>
<Link className={styles.link} size="L" href={`tel:${telephone}`}>
{telephone}
</Link>
</div>
)}
{providerContactInfo && <div>{providerContactInfo}</div>}

{infoUrl && (
<SecondaryLink
Expand All @@ -289,13 +276,14 @@ const OtherInfo: React.FC<{
) => {
return (
!!externalLink.link &&
!!externalLink.name &&
externalLink.link !== registrationUrl && (
<SecondaryLink
className={styles.link}
key={index}
key={`externalLink-${index}`}
href={externalLink.link}
>
{translateValue('info.', externalLink.name as string, t)}
{translateValue('info.', externalLink.name, t)}
</SecondaryLink>
)
);
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/components/domain/event/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export const QUERY_EVENT_DETAILS = gql`
provider {
...localizedFields
}
providerContactInfo {
...localizedFields
}
infoUrl {
...localizedFields
}
Expand Down
29 changes: 28 additions & 1 deletion packages/components/src/types/generated/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2907,7 +2907,7 @@ export type EventDetails = {
name: LocalizedObject;
offers: Array<Offer>;
provider?: Maybe<LocalizedObject>;
providerContactInfo?: Maybe<Scalars['String']['output']>;
providerContactInfo?: Maybe<LocalizedObject>;
publisher?: Maybe<Scalars['ID']['output']>;
remainingAttendeeCapacity?: Maybe<Scalars['Int']['output']>;
shortDescription?: Maybe<LocalizedObject>;
Expand Down Expand Up @@ -12625,6 +12625,12 @@ export type EventFieldsFragment = {
fi?: string | null;
sv?: string | null;
} | null;
providerContactInfo?: {
__typename?: 'LocalizedObject';
en?: string | null;
fi?: string | null;
sv?: string | null;
} | null;
infoUrl?: {
__typename?: 'LocalizedObject';
en?: string | null;
Expand Down Expand Up @@ -12812,6 +12818,12 @@ export type EventDetailsQuery = {
fi?: string | null;
sv?: string | null;
} | null;
providerContactInfo?: {
__typename?: 'LocalizedObject';
en?: string | null;
fi?: string | null;
sv?: string | null;
} | null;
infoUrl?: {
__typename?: 'LocalizedObject';
en?: string | null;
Expand Down Expand Up @@ -13079,6 +13091,12 @@ export type EventListQuery = {
fi?: string | null;
sv?: string | null;
} | null;
providerContactInfo?: {
__typename?: 'LocalizedObject';
en?: string | null;
fi?: string | null;
sv?: string | null;
} | null;
infoUrl?: {
__typename?: 'LocalizedObject';
en?: string | null;
Expand Down Expand Up @@ -13278,6 +13296,12 @@ export type EventsByIdsQuery = {
fi?: string | null;
sv?: string | null;
} | null;
providerContactInfo?: {
__typename?: 'LocalizedObject';
en?: string | null;
fi?: string | null;
sv?: string | null;
} | null;
infoUrl?: {
__typename?: 'LocalizedObject';
en?: string | null;
Expand Down Expand Up @@ -14251,6 +14275,9 @@ export const EventFieldsFragmentDoc = gql`
provider {
...localizedFields
}
providerContactInfo {
...localizedFields
}
infoUrl {
...localizedFields
}
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/utils/eventUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ export const getEventFields = (event: EventFields, locale: AppLanguage) => {
remainingAttendeeCapacity: event.remainingAttendeeCapacity,
enrolmentStartTime: event.enrolmentStartTime,
enrolmentEndTime: event.enrolmentEndTime,
providerContactInfo: getLocalizedString(event.providerContactInfo, locale),
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ type EventDetails {
shortDescription: LocalizedObject
provider: LocalizedObject
infoUrl: LocalizedObject
providerContactInfo: String
providerContactInfo: LocalizedObject
description: LocalizedObject
internalId: String
internalContext: String
Expand Down
2 changes: 1 addition & 1 deletion proxies/events-graphql-federation/supergraph.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4438,7 +4438,7 @@ type EventDetails
shortDescription: LocalizedObject
provider: LocalizedObject
infoUrl: LocalizedObject
providerContactInfo: String
providerContactInfo: LocalizedObject
description: LocalizedObject
internalId: String
internalContext: String
Expand Down
Loading