fix(customers): allow cashiers to view customers and use refreshed token
Some checks failed
CI / lint-and-test (3.11) (push) Has been cancelled
CI / lint-and-test (3.13) (push) Has been cancelled

This commit is contained in:
2026-07-02 14:49:47 +00:00
parent 670db75fcd
commit 944b9b51b3
3 changed files with 23 additions and 12 deletions

View File

@@ -5,7 +5,6 @@
* Wired to the design-system HTML (customers.html).
*/
const Customers = (() => {
let token = localStorage.getItem('pos_token') || '';
let currentPage = 1;
let totalPages = 1;
let currentCustomer = null;
@@ -16,6 +15,10 @@ const Customers = (() => {
const userPerms = user.permissions || [];
const canDeleteCustomer = userRole === 'owner' || userRole === 'admin' || userPerms.includes('customers.delete');
function getToken() {
return localStorage.getItem('pos_token') || '';
}
const fmt = (n) => '$' + parseFloat(n || 0).toLocaleString('es-MX', {
minimumFractionDigits: 2, maximumFractionDigits: 2
});
@@ -28,7 +31,7 @@ const Customers = (() => {
};
function headers() {
return { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token };
return { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + getToken() };
}
async function api(url, options = {}) {
@@ -733,7 +736,7 @@ const Customers = (() => {
// ─── Init ────────────────────────────
function init() {
// Auth check
if (!token) {
if (!getToken()) {
window.location.href = '/pos/login';
return;
}