@travories/frontend-sdk 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +159 -8
- package/dist/index.d.ts +159 -8
- package/dist/index.js +416 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +413 -42
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -214,15 +214,118 @@ var PackagesResource = class {
|
|
|
214
214
|
}
|
|
215
215
|
};
|
|
216
216
|
|
|
217
|
+
// src/api/agencies.ts
|
|
218
|
+
var normalizeImage2 = (img) => ({
|
|
219
|
+
id: img?.id ?? "",
|
|
220
|
+
key: img?.key ?? "",
|
|
221
|
+
type: img?.type ?? "image",
|
|
222
|
+
alt: img?.alt ?? "",
|
|
223
|
+
preview: img?.preview ?? null,
|
|
224
|
+
url: {
|
|
225
|
+
original: img?.url?.original ?? null,
|
|
226
|
+
hero: img?.url?.hero ?? null,
|
|
227
|
+
hero_fit: img?.url?.hero_fit ?? null,
|
|
228
|
+
section: img?.url?.section ?? null,
|
|
229
|
+
portrait: img?.url?.portrait ?? null,
|
|
230
|
+
general: img?.url?.general ?? null,
|
|
231
|
+
jpeg: img?.url?.jpeg ?? null
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
var normalizeAgencyCard = (raw) => ({
|
|
235
|
+
id: raw?.id ?? "",
|
|
236
|
+
title: raw?.title ?? "",
|
|
237
|
+
slug: raw?.slug ?? "",
|
|
238
|
+
agencySlug: raw?.agencySlug ?? "",
|
|
239
|
+
totalDays: Number(raw?.totalDays ?? 0),
|
|
240
|
+
minPrice: Number(raw?.minPrice ?? 0),
|
|
241
|
+
maxPrice: Number(raw?.maxPrice ?? 0),
|
|
242
|
+
rating: Number(raw?.rating ?? 0),
|
|
243
|
+
packageCategory: raw?.packageCategory ?? "",
|
|
244
|
+
thumbnail: normalizeImage2(raw?.thumbnail)
|
|
245
|
+
});
|
|
246
|
+
var AgenciesResource = class {
|
|
247
|
+
constructor(http) {
|
|
248
|
+
this.http = http;
|
|
249
|
+
}
|
|
250
|
+
/** Public profile of an agency by its slug. Null on 404. */
|
|
251
|
+
async getBySlug(slug, options) {
|
|
252
|
+
if (!slug) throw new Error("[TravoriesClient] agencies.getBySlug requires a slug");
|
|
253
|
+
const raw = await this.http.request(`/agency-info/by-slug/${slug}`, {
|
|
254
|
+
silent: true,
|
|
255
|
+
...options
|
|
256
|
+
});
|
|
257
|
+
if (!raw?.hostDetails) return null;
|
|
258
|
+
return {
|
|
259
|
+
success: raw.success,
|
|
260
|
+
message: raw.message,
|
|
261
|
+
hostDetails: {
|
|
262
|
+
...raw.hostDetails,
|
|
263
|
+
logo: raw.hostDetails.logo ? normalizeImage2(raw.hostDetails.logo) : null
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
/** Partner / association badges shown on the agency profile. */
|
|
268
|
+
async getAssociations(slug, options) {
|
|
269
|
+
if (!slug) throw new Error("[TravoriesClient] agencies.getAssociations requires a slug");
|
|
270
|
+
const raw = await this.http.request(
|
|
271
|
+
`/agency-association/agency/slug/${slug}`,
|
|
272
|
+
{ silent: true, ...options }
|
|
273
|
+
);
|
|
274
|
+
if (!Array.isArray(raw)) return [];
|
|
275
|
+
return raw.map((a) => ({
|
|
276
|
+
id: a.id,
|
|
277
|
+
name: a.name,
|
|
278
|
+
url: a.url,
|
|
279
|
+
image: a.image ? normalizeImage2(a.image) : null
|
|
280
|
+
}));
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Packages published by this agency. Returns the same card shape as the home
|
|
284
|
+
* sections so `<PackagesCarousel>` / `<PackageCard>` render them directly.
|
|
285
|
+
*/
|
|
286
|
+
async getPackages(slug, params, options) {
|
|
287
|
+
if (!slug) throw new Error("[TravoriesClient] agencies.getPackages requires a slug");
|
|
288
|
+
const limit = params?.limit ?? 10;
|
|
289
|
+
const page = params?.page ?? 1;
|
|
290
|
+
const raw = await this.http.request(
|
|
291
|
+
`/agency-package/by-agency/${slug}?limit=${limit}&page=${page}`,
|
|
292
|
+
{ silent: true, ...options }
|
|
293
|
+
);
|
|
294
|
+
if (!raw) return [];
|
|
295
|
+
const list = Array.isArray(raw) ? raw : Array.isArray(raw.packages) ? raw.packages : [];
|
|
296
|
+
return list.map(normalizeAgencyCard);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Convenience: fetch the full agency bundle (profile + associations + their
|
|
300
|
+
* packages) in parallel. Drives `<AgencyDetailView />`.
|
|
301
|
+
*/
|
|
302
|
+
async getBundle(slug, params, options) {
|
|
303
|
+
const [agency, associations, packages] = await Promise.all([
|
|
304
|
+
this.getBySlug(slug, options),
|
|
305
|
+
this.getAssociations(slug, options),
|
|
306
|
+
this.getPackages(slug, { limit: params?.packagesLimit ?? 12 }, options)
|
|
307
|
+
]);
|
|
308
|
+
if (!agency?.hostDetails) return null;
|
|
309
|
+
return {
|
|
310
|
+
agency: agency.hostDetails,
|
|
311
|
+
associations,
|
|
312
|
+
packages
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
|
|
217
317
|
// src/client/TravoriesClient.ts
|
|
218
318
|
var TravoriesClient = class {
|
|
219
319
|
constructor(config) {
|
|
220
|
-
|
|
320
|
+
// ---- Convenience shortcuts on the client itself (no need to remember the
|
|
321
|
+
// resource name for the common one-shot lookups). -------------------
|
|
221
322
|
this.getPackageBySlug = (slug) => this.packages.getBySlug(slug);
|
|
222
|
-
/** Shortcut for `client.packages.getBundle(slug)` — package + host + attractions in one call. */
|
|
223
323
|
this.getPackageBundle = (slug) => this.packages.getBundle(slug);
|
|
324
|
+
this.getAgencyBySlug = (slug) => this.agencies.getBySlug(slug);
|
|
325
|
+
this.getAgencyBundle = (slug) => this.agencies.getBundle(slug);
|
|
224
326
|
this.http = new HttpClient(config);
|
|
225
327
|
this.packages = new PackagesResource(this.http);
|
|
328
|
+
this.agencies = new AgenciesResource(this.http);
|
|
226
329
|
}
|
|
227
330
|
};
|
|
228
331
|
function createTravoriesClient(config) {
|
|
@@ -330,6 +433,40 @@ function useHomeSections(client) {
|
|
|
330
433
|
}, [client]);
|
|
331
434
|
return { data, loading, error, refetch: run };
|
|
332
435
|
}
|
|
436
|
+
function useAgencyBundle(client, slug) {
|
|
437
|
+
const [data, setData] = useState(null);
|
|
438
|
+
const [loading, setLoading] = useState(Boolean(client && slug));
|
|
439
|
+
const [error, setError] = useState(null);
|
|
440
|
+
const reqId = useRef(0);
|
|
441
|
+
const run = () => {
|
|
442
|
+
if (!client || !slug) {
|
|
443
|
+
setData(null);
|
|
444
|
+
setLoading(false);
|
|
445
|
+
setError(null);
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
const myReq = ++reqId.current;
|
|
449
|
+
setLoading(true);
|
|
450
|
+
setError(null);
|
|
451
|
+
client.agencies.getBundle(slug).then((res) => {
|
|
452
|
+
if (myReq !== reqId.current) return;
|
|
453
|
+
setData(res);
|
|
454
|
+
}).catch((err) => {
|
|
455
|
+
if (myReq !== reqId.current) return;
|
|
456
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
457
|
+
}).finally(() => {
|
|
458
|
+
if (myReq !== reqId.current) return;
|
|
459
|
+
setLoading(false);
|
|
460
|
+
});
|
|
461
|
+
};
|
|
462
|
+
useEffect(() => {
|
|
463
|
+
run();
|
|
464
|
+
return () => {
|
|
465
|
+
reqId.current++;
|
|
466
|
+
};
|
|
467
|
+
}, [client, slug]);
|
|
468
|
+
return { data, loading, error, refetch: run };
|
|
469
|
+
}
|
|
333
470
|
|
|
334
471
|
// src/utils/format.ts
|
|
335
472
|
function pickImageUrl(img) {
|
|
@@ -364,7 +501,7 @@ var PackageCard = ({
|
|
|
364
501
|
onSelect,
|
|
365
502
|
href,
|
|
366
503
|
openInNewTab = false,
|
|
367
|
-
showHeart =
|
|
504
|
+
showHeart = false,
|
|
368
505
|
liked,
|
|
369
506
|
onLike
|
|
370
507
|
}) => {
|
|
@@ -1949,44 +2086,90 @@ var getMonthsHosting = (createdDate) => {
|
|
|
1949
2086
|
);
|
|
1950
2087
|
return Math.max(1, monthsDiff);
|
|
1951
2088
|
};
|
|
1952
|
-
var HostCard = ({
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
] }),
|
|
1970
|
-
/* @__PURE__ */ jsxs("div", { className: "flex justify-between text-center mt-2", children: [
|
|
1971
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1972
|
-
/* @__PURE__ */ jsx("p", { className: "text-base md:text-lg text-primary-normal tracking-[-0.02em] font-medium", children: hostData?.review ?? 0 }),
|
|
1973
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm md:text-base text-secondary-normal-hover tracking-[-0.02em]", children: "Reviews" })
|
|
1974
|
-
] }),
|
|
1975
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1976
|
-
/* @__PURE__ */ jsx("p", { className: "text-base md:text-lg text-primary-normal tracking-[-0.02em] font-medium", children: (hostData?.rating ?? 0).toFixed(2) }),
|
|
1977
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm md:text-base text-secondary-normal-hover tracking-[-0.02em]", children: "Rating" })
|
|
1978
|
-
] }),
|
|
1979
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1980
|
-
/* @__PURE__ */ jsxs("p", { className: "text-base md:text-lg text-primary-normal tracking-[-0.02em] font-medium", children: [
|
|
1981
|
-
getMonthsHosting(hostData?.agencyCreatedDate),
|
|
1982
|
-
" mth"
|
|
1983
|
-
] }),
|
|
1984
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm md:text-base text-secondary-normal-hover tracking-[-0.02em]", children: "Hosting" })
|
|
1985
|
-
] })
|
|
1986
|
-
] })
|
|
1987
|
-
]
|
|
2089
|
+
var HostCard = ({
|
|
2090
|
+
hostData,
|
|
2091
|
+
onAgencyClick,
|
|
2092
|
+
href,
|
|
2093
|
+
openInNewTab,
|
|
2094
|
+
className = ""
|
|
2095
|
+
}) => {
|
|
2096
|
+
const data = hostData;
|
|
2097
|
+
const displayName = data.agencyName || data.username;
|
|
2098
|
+
const logoUrl = pickImageUrl(data?.logo);
|
|
2099
|
+
const isClickable = Boolean(onAgencyClick || href);
|
|
2100
|
+
const handleAnchorClick = (e) => {
|
|
2101
|
+
if (e.metaKey || e.ctrlKey || e.button === 1) return;
|
|
2102
|
+
if (openInNewTab) return;
|
|
2103
|
+
if (onAgencyClick) {
|
|
2104
|
+
e.preventDefault();
|
|
2105
|
+
onAgencyClick(data.slug);
|
|
1988
2106
|
}
|
|
1989
|
-
|
|
2107
|
+
};
|
|
2108
|
+
const body = /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
2109
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
|
|
2110
|
+
/* @__PURE__ */ jsx("div", { className: "relative rounded-full h-20 w-20 bg-gray-200 flex items-center justify-center text-xl text-primary-normal overflow-hidden", children: logoUrl ? /* @__PURE__ */ jsx(
|
|
2111
|
+
"img",
|
|
2112
|
+
{
|
|
2113
|
+
src: logoUrl,
|
|
2114
|
+
alt: `${displayName}'s logo`,
|
|
2115
|
+
className: "object-cover w-full h-full"
|
|
2116
|
+
}
|
|
2117
|
+
) : /* @__PURE__ */ jsx("span", { children: getUserInitials(displayName) }) }),
|
|
2118
|
+
/* @__PURE__ */ jsx("span", { className: "text-[18px] tracking-[-0.02em] font-medium text-primary-normal whitespace-normal break-words", children: displayName })
|
|
2119
|
+
] }),
|
|
2120
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-between text-center mt-2", children: [
|
|
2121
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2122
|
+
/* @__PURE__ */ jsx("p", { className: "text-base md:text-lg text-primary-normal tracking-[-0.02em] font-medium", children: data?.review ?? 0 }),
|
|
2123
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm md:text-base text-secondary-normal-hover tracking-[-0.02em]", children: "Reviews" })
|
|
2124
|
+
] }),
|
|
2125
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2126
|
+
/* @__PURE__ */ jsx("p", { className: "text-base md:text-lg text-primary-normal tracking-[-0.02em] font-medium", children: (data?.rating ?? 0).toFixed(2) }),
|
|
2127
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm md:text-base text-secondary-normal-hover tracking-[-0.02em]", children: "Rating" })
|
|
2128
|
+
] }),
|
|
2129
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2130
|
+
/* @__PURE__ */ jsxs("p", { className: "text-base md:text-lg text-primary-normal tracking-[-0.02em] font-medium", children: [
|
|
2131
|
+
getMonthsHosting(data?.agencyCreatedDate),
|
|
2132
|
+
" mth"
|
|
2133
|
+
] }),
|
|
2134
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm md:text-base text-secondary-normal-hover tracking-[-0.02em]", children: "Hosting" })
|
|
2135
|
+
] })
|
|
2136
|
+
] })
|
|
2137
|
+
] });
|
|
2138
|
+
const wrapperClass = `w-full sm:min-w-[320px] rounded-2xl border border-[#E0E4E8] bg-white p-6 lg:p-8 shadow-md ${isClickable ? "cursor-pointer transition-shadow hover:shadow-lg" : ""} ${className}`.trim();
|
|
2139
|
+
if (href) {
|
|
2140
|
+
return /* @__PURE__ */ jsx(
|
|
2141
|
+
"a",
|
|
2142
|
+
{
|
|
2143
|
+
href,
|
|
2144
|
+
target: openInNewTab ? "_blank" : void 0,
|
|
2145
|
+
rel: openInNewTab ? "noopener noreferrer" : void 0,
|
|
2146
|
+
onClick: handleAnchorClick,
|
|
2147
|
+
className: `${wrapperClass} block no-underline text-inherit`,
|
|
2148
|
+
"aria-label": openInNewTab ? `View ${displayName} (opens in a new tab)` : `View ${displayName}`,
|
|
2149
|
+
children: body
|
|
2150
|
+
}
|
|
2151
|
+
);
|
|
2152
|
+
}
|
|
2153
|
+
if (onAgencyClick) {
|
|
2154
|
+
return /* @__PURE__ */ jsx(
|
|
2155
|
+
"div",
|
|
2156
|
+
{
|
|
2157
|
+
role: "button",
|
|
2158
|
+
tabIndex: 0,
|
|
2159
|
+
onClick: () => onAgencyClick(data.slug),
|
|
2160
|
+
onKeyDown: (e) => {
|
|
2161
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
2162
|
+
e.preventDefault();
|
|
2163
|
+
onAgencyClick(data.slug);
|
|
2164
|
+
}
|
|
2165
|
+
},
|
|
2166
|
+
className: wrapperClass,
|
|
2167
|
+
"aria-label": `View ${displayName}`,
|
|
2168
|
+
children: body
|
|
2169
|
+
}
|
|
2170
|
+
);
|
|
2171
|
+
}
|
|
2172
|
+
return /* @__PURE__ */ jsx("div", { className: wrapperClass, children: body });
|
|
1990
2173
|
};
|
|
1991
2174
|
var HostCard_default = HostCard;
|
|
1992
2175
|
var GalleryImg = ({
|
|
@@ -2276,6 +2459,9 @@ function PackageDetailView({
|
|
|
2276
2459
|
initialBundle,
|
|
2277
2460
|
currency = "USD",
|
|
2278
2461
|
onReserve,
|
|
2462
|
+
onSelectHost,
|
|
2463
|
+
agencyHrefFor,
|
|
2464
|
+
openAgencyInNewTab,
|
|
2279
2465
|
className,
|
|
2280
2466
|
renderLoading,
|
|
2281
2467
|
renderNotFound
|
|
@@ -2309,6 +2495,9 @@ function PackageDetailView({
|
|
|
2309
2495
|
routes: bundle.routes ?? [],
|
|
2310
2496
|
currency,
|
|
2311
2497
|
onReserve,
|
|
2498
|
+
onSelectHost,
|
|
2499
|
+
agencyHrefFor,
|
|
2500
|
+
openAgencyInNewTab,
|
|
2312
2501
|
className
|
|
2313
2502
|
}
|
|
2314
2503
|
);
|
|
@@ -2319,6 +2508,9 @@ function DetailContent({
|
|
|
2319
2508
|
routes,
|
|
2320
2509
|
currency,
|
|
2321
2510
|
onReserve,
|
|
2511
|
+
onSelectHost,
|
|
2512
|
+
agencyHrefFor,
|
|
2513
|
+
openAgencyInNewTab,
|
|
2322
2514
|
className
|
|
2323
2515
|
}) {
|
|
2324
2516
|
const topData = buildTopData(pkg, host);
|
|
@@ -2339,7 +2531,16 @@ function DetailContent({
|
|
|
2339
2531
|
host && /* @__PURE__ */ jsxs("div", { className: "py-6 sm:py-8 border-b-2 border-gray-200 flex flex-col gap-6", children: [
|
|
2340
2532
|
/* @__PURE__ */ jsx("h2", { className: "text-primary-normal text-xl md:text-2xl font-medium tracking-[-0.04em]", children: "Host Details" }),
|
|
2341
2533
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col lg:flex-row gap-8 lg:gap-10 h-full items-start lg:items-center", children: [
|
|
2342
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-6 sm:gap-8 w-full sm:w-[320px]", children: /* @__PURE__ */ jsx(
|
|
2534
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-6 sm:gap-8 w-full sm:w-[320px]", children: /* @__PURE__ */ jsx(
|
|
2535
|
+
HostCard_default,
|
|
2536
|
+
{
|
|
2537
|
+
hostData: host,
|
|
2538
|
+
onAgencyClick: onSelectHost ? () => onSelectHost(host) : void 0,
|
|
2539
|
+
href: agencyHrefFor ? agencyHrefFor(host) : void 0,
|
|
2540
|
+
openInNewTab: openAgencyInNewTab,
|
|
2541
|
+
className: "w-full"
|
|
2542
|
+
}
|
|
2543
|
+
) }),
|
|
2343
2544
|
/* @__PURE__ */ jsx("div", { className: "w-full lg:w-4/5 h-full flex flex-col justify-center", children: /* @__PURE__ */ jsx(
|
|
2344
2545
|
HostAbout_default,
|
|
2345
2546
|
{
|
|
@@ -2367,7 +2568,177 @@ function DefaultLoading() {
|
|
|
2367
2568
|
] })
|
|
2368
2569
|
] });
|
|
2369
2570
|
}
|
|
2571
|
+
var AgencyAssociations = ({
|
|
2572
|
+
associations,
|
|
2573
|
+
title = "We are associated with",
|
|
2574
|
+
className
|
|
2575
|
+
}) => {
|
|
2576
|
+
if (!associations?.length) return null;
|
|
2577
|
+
return /* @__PURE__ */ jsxs("section", { className: `flex flex-col gap-4 mt-2 ${className ?? ""}`.trim(), children: [
|
|
2578
|
+
/* @__PURE__ */ jsx("h3", { className: "text-xl md:text-2xl font-medium tracking-[-0.04em] text-primary-normal", children: title }),
|
|
2579
|
+
/* @__PURE__ */ jsx("ul", { className: "flex flex-wrap gap-6 items-center justify-start list-none p-0 m-0", children: associations.map((assoc) => {
|
|
2580
|
+
const img = pickImageUrl(assoc.image);
|
|
2581
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
2582
|
+
"a",
|
|
2583
|
+
{
|
|
2584
|
+
href: assoc.url,
|
|
2585
|
+
target: "_blank",
|
|
2586
|
+
rel: "noopener noreferrer",
|
|
2587
|
+
title: assoc.name,
|
|
2588
|
+
"aria-label": assoc.name,
|
|
2589
|
+
className: "relative w-32 h-20 flex items-center justify-center hover:opacity-80 transition-opacity rounded-lg p-2 bg-white border border-[#E0E4E8]",
|
|
2590
|
+
children: img ? /* @__PURE__ */ jsx(
|
|
2591
|
+
"img",
|
|
2592
|
+
{
|
|
2593
|
+
src: img,
|
|
2594
|
+
alt: assoc.image?.alt || assoc.name,
|
|
2595
|
+
loading: "lazy",
|
|
2596
|
+
className: "max-w-full max-h-full object-contain"
|
|
2597
|
+
}
|
|
2598
|
+
) : /* @__PURE__ */ jsx("span", { className: "text-[#47586E] text-xs text-center leading-tight", children: assoc.name })
|
|
2599
|
+
}
|
|
2600
|
+
) }, assoc.id);
|
|
2601
|
+
}) })
|
|
2602
|
+
] });
|
|
2603
|
+
};
|
|
2604
|
+
var AgencyAssociations_default = AgencyAssociations;
|
|
2605
|
+
function AgencyDetailView({
|
|
2606
|
+
client,
|
|
2607
|
+
slug,
|
|
2608
|
+
initialBundle,
|
|
2609
|
+
currency = "USD",
|
|
2610
|
+
onSelectPackage,
|
|
2611
|
+
packageHrefFor,
|
|
2612
|
+
openPackagesInNewTab,
|
|
2613
|
+
className,
|
|
2614
|
+
renderLoading,
|
|
2615
|
+
renderNotFound
|
|
2616
|
+
}) {
|
|
2617
|
+
if (!initialBundle && (!client || !slug)) {
|
|
2618
|
+
throw new Error(
|
|
2619
|
+
"[AgencyDetailView] Provide either `initialBundle` or both `client` and `slug`."
|
|
2620
|
+
);
|
|
2621
|
+
}
|
|
2622
|
+
const remote = useAgencyBundle(
|
|
2623
|
+
initialBundle ? null : client ?? null,
|
|
2624
|
+
initialBundle ? null : slug ?? null
|
|
2625
|
+
);
|
|
2626
|
+
const bundle = initialBundle ?? remote.data;
|
|
2627
|
+
const loading = !initialBundle && remote.loading;
|
|
2628
|
+
const error = !initialBundle && remote.error;
|
|
2629
|
+
if (loading) {
|
|
2630
|
+
return /* @__PURE__ */ jsx("div", { className: `tvr-package-detail ${className ?? ""}`.trim(), children: renderLoading ? renderLoading() : /* @__PURE__ */ jsx(DefaultLoading2, {}) });
|
|
2631
|
+
}
|
|
2632
|
+
if (error) {
|
|
2633
|
+
return /* @__PURE__ */ jsx("div", { className: `tvr-package-detail ${className ?? ""}`.trim(), children: /* @__PURE__ */ jsxs("div", { className: "max-w-screen-xl mx-auto px-6 py-16 text-center text-red-600 text-sm", children: [
|
|
2634
|
+
"Failed to load agency: ",
|
|
2635
|
+
error.message
|
|
2636
|
+
] }) });
|
|
2637
|
+
}
|
|
2638
|
+
if (!bundle?.agency) {
|
|
2639
|
+
return /* @__PURE__ */ jsx("div", { className: `tvr-package-detail ${className ?? ""}`.trim(), children: renderNotFound ? renderNotFound() : /* @__PURE__ */ jsx("div", { className: "max-w-screen-xl mx-auto px-6 py-16 text-center text-secondary-normal-hover text-sm", children: "Agency not found." }) });
|
|
2640
|
+
}
|
|
2641
|
+
return /* @__PURE__ */ jsx(
|
|
2642
|
+
DetailContent2,
|
|
2643
|
+
{
|
|
2644
|
+
agency: bundle.agency,
|
|
2645
|
+
associations: bundle.associations,
|
|
2646
|
+
packages: bundle.packages,
|
|
2647
|
+
currency,
|
|
2648
|
+
onSelectPackage,
|
|
2649
|
+
packageHrefFor,
|
|
2650
|
+
openPackagesInNewTab,
|
|
2651
|
+
className
|
|
2652
|
+
}
|
|
2653
|
+
);
|
|
2654
|
+
}
|
|
2655
|
+
function DetailContent2({
|
|
2656
|
+
agency,
|
|
2657
|
+
associations,
|
|
2658
|
+
packages,
|
|
2659
|
+
currency,
|
|
2660
|
+
onSelectPackage,
|
|
2661
|
+
packageHrefFor,
|
|
2662
|
+
openPackagesInNewTab,
|
|
2663
|
+
className
|
|
2664
|
+
}) {
|
|
2665
|
+
const displayName = agency.agencyName || agency.username;
|
|
2666
|
+
return /* @__PURE__ */ jsx("div", { className: `tvr-package-detail ${className ?? ""}`.trim(), children: /* @__PURE__ */ jsxs("article", { className: "mx-auto max-w-[1440px] flex flex-col gap-8 md:px-12 px-6 lg:py-10 py-6", children: [
|
|
2667
|
+
/* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-2", children: [
|
|
2668
|
+
/* @__PURE__ */ jsxs(
|
|
2669
|
+
"nav",
|
|
2670
|
+
{
|
|
2671
|
+
"aria-label": "Breadcrumb",
|
|
2672
|
+
className: "flex items-center gap-2 text-sm",
|
|
2673
|
+
children: [
|
|
2674
|
+
/* @__PURE__ */ jsx("a", { href: "/", className: "text-secondary hover:underline", children: "Home" }),
|
|
2675
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "text-secondary", children: "\u203A" }),
|
|
2676
|
+
/* @__PURE__ */ jsx("span", { className: "text-secondary underline font-medium", children: displayName })
|
|
2677
|
+
]
|
|
2678
|
+
}
|
|
2679
|
+
),
|
|
2680
|
+
/* @__PURE__ */ jsx("h1", { className: "text-xl md:text-2xl font-medium text-primary-normal leading-tight", children: displayName })
|
|
2681
|
+
] }),
|
|
2682
|
+
/* @__PURE__ */ jsxs("section", { className: "flex flex-col lg:flex-row items-stretch gap-8 pb-8 border-b border-[#E0E4E8]", children: [
|
|
2683
|
+
/* @__PURE__ */ jsx("div", { className: "w-full lg:w-[320px] flex-shrink-0", children: /* @__PURE__ */ jsx(HostCard_default, { hostData: agency, className: "w-full" }) }),
|
|
2684
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col gap-5 pt-2", children: [
|
|
2685
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2686
|
+
/* @__PURE__ */ jsx("h2", { className: "lg:text-2xl text-xl tracking-[-0.04em] font-medium text-primary-normal", children: "Overview" }),
|
|
2687
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-secondary font-medium md:text-lg text-sm", children: [
|
|
2688
|
+
/* @__PURE__ */ jsx(
|
|
2689
|
+
Icon,
|
|
2690
|
+
{
|
|
2691
|
+
icon: "material-symbols:verified-rounded",
|
|
2692
|
+
className: "lg:w-6 lg:h-6 w-4 h-4"
|
|
2693
|
+
}
|
|
2694
|
+
),
|
|
2695
|
+
/* @__PURE__ */ jsx("span", { children: "Verified Agency" })
|
|
2696
|
+
] })
|
|
2697
|
+
] }),
|
|
2698
|
+
/* @__PURE__ */ jsx("p", { className: "lg:text-lg text-sm text-[#47586E] leading-relaxed", children: agency.description || `Verified Nepal travel agency on Travories.` })
|
|
2699
|
+
] })
|
|
2700
|
+
] }),
|
|
2701
|
+
associations.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2702
|
+
/* @__PURE__ */ jsx(AgencyAssociations_default, { associations }),
|
|
2703
|
+
/* @__PURE__ */ jsx("div", { className: "border-b border-[#E0E4E8]" })
|
|
2704
|
+
] }),
|
|
2705
|
+
packages.length > 0 && /* @__PURE__ */ jsx("section", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsx(
|
|
2706
|
+
PackagesCarousel_default,
|
|
2707
|
+
{
|
|
2708
|
+
title: `Popular Packages from ${displayName}`,
|
|
2709
|
+
packages,
|
|
2710
|
+
currency,
|
|
2711
|
+
onSelect: onSelectPackage,
|
|
2712
|
+
hrefFor: packageHrefFor,
|
|
2713
|
+
openInNewTab: openPackagesInNewTab
|
|
2714
|
+
}
|
|
2715
|
+
) })
|
|
2716
|
+
] }) });
|
|
2717
|
+
}
|
|
2718
|
+
function DefaultLoading2() {
|
|
2719
|
+
return /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-[1440px] px-6 md:px-12 py-8 animate-pulse", children: [
|
|
2720
|
+
/* @__PURE__ */ jsx("div", { className: "h-4 w-32 bg-gray-200 rounded mb-3" }),
|
|
2721
|
+
/* @__PURE__ */ jsx("div", { className: "h-8 w-72 bg-gray-200 rounded mb-8" }),
|
|
2722
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col lg:flex-row gap-8 mb-10", children: [
|
|
2723
|
+
/* @__PURE__ */ jsx("div", { className: "w-full lg:w-[320px] h-48 bg-gray-100 rounded-2xl" }),
|
|
2724
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-3", children: [
|
|
2725
|
+
/* @__PURE__ */ jsx("div", { className: "h-6 w-40 bg-gray-200 rounded" }),
|
|
2726
|
+
/* @__PURE__ */ jsx("div", { className: "h-4 w-full bg-gray-100 rounded" }),
|
|
2727
|
+
/* @__PURE__ */ jsx("div", { className: "h-4 w-5/6 bg-gray-100 rounded" }),
|
|
2728
|
+
/* @__PURE__ */ jsx("div", { className: "h-4 w-2/3 bg-gray-100 rounded" })
|
|
2729
|
+
] })
|
|
2730
|
+
] }),
|
|
2731
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-4 overflow-hidden", children: Array.from({ length: 4 }).map((_, i) => /* @__PURE__ */ jsx(
|
|
2732
|
+
"div",
|
|
2733
|
+
{
|
|
2734
|
+
className: "w-[300px] shrink-0 rounded-xl bg-gray-100",
|
|
2735
|
+
style: { height: 280 }
|
|
2736
|
+
},
|
|
2737
|
+
i
|
|
2738
|
+
)) })
|
|
2739
|
+
] });
|
|
2740
|
+
}
|
|
2370
2741
|
|
|
2371
|
-
export { BookingCardLite_default as BookingCardLite, DescriptionSection_default as DescriptionSection, GallerySection_default as GallerySection, HomeSections, HomeSectionsProvider, HostAbout_default as HostAbout, HostCard_default as HostCard, Itinerary_default as Itinerary, PackageCard_default as PackageCard, PackageDetailView, PackageExcludedAndToPack_default as PackageExcludedAndToPack, PackageIncluded_default as PackageIncluded, PackageMap, PackageOverview_default as PackageOverview, PackagesCarousel_default as PackagesCarousel, PackagesResource, PackagesSection_default as PackagesSection, TopSection_default as TopSection, TravoriesApiError, TravoriesClient, buildDescriptionData, buildGalleryMedia, buildTopData, createTravoriesClient, formatCurrency, formatRating, pickImageUrl, startingPrice, useHomeSections, useHomeSectionsContext, usePackageBundle, usePackageBySlug };
|
|
2742
|
+
export { AgenciesResource, AgencyAssociations_default as AgencyAssociations, AgencyDetailView, BookingCardLite_default as BookingCardLite, DescriptionSection_default as DescriptionSection, GallerySection_default as GallerySection, HomeSections, HomeSectionsProvider, HostAbout_default as HostAbout, HostCard_default as HostCard, Itinerary_default as Itinerary, PackageCard_default as PackageCard, PackageDetailView, PackageExcludedAndToPack_default as PackageExcludedAndToPack, PackageIncluded_default as PackageIncluded, PackageMap, PackageOverview_default as PackageOverview, PackagesCarousel_default as PackagesCarousel, PackagesResource, PackagesSection_default as PackagesSection, TopSection_default as TopSection, TravoriesApiError, TravoriesClient, buildDescriptionData, buildGalleryMedia, buildTopData, createTravoriesClient, formatCurrency, formatRating, pickImageUrl, startingPrice, useAgencyBundle, useHomeSections, useHomeSectionsContext, usePackageBundle, usePackageBySlug };
|
|
2372
2743
|
//# sourceMappingURL=index.mjs.map
|
|
2373
2744
|
//# sourceMappingURL=index.mjs.map
|