Skip to content

Commit

Permalink
Updated createTimestamp.ts and removed eslint.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
Clerise Swart committed Nov 19, 2024
1 parent a584901 commit 8e73efa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 37 deletions.
6 changes: 0 additions & 6 deletions .idea/jsLinters/eslint.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
<template>
<div>
<b class="mp-block" v-text="translate(OPENING_HOURS)" />

<div v-if="openingHours.length === 0" class="mp-content-between" v-text="translate(CLOSED)">
</div>

<div v-for="hours in openingHours" :key="hours.weekday" class="mp-content-between mp-gap-1 mp-grid mp-grid-cols-2">
<b
class="mp-block"
v-text="translate(OPENING_HOURS)" />

<div
v-if="openingHours.length === 0"
class="mp-content-between"
v-text="translate(CLOSED)"></div>

<div
v-for="hours in openingHours"
:key="hours.weekday"
class="mp-content-between mp-gap-1 mp-grid mp-grid-cols-2">
<span v-text="translate(hours.weekday)" />
<span class="mp-text-nowrap" v-text="hours.timeString === CLOSED ? translate(CLOSED) : hours.timeString" />
<span
class="mp-text-nowrap"
v-text="hours.timeString === CLOSED ? translate(CLOSED) : hours.timeString" />
</div>
</div>
</template>

<script lang="ts" setup>
import { computed, toRef } from 'vue';
import { OPENING_HOURS, CLOSED } from '@myparcel-do/shared';
import { useLanguage, usePickupLocation } from '../../../../composables';
import {computed, toRef} from 'vue';
import {OPENING_HOURS, CLOSED} from '@myparcel-do/shared';
import {useLanguage, usePickupLocation} from '../../../../composables';
const props = defineProps<{ locationCode: string; expanded?: boolean }>();
const props = defineProps<{locationCode: string; expanded?: boolean}>();
const { translate } = useLanguage();
const {translate} = useLanguage();
const locationCodeRef = toRef(props, 'locationCode');
const { pickupLocation } = usePickupLocation(locationCodeRef);
const weekDaysMap = [
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday',
];
const {pickupLocation} = usePickupLocation(locationCodeRef);
const weekDaysMap = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
const openingHours = computed(() => {
const location = pickupLocation.value;
const openingHoursData = location?.openingHours || [];
const openingHoursData = pickupLocation.value?.openingHours ?? [];
return weekDaysMap.map((day, index) => {
const dayData = openingHoursData.find((entry: { weekday: number }) => entry.weekday === index);
const dayData = openingHoursData.find((entry: {weekday: number}) => entry.weekday === index);
if (dayData?.hours && dayData.hours.length > 0) {
const times = dayData.hours[0];
Expand Down
11 changes: 6 additions & 5 deletions libs/shared/src/utils/createTimestamp.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {format} from 'date-fns';
import {type DateLike, normalizeDate} from '@vueuse/core';
import {type Timestamp} from '@myparcel/sdk';
import {API_DATE_FORMAT} from '../data';
import {API_DATE_FORMAT, DEFAULT_TIMEZONE_TYPE, DEFAULT_TIMEZONE} from '../data';

export const createTimestamp = (date: DateLike = new Date()): Timestamp => {
export const createTimestamp = (
date: DateLike = new Date(),
): {date: string; timezone: string; timezone_type: number} => {

Check warning on line 7 in libs/shared/src/utils/createTimestamp.ts

View check run for this annotation

Codecov / codecov/patch

libs/shared/src/utils/createTimestamp.ts#L6-L7

Added lines #L6 - L7 were not covered by tests
return {
date: format(normalizeDate(date), API_DATE_FORMAT),
timezone: 'GMT',
timezone_type: 0,
timezone: DEFAULT_TIMEZONE,
timezone_type: DEFAULT_TIMEZONE_TYPE,
};
};

0 comments on commit 8e73efa

Please sign in to comment.