-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1430: Extend card add params (#1803)
* 1430: Add extendable field to the card verification result * 1430: Extend card notification * 1430: Refactor CardQueryService * 1430: Adjust translations * 1430: Adjust translations and text style * 1430: Use FilledButton instead of ElevatedButton * Remove extra line break in the Koblenz publisher text * 1430: Add elevation to the extend card notification * 1430: add queryParams to card extension buttons * 1430: pass each key separate to avoid linting issues, add tests, add workaround to fix display of more actions button * 1430: fix formatting * 1430: add projectId check * 1430: rename params, adjust getApplicationUrl function, add todo for test improvements, only add queryParams if card is extendable * 1430: fix minor issues --------- Co-authored-by: seluianova <[email protected]> Co-authored-by: Tory <[email protected]>
- Loading branch information
1 parent
57bddc0
commit 014ef5d
Showing
13 changed files
with
157 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:ehrenamtskarte/build_config/build_config.dart'; | ||
import 'package:ehrenamtskarte/configuration/definitions.dart'; | ||
import 'package:ehrenamtskarte/configuration/settings_model.dart'; | ||
import 'package:ehrenamtskarte/identification/util/card_info_utils.dart'; | ||
import 'package:ehrenamtskarte/proto/card.pb.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
String getApplicationUrl(BuildContext context) { | ||
final isStagingEnabled = Provider.of<SettingsModel>(context, listen: false).enableStaging; | ||
final applicationUrl = buildConfig.applicationUrl; | ||
if (isStagingEnabled) { | ||
return applicationUrl.staging; | ||
} | ||
return isProduction() ? applicationUrl.production : applicationUrl.local; | ||
} | ||
|
||
String getApplicationUrlForCardExtension(String applicationUrl, CardInfo cardInfo, String? applicationQueryKeyName, | ||
String? applicationQueryKeyBirthday, String? applicationQueryKeyReferenceNumber) { | ||
if (applicationQueryKeyName != null && | ||
applicationQueryKeyBirthday != null && | ||
applicationQueryKeyReferenceNumber != null) { | ||
final parsedUrl = Uri.parse(applicationUrl); | ||
final queryParams = { | ||
applicationQueryKeyName: cardInfo.fullName, | ||
applicationQueryKeyBirthday: getFormattedBirthday(cardInfo), | ||
applicationQueryKeyReferenceNumber: cardInfo.extensions.hasExtensionKoblenzReferenceNumber() | ||
? cardInfo.extensions.extensionKoblenzReferenceNumber.referenceNumber | ||
: null, | ||
}; | ||
return parsedUrl.replace(queryParameters: queryParams).toString(); | ||
} | ||
return applicationUrl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'package:ehrenamtskarte/proto/card.pb.dart'; | ||
import 'package:ehrenamtskarte/util/get_application_url.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('getApplicationUrlForCardExtension', () { | ||
test('results in url with queryParams for koblenz', () { | ||
final applicationUrl = 'https://koblenz.sozialpass.app/erstellen'; | ||
final applicationUrlQueryKeyName = 'Name'; | ||
final applicationUrlQueryKeyBirthday = 'Geburtsdatum'; | ||
final applicationUrlQueryKeyReferenceNumber = 'Referenznummer'; | ||
final cardInfo = CardInfo() | ||
..fullName = 'Karla Koblenz' | ||
..expirationDay = 365 * 40 // Equals 14.600 | ||
..extensions = (CardExtensions() | ||
..extensionBirthday = (BirthdayExtension()..birthday = -365 * 10) | ||
..extensionKoblenzReferenceNumber = (KoblenzReferenceNumberExtension()..referenceNumber = '123K')); | ||
final applicationUrlWithParameters = getApplicationUrlForCardExtension(applicationUrl, cardInfo, | ||
applicationUrlQueryKeyName, applicationUrlQueryKeyBirthday, applicationUrlQueryKeyReferenceNumber); | ||
expect(applicationUrlWithParameters, | ||
'https://koblenz.sozialpass.app/erstellen?Name=Karla+Koblenz&Geburtsdatum=04.01.1960&Referenznummer=123K'); | ||
}); | ||
|
||
test('results in url without queryParams if no keys were provided and card info bayern', () { | ||
final applicationUrl = 'https://bayern.ehrenamtskarte.app/beantragen'; | ||
final String? applicationUrlQueryKeyName = null; | ||
final String? applicationUrlQueryKeyBirthday = null; | ||
final String? applicationUrlQueryKeyReferenceNumber = null; | ||
final cardInfo = CardInfo() | ||
..fullName = 'Max Mustermann' | ||
..expirationDay = 365 * 40 // Equals 14.600 | ||
..extensions = (CardExtensions() | ||
..extensionRegion = (RegionExtension()..regionId = 16) | ||
..extensionBavariaCardType = (BavariaCardTypeExtension()..cardType = BavariaCardType.STANDARD)); | ||
final applicationUrlWithParameters = getApplicationUrlForCardExtension(applicationUrl, cardInfo, | ||
applicationUrlQueryKeyName, applicationUrlQueryKeyBirthday, applicationUrlQueryKeyReferenceNumber); | ||
expect(applicationUrlWithParameters, 'https://bayern.ehrenamtskarte.app/beantragen'); | ||
}); | ||
|
||
test('results in url without queryParams if no keys were provided and card info nuernberg', () { | ||
final applicationUrl = 'https://beantragen.nuernberg.sozialpass.app'; | ||
final String? applicationUrlQueryKeyName = null; | ||
final String? applicationUrlQueryKeyBirthday = null; | ||
final String? applicationUrlQueryKeyReferenceNumber = null; | ||
final cardInfo = CardInfo() | ||
..fullName = 'Max Mustermann' | ||
..expirationDay = 365 * 40 // Equals 14.600 | ||
..extensions = (CardExtensions() | ||
..extensionRegion = (RegionExtension()..regionId = 93) | ||
..extensionBirthday = (BirthdayExtension()..birthday = -365 * 10) | ||
..extensionNuernbergPassId = (NuernbergPassIdExtension()..passId = 99999999) | ||
..extensionStartDay = (StartDayExtension()..startDay = 365 * 2)); | ||
final applicationUrlWithParameters = getApplicationUrlForCardExtension(applicationUrl, cardInfo, | ||
applicationUrlQueryKeyName, applicationUrlQueryKeyBirthday, applicationUrlQueryKeyReferenceNumber); | ||
expect(applicationUrlWithParameters, 'https://beantragen.nuernberg.sozialpass.app'); | ||
}); | ||
}); | ||
} |