mirror of
https://github.com/velocitatem/PHANTOM.git
synced 2026-07-15 17:43:36 +00:00
* supabase product proxy and rendering * minor pipeline refactor * refactoring and demand estimation * trackion of date index searching * fixing changes of imports * data seeding * chore: airline basic refactor * feat: huge push of product changes and item review with cart * refactored design * chore: moving route elsewhere and align * fix: build of web/ * chore: fixing paper build * fixing chars
26 lines
775 B
TypeScript
26 lines
775 B
TypeScript
import { HotelProduct, Hotel, transformProduct as transformHotel } from './hotel-utils';
|
|
import { AirlineProduct, Flight, transformProduct as transformFlight } from './airline-utils';
|
|
|
|
export type Product = Hotel | Flight;
|
|
export type ProductRaw = HotelProduct | AirlineProduct;
|
|
|
|
export const isHotelProduct = (p: ProductRaw): p is HotelProduct => {
|
|
return 'room_type' in p;
|
|
};
|
|
|
|
export const isAirlineProduct = (p: ProductRaw): p is AirlineProduct => {
|
|
return 'flight_type' in p;
|
|
};
|
|
|
|
export const transformProduct = (p: ProductRaw): Product => {
|
|
if (isHotelProduct(p)) {
|
|
return transformHotel(p);
|
|
}
|
|
return transformFlight(p);
|
|
};
|
|
|
|
export const getProductType = (p: Product): 'hotel' | 'airline' => {
|
|
if ('roomType' in p) return 'hotel';
|
|
return 'airline';
|
|
};
|