Skip to content

Commit

Permalink
1419: fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
f1sh1918 committed Oct 1, 2024
1 parent 67340f7 commit 1ef5a0f
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 30 deletions.
12 changes: 8 additions & 4 deletions administration/src/bp-modules/cards/AddCardForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, Card, FormGroup, InputGroup, Intent } from '@blueprintjs/core'
import { TextField } from '@mui/material'
import React, { ChangeEvent, ReactElement } from 'react'
import React, { ChangeEvent, JSXElementConstructor, ReactElement } from 'react'
import styled from 'styled-components'

import { CardBlueprint } from '../../cards/CardBlueprint'
Expand Down Expand Up @@ -29,13 +29,17 @@ type CreateCardsFormProps = {
}

export const maxCardValidity = { years: 99 }
export const ExtensionForm = ({ extension, onUpdate, viewportSmall }: ExtensionFormProps) => {
export const ExtensionForm = ({
extension,
onUpdate,
viewportSmall,
}: ExtensionFormProps): ReactElement<ExtensionInstance, string | JSXElementConstructor<ExtensionInstance>> | null => {
return extension.createForm(() => {
onUpdate()
}, viewportSmall)
}

const CreateCardForm = ({ cardBlueprint, onRemove, onUpdate }: CreateCardsFormProps): ReactElement => {
const AddCardForm = ({ cardBlueprint, onRemove, onUpdate }: CreateCardsFormProps): ReactElement => {
const { viewportSmall } = useWindowDimensions()
const today = PlainDate.fromLocalDate(new Date())
return (
Expand Down Expand Up @@ -89,4 +93,4 @@ const CreateCardForm = ({ cardBlueprint, onRemove, onUpdate }: CreateCardsFormPr
)
}

export default CreateCardForm
export default AddCardForm
4 changes: 2 additions & 2 deletions administration/src/bp-modules/cards/AddCardsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import styled from 'styled-components'
import { CardBlueprint } from '../../cards/CardBlueprint'
import { Region } from '../../generated/graphql'
import { ProjectConfigContext } from '../../project-configs/ProjectConfigContext'
import CreateCardForm from './AddCardForm'
import AddCardForm from './AddCardForm'
import CardFormButton from './CardFormButton'
import { getHeaders } from './ImportCardsController'

Expand Down Expand Up @@ -110,7 +110,7 @@ const AddCardsForm = ({
}}>
{cardBlueprints.map(blueprint => (
<FormColumn key={blueprint.id}>
<CreateCardForm
<AddCardForm
cardBlueprint={blueprint}
onRemove={() => removeCardBlueprint(blueprint)}
onUpdate={notifyUpdate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const StyledCheckbox = styled(Checkbox)`

const StyledAlert = styled(Alert)`
margin-bottom: 24px;
white-space: pre-line;
`

const Container = styled('div')`
Expand All @@ -52,7 +53,7 @@ const getTooltipMessage = (cardsValid: boolean, dataPrivacyAccepted: boolean): s
tooltipMessages.push('Bitte akzeptieren Sie die Datenschutzerklärung.')
}

return tooltipMessages.join(' ')
return tooltipMessages.join('\n')
}
const CardSelfServiceForm = ({
card,
Expand Down Expand Up @@ -123,11 +124,7 @@ const CardSelfServiceForm = ({
maxWidth='md'
onUpdateOpen={setOpenDataPrivacy}
title={projectConfig.dataPrivacyHeadline}
content={
<>
<projectConfig.dataPrivacyContent />
</>
}
content={<projectConfig.dataPrivacyContent />}
/>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const useCardGeneratorSelfService = (): UseCardGeneratorSelfServiceReturn => {
[appToaster, setSelfServiceState]
)

const generateCards = useCallback(async () => {
const generateCards = useCallback(async (): Promise<void> => {
setIsLoading(true)

try {
Expand Down Expand Up @@ -125,9 +125,9 @@ const useCardGeneratorSelfService = (): UseCardGeneratorSelfServiceReturn => {
} catch (error) {
handleErrors(error)
}
}, [selfServiceCards, projectConfig, setIsLoading, setSelfServiceCards, setDeepLink, setCode])
}, [projectConfig, setIsLoading, setDeepLink, setCode, createCardsSelfService, handleErrors, selfServiceCards])

const downloadPdf = async (code: CreateCardsResult, fileName: string) => {
const downloadPdf = async (code: CreateCardsResult, fileName: string): Promise<void> => {
const blob = await generatePdf([code], selfServiceCards, projectConfig.pdf)
downloadDataUri(blob, fileName)
}
Expand Down
2 changes: 1 addition & 1 deletion administration/src/cards/PdfFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export async function generatePdf(
cardBlueprints: CardBlueprint[],
pdfConfig: PdfConfig,
region?: Region
):Promise<Blob> {
): Promise<Blob> {
try {
const doc = await PDFDocument.create()

Expand Down
4 changes: 2 additions & 2 deletions administration/src/cards/extensions/BirthdayExtension.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Colors, FormGroup } from '@blueprintjs/core'
import { PartialMessage } from '@bufbuild/protobuf'
import { TextField } from '@mui/material'
import {ReactElement} from "react";
import { ReactElement } from 'react'

import { CardExtensions } from '../../generated/card_pb'
import PlainDate from '../../util/PlainDate'
Expand All @@ -14,7 +14,7 @@ const minBirthday = new PlainDate(1900, 1, 1)
class BirthdayExtension extends Extension<BirthdayState, null> {
public readonly name = BirthdayExtension.name

setInitialState() {
setInitialState(): void {
this.state = { birthday: minBirthday.toDaysSinceEpoch() }
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FormGroup, InputGroup, Intent } from '@blueprintjs/core'
import { PartialMessage } from '@bufbuild/protobuf'
import { ReactElement } from 'react'

import { CardExtensions } from '../../generated/card_pb'
import ClearInputButton from './components/ClearInputButton'
Expand All @@ -13,8 +14,8 @@ const KoblenzReferenceNumberMaxLength = 15
class KoblenzReferenceNumberExtension extends Extension<KoblenzReferenceNumberState, null> {
public readonly name = KoblenzReferenceNumberExtension.name

setInitialState() {}
createForm(onUpdate: () => void, viewportSmall = true) {
setInitialState(): void {}
createForm(onUpdate: () => void, viewportSmall = true): ReactElement {
const clearInput = () => {
this.state = { referenceNumber: '' }
onUpdate()
Expand Down Expand Up @@ -53,31 +54,28 @@ class KoblenzReferenceNumberExtension extends Extension<KoblenzReferenceNumberSt
)
}

causesInfiniteLifetime() {
causesInfiniteLifetime(): boolean {
return false
}
setProtobufData(message: PartialMessage<CardExtensions>) {
setProtobufData(message: PartialMessage<CardExtensions>): void {
message.extensionKoblenzReferenceNumber = {
referenceNumber: this.state?.referenceNumber,
}
}

isValid() {
isValid(): boolean {
return (
this.state !== null &&
this.state.referenceNumber.length >= KoblenzReferenceNumberMinLength &&
this.state.referenceNumber.length <= KoblenzReferenceNumberMaxLength
)
}

fromString(state: string) {
if (state === null) {
this.state = null
}
fromString(state: string): void {
this.state = { referenceNumber: state }
}

toString() {
toString(): string {
return this.state?.referenceNumber ?? ''
}
}
Expand Down
4 changes: 2 additions & 2 deletions administration/src/project-configs/koblenz/activationText.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, Typography, styled } from '@mui/material'
import React from 'react'
import React, { ReactElement } from 'react'

const ActivationButton = styled(Button)`
margin-top: 12px;
Expand All @@ -8,7 +8,7 @@ const ActivationButton = styled(Button)`
}
`

export const ActivationText = (applicationName: string, downloadLink: string, deepLink: string) => (
export const ActivationText = (applicationName: string, downloadLink: string, deepLink: string): ReactElement => (
<div>
<Typography variant='h6' mb='8px'>
Aktivierung nur in der App möglich
Expand Down

0 comments on commit 1ef5a0f

Please sign in to comment.