Skip to content

Commit d019133

Browse files
authored
Bugfix/tables store (#15)
* Fix duplicate tables and local storage * fix(tables): correct TypeScript types in spec and remove unused watch import
1 parent 4eb7027 commit d019133

11 files changed

Lines changed: 951 additions & 9 deletions

File tree

apps/web/src/components/tables/ManageTables.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ const handleScroll = () => {
621621
}
622622
623623
onMounted(() => {
624+
if(!tableStore.tables.length) tableStore.resetToDefaults()
624625
window.addEventListener('scroll', handleScroll)
625626
})
626627

apps/web/src/composables/useNavItems.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ describe('useNavItems', () => {
2020
})
2121

2222
describe('navItems', () => {
23-
it('should export 3 nav items', () => {
24-
expect(navItems).toHaveLength(3)
23+
it('should export 4 nav items', () => {
24+
expect(navItems).toHaveLength(4)
2525
})
2626

27-
it('should contain tables, menu and history items', () => {
27+
it('should contain tables, menu, orders and history items', () => {
2828
const keys = navItems.map(i => i.key)
2929
expect(keys).toContain('tables')
3030
expect(keys).toContain('menu')
31+
expect(keys).toContain('orders')
3132
expect(keys).toContain('history')
3233
})
3334

@@ -44,6 +45,7 @@ describe('useNavItems', () => {
4445
const routeMap = Object.fromEntries(navItems.map(i => [i.key, i.routeName]))
4546
expect(routeMap.tables).toBe(AppRoute.TABLES)
4647
expect(routeMap.menu).toBe(AppRoute.PRODUCTS)
48+
expect(routeMap.orders).toBe(AppRoute.ORDERS)
4749
expect(routeMap.history).toBe(AppRoute.QR)
4850
})
4951

@@ -86,6 +88,8 @@ describe('useNavItems', () => {
8688
const { navigate } = useNavItems()
8789
navigate(AppRoute.PRODUCTS)
8890
expect(mockPush).toHaveBeenCalledWith({ name: AppRoute.PRODUCTS })
91+
navigate(AppRoute.ORDERS)
92+
expect(mockPush).toHaveBeenCalledWith({ name: AppRoute.ORDERS })
8993
navigate(AppRoute.QR)
9094
expect(mockPush).toHaveBeenCalledWith({ name: AppRoute.QR })
9195
})

apps/web/src/composables/useNavItems.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ export const navItems: NavItem[] = [
2323
routeName: AppRoute.PRODUCTS,
2424
icon: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"/></svg>`,
2525
},
26+
{
27+
key: 'orders',
28+
labelKey: 'sidebar.orders',
29+
routeName: AppRoute.ORDERS,
30+
icon: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2"/><rect x="9" y="3" width="6" height="4" rx="1"/><path d="M9 12h6M9 16h4"/></svg>`,
31+
},
2632
{
2733
key: 'history',
2834
labelKey: 'sidebar.history',

apps/web/src/interfaces/routes.interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ export enum AppRoute {
66
SIGNUP = 'signup',
77
TEST = 'test',
88
TABLES = 'tables',
9+
ORDERS = 'orders',
910
}
1011

apps/web/src/locales/ca.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,24 @@
8282
"total": "Total",
8383
"confirmButton": "Confirmar"
8484
},
85+
"orders": {
86+
"title": "Obrir / Crear taula",
87+
"subtitle": "Selecciona una taula disponible per continuar",
88+
"tableLabel": "Taula",
89+
"seats": "seients",
90+
"noTablesAvailable": "No hi ha taules disponibles en aquest moment",
91+
"openTable": "Obrir taula",
92+
"selectTableFirst": "Selecciona una taula per continuar",
93+
"generating": "Generant...",
94+
"continueTable": "Continuar amb taula",
95+
"closeTable": "Tancar taula"
96+
},
8597
"sidebar": {
8698
"dashboard": "Taulell",
8799
"menu": "Menú",
88100
"stock": "Inventari",
89101
"table": "Taules",
102+
"orders": "Comandes",
90103
"history": "Historial",
91104
"settings": "Configuració",
92105
"signOut": "Tancar sessió",

apps/web/src/locales/en.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,24 @@
8282
"total": "Total",
8383
"confirmButton": "Confirm"
8484
},
85+
"orders": {
86+
"title": "Open / Create Table",
87+
"subtitle": "Select an available table to continue",
88+
"tableLabel": "Table",
89+
"seats": "seats",
90+
"noTablesAvailable": "No tables available at the moment",
91+
"openTable": "Open table",
92+
"selectTableFirst": "Select a table to continue",
93+
"generating": "Generating...",
94+
"continueTable": "Continue with table",
95+
"closeTable": "Close table"
96+
},
8597
"sidebar": {
8698
"dashboard": "Dashboard",
8799
"menu": "Menu",
88100
"stock": "Stock",
89101
"table": "Tables",
102+
"orders": "Orders",
90103
"history": "History",
91104
"settings": "Settings",
92105
"signOut": "Sign Out",

apps/web/src/locales/es.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,24 @@
8282
"total": "Total",
8383
"confirmButton": "Confirmar"
8484
},
85+
"orders": {
86+
"title": "Abrir / Crear mesa",
87+
"subtitle": "Selecciona una mesa disponible para continuar",
88+
"tableLabel": "Mesa",
89+
"seats": "asientos",
90+
"noTablesAvailable": "No hay mesas disponibles en este momento",
91+
"openTable": "Abrir mesa",
92+
"selectTableFirst": "Selecciona una mesa para continuar",
93+
"generating": "Generando...",
94+
"continueTable": "Continuar con mesa",
95+
"closeTable": "Cerrar mesa"
96+
},
8597
"sidebar": {
8698
"dashboard": "Tablero",
8799
"menu": "Menú",
88100
"stock": "Inventario",
89101
"table": "Mesas",
102+
"orders": "Pedidos",
90103
"history": "Historial",
91104
"settings": "Configuración",
92105
"signOut": "Cerrar sesión",

0 commit comments

Comments
 (0)