Skip to content

Commit

Permalink
fix the timezone problem, remove the travel restrictions info
Browse files Browse the repository at this point in the history
  • Loading branch information
ayaz committed Jul 1, 2024
1 parent ce11277 commit fd6c6b4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 84 deletions.
2 changes: 1 addition & 1 deletion src/components/exchange-rate/ExchangeRate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function ExchangeRate(props: CurrencyData) {
}, [props]);

useEffect(() => {
axios.get(`https://visperto.com/api/exchange-rate/?base=${baseCurrency}&quote=${props.targetCurrency}`)
axios.get(`${import.meta.env.PUBLIC_API_HOSTNAME}/exchange/?base=${baseCurrency}&quote=${props.targetCurrency}`)
.then((response) => {
const data: ExchangeRate = response.data;
const fraction = Number(data[props.targetCurrency]) < 1 ? 5 : 2;
Expand Down
75 changes: 0 additions & 75 deletions src/components/restrictions/Restrictions.tsx

This file was deleted.

8 changes: 4 additions & 4 deletions src/components/time-and-date/TimeAndDate.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -13,7 +13,7 @@ export default function TimeAndDate(props: { timezone: number }) {
const [loading, setLoading] = useState(true);

useEffect(() => {
axios.get(`${import.meta.env.PUBLIC_API_HOSTNAME}/time?offset=${props.timezone}`)
axios.get(`https://visperto-api-time.ayazqv.workers.dev/time?offset=${props.timezone}`)
.then((response) => {
const data: { time: Date } = response.data;
const serverTime = new Date(data.time);
Expand Down Expand Up @@ -68,4 +68,4 @@ export default function TimeAndDate(props: { timezone: number }) {
</div>
</div>
</Fragment>);
}
}
2 changes: 2 additions & 0 deletions src/models.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export interface Country {
timezone: {
timezone_offset: number;
timezone_offset_with_dst: number;
dst_exists: boolean;
is_dst: boolean;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/pages/travel/[country].astro
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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],
Expand Down Expand Up @@ -99,7 +100,7 @@ const transformItems = (items: string[]) => {
targetCurrencySymbol={targetCurrencySymbol}></ExchangeRate>
<TimeAndDate
client:only="preact"
timezone={timezone.standard}></TimeAndDate>
timezone={timezone.isDst ? timezone.daylightSaving : timezone.standard}></TimeAndDate>
</CountryStats>
</div>
<InfoSection title="General information">
Expand All @@ -108,7 +109,6 @@ const transformItems = (items: string[]) => {
<InfoItem icon="capital" title="Capital cities" value={transformItems(capital)}/>
<InfoItem icon="world" title="Languages" value={transformItems(listOfLanguages)}/>
</InfoSection>
<Restrictions client:load/>
</Layout>

<style>
Expand Down

0 comments on commit fd6c6b4

Please sign in to comment.