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

Update/parking machines info #247

Merged
merged 4 commits into from
Jun 3, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ParkingMachinesContent from './components/ParkingMachinesContent';
const ParkingMachines = () => {
const options = {
type_name: 'ParkingMachine',
page_size: 500,
page_size: 200,
};

const { showParkingMachines } = useMobilityPlatformContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@ const ParkingMachinesContent = ({ item }) => {
sv: item.address_sv,
};

const formatPrice = price => price.toString().replace('.', ',');
const paymentType = {
fi: item.extra.maksutapa_fi,
en: item.extra.maksutapa_en,
sv: item.extra.maksutapa_sv,
};

const otherInfo = {
fi: item.extra.muu_tieto_fi,
en: item.extra.muu_tieto_en,
sv: item.extra.muu_tieto_sv,
};

const parkingMachineInfo = (
<StyledContainer>
Expand All @@ -33,11 +43,10 @@ const ParkingMachinesContent = ({ item }) => {
</Typography>
</StyledHeaderContainer>
<div>
{item.address_fi ? <TextComponent messageId="mobilityPlatform.content.address" textObj={machineAddress} /> : null}
<TextComponent messageId="mobilityPlatform.content.parkingMachine.location" textObj={item.extra.Sijainti} />
{singleValText('mobilityPlatform.content.parkingMachine.payment', formatPrice(item.extra['Taksa/h']))}
<TextComponent messageId="mobilityPlatform.content.parkingMachine.paymentTypes" textObj={item.extra.Maksutapa} />
{item.extra.Muuta ? singleValText('mobilityPlatform.content.parkingMachine.otherInfo', item.extra.Muuta) : null}
{item?.address_fi ? <TextComponent messageId="mobilityPlatform.content.address" textObj={machineAddress} /> : null}
{singleValText('mobilityPlatform.content.parkingMachine.payment', item?.extra?.taksa)}
<TextComponent messageId="mobilityPlatform.content.parkingMachine.paymentTypes" textObj={paymentType} />
{item?.extra?.muu_tieto_fi ? <TextComponent messageId="mobilityPlatform.content.parkingMachine.otherInfo" textObj={otherInfo} /> : null}
</div>
</StyledContainer>
);
Expand All @@ -55,10 +64,13 @@ ParkingMachinesContent.propTypes = {
address_en: PropTypes.string,
address_sv: PropTypes.string,
extra: PropTypes.shape({
Sijainti: PropTypes.objectOf(PropTypes.string),
Maksutapa: PropTypes.objectOf(PropTypes.string),
'Taksa/h': PropTypes.number,
Muuta: PropTypes.string,
maksutapa_fi: PropTypes.string,
maksutapa_en: PropTypes.string,
maksutapa_sv: PropTypes.string,
taksa: PropTypes.string,
muu_tieto_fi: PropTypes.string,
muu_tieto_en: PropTypes.string,
muu_tieto_sv: PropTypes.string,
}),
}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@ const mockProps = {
address_en: 'address',
address_sv: 'addres',
extra: {
Sijainti: {
en: 'On-street',
fi: 'Katuosa',
sv: 'Gata',
},
'Taksa/h': '1.8',
Maksutapa: {
en: 'Coin, card, contactless',
fi: 'Kolikko, kortti, lähimaksu',
sv: 'Mynt, kort, kontaktlös',
},
Muuta: 'Testiteksti',
taksa: '0,5 €/h',
maksutapa_en: 'Coin, card, contactless',
maksutapa_fi: 'Kolikko, kortti, lähimaksu',
maksutapa_sv: 'Mynt, kort, kontaktlös',
muu_tieto_en: 'Tariff 0,5 €/h first 8h, 0,2 €/h time over 8h',
muu_tieto_fi: 'Taksa 0,5€/h ensimmäiset 8h, 0,2€/h aika yli 8h',
muu_tieto_sv: 'Taxa 0,5 €/t första 8t, 0,2 €/t efter 8t',
},
},
};
Expand All @@ -44,9 +39,8 @@ describe('<ParkingMachinesContent />', () => {
const p = container.querySelectorAll('p');
expect(h3[0].textContent).toContain(finnishTranslations['mobilityPlatform.content.parkingMachine.title']);
expect(p[0].textContent).toContain(`Osoite: ${mockProps.item.address_fi}`);
expect(p[1].textContent).toContain(`Sijainti: ${mockProps.item.extra.Sijainti.fi}`);
expect(p[2].textContent).toContain('Maksu: 1,8 €/t');
expect(p[3].textContent).toContain(`Maksutavat: ${mockProps.item.extra.Maksutapa.fi}`);
expect(p[4].textContent).toContain(`Lisätietoja: ${mockProps.item.extra.Muuta}`);
expect(p[1].textContent).toContain('Maksu: 0,5 €/h');
expect(p[2].textContent).toContain(`Maksutavat: ${mockProps.item.extra.maksutapa_fi}`);
expect(p[3].textContent).toContain(`Lisätietoja: ${mockProps.item.extra.muu_tieto_fi}`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,7 @@ exports[`<ParkingMachinesContent /> should match snapshot 1`] = `
<p
class="MuiTypography-root MuiTypography-body2 css-1ak20dk-MuiTypography-root"
>
Sijainti: Katuosa
</p>
</div>
<div
class="css-1fhgjcy"
>
<p
class="MuiTypography-root MuiTypography-body2 css-1ak20dk-MuiTypography-root"
>
Maksu: 1,8 €/t
Maksu: 0,5 €/h
</p>
</div>
<div
Expand All @@ -58,7 +49,7 @@ exports[`<ParkingMachinesContent /> should match snapshot 1`] = `
<p
class="MuiTypography-root MuiTypography-body2 css-1ak20dk-MuiTypography-root"
>
Lisätietoja: Testiteksti
Lisätietoja: Taksa 0,5€/h ensimmäiset 8h, 0,2€/h aika yli 8h
</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ const translations = {
'mobilityPlatform.content.publicParking.totalTime': 'Parking time limit: {value} hours',
'mobilityPlatform.content.parkingMachine.title': 'Parking machine',
'mobilityPlatform.content.parkingMachine.location': 'Location: {value}',
'mobilityPlatform.content.parkingMachine.payment': 'Charge: {value} €/h',
'mobilityPlatform.content.parkingMachine.payment': 'Charge: {value}',
'mobilityPlatform.content.parkingMachine.paymentTypes': 'Payment methods: {value}',
'mobilityPlatform.content.parkingMachine.otherInfo': 'Additional info: {value}',
'mobilityPlatform.content.crosswalks.title': 'Crosswalk',
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/fi.js
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ const translations = {
'mobilityPlatform.content.publicParking.totalTime': 'Pysäköinnin enimmäisaika: {value} tuntia',
'mobilityPlatform.content.parkingMachine.title': 'Pysäköintiautomaatti',
'mobilityPlatform.content.parkingMachine.location': 'Sijainti: {value}',
'mobilityPlatform.content.parkingMachine.payment': 'Maksu: {value} €/t',
'mobilityPlatform.content.parkingMachine.payment': 'Maksu: {value}',
'mobilityPlatform.content.parkingMachine.paymentTypes': 'Maksutavat: {value}',
'mobilityPlatform.content.parkingMachine.otherInfo': 'Lisätietoja: {value}',
'mobilityPlatform.content.crosswalks.title': 'Suojatie',
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/sv.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ const translations = {
'mobilityPlatform.content.publicParking.totalTime': 'Parkeringstidsgräns: {value} timmar',
'mobilityPlatform.content.parkingMachine.title': 'Parkeringsautomat',
'mobilityPlatform.content.parkingMachine.location': 'Plats: {value}',
'mobilityPlatform.content.parkingMachine.payment': 'För en avgift: {value} €/h',
'mobilityPlatform.content.parkingMachine.payment': 'För en avgift: {value}',
'mobilityPlatform.content.parkingMachine.paymentTypes': 'Betalningstyper: {value}',
'mobilityPlatform.content.parkingMachine.otherInfo': 'Ytterligare info: {value}',
'mobilityPlatform.content.crosswalks.title': 'Övergångställe',
Expand Down
Loading