From 63db7225a778a8911009f9588f130ae854e45498 Mon Sep 17 00:00:00 2001 From: pablopupulin Date: Thu, 6 Feb 2025 03:05:50 -0300 Subject: [PATCH 1/2] Add HASH with current OrgId and CostCenterId --- node/package.json | 4 ++-- node/resolvers/Routes/index.ts | 11 ++++++++++- node/yarn.lock | 10 +++++----- vtex.session/configuration.json | 6 ++++-- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/node/package.json b/node/package.json index f58463c..82795f7 100644 --- a/node/package.json +++ b/node/package.json @@ -2,7 +2,7 @@ "name": "vtex.checkout-ui-custom", "version": "1.45.1", "dependencies": { - "@vtex/api": "6.47.0", + "@vtex/api": "6.48.0", "atob": "^2.1.2", "co-body": "^6.0.0", "cookie": "^0.3.1", @@ -21,7 +21,7 @@ "@types/jsonwebtoken": "^8.5.0", "@types/node": "^12.0.0", "@types/ramda": "types/npm-ramda#dist", - "@vtex/api": "6.47.0", + "@vtex/api": "6.48.0", "@vtex/prettier-config": "^0.3.1", "tslint": "^5.12.0", "tslint-config-prettier": "^1.18.0", diff --git a/node/resolvers/Routes/index.ts b/node/resolvers/Routes/index.ts index 28984e7..9cc834f 100644 --- a/node/resolvers/Routes/index.ts +++ b/node/resolvers/Routes/index.ts @@ -6,6 +6,7 @@ import { getSessionWatcher } from '../Queries/Settings' import { getActiveUserByEmail, getUserByEmail } from '../Queries/Users' import { generateClUser } from './utils' import { getUser, setActiveUserByOrganization } from '../Mutations/Users' +import { toHash } from '../../utils' export const Routes = { PROFILE_DOCUMENT_TYPE: 'cpf', @@ -131,6 +132,9 @@ export const Routes = { userId: { value: '', }, + hash: { + value: '', + }, }, } @@ -251,6 +255,11 @@ export const Routes = { }) } + const hash = toHash(`${user.orgId}|${user.costId}`) + const changed = body?.['storefront-permissions']?.hash?.value !== hash + + response['storefront-permissions'].hash.value = hash + const [ organizationResponse, costCenterResponse, @@ -449,7 +458,7 @@ export const Routes = { response.public.sc.value = salesChannel.toString() } - if (orderFormId) { + if (changed && orderFormId) { try { const { uiSettings: { clearCart }, diff --git a/node/yarn.lock b/node/yarn.lock index 1a57dcf..87f3824 100644 --- a/node/yarn.lock +++ b/node/yarn.lock @@ -190,10 +190,10 @@ "@types/mime" "^1" "@types/node" "*" -"@vtex/api@6.47.0": - version "6.47.0" - resolved "https://registry.yarnpkg.com/@vtex/api/-/api-6.47.0.tgz#6910455d593d8bb76f1f4f2b7660023853fda35e" - integrity sha512-t9gt7Q89EMbSj3rLhho+49Fv+/lQgiy8EPVRgtmmXFp1J4v8hIAZF7GPjCPie111KVs4eG0gfZFpmhA5dafKNA== +"@vtex/api@6.48.0": + version "6.48.0" + resolved "https://registry.yarnpkg.com/@vtex/api/-/api-6.48.0.tgz#67f9f11d197d543d4f854b057d31a8d6999241e9" + integrity sha512-mAdT7gbV0/BwiuqUkNH1E7KZqTUczT5NbBBZcPJq5kmTr73PUjbR9wh//70ryJo2EAdHlqIgqgwsCVpozenlhg== dependencies: "@types/koa" "^2.11.0" "@types/koa-compose" "^3.2.3" @@ -1428,7 +1428,7 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= -"stats-lite@github:vtex/node-stats-lite#dist": +stats-lite@vtex/node-stats-lite#dist: version "2.2.0" resolved "https://codeload.github.com/vtex/node-stats-lite/tar.gz/1b0d39cc41ef7aaecfd541191f877887a2044797" dependencies: diff --git a/vtex.session/configuration.json b/vtex.session/configuration.json index 3865f4e..857dc98 100644 --- a/vtex.session/configuration.json +++ b/vtex.session/configuration.json @@ -4,7 +4,8 @@ "authentication": ["storeUserEmail"], "checkout": ["orderFormId"], "impersonate": ["storeUserEmail", "storeUserId"], - "public": ["impersonate", "removeB2B", "b2bCurrentCostCenter"] + "public": ["impersonate", "removeB2B", "b2bCurrentCostCenter"], + "storefront-permissions": ["hash"] }, "output": { "public": ["facets", "sc", "regionId"], @@ -15,7 +16,8 @@ "costcenter", "priceTables", "collections", - "userId" + "userId", + "hash" ] } } From f0870f23c3ec1c3890266bd75405819a11196370 Mon Sep 17 00:00:00 2001 From: pablopupulin Date: Thu, 6 Feb 2025 03:13:11 -0300 Subject: [PATCH 2/2] Fix --- CHANGELOG.md | 4 ++++ node/resolvers/Routes/index.ts | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c26d40..e05f686 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +- Clear cart only changed Hash (OrgId+CostId) + ## [1.45.1] - 2024-10-28 ### Fixed diff --git a/node/resolvers/Routes/index.ts b/node/resolvers/Routes/index.ts index 9cc834f..afb28f6 100644 --- a/node/resolvers/Routes/index.ts +++ b/node/resolvers/Routes/index.ts @@ -256,7 +256,7 @@ export const Routes = { } const hash = toHash(`${user.orgId}|${user.costId}`) - const changed = body?.['storefront-permissions']?.hash?.value !== hash + const hashChanged = body?.['storefront-permissions']?.hash?.value !== hash response['storefront-permissions'].hash.value = hash @@ -458,7 +458,7 @@ export const Routes = { response.public.sc.value = salesChannel.toString() } - if (changed && orderFormId) { + if (hashChanged && orderFormId) { try { const { uiSettings: { clearCart },