commit f4265ebd9bac59285c6bc96e4a598258039bf9d1
parent 02fa0aedbdd8700f3c63c10d7aa3fbb1c3f2a37c
Author: Sebastian <sebasjm@gmail.com>
Date: Mon, 14 Apr 2025 11:43:50 -0300
change CONTACT_PERSON_NAME to CONTACT_NAME
Diffstat:
2 files changed, 62 insertions(+), 45 deletions(-)
diff --git a/packages/challenger-ui/src/pages/AnswerChallenge.tsx b/packages/challenger-ui/src/pages/AnswerChallenge.tsx
@@ -75,10 +75,10 @@ export function getAddressDescriptionFromAddrType(type: ChallengerApi.Challenger
return addr[TalerFormAttributes.CONTACT_PHONE];
}
case "postal": {
- return addr[TalerFormAttributes.ADDRESS_ZIPCODE];
+ return addr[TalerFormAttributes.CONTACT_NAME];
}
case "postal-ch": {
- return addr[TalerFormAttributes.ADDRESS_ZIPCODE];
+ return addr[TalerFormAttributes.CONTACT_NAME];
}
}
@@ -202,12 +202,12 @@ export function AnswerChallenge({
<p class="mt-2 text-lg leading-8 text-gray-600">
{!lastStatus || !deadline || AbsoluteTime.isExpired(deadline) ? (
<i18n.Translate>
- Last TAN code was sent to your address "{lastAddr}
+ Last TAN code was sent to "{lastAddr}
" is not valid anymore.
</i18n.Translate>
) : (
<Attention
- title={i18n.str`A TAN code was sent to your address "${lastAddr}"`}
+ title={i18n.str`A TAN code was sent to "${lastAddr}"`}
>
<i18n.Translate>
You should wait until "
diff --git a/packages/challenger-ui/src/pages/AskChallenge.tsx b/packages/challenger-ui/src/pages/AskChallenge.tsx
@@ -142,7 +142,7 @@ export function AskChallenge({
i18n,
config.address_type,
config.restrictions ?? {},
- lastStatus.last_address ?? {}
+ lastStatus.last_address ?? {},
);
const form = useForm(design, lastStatus.last_address ?? {});
@@ -496,11 +496,11 @@ Grunerstraße 1
country_name `;
export const EMAIL_REGEX = /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/;
-export const PHONE_REGEX = /^(\+\d{1,2}\s?)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/;
-export const CONTACT_REGEX = /.*/
-export const ZIPCODE_REGEX = /.*/
-export const ADDR_LINES_REGEX = /.*/
-
+export const PHONE_REGEX =
+ /^(\+\d{1,2}\s?)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/;
+export const CONTACT_REGEX = /.*/;
+export const ZIPCODE_REGEX = /.*/;
+export const ADDR_LINES_REGEX = /.*/;
function getFormDesignBasedOnAddressType(
i18n: InternationalizationAPI,
@@ -508,7 +508,6 @@ function getFormDesignBasedOnAddressType(
restrictions: Record<string, ChallengerApi.Restriction | undefined>,
prevValue: Record<string, string>,
): FormDesign {
-
function getRestriction(
serverConfig: ChallengerApi.Restriction | undefined,
fallback?: RegExp,
@@ -517,7 +516,7 @@ function getFormDesignBasedOnAddressType(
serverConfig && serverConfig.regex ? serverConfig.regex : undefined;
const hint =
serverConfig && serverConfig.hint
- ? serverConfig.hint as TranslatedString
+ ? (serverConfig.hint as TranslatedString)
: i18n.str`Invalid field`;
let regex;
@@ -553,15 +552,18 @@ function getFormDesignBasedOnAddressType(
required: true,
label: i18n.str`Email`,
validator(text) {
- const restriction = getRestriction(restrictions[TalerFormAttributes.CONTACT_EMAIL], EMAIL_REGEX)
- if (!restriction.regex?.test(text)) {
- return restriction.hint
+ const restriction = getRestriction(
+ restrictions[TalerFormAttributes.CONTACT_EMAIL],
+ EMAIL_REGEX,
+ );
+ if (restriction.regex && !restriction.regex.test(text)) {
+ return restriction.hint;
}
- const prev = prevValue[TalerFormAttributes.CONTACT_EMAIL]
+ const prev = prevValue[TalerFormAttributes.CONTACT_EMAIL];
if (prev === text) {
- return i18n.str`Can't use the same address`
+ return i18n.str`Can't use the same address`;
}
- return undefined
+ return undefined;
},
},
],
@@ -576,15 +578,18 @@ function getFormDesignBasedOnAddressType(
required: true,
label: i18n.str`Phone`,
validator(text) {
- const restriction = getRestriction(restrictions[TalerFormAttributes.CONTACT_PHONE], PHONE_REGEX)
- if (!restriction.regex?.test(text)) {
- return restriction.hint
+ const restriction = getRestriction(
+ restrictions[TalerFormAttributes.CONTACT_PHONE],
+ PHONE_REGEX,
+ );
+ if (restriction.regex && !restriction.regex.test(text)) {
+ return restriction.hint;
}
- const prev = prevValue[TalerFormAttributes.CONTACT_PHONE]
+ const prev = prevValue[TalerFormAttributes.CONTACT_PHONE];
if (prev === text) {
- return i18n.str`Can't use the same number`
+ return i18n.str`Can't use the same number`;
}
- return undefined
+ return undefined;
},
},
],
@@ -600,11 +605,14 @@ function getFormDesignBasedOnAddressType(
label: i18n.str`Contact name`,
placeholder: i18n.str`Person full name or name of the business`,
validator(text) {
- const restriction = getRestriction(restrictions[TalerFormAttributes.CONTACT_NAME], CONTACT_REGEX)
- if (!restriction.regex?.test(text)) {
- return restriction.hint
+ const restriction = getRestriction(
+ restrictions[TalerFormAttributes.CONTACT_NAME],
+ CONTACT_REGEX,
+ );
+ if (restriction.regex && !restriction.regex.test(text)) {
+ return restriction.hint;
}
- return undefined
+ return undefined;
},
},
{
@@ -614,11 +622,14 @@ function getFormDesignBasedOnAddressType(
label: i18n.str`Address`,
placeholder: ADDRESS_EXAMPLE_INTERNATIONAL,
validator(text) {
- const restriction = getRestriction(restrictions[TalerFormAttributes.ADDRESS_LINES], ADDR_LINES_REGEX)
- if (!restriction.regex?.test(text)) {
- return restriction.hint
+ const restriction = getRestriction(
+ restrictions[TalerFormAttributes.ADDRESS_LINES],
+ ADDR_LINES_REGEX,
+ );
+ if (restriction.regex && !restriction.regex.test(text)) {
+ return restriction.hint;
}
- return undefined
+ return undefined;
},
},
{
@@ -629,11 +640,13 @@ function getFormDesignBasedOnAddressType(
required: true,
preferredChoiceVals: ["CH", "DE"],
validator(text) {
- const restriction = getRestriction(restrictions[TalerFormAttributes.ADDRESS_COUNTRY])
- if (!restriction.regex?.test(text)) {
- return restriction.hint
+ const restriction = getRestriction(
+ restrictions[TalerFormAttributes.ADDRESS_COUNTRY],
+ );
+ if (restriction.regex && !restriction.regex.test(text)) {
+ return restriction.hint;
}
- return undefined
+ return undefined;
},
},
],
@@ -645,16 +658,18 @@ function getFormDesignBasedOnAddressType(
fields: [
{
type: "text",
- id: TalerFormAttributes.CONTACT_PERSON_NAME,
+ id: TalerFormAttributes.CONTACT_NAME,
required: true,
label: i18n.str`Contact name`,
placeholder: i18n.str`Your full name`,
validator(text) {
- const restriction = getRestriction(restrictions[TalerFormAttributes.CONTACT_PERSON_NAME])
- if (!restriction.regex?.test(text)) {
- return restriction.hint
+ const restriction = getRestriction(
+ restrictions[TalerFormAttributes.CONTACT_NAME],
+ );
+ if (restriction.regex && !restriction.regex.test(text)) {
+ return restriction.hint;
}
- return undefined
+ return undefined;
},
},
{
@@ -664,11 +679,13 @@ function getFormDesignBasedOnAddressType(
label: i18n.str`Address`,
placeholder: ADDRESS_EXAMPLE_CH,
validator(text) {
- const restriction = getRestriction(restrictions[TalerFormAttributes.ADDRESS_LINES])
- if (!restriction.regex?.test(text)) {
- return restriction.hint
+ const restriction = getRestriction(
+ restrictions[TalerFormAttributes.ADDRESS_LINES],
+ );
+ if (restriction.regex && !restriction.regex.test(text)) {
+ return restriction.hint;
}
- return undefined
+ return undefined;
},
},
],