summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/controllers/product-page/see-all-intent-controller.js
blob: 618bf5dfb7772b8047824a6e7ea2cfbf7f4f2266 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { injectSEOData } from "../../api/models/web-renderable-page";
import { withActiveIntent } from "../../foundation/dependencies/active-intent";
import * as mediaNetwork from "../../foundation/media/network";
import { validateAdamId } from "../../foundation/media/util";
import { mediaApiProductSeeAllRequest } from "../../common/builders/url-mapping";
import { createProductPageFromResponse } from "../../common/product-page/product-page-util";
import { seeAllPageRoutes } from "../../common/product-page/intent-controller-routing";
import { injectWebNavigation } from "../../common/web-navigation/inject-web-navigation";
export const SeeAllPageIntentController = {
    $intentKind: "SeeAllPageIntent",
    routes: seeAllPageRoutes,
    async perform(intent, objectGraphWithoutActiveIntent) {
        return await withActiveIntent(objectGraphWithoutActiveIntent, intent, async (objectGraph) => {
            var _a, _b;
            validateAdamId(objectGraph, intent.id);
            const seeAllRequest = mediaApiProductSeeAllRequest(objectGraph, intent.id, intent["see-all"]);
            const seeAllResponse = await mediaNetwork.fetchData(objectGraph, seeAllRequest);
            const page = (await createProductPageFromResponse(objectGraph, seeAllResponse));
            if (objectGraph.client.isWeb) {
                // Synthesize the URL for the page based on the product page URL and the expected query param
                if (page.canonicalURL) {
                    const pageURL = new URL(page.canonicalURL);
                    const params = pageURL.searchParams;
                    params.set("see-all", intent["see-all"]);
                    params.set("platform", intent.platform);
                    if (intent.platform) {
                        params.set("platform", intent.platform);
                    }
                    page.canonicalURL = pageURL.toString();
                }
                page.seeAllType = intent["see-all"];
                injectWebNavigation(objectGraph, page, intent.platform);
                injectSEOData(page, (_b = (_a = objectGraph.seo) === null || _a === void 0 ? void 0 : _a.getSEODataForSeeAllPage) === null || _b === void 0 ? void 0 : _b.call(_a, objectGraph, page, seeAllResponse));
            }
            return page;
        });
    },
};
//# sourceMappingURL=see-all-intent-controller.js.map