From 67c3764864099461b77aae0ce408a8a27763628c Mon Sep 17 00:00:00 2001 From: Loi Phan Date: Thu, 30 Nov 2023 08:44:27 +0700 Subject: [PATCH] Update section comments --- hotel-management/src/helpers/helper.ts | 12 ++++++++++++ hotel-management/src/services/bookingServices.ts | 13 +++++++++---- hotel-management/src/services/roomServices.ts | 9 +++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/hotel-management/src/helpers/helper.ts b/hotel-management/src/helpers/helper.ts index 5f88c70..9aae61c 100644 --- a/hotel-management/src/helpers/helper.ts +++ b/hotel-management/src/helpers/helper.ts @@ -10,6 +10,13 @@ const formatCurrency = (value: number): string => { }).format(value); }; + +/** + * Calculate the day durations + * @param startDate The start of date + * @param endDate The end of date + * @returns The number of days between 2 date input + */ const getDayDiff = (startDate: Date, endDate: Date): number => { const msInDay = 24 * 60 * 60 * 1000; @@ -18,6 +25,11 @@ const getDayDiff = (startDate: Date, endDate: Date): number => { ); } +/** + * Convert from currency string to the number + * @param currency The currency string + * @returns The number + */ const convertCurrencyToNumber = (currency: string) => { return Number(currency.replace(/[^0-9.-]+/g,"")) } diff --git a/hotel-management/src/services/bookingServices.ts b/hotel-management/src/services/bookingServices.ts index 68b719f..b8cac0e 100644 --- a/hotel-management/src/services/bookingServices.ts +++ b/hotel-management/src/services/bookingServices.ts @@ -82,8 +82,8 @@ const updateBooking = async (booking: IBooking): Promise => { }; /** - * Add room to database - * @param room The room object need to be add + * Add booking to database + * @param booking The booking object need to be add */ const createBooking = async (booking: IBooking): Promise => { const { data, error: createBookingError } = await supabase @@ -101,8 +101,8 @@ const createBooking = async (booking: IBooking): Promise => { }; /** - * Delete room in database - * @param idRoom The id of room need to delete + * Delete booking in database + * @param idRoom The id of booking need to delete */ const deleteBooking = async (idBooking: number) => { const { error } = await supabase @@ -116,6 +116,11 @@ const deleteBooking = async (idBooking: number) => { } }; +/** + * Check out booking services + * @param param0 The ICheckOutBooking object + * @returns The data of booking after insert to database + */ const checkOutBooking = async ({ idBooking, roomId, diff --git a/hotel-management/src/services/roomServices.ts b/hotel-management/src/services/roomServices.ts index ac08893..e660376 100644 --- a/hotel-management/src/services/roomServices.ts +++ b/hotel-management/src/services/roomServices.ts @@ -107,6 +107,11 @@ const deleteRoom = async (idRoom: number) => { } }; +/** + * Get room by id in database + * @param idRoom The id room need to be get + * @returns The data of room + */ const getRoomById = async (idRoom: string): Promise => { const { data, error } = await supabase .from(ROOMS_TABLE) @@ -122,6 +127,10 @@ const getRoomById = async (idRoom: string): Promise => { return data; }; +/** + * + * @returns + */ const getRoomsAvailable = async (): Promise => { const { data, error } = await supabase .from(ROOMS_TABLE)