Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/actions/StopPlaceActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,16 @@ StopPlaceActions.changeParkingPaymentProcess =
);
};

StopPlaceActions.changeParkingPaymentMethods =
(index, paymentMethods) => (dispatch) => {
dispatch(
createThunk(types.CHANGED_PARKING_PAYMENT_METHODS, {
index,
paymentMethods,
}),
);
};

StopPlaceActions.changeParkingRechargingAvailable =
(index, rechargingAvailable) => (dispatch) => {
dispatch(
Expand Down
2 changes: 2 additions & 0 deletions src/actions/Types.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export const CHANGED_PARKING_SECURE = "CHANGED_PARKING_SECURE";
export const CHANGED_PARKING_LIGHTING = "CHANGED_PARKING_LIGHTING";
export const CHANGED_PARKING_PAYMENT_PROCESS =
"CHANGED_PARKING_PAYMENT_PROCESS";
export const CHANGED_PARKING_PAYMENT_METHODS =
"CHANGED_PARKING_PAYMENT_METHODS";
export const CHANGED_PARKING_RECHARGING_AVAILABLE =
"CHANGED_PARKING_RECHARGING_AVAILABLE";
export const CHANGED_PARKING_NUMBER_OF_SPACES =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ const ParkingItemPayAndRideExpandedFields = (props) => {
.map((key) => {
return formatMessage({
id: `parking_payment_process_${key}`,
defaultMessage: key,
});
})
.join(", ");
Expand All @@ -243,6 +244,7 @@ const ParkingItemPayAndRideExpandedFields = (props) => {
<ListItemText
primary={formatMessage({
id: `parking_payment_process_${key}`,
defaultMessage: key,
})}
secondary={
key === `payByPrepaidToken`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { StopPlaceActions } from "../../../../actions";
import { LightingEnum } from "../../../../models/Lighting";
import { parkingLayouts } from "../../../../models/parkingLayout";
import { parkingPaymentProcesses } from "../../../../models/parkingPaymentProcess";
import { paymentMethods } from "../../../../models/paymentMethod";
import { useAppDispatch } from "../../../../store/hooks";
import { Parking } from "../types";

Expand All @@ -45,7 +46,7 @@ interface ParkAndRideFieldsProps {
}

/**
* All Park-and-Ride–specific fields: layout, payment process, capacity, recharging, accessibility.
* All Park-and-Ride–specific fields: layout, payment process, payment methods, capacity, recharging, accessibility.
* Extracted from ParkingPanel to keep that component within the file size limit.
*/
export const ParkAndRideFields: React.FC<ParkAndRideFieldsProps> = ({
Expand Down Expand Up @@ -173,7 +174,14 @@ export const ParkAndRideFields: React.FC<ParkAndRideFieldsProps> = ({
? formatMessage({ id: "parking_payment_process_undefined" })
: selected
.map((k) =>
formatMessage({ id: `parking_payment_process_${k}` }),
// defaultMessage falls back to the raw enum value so a
// stop place holding a value with no translated label
// still renders something readable instead of an empty
// string.
formatMessage({
id: `parking_payment_process_${k}`,
defaultMessage: k,
}),
)
.join(", ")
}
Expand All @@ -197,6 +205,7 @@ export const ParkAndRideFields: React.FC<ParkAndRideFieldsProps> = ({
<ListItemText
primary={formatMessage({
id: `parking_payment_process_${key}`,
defaultMessage: key,
})}
secondary={
key === "payByPrepaidToken"
Expand All @@ -211,6 +220,57 @@ export const ParkAndRideFields: React.FC<ParkAndRideFieldsProps> = ({
</Select>
</FormControl>

{/* Payment methods (multi-select) */}
<FormControl fullWidth size="small" disabled={fieldDisabled}>
<InputLabel>
{formatMessage({ id: "parking_payment_methods" })}
</InputLabel>
<Select
multiple
value={parking.paymentMethods || []}
label={formatMessage({ id: "parking_payment_methods" })}
renderValue={(selected: string[]) =>
selected.length === 0
? formatMessage({ id: "parking_payment_methods_undefined" })
: selected
.map((k) =>
// defaultMessage falls back to the raw enum value so a
// stop place holding a value with no translated label
// still renders something readable instead of an empty
// string.
formatMessage({
id: `parking_payment_methods_${k}`,
defaultMessage: k,
}),
)
.join(", ")
}
onChange={(e) =>
dispatch(
StopPlaceActions.changeParkingPaymentMethods(
parkingIndex,
e.target.value as string[],
),
)
}
>
{paymentMethods.map((key) => (
<MenuItem key={key} value={key}>
<Checkbox
checked={(parking.paymentMethods || []).indexOf(key) > -1}
size="small"
/>
<ListItemText
primary={formatMessage({
id: `parking_payment_methods_${key}`,
defaultMessage: key,
})}
/>
</MenuItem>
))}
</Select>
</FormControl>

{/* Capacity */}
<Box>
<Typography variant="caption" color="text.secondary">
Expand Down
1 change: 1 addition & 0 deletions src/components/modern/EditStopPage/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export interface Parking {
parkingType?: string;
parkingLayout?: string;
parkingPaymentProcess?: string[];
paymentMethods?: string[];
rechargingAvailable?: boolean | null;
secure?: boolean | null;
lighting?: string | null;
Expand Down
1 change: 1 addition & 0 deletions src/graphql/Tiamat/fragments.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ Fragments.parking = {
}
parkingLayout
parkingPaymentProcess
paymentMethods
rechargingAvailable
secure
lighting
Expand Down
1 change: 1 addition & 0 deletions src/graphql/Tiamat/stopPlaceWithAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ const verboseParkingFragment = gql`
}
parkingLayout
parkingPaymentProcess
paymentMethods
rechargingAvailable
secure
lighting
Expand Down
7 changes: 7 additions & 0 deletions src/modelUtils/mapToClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,13 @@ helpers.changeParkingPaymentProcess = (original, payload) => {
return copy;
};

helpers.changeParkingPaymentMethods = (original, payload) => {
const { index, paymentMethods } = payload;
const copy = JSON.parse(JSON.stringify(original));
copy.parking[index].paymentMethods = paymentMethods;
return copy;
};

helpers.changeParkingRechargingAvailable = (original, payload) => {
const { index, rechargingAvailable } = payload;
const copy = JSON.parse(JSON.stringify(original));
Expand Down
4 changes: 4 additions & 0 deletions src/modelUtils/mapToQueryVariables.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ helpers.mapParkingToVariables = (parkingArr, parentRef) => {
parking.parkingPaymentProcess = source.parkingPaymentProcess;
}

if (source.paymentMethods) {
parking.paymentMethods = source.paymentMethods;
}

if (source.rechargingAvailable !== undefined) {
parking.rechargingAvailable = source.rechargingAvailable;
}
Expand Down
1 change: 1 addition & 0 deletions src/models/Parking.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class Parking {
name: getIn(parking, ["name", "value"], ""),
parkingType: this.parkingType,
parkingPaymentProcess: parking.parkingPaymentProcess,
paymentMethods: parking.paymentMethods,
rechargingAvailable: parking.rechargingAvailable,
numberOfSpaces: this.isParkAndRide ? this.numberOfSpaces : null,
numberOfSpacesWithRechargePoint: this.isParkAndRide
Expand Down
31 changes: 31 additions & 0 deletions src/models/paymentMethod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed under the EUPL, Version 1.2 or – as soon they will be approved by
the European Commission - subsequent versions of the EUPL (the "Licence");
You may not use this work except in compliance with the Licence.
You may obtain a copy of the Licence at:

https://joinup.ec.europa.eu/software/page/eupl

Unless required by applicable law or agreed to in writing, software
distributed under the Licence is distributed on an "AS IS" basis,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Licence for the specific language governing permissions and
limitations under the Licence. */

const paymentMethod = Object.freeze({
cash: "cash",
cashAndCard: "cashAndCard",
coin: "coin",
banknote: "banknote",
creditCard: "creditCard",
debitCard: "debitCard",
cardsOnly: "cardsOnly",
contactlessPaymentCard: "contactlessPaymentCard",
mobilePhone: "mobilePhone",
mobileApp: "mobileApp",
other: "other",
});

export const paymentMethods = Object.values(paymentMethod);

export default paymentMethod;
9 changes: 9 additions & 0 deletions src/reducers/stopPlaceReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,15 @@ const stopPlaceReducer = (state = initialState, action) => {
stopHasBeenModified: true,
});

case types.CHANGED_PARKING_PAYMENT_METHODS:
return Object.assign({}, state, {
current: formatHelpers.changeParkingPaymentMethods(
state.current,
action.payload,
),
stopHasBeenModified: true,
});

case types.CHANGED_PARKING_RECHARGING_AVAILABLE:
return Object.assign({}, state, {
current: formatHelpers.changeParkingRechargingAvailable(
Expand Down
15 changes: 14 additions & 1 deletion src/static/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,20 @@
"parking_number_of_spaces_for_registered_disabled_user_type": "Number of spaces for registered disabled",
"parking_number_of_spaces_with_recharge_point": "Number of spaces with recharge point",
"parking_parkAndRide_capacity_sub_header": "Total capacity",
"parking_payment_process": "Parking payment method",
"parking_payment_methods": "Payment methods",
"parking_payment_methods_banknote": "Banknotes",
"parking_payment_methods_cardsOnly": "Cards only",
"parking_payment_methods_cash": "Cash",
"parking_payment_methods_cashAndCard": "Cash and card",
"parking_payment_methods_coin": "Coins",
"parking_payment_methods_contactlessPaymentCard": "Contactless card",
"parking_payment_methods_creditCard": "Credit card",
"parking_payment_methods_debitCard": "Debit card",
"parking_payment_methods_mobileApp": "Mobile app",
"parking_payment_methods_mobilePhone": "Mobile phone",
"parking_payment_methods_other": "Other",
"parking_payment_methods_undefined": "Undefined",
"parking_payment_process": "Payment process",
"parking_payment_process_free": "Free",
"parking_payment_process_payAndDisplay": "Pay and display",
"parking_payment_process_payByMobileDevice": "Mobile device",
Expand Down
15 changes: 14 additions & 1 deletion src/static/lang/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,20 @@
"parking_number_of_spaces_for_registered_disabled_user_type": "Paikkojen määrä rekisteröidyille liikuntarajoitteisille",
"parking_number_of_spaces_with_recharge_point": "Latauspisteellisten paikkojen määrä",
"parking_parkAndRide_capacity_sub_header": "Kokonaiskapasiteetti",
"parking_payment_process": "Pysäköinnin maksutapa",
"parking_payment_methods": "Maksutavat",
"parking_payment_methods_banknote": "Setelit",
"parking_payment_methods_cardsOnly": "Vain kortit",
"parking_payment_methods_cash": "Käteinen",
"parking_payment_methods_cashAndCard": "Käteinen ja kortti",
"parking_payment_methods_coin": "Kolikot",
"parking_payment_methods_contactlessPaymentCard": "Lähimaksukortti",
"parking_payment_methods_creditCard": "Luottokortti",
"parking_payment_methods_debitCard": "Pankkikortti",
"parking_payment_methods_mobileApp": "Mobiilisovellus",
"parking_payment_methods_mobilePhone": "Matkapuhelin",
"parking_payment_methods_other": "Muu",
"parking_payment_methods_undefined": "Määrittelemätön",
"parking_payment_process": "Maksuprosessi",
"parking_payment_process_free": "Ilmainen",
"parking_payment_process_payAndDisplay": "Maksa ja näytä",
"parking_payment_process_payByMobileDevice": "Mobiililaite",
Expand Down
15 changes: 14 additions & 1 deletion src/static/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,20 @@
"parking_number_of_spaces_for_registered_disabled_user_type": "Nombre de places réservées aux personnes handicapées",
"parking_number_of_spaces_with_recharge_point": "Nombre de places avec borne de recharge",
"parking_parkAndRide_capacity_sub_header": "Capacité",
"parking_payment_process": "Méthode de paiement",
"parking_payment_methods": "Méthodes de paiement",
"parking_payment_methods_banknote": "Billets",
"parking_payment_methods_cardsOnly": "Cartes uniquement",
"parking_payment_methods_cash": "Espèces",
"parking_payment_methods_cashAndCard": "Espèces et carte",
"parking_payment_methods_coin": "Pièces",
"parking_payment_methods_contactlessPaymentCard": "Carte sans contact",
"parking_payment_methods_creditCard": "Carte de crédit",
"parking_payment_methods_debitCard": "Carte de débit",
"parking_payment_methods_mobileApp": "Application mobile",
"parking_payment_methods_mobilePhone": "Téléphone mobile",
"parking_payment_methods_other": "Autre",
"parking_payment_methods_undefined": "Non défini",
"parking_payment_process": "Processus de paiement",
"parking_payment_process_free": "Gratuit",
"parking_payment_process_payAndDisplay": "Paiment par horodateur",
"parking_payment_process_payByMobileDevice": "Paiement mobile",
Expand Down
15 changes: 14 additions & 1 deletion src/static/lang/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,20 @@
"parking_number_of_spaces_for_registered_disabled_user_type": "Antall plasser for forflytningshemmede",
"parking_number_of_spaces_with_recharge_point": "Antall plasser med ladestasjon",
"parking_parkAndRide_capacity_sub_header": "Total kapasitet",
"parking_payment_process": "Betalingsmetode for parkering",
"parking_payment_methods": "Betalingsmetoder",
"parking_payment_methods_banknote": "Sedler",
"parking_payment_methods_cardsOnly": "Kun kort",
"parking_payment_methods_cash": "Kontanter",
"parking_payment_methods_cashAndCard": "Kontanter og kort",
"parking_payment_methods_coin": "Mynt",
"parking_payment_methods_contactlessPaymentCard": "Kontaktløst kort",
"parking_payment_methods_creditCard": "Kredittkort",
"parking_payment_methods_debitCard": "Debetkort",
"parking_payment_methods_mobileApp": "Mobilapp",
"parking_payment_methods_mobilePhone": "Mobiltelefon",
"parking_payment_methods_other": "Annet",
"parking_payment_methods_undefined": "Udefinert",
"parking_payment_process": "Betalingsprosess",
"parking_payment_process_free": "Gratis",
"parking_payment_process_payAndDisplay": "Parkeringslapp",
"parking_payment_process_payByMobileDevice": "Betaling med mobil",
Expand Down
15 changes: 14 additions & 1 deletion src/static/lang/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,20 @@
"parking_number_of_spaces_for_registered_disabled_user_type": "Antal platser för förflyttningshämmade",
"parking_number_of_spaces_with_recharge_point": "Antal platser med laddstation",
"parking_parkAndRide_capacity_sub_header": "Total kapacitet",
"parking_payment_process": "Betalningsmetod för parkering",
"parking_payment_methods": "Betalningsmetoder",
"parking_payment_methods_banknote": "Sedlar",
"parking_payment_methods_cardsOnly": "Endast kort",
"parking_payment_methods_cash": "Kontanter",
"parking_payment_methods_cashAndCard": "Kontanter och kort",
"parking_payment_methods_coin": "Mynt",
"parking_payment_methods_contactlessPaymentCard": "Kontaktlöst kort",
"parking_payment_methods_creditCard": "Kreditkort",
"parking_payment_methods_debitCard": "Betalkort",
"parking_payment_methods_mobileApp": "Mobilapp",
"parking_payment_methods_mobilePhone": "Mobiltelefon",
"parking_payment_methods_other": "Annat",
"parking_payment_methods_undefined": "Odefinerat",
"parking_payment_process": "Betalningsprocess",
"parking_payment_process_free": "Gratis",
"parking_payment_process_payAndDisplay": "Parkeringsbiljett",
"parking_payment_process_payByMobileDevice": "Betalning med mobil",
Expand Down
Loading
Loading