diff --git a/src/components/Card/ScheduleCard/index.tsx b/src/components/Card/ScheduleCard/index.tsx index d417fdf..d063c7c 100644 --- a/src/components/Card/ScheduleCard/index.tsx +++ b/src/components/Card/ScheduleCard/index.tsx @@ -1,7 +1,7 @@ interface DaySchedule { day: 'Sunday' | 'Monday' | 'Tuesday' | 'Wednesday' | 'Thursday' | 'Friday' | 'Saturday'; - open: string; // e.g. "7.00 AM" - close: string; // e.g. "21.00 PM" + open?: string; + close?: string; closed?: boolean; } @@ -21,7 +21,7 @@ function getCurrentDay(): DaySchedule['day'] { function isOpenNow(schedules: DaySchedule[]): boolean { const today = getCurrentDay(); const todaySchedule = schedules.find((s) => s.day === today); - if (!todaySchedule || todaySchedule.closed) return false; + if (!todaySchedule || todaySchedule.closed || !todaySchedule.open || !todaySchedule.close) return false; const now = new Date(); const [openHour, openMin] = todaySchedule.open.replace(/[^0-9.]/g, '').split('.').map(Number); @@ -55,26 +55,30 @@ export function ScheduleCard({ schedules, onSuggestEdit }: ScheduleCardProps) { {/*
*/} -
- {DAYS.map((day) => { - const schedule = schedules.find((s) => s.day === day); - const isToday = day === today; + {schedules.length === 0 ? ( +

No data yet

+ ) : ( +
+ {DAYS.map((day) => { + const schedule = schedules.find((s) => s.day === day); + const isToday = day === today; - return ( -
- {day} - - {!schedule || schedule.closed - ? 'Closed' - : `${schedule.open} - ${schedule.close}`} - -
- ); - })} -
+ return ( +
+ {day} + + {!schedule || schedule.closed + ? 'Closed' + : `${schedule.open} - ${schedule.close}`} + +
+ ); + })} +
+ )} ); } diff --git a/src/datas/popular.json b/src/datas/popular.json index 9fba413..b041b51 100755 --- a/src/datas/popular.json +++ b/src/datas/popular.json @@ -4,6 +4,7 @@ "id": 1, "name": "Warung Sate Kambing", "thumbnail": "https://fatahilaharis.files.wordpress.com/2017/07/wp-1499292117215.jpeg", + "location_type": "culinary", "location": "Bandung", "critic_rating": 78, "visited": 48, @@ -15,6 +16,7 @@ "id": 2, "name": "Pantai Balekambang", "thumbnail": "https://www.nativeindonesia.com/foto/pantai-balekambang/Lokasi-Pura-Yang-Berada-Di-Atas-Pulau-Karang.jpg", + "location_type": "culinary", "location": "Malang", "critic_rating": 82, "visited": 48, @@ -26,6 +28,7 @@ "id": 3, "name": "Bebek Sinjay", "thumbnail": "https://i0.wp.com/harga.web.id/wp-content/uploads/bebek-sinjay-surabaya-1.jpg?resize=680%2C300&ssl=1", + "location_type": "culinary", "location": "Surabaya", "critic_rating": 70, "visited": 48, @@ -37,6 +40,7 @@ "id": 4, "name": "Taman Pelangi", "thumbnail": "https://tempat.org/wp-content/uploads/2016/11/57488321_255018015317182_1189210435487115990_n.jpg", + "location_type": "culinary", "location": "Surabaya", "critic_rating": 75, "visited": 48, @@ -47,6 +51,7 @@ { "id": 5, "thumbnail": "https://ak-d.tripcdn.com/images/1i61t22348mz2uz9cB9FF.jpg?proc=source/trip", + "location_type": "culinary", "name": "Ragunan Zoo", "location": "Jakarta", "critic_rating": 88, @@ -59,6 +64,7 @@ "id": 6, "name": "Sate Lilit Bali", "thumbnail": "https://lh3.googleusercontent.com/p/AF1QipNX3DCZxF8MOuyptvxPGfTT4-KNw0BTEqYqeled=s680-w680-h510", + "location_type": "culinary", "location": "Denpasar", "critic_rating": 83, "visited": 48, diff --git a/src/pages/LocationDetail/index.tsx b/src/pages/LocationDetail/index.tsx index 534687e..69fe333 100755 --- a/src/pages/LocationDetail/index.tsx +++ b/src/pages/LocationDetail/index.tsx @@ -451,15 +451,7 @@ function LocationDetail() {
console.log('suggest edit')} />
diff --git a/src/pages/LocationDetail/types.ts b/src/pages/LocationDetail/types.ts index 8fdea07..b9c9882 100755 --- a/src/pages/LocationDetail/types.ts +++ b/src/pages/LocationDetail/types.ts @@ -1,6 +1,13 @@ import { NullValueRes } from "../../types/common" import { SlideImage } from "yet-another-react-lightbox" +export interface BusinessHourEntry { + day: 'Sunday' | 'Monday' | 'Tuesday' | 'Wednesday' | 'Thursday' | 'Friday' | 'Saturday'; + open?: string; + close?: string; + closed?: boolean; +} + export interface ILocationDetail { id: number, name: string, @@ -8,14 +15,15 @@ export interface ILocationDetail { regency_name: string, province_name: string, location_type: string, - region_name: string, + region_name: string, google_maps_link: string, thumbnail: string | null, submitted_by: number, critic_score: number, critic_count: number, user_score: number, - user_count: number + user_count: number, + business_hours: BusinessHourEntry[] | null, } export function emptyLocationDetail(): ILocationDetail { @@ -34,6 +42,7 @@ export function emptyLocationDetail(): ILocationDetail { critic_count: 0, user_score: 0, user_count: 0, + business_hours: null, } }