Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-info-card
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 17, 2024
2 parents 2ce88fa + c07421f commit a08e450
Show file tree
Hide file tree
Showing 28 changed files with 159 additions and 92 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn('endorsement_list', 'owner_name', {
type: Sequelize.STRING,
allowNull: true,
})
},

down: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn('endorsement_list', 'owner_name')
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ export class EndorsementList extends Model {
})
owner!: string

@ApiProperty()
@Column({
type: DataType.STRING,
allowNull: true,
})
ownerName?: string

@ApiProperty()
@Column({
type: DataType.BOOLEAN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,11 @@ export class EndorsementListService {
])
}
this.logger.info(`Creating endorsement list: ${list.title}`)
const endorsementList = await this.endorsementListModel.create({ ...list })
const ownerName = await this.fetchOwnerNameFromRegistry(list.owner)
const endorsementList = await this.endorsementListModel.create({
...list,
ownerName,
})

if (process.env.NODE_ENV === 'production') {
await this.emailCreated(endorsementList)
Expand Down Expand Up @@ -305,6 +309,10 @@ export class EndorsementListService {
throw new NotFoundException(['This endorsement list does not exist.'])
}
owner = endorsementList.owner
// Use stored ownerName if available
if (endorsementList.ownerName) {
return endorsementList.ownerName
}
}

try {
Expand Down Expand Up @@ -953,4 +961,19 @@ export class EndorsementListService {
)
}
}

private async fetchOwnerNameFromRegistry(
nationalId: string,
): Promise<string> {
try {
const person = await this.nationalRegistryApiV3.getName(nationalId)
return person?.fulltNafn ? person.fulltNafn : ''
} catch (error) {
this.logger.error('Failed to fetch owner name from NationalRegistry', {
error: error.message,
nationalId,
})
return ''
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,13 @@ export const OrganizationHeader: React.FC<
logoImageClassName={styles.logoLarge}
/>
)
case 'rannis':
return (
<DefaultHeader
{...defaultProps}
background="linear-gradient(271deg, #C00B02 5.72%, #DB0B00 91.04%)"
/>
)
default:
return <DefaultHeader {...defaultProps} />
}
Expand Down
65 changes: 30 additions & 35 deletions libs/application/core/src/lib/fieldBuilders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ const extractCommonFields = (
dataTestId,
width = 'full',
nextButtonText,
marginBottom,
marginTop,
} = data

return {
Expand All @@ -86,6 +88,8 @@ const extractCommonFields = (
title,
width,
nextButtonText,
marginBottom,
marginTop,
}
}

Expand Down Expand Up @@ -154,8 +158,6 @@ export const buildDescriptionField = (
tooltip,
titleTooltip,
space,
marginBottom,
marginTop,
doesNotRequireAnswer = true,
} = data
return {
Expand All @@ -167,8 +169,6 @@ export const buildDescriptionField = (
tooltip,
titleTooltip,
space,
marginBottom,
marginTop,
type: FieldTypes.DESCRIPTION,
component: FieldComponents.DESCRIPTION,
}
Expand Down Expand Up @@ -400,8 +400,10 @@ export const buildDividerField = (data: {
condition?: Condition
title?: FormText
color?: Colors
marginBottom?: BoxProps['marginBottom']
marginTop?: BoxProps['marginTop']
}): DividerField => {
const { title, color, condition } = data
const { title, color, condition, marginTop, marginBottom } = data
return {
id: '',
children: undefined,
Expand All @@ -411,6 +413,8 @@ export const buildDividerField = (data: {
title: title ?? '',
color,
condition,
marginTop,
marginBottom,
}
}

Expand Down Expand Up @@ -463,6 +467,8 @@ export const buildSubmitField = (data: {
id: string
title: FormText
placement?: 'footer' | 'screen'
marginBottom?: BoxProps['marginBottom']
marginTop?: BoxProps['marginTop']
refetchApplicationAfterSubmit?: boolean
actions: CallToAction[]
}): SubmitField => {
Expand All @@ -472,6 +478,8 @@ export const buildSubmitField = (data: {
title,
actions,
refetchApplicationAfterSubmit,
marginTop,
marginBottom,
} = data
return {
children: undefined,
Expand All @@ -484,6 +492,8 @@ export const buildSubmitField = (data: {
typeof refetchApplicationAfterSubmit !== 'undefined'
? refetchApplicationAfterSubmit
: false,
marginTop,
marginBottom,
type: FieldTypes.SUBMIT,
component: FieldComponents.SUBMIT,
}
Expand Down Expand Up @@ -514,12 +524,16 @@ export const buildFieldRequired = (
export const buildRedirectToServicePortalField = (data: {
id: string
title: FormText
marginBottom?: BoxProps['marginBottom']
marginTop?: BoxProps['marginTop']
}): RedirectToServicePortalField => {
const { id, title } = data
const { id, title, marginTop, marginBottom } = data
return {
children: undefined,
id,
title,
marginTop,
marginBottom,
type: FieldTypes.REDIRECT_TO_SERVICE_PORTAL,
component: FieldComponents.REDIRECT_TO_SERVICE_PORTAL,
}
Expand All @@ -542,7 +556,7 @@ export const buildPaymentPendingField = (data: {
export const buildMessageWithLinkButtonField = (
data: Omit<MessageWithLinkButtonField, 'type' | 'component' | 'children'>,
): MessageWithLinkButtonField => {
const { id, title, url, message, buttonTitle, marginBottom, marginTop } = data
const { id, title, url, message, buttonTitle } = data
return {
...extractCommonFields(data),
children: undefined,
Expand All @@ -551,8 +565,6 @@ export const buildMessageWithLinkButtonField = (
url,
message,
buttonTitle,
marginTop,
marginBottom,
type: FieldTypes.MESSAGE_WITH_LINK_BUTTON_FIELD,
component: FieldComponents.MESSAGE_WITH_LINK_BUTTON_FIELD,
}
Expand All @@ -563,6 +575,7 @@ export const buildExpandableDescriptionField = (
): ExpandableDescriptionField => {
const { id, title, description, introText, startExpanded } = data
return {
...extractCommonFields(data),
children: undefined,
id,
title,
Expand All @@ -576,16 +589,14 @@ export const buildExpandableDescriptionField = (
export const buildAlertMessageField = (
data: Omit<AlertMessageField, 'type' | 'component' | 'children'>,
): AlertMessageField => {
const { message, alertType, marginTop, marginBottom, links } = data
const { message, alertType, links } = data
return {
...extractCommonFields(data),
children: undefined,
message,
alertType,
type: FieldTypes.ALERT_MESSAGE,
component: FieldComponents.ALERT_MESSAGE,
marginTop,
marginBottom,
links,
}
}
Expand All @@ -611,6 +622,7 @@ export const buildPaymentChargeOverviewField = (
const { id, title, forPaymentLabel, totalLabel, getSelectedChargeItems } =
data
return {
...extractCommonFields(data),
children: undefined,
id,
title,
Expand All @@ -630,23 +642,20 @@ export const buildImageField = (
title,
image,
alt,
marginTop,
marginBottom,
condition,
titleVariant = 'h4',
// imageWidth and imagePosition can be arrays [sm, md, lg, xl] for different screen sizes
imageWidth = 'full',
imagePosition = 'left',
} = data
return {
...extractCommonFields(data),
children: undefined,
id,
title,
image,
alt,
imageWidth,
marginTop,
marginBottom,
condition,
titleVariant,
imagePosition,
Expand Down Expand Up @@ -754,8 +763,6 @@ export const buildNationalIdWithNameField = (
searchCompanies,
titleVariant,
description,
marginTop,
marginBottom,
} = data
return {
...extractCommonFields(data),
Expand All @@ -776,24 +783,20 @@ export const buildNationalIdWithNameField = (
component: FieldComponents.NATIONAL_ID_WITH_NAME,
titleVariant,
description,
marginTop,
marginBottom,
}
}

export const buildActionCardListField = (
data: Omit<ActionCardListField, 'type' | 'component' | 'children'>,
): ActionCardListField => {
const { items, space, marginTop, marginBottom } = data
const { items, space } = data

return {
...extractCommonFields(data),
children: undefined,
type: FieldTypes.ACTION_CARD_LIST,
component: FieldComponents.ACTION_CARD_LIST,
items,
marginTop,
marginBottom,
space,
}
}
Expand All @@ -805,8 +808,6 @@ export const buildTableRepeaterField = (
fields,
table,
formTitle,
marginTop,
marginBottom,
titleVariant,
addItemButtonText,
saveItemButtonText,
Expand All @@ -825,8 +826,6 @@ export const buildTableRepeaterField = (
fields,
table,
formTitle,
marginTop,
marginBottom,
titleVariant,
addItemButtonText,
saveItemButtonText,
Expand All @@ -849,8 +848,6 @@ export const buildFieldsRepeaterField = (
formTitle,
formTitleVariant,
formTitleNumbering,
marginTop,
marginBottom,
removeItemButtonText,
addItemButtonText,
saveItemButtonText,
Expand All @@ -870,8 +867,6 @@ export const buildFieldsRepeaterField = (
formTitle,
formTitleVariant,
formTitleNumbering,
marginTop,
marginBottom,
removeItemButtonText,
addItemButtonText,
saveItemButtonText,
Expand Down Expand Up @@ -951,6 +946,8 @@ export const buildSliderField = (
labelMultiplier = 1,
id,
saveAsString,
marginTop,
marginBottom,
} = data
return {
title: '',
Expand All @@ -977,6 +974,8 @@ export const buildSliderField = (
labelMultiplier,
condition,
saveAsString,
marginTop,
marginBottom,
}
}

Expand All @@ -988,8 +987,6 @@ export const buildDisplayField = (
titleVariant,
label,
variant,
marginTop,
marginBottom,
value,
suffix,
rightAlign,
Expand All @@ -1001,8 +998,6 @@ export const buildDisplayField = (
titleVariant,
label,
variant,
marginTop,
marginBottom,
type: FieldTypes.DISPLAY,
component: FieldComponents.DISPLAY,
children: undefined,
Expand Down
Loading

0 comments on commit a08e450

Please sign in to comment.