diff --git a/src/components/exchange-rate/ExchangeRate.tsx b/src/components/exchange-rate/ExchangeRate.tsx index 5687e4d..b0716d9 100644 --- a/src/components/exchange-rate/ExchangeRate.tsx +++ b/src/components/exchange-rate/ExchangeRate.tsx @@ -32,7 +32,7 @@ export default function ExchangeRate(props: CurrencyData) { }, [props]); useEffect(() => { - axios.get(`https://visperto.com/api/exchange-rate/?base=${baseCurrency}"e=${props.targetCurrency}`) + axios.get(`${import.meta.env.PUBLIC_API_HOSTNAME}/exchange/?base=${baseCurrency}"e=${props.targetCurrency}`) .then((response) => { const data: ExchangeRate = response.data; const fraction = Number(data[props.targetCurrency]) < 1 ? 5 : 2; diff --git a/src/components/restrictions/Restrictions.tsx b/src/components/restrictions/Restrictions.tsx deleted file mode 100644 index 73c8b26..0000000 --- a/src/components/restrictions/Restrictions.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import { useEffect, useState } from 'preact/hooks'; -import { Fragment } from 'preact'; -import InfoSection from '../info-section/InfoSection'; -import InfoItem from '../info-item/InfoItem'; -import NewsItem from '../news-item/NewsItem'; -import axios from 'axios'; -import type { TravelRestriction } from '../../models.interface'; -import { useStore } from '@nanostores/preact'; -import { countryRestrictionIdStore } from '../../store/countryRestrictionIdStore'; - -export default function Restrictions() { - const [restrictionDetails, setRestrictionDetails] = useState(null); - const [loading, setLoading] = useState(true); - const $countryRestrictionIdStore = useStore(countryRestrictionIdStore); - - - useEffect(() => { - if ($countryRestrictionIdStore) { - axios.get(`${import.meta.env.PUBLIC_API_HOSTNAME}/restriction/${$countryRestrictionIdStore}`) - .then((response) => { - const data: TravelRestriction = response.data; - setRestrictionDetails(data); - setLoading(false); - }).catch(error => console.log(error)); - } - }, [$countryRestrictionIdStore]); - - const getValueColor = (value: string) => { - const transformedValue = value.toLowerCase(); - const danger = ['yes', 'high', 'yes, conditional']; - const warning = ['partial', 'moderate', 'medium']; - if (danger.includes(transformedValue)) { - return 'danger'; - } else if (warning.includes(transformedValue)) { - return 'warning'; - } - } - - return ( - {restrictionDetails && - {restrictionDetails.diseaseRiskLevel.text && - restrictionDetails.areaAccessRestriction.travelTest.isRequired && - restrictionDetails.areaAccessRestriction.declarationDocuments.isRequired && - restrictionDetails.areaAccessRestriction.masks.isRequired && - - - - - - } - {restrictionDetails.summary.text && - - } - } - ); -} diff --git a/src/components/time-and-date/TimeAndDate.tsx b/src/components/time-and-date/TimeAndDate.tsx index 0e0c36c..e4d846e 100644 --- a/src/components/time-and-date/TimeAndDate.tsx +++ b/src/components/time-and-date/TimeAndDate.tsx @@ -1,5 +1,5 @@ -import {useEffect, useState} from "preact/hooks"; -import {Fragment} from "preact"; +import { useEffect, useState } from "preact/hooks"; +import { Fragment } from "preact"; import "./TimeAndDate.css"; import axios from "axios"; import Loading from "../loading/Loading"; @@ -68,4 +68,4 @@ export default function TimeAndDate(props: { timezone: number }) { ); -} \ No newline at end of file +} diff --git a/src/models.interface.ts b/src/models.interface.ts index 8093b18..b892bca 100644 --- a/src/models.interface.ts +++ b/src/models.interface.ts @@ -53,6 +53,8 @@ export interface Country { timezone: { timezone_offset: number; timezone_offset_with_dst: number; + dst_exists: boolean; + is_dst: boolean; } } diff --git a/src/pages/travel/[country].astro b/src/pages/travel/[country].astro index 29dadb3..83b6ef7 100644 --- a/src/pages/travel/[country].astro +++ b/src/pages/travel/[country].astro @@ -8,7 +8,6 @@ import ExchangeRate from '../../components/exchange-rate/ExchangeRate'; import TimeAndDate from '../../components/time-and-date/TimeAndDate'; import InfoItem from '../../components/info-item/InfoItem'; import InfoSection from '../../components/info-section/InfoSection'; -import Restrictions from '../../components/restrictions/Restrictions'; import CountryStats from '../../components/CountryStats.astro'; import {Country} from '../../models.interface'; @@ -29,7 +28,9 @@ export async function getStaticPaths() { flags: country.flags, timezone: { standard: country.timezone.timezone_offset, - daylightSaving: country.timezone.timezone_offset_with_dst + daylightSaving: country.timezone.timezone_offset_with_dst, + dstExists: country.timezone.dst_exists, + isDst: country.timezone.is_dst }, capitalCoordinates: { latitude: country.capitalInfo.latlng[0], @@ -99,7 +100,7 @@ const transformItems = (items: string[]) => { targetCurrencySymbol={targetCurrencySymbol}> + timezone={timezone.isDst ? timezone.daylightSaving : timezone.standard}> @@ -108,7 +109,6 @@ const transformItems = (items: string[]) => { -