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

1082: Prefill card form from query params #1089

Merged
merged 4 commits into from
Aug 18, 2023

Conversation

sarahsporck
Copy link
Contributor

A few examples:

// bayern
localhost:3000/cards/add?Name=Thea+Test&Ablaufdatum=03.3.2026&Kartentyp=Standard
localhost:3000/cards/add?Name=Thea+Test&Kartentyp=Goldkarte
localhost:3000/cards/add?Name=Rolf+Rügen
localhost:3000/cards/add?Nam=Rolf+Rügen

// nürnberg
localhost:3000/cards/add?Name=Thea+Test&Ablaufdatum=03.3.2026&Geburtsdatum=01.01.2000&Passnummer=12345678&Pass-ID=123
localhost:3000/cards/add?Name=Thea+Test&Ablaufdatum=03.3.2026&Geburtsdatum=01.01.2000&Passnummer=12345678&Pass-ID=123&Adresszeile+1=Teststraße+3
localhost:3000/cards/add?Name=Thea+Test&Ablaufdatum=fehler&Geburtsdatum=fehler&Passnummer=abc&Pass-ID=abc

I'd really like to add tests for this, but I think we need to migrate to jest for this.
Mind that you can now cheesily set the Adressvalues, when passing them as query params, but I don't think we need to prohibit that, as it (1) adds more complexity to this and (2) will be unknown to our users as long as we don't tell them :D

@sarahsporck sarahsporck linked an issue Aug 17, 2023 that may be closed by this pull request
@sarahsporck sarahsporck changed the title 1082: Prefill card form by query params 1082: Prefill card form from query params Aug 17, 2023
Copy link
Contributor

@f1sh1918 f1sh1918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on chrome! Works fine to me :)

If i'm right there shouldn't be additional effort for the starting date (my pr) since this is an extension

cardBlueprint.setValue(header, value)
})
setCardBlueprints([cardBlueprint])
setSearchParams()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm it might be better to clean the searchParams after creating barcodes?
On the other hand f.e. a logout doesn't trigger cleaning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it makes sense to remove the searchParams imediately to not accidentally refill the form with values. So I'd keep it.

@@ -42,6 +44,24 @@ type CreateCardsFormProps = {

const CreateCardsForm = ({ region, cardBlueprints, setCardBlueprints }: CreateCardsFormProps) => {
const projectConfig = useContext(ProjectConfigContext)
// http://localhost:3000/cards/add?name=Thea+Test&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

@@ -69,6 +88,15 @@ export class CardBlueprint {
return this.expirationDate !== null && this.expirationDate.isAfter(today)
}

setExpirationDate = (value: string) => {
if (value.length === 0) return null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (value.length === 0) return null
if (value.length === 0) return

i think this should be fine without null

@sarahsporck sarahsporck enabled auto-merge August 18, 2023 06:26
@sarahsporck sarahsporck merged commit 73e48c8 into main Aug 18, 2023
@sarahsporck sarahsporck deleted the 1082-sozialpass-query-params-for-card-creation branch August 18, 2023 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Sozialpass] Query params for card creation
2 participants