PageSourceSearch

https://www.tangol.com/js/paquete-confirm-all.8el0yi8yxd.js

js tangol.com collected 2026-10-01 13:53:03 UTC 3,983 bytes, 79 lines download raw bytes

1(function () {
2    'use strict';
3
4    function postJson(url, body) {
5        return fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) })
6            .then(function (res) { return res.ok ? res.json() : Promise.reject(new Error('http ' + res.status)); })
7            .then(function (result) {
8                if (!result.success) return Promise.reject(new Error(result.outcome || 'add failed'));
9                return result;
10            });
11    }
12
13    function addOne(ctx, step) {
14        var c = step.confirmed;
15        var paqueteGrupoId = ctx.paquetesId;
16
17        if (step.tipo === 'HotelPropio' || step.tipo === 'HotelPorDestino') {
18            if (c.source === 'own') {
19                return postJson('/api/cart/add-hotel', {
20                    hospedajeId: c.hospedajeId, checkIn: c.checkIn, checkOut: c.checkOut, codCat: c.codCat,
21                    rooms: ctx.rooms, roomChildAges: ctx.childAges, nationalityIso: ctx.nationalityIso,
22                    paqueteGrupoId: paqueteGrupoId,
23                });
24            }
25            return postJson('/api/cart/add-online-hotel', {
26                onlineToken: c.onlineToken, roomKey: c.roomKey, paqueteGrupoId: paqueteGrupoId,
27            });
28        }
29        if (step.tipo === 'Traslado') {
30            return postJson('/api/cart/add-traslado', {
31                desId: c.desId, servicioId: c.servicioId, codServ: c.codServ, codCat: c.codCat,
32                fecha: c.fecha, hora: c.hora, pax: c.pax,
33                origenNombre: c.origenNombre, destinoNombre: c.destinoNombre, vehiculoNombre: c.vehiculoNombre,
34                obsServicio: c.obsServicio || null, infoVuelo: c.infoVuelo || null, paqueteGrupoId: paqueteGrupoId,
35            });
36        }
37        if (step.tipo === 'Tour') {
38            var adults = ctx.rooms.reduce(function (sum, r) { return sum + r.adults; }, 0);
39            var children = ctx.rooms.reduce(function (sum, r) { return sum + r.children; }, 0);
40            return postJson('/api/cart/add', {
41                paquetesId: c.tourId, optionKey: c.optionKey, date: c.date,
42                adults: adults, children: children, infants: 0, paqueteGrupoId: paqueteGrupoId,
43            });
44        }
45        if (step.tipo === 'Crucero') {
46            return postJson('/api/cart/add-cruise', {
47                expId: c.expId, viaId: c.viaId, cabId: c.cabId, ocupacion: c.ocupacion,
48                adults: ctx.rooms.reduce(function (sum, r) { return sum + r.adults; }, 0),
49                children: ctx.rooms.reduce(function (sum, r) { return sum + r.children; }, 0),
50                infants: 0, paqueteGrupoId: paqueteGrupoId,
51            });
52        }
53        if (step.tipo === 'Ticket') {
54            return postJson('/api/cart/add-ticket', {
55                partidoId: c.partidoId, dispoId: c.dispoId, quantity: c.quantity, paqueteGrupoId: paqueteGrupoId,
56            });
57        }
58        // Informativo: nada que agregar al carrito.
59        return Promise.resolve();
60    }
61
62    function confirmAll(ctx, confirmedSteps) {
63        var chain = Promise.resolve();
64        confirmedSteps.forEach(function (step) {
65            if (step.cartAdded) return;
66            chain = chain.then(function () { return addOne(ctx, step); })
67                .then(function () { step.cartAdded = true; })
68                // Un error sin contexto en un chain secuencial deja al usuario sin saber cuál de
69                // los N pasos ya confirmados falló al agregarse al carrito — etiquetar el error con
70                // el nombre del paso antes de re-lanzarlo para que el handler del botón lo muestre.
71                .catch(function (err) { err.failedStepNombre = step.nombre; throw err; });
72        });
73        return chain.then(function () {
74            window.location.href = '/Carrito';
75        });
76    }
77
78    window.tangolPaqueteQuoteConfirmAll = confirmAll;
79})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.