Update section comments

This commit is contained in:
2023-11-30 08:44:27 +07:00
parent 139db98283
commit 67c3764864
3 changed files with 30 additions and 4 deletions
+12
View File
@@ -10,6 +10,13 @@ const formatCurrency = (value: number): string => {
}).format(value); }).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 getDayDiff = (startDate: Date, endDate: Date): number => {
const msInDay = 24 * 60 * 60 * 1000; 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) => { const convertCurrencyToNumber = (currency: string) => {
return Number(currency.replace(/[^0-9.-]+/g,"")) return Number(currency.replace(/[^0-9.-]+/g,""))
} }
@@ -82,8 +82,8 @@ const updateBooking = async (booking: IBooking): Promise<IBooking> => {
}; };
/** /**
* Add room to database * Add booking to database
* @param room The room object need to be add * @param booking The booking object need to be add
*/ */
const createBooking = async (booking: IBooking): Promise<IBooking> => { const createBooking = async (booking: IBooking): Promise<IBooking> => {
const { data, error: createBookingError } = await supabase const { data, error: createBookingError } = await supabase
@@ -101,8 +101,8 @@ const createBooking = async (booking: IBooking): Promise<IBooking> => {
}; };
/** /**
* Delete room in database * Delete booking in database
* @param idRoom The id of room need to delete * @param idRoom The id of booking need to delete
*/ */
const deleteBooking = async (idBooking: number) => { const deleteBooking = async (idBooking: number) => {
const { error } = await supabase 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 ({ const checkOutBooking = async ({
idBooking, idBooking,
roomId, roomId,
@@ -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<IRoom> => { const getRoomById = async (idRoom: string): Promise<IRoom> => {
const { data, error } = await supabase const { data, error } = await supabase
.from(ROOMS_TABLE) .from(ROOMS_TABLE)
@@ -122,6 +127,10 @@ const getRoomById = async (idRoom: string): Promise<IRoom> => {
return data; return data;
}; };
/**
*
* @returns
*/
const getRoomsAvailable = async (): Promise<IDataState[]> => { const getRoomsAvailable = async (): Promise<IDataState[]> => {
const { data, error } = await supabase const { data, error } = await supabase
.from(ROOMS_TABLE) .from(ROOMS_TABLE)