Skip to content

Commit

Permalink
feat(web): add button label (#17191)
Browse files Browse the repository at this point in the history
* fix: add label

* chore: revert sdiebar

* fix: add label

* chore: wip

* feat: use label

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
thorkellmani and kodiakhq[bot] authored Dec 16, 2024
1 parent 7cc0395 commit 4fcc879
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 66 deletions.
34 changes: 15 additions & 19 deletions apps/web/screens/Grants/Grant/Grant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ const GrantSinglePage: CustomScreen<GrantSingleProps> = ({ grant, locale }) => {
backgroundColor="blue"
cta={{
disabled: !grant.applicationUrl?.slug,
label: formatMessage(m.single.apply),
label:
grant.applicationButtonLabel ?? formatMessage(m.single.apply),
onClick: () => router.push(grant.applicationUrl?.slug ?? ''),
icon: 'open',
iconType: 'outline',
Expand Down Expand Up @@ -139,26 +140,21 @@ const GrantSinglePage: CustomScreen<GrantSingleProps> = ({ grant, locale }) => {
</>
) : undefined}
{grant.howToApply?.length ? (
<Box>
<Text variant="h3">{formatMessage(m.single.howToApply)}</Text>
<Box className="rs_read">
{webRichText(
grant.howToApply as SliceType[],
undefined,
locale,
)}
<>
<Box>
<Text variant="h3">{formatMessage(m.single.howToApply)}</Text>
<Box className="rs_read">
{webRichText(
grant.howToApply as SliceType[],
undefined,
locale,
)}
</Box>
</Box>
</Box>
) : undefined}
{grant.applicationDeadline?.length ? (
<Box className="rs_read">
{webRichText(
grant.applicationDeadline as SliceType[],
undefined,
locale,
)}
</Box>
<Divider />
</>
) : undefined}

{grant.applicationHints?.length ? (
<Box className="rs_read">
{webRichText(
Expand Down
6 changes: 0 additions & 6 deletions apps/web/screens/Grants/Grant/GrantSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ export const GrantSidebar = ({ grant, locale }: Props) => {
<Text variant="medium">{grant.typeTag?.title}</Text>
) : undefined,
),
generateLine(
formatMessage(m.single.deadline),
status.deadlineStatus ? (
<Text variant="medium">{status.deadlineStatus}</Text>
) : undefined,
),
generateLine(
formatMessage(m.single.status),
grant?.status ? (
Expand Down
6 changes: 5 additions & 1 deletion apps/web/screens/Grants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,13 @@ export const m = {
id: 'web.grants:single.type',
defaultMessage: 'Tegund',
},
applications: {
id: 'web.grants:single.applications',
defaultMessage: 'Umsóknir',
},
deadline: {
id: 'web.grants:single.deadline',
defaultMessage: 'Umsóknarfrestur',
defaultMessage: 'Umsóknir',
},
status: {
id: 'web.grants:single.status',
Expand Down
8 changes: 2 additions & 6 deletions apps/web/screens/queries/Grants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import gql from 'graphql-tag'

import { nestedFields, slices } from './fragments'

export const GET_GRANTS_QUERY = gql`
Expand All @@ -9,7 +10,6 @@ export const GET_GRANTS_QUERY = gql`
name
description
applicationId
applicationDeadlineStatus
applicationUrl {
slug
type
Expand Down Expand Up @@ -67,7 +67,7 @@ export const GET_GRANT_QUERY = gql`
slug
type
}
applicationDeadlineStatus
applicationButtonLabel
status
statusText
dateFrom
Expand Down Expand Up @@ -120,10 +120,6 @@ export const GET_GRANT_QUERY = gql`
...AllSlices
${nestedFields}
}
applicationDeadline {
...AllSlices
${nestedFields}
}
applicationHints {
...AllSlices
${nestedFields}
Expand Down
23 changes: 10 additions & 13 deletions libs/cms/src/lib/generated/contentfulTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1814,14 +1814,11 @@ export interface IGrantFields {
/** Description */
grantDescription?: string | undefined

/** Grant Application ID */
/** Grant reference ID */
grantApplicationId?: string | undefined

/** Application Deadline Status */
grantApplicationDeadlineStatus?: string | undefined

/** Application Url */
granApplicationUrl?: ILinkUrl | undefined
/** Fund */
grantFund: IFund

/** Special emphasis */
grantSpecialEmphasis?: Document | undefined
Expand All @@ -1832,13 +1829,16 @@ export interface IGrantFields {
/** How to apply? */
grantHowToApply?: Document | undefined

/** Application deadline */
grantApplicationDeadline?: Document | undefined

/** Application hints */
grantApplicationHints?: Document | undefined

/** Open from */
/** Application url */
granApplicationUrl?: ILinkUrl | undefined

/** Application button label */
grantButtonLabel?: string | undefined

/** Date from */
grantDateFrom?: string | undefined

/** Open from hour */
Expand Down Expand Up @@ -1874,9 +1874,6 @@ export interface IGrantFields {

/** Type tag */
grantTypeTag?: IGenericTag | undefined

/** Fund */
grantFund: IFund
}

/** Grant is a part of "Styrkjatorg". */
Expand Down
18 changes: 4 additions & 14 deletions libs/cms/src/lib/models/grant.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export class Grant {
@Field({ nullable: true })
applicationId?: string

@Field({ nullable: true })
applicationDeadlineStatus?: string

@CacheField(() => ReferenceLink, { nullable: true })
applicationUrl?: ReferenceLink

@Field({ nullable: true })
applicationButtonLabel?: string

@CacheField(() => [SliceUnion])
specialEmphasis?: Array<typeof SliceUnion>

Expand All @@ -56,9 +56,6 @@ export class Grant {
@CacheField(() => [SliceUnion])
howToApply?: Array<typeof SliceUnion>

@CacheField(() => [SliceUnion])
applicationDeadline?: Array<typeof SliceUnion>

@CacheField(() => [SliceUnion])
applicationHints?: Array<typeof SliceUnion>

Expand Down Expand Up @@ -141,11 +138,10 @@ export const mapGrant = ({ fields, sys }: IGrant): Grant => {
name: fields.grantName,
description: fields.grantDescription,
applicationId: fields.grantApplicationId,
applicationDeadlineStatus: fields.grantApplicationDeadlineStatus,
applicationUrl: fields.granApplicationUrl?.fields
? mapReferenceLink(fields.granApplicationUrl)
: undefined,

applicationButtonLabel: fields.grantButtonLabel,
specialEmphasis: fields.grantSpecialEmphasis
? mapDocument(fields.grantSpecialEmphasis, sys.id + ':special-emphasis')
: [],
Expand All @@ -155,12 +151,6 @@ export const mapGrant = ({ fields, sys }: IGrant): Grant => {
howToApply: fields.grantHowToApply
? mapDocument(fields.grantHowToApply, sys.id + ':how-to-apply')
: [],
applicationDeadline: fields.grantApplicationDeadline
? mapDocument(
fields.grantApplicationDeadline,
sys.id + ':application-deadline',
)
: [],
applicationHints: fields.grantApplicationHints
? mapDocument(fields.grantApplicationHints, sys.id + ':application-hints')
: [],
Expand Down
7 changes: 0 additions & 7 deletions libs/cms/src/lib/search/importers/grants.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ export class GrantsSyncService implements CmsSyncProvider<IGrant> {
mapped?.howToApply?.map(pruneNonSearchableSliceUnionFields),
)
: undefined,
mapped.applicationDeadline
? extractStringsFromObject(
mapped?.applicationDeadline?.map(
pruneNonSearchableSliceUnionFields,
),
)
: undefined,
mapped?.applicationHints
? extractStringsFromObject(
mapped?.applicationHints?.map(
Expand Down

0 comments on commit 4fcc879

Please sign in to comment.