format
This commit is contained in:
@@ -86,7 +86,10 @@ export async function callTools(
|
||||
}
|
||||
|
||||
if (tripPlan.listAccommodations) {
|
||||
ui.write("accommodations-list", getAccommodationsListProps(state.tripDetails));
|
||||
ui.write(
|
||||
"accommodations-list",
|
||||
getAccommodationsListProps(state.tripDetails),
|
||||
);
|
||||
}
|
||||
if (tripPlan.bookAccommodation && tripPlan.accommodationName) {
|
||||
ui.write("book-accommodation", {
|
||||
|
||||
@@ -17,7 +17,8 @@ export function getAccommodationsListProps(tripDetails: TripDetails) {
|
||||
"https://a0.muscache.com/im/pictures/11bcbeec-749c-4897-8593-1ec6f6dc04ad.jpg?im_w=720&im_format=avif",
|
||||
"https://a0.muscache.com/im/pictures/prohost-api/Hosting-18327626/original/fba2e4e8-9d68-47a8-838e-dab5353e5209.jpeg?im_w=720&im_format=avif",
|
||||
"https://a0.muscache.com/im/pictures/miso/Hosting-813949239894880001/original/b2abe806-b60f-4c0b-b4e6-46808024e5b6.jpeg?im_w=720&im_format=avif",
|
||||
"https://a0.muscache.com/im/pictures/prohost-api/Hosting-894877242638354447/original/29e50d48-1733-4c5b-9068-da4443dd7757.jpeg?im_w=720&im_format=avif",,
|
||||
"https://a0.muscache.com/im/pictures/prohost-api/Hosting-894877242638354447/original/29e50d48-1733-4c5b-9068-da4443dd7757.jpeg?im_w=720&im_format=avif",
|
||||
,
|
||||
"https://a0.muscache.com/im/pictures/hosting/Hosting-1079897686805296552/original/b24bd803-52f2-4ca7-9389-f73c9d9b3c64.jpeg?im_w=720&im_format=avif",
|
||||
"https://a0.muscache.com/im/pictures/miso/Hosting-43730011/original/29f90186-4f83-408a-89ce-a82e520b4e36.png?im_w=720&im_format=avif",
|
||||
"https://a0.muscache.com/im/pictures/300ae0e1-fc7e-4a05-93a4-26809311ef19.jpg?im_w=720&im_format=avif",
|
||||
@@ -37,20 +38,22 @@ export function getAccommodationsListProps(tripDetails: TripDetails) {
|
||||
"https://a0.muscache.com/im/pictures/ecbfed18-29d0-4f86-b6aa-4325b076dfb3.jpg?im_w=720&im_format=avif",
|
||||
"https://a0.muscache.com/im/pictures/prohost-api/Hosting-52443635/original/05f084c6-60d0-4945-81ff-d23dfb89c3ca.jpeg?im_w=720&im_format=avif",
|
||||
];
|
||||
|
||||
|
||||
const getAccommodations = (city: string): Accommodation[] => {
|
||||
// Shuffle the image URLs array and take the first 6
|
||||
const shuffledImages = [...IMAGE_URLS]
|
||||
.sort(() => Math.random() - 0.5)
|
||||
.slice(0, 6)
|
||||
.filter((i): i is string => typeof i === "string")
|
||||
|
||||
.filter((i): i is string => typeof i === "string");
|
||||
|
||||
return Array.from({ length: 6 }, (_, index) => ({
|
||||
id: faker.string.uuid(),
|
||||
name: faker.location.streetAddress(),
|
||||
price: faker.number.int({ min: 100, max: 1000 }),
|
||||
rating: Number(
|
||||
faker.number.float({ min: 4.0, max: 5.0, fractionDigits: 2 }).toFixed(2),
|
||||
faker.number
|
||||
.float({ min: 4.0, max: 5.0, fractionDigits: 2 })
|
||||
.toFixed(2),
|
||||
),
|
||||
city: city,
|
||||
image: shuffledImages[index],
|
||||
@@ -60,5 +63,5 @@ export function getAccommodationsListProps(tripDetails: TripDetails) {
|
||||
return {
|
||||
tripDetails,
|
||||
accommodations: getAccommodations(tripDetails.location),
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -103,7 +103,9 @@ function SelectedAccommodation({
|
||||
<StarSVG fill="black" />
|
||||
{accommodation.rating}
|
||||
</span>
|
||||
<p className="text-gray-600">{capitalizeSentence(accommodation.city)}</p>
|
||||
<p className="text-gray-600">
|
||||
{capitalizeSentence(accommodation.city)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="space-y-2 text-sm text-gray-600">
|
||||
<div className="flex justify-between">
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
* Capitalizes the first letter of each word in a string.
|
||||
*/
|
||||
export function capitalizeSentence(string: string): string {
|
||||
return string.split(' ').map(word => {
|
||||
return word.charAt(0).toUpperCase() + word.slice(1);
|
||||
}).join(' ');
|
||||
return string
|
||||
.split(" ")
|
||||
.map((word) => {
|
||||
return word.charAt(0).toUpperCase() + word.slice(1);
|
||||
})
|
||||
.join(" ");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user