@rocketsearch/vue-uappi 0.2.0 → 0.2.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/README.md CHANGED
@@ -30,8 +30,11 @@ Use os componentes em PascalCase (`<RocketSearch>`, `<RocketShowcase position="t
30
30
  Vitrines em abas: `showcaseTabs: true` (ou `['top']`, só nessas posições) no `app.use` junta as vitrines da mesma
31
31
  posição numa barra de abas; a prop `tabs` / `:tabs="false"` do `<RocketShowcase>` vence a opção.
32
32
 
33
- Landing page ("Personalizado" no painel): `<RocketLanding>` mostra todas as vitrines da landing, na ordem do
34
- painel. O identificador vem do nome da rota (`/black-friday` → `black-friday`) ou de `custom-key="..."`.
33
+ Landing page ("Personalizado" no painel): na landing da Uappi (nivel `landing-page`), os `<RocketShowcase position>`
34
+ que o tema já tem mostram as vitrines da landing, cada uma na posição escolhida no painel. O identificador é o fim da
35
+ URL (`/c/black-friday` → `black-friday`). Página sem essas posições: `<RocketLanding>` empilha todas as vitrines da
36
+ landing na ordem do painel, com o identificador do nome da rota ou de `custom-key="..."`. Não use os dois na mesma
37
+ página, senão a vitrine aparece duas vezes.
35
38
  Banners da landing: `<RocketBanner page-type="custom" />`, com a mesma regra do identificador.
36
39
 
37
40
  Banners do megamenu: `<RocketBanner position="menu" :menu-key="aba.label" page-type="home" @loaded="...">`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocketsearch/vue-uappi",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Rocket Search para storefronts Uappi em Vue 3 + Vite + Pinia: busca, autocomplete, vitrines, banners e eventos",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/runtime/rocket.js CHANGED
@@ -94,7 +94,10 @@ export function sectionFromNivel (nivel) {
94
94
  // Vocabulário da API de vitrines/banners (pageType): product|category|home|search|cart|checkout.
95
95
  export function pageTypeFromSection (section) {
96
96
  if (section === 'pdp') return 'product';
97
- if (section === 'list' || section === 'brand') return 'category';
97
+ // Landing (list) não é categoria (ROC-709): é a página Personalizado do painel, com o fim da URL
98
+ // como customKey. As posições da landing (hero, top...) pedem as vitrines dela, não as de categoria.
99
+ if (section === 'list') return 'custom';
100
+ if (section === 'brand') return 'category';
98
101
  if (section === 'other') return '';
99
102
  return section || '';
100
103
  }
@@ -150,6 +153,13 @@ export function createRocket (config) {
150
153
  }
151
154
  rocket.resolvePageType = resolvePageType;
152
155
 
156
+ // Identificador da landing sem custom-key explícito: o fim da URL (/c/black-friday → black-friday),
157
+ // a mesma regra do <RocketLanding>. No servidor não há URL: a landing fica sem vitrine/banner.
158
+ function landingKey (customKey) {
159
+ if (customKey) return customKey;
160
+ return isBrowser ? (location.pathname || '').toLowerCase().split('/').filter(Boolean).pop() || '' : '';
161
+ }
162
+
153
163
  // ---- Sessão ----
154
164
 
155
165
  // Sessão = id local, igual à Linx para shopper anônimo. NÃO usamos o PHPSESSID da Uappi:
@@ -304,7 +314,8 @@ export function createRocket (config) {
304
314
  // customKey: identificador da landing (pageType=custom); sem ele a API responde 400.
305
315
  rocket.getShowcasesByContext = async function (type, customKey) {
306
316
  const pageType = resolvePageType(type);
307
- if (!pageType) return [];
317
+ if (pageType === 'custom') customKey = landingKey(customKey);
318
+ if (!pageType || (pageType === 'custom' && !customKey)) return [];
308
319
  const sessionId = await getSessionIdWithTimeout();
309
320
  const params = { storeId: config.storeId, pageType, page: pageType, sessionId };
310
321
  if (pageType === 'product' && page.productId) params.productId = page.productId;
@@ -344,9 +355,9 @@ export function createRocket (config) {
344
355
  const bannerCache = {};
345
356
  rocket.getBannersByContext = function (type, options) {
346
357
  const pageType = resolvePageType(type);
347
- if (!pageType) return Promise.resolve([]);
348
358
  const opts = options || {};
349
- const customKey = pageType === 'custom' ? opts.customKey : undefined;
359
+ const customKey = pageType === 'custom' ? landingKey(opts.customKey) : undefined;
360
+ if (!pageType || (pageType === 'custom' && !customKey)) return Promise.resolve([]);
350
361
  const key = pageType + '|' + (opts.position || '') + '|' + (customKey || '');
351
362
  const hit = bannerCache[key];
352
363
  if (hit && Date.now() - hit.at < BANNER_TTL) return hit.list;