From 5dcae016369ceb60d031a525103a924eb7acfb81 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 30 Jan 2026 18:51:20 +0000 Subject: [PATCH 1/2] Initial plan From 4cb88c7d79c782590b1928a1bf3ddded60c3d6aa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 30 Jan 2026 18:56:05 +0000 Subject: [PATCH 2/2] Address PR review comments: fix locale default, optimize retention calc, remove console logs, fix Playwright cleanup, update shipping threshold Co-authored-by: rafiqul4 <124497017+rafiqul4@users.noreply.github.com> --- e2e/analytics.spec.ts | 13 ++++--- package-lock.json | 37 +------------------ .../analytics/analytics-dashboard.tsx | 4 -- src/components/ui/enhanced-data-table.tsx | 6 ++- src/lib/services/analytics.service.ts | 3 +- src/lib/services/checkout.service.ts | 2 +- src/lib/services/store.service.ts | 2 +- 7 files changed, 16 insertions(+), 51 deletions(-) diff --git a/e2e/analytics.spec.ts b/e2e/analytics.spec.ts index 21f59d1c..bfae1915 100644 --- a/e2e/analytics.spec.ts +++ b/e2e/analytics.spec.ts @@ -1,4 +1,4 @@ -import { test, expect, Page } from "@playwright/test"; +import { test, expect, Page, BrowserContext } from "@playwright/test"; /** * Analytics Dashboard E2E Tests - Serial Execution @@ -18,8 +18,9 @@ const ANALYTICS_USER = { password: "Test123!@#", }; -// Shared page context between tests +// Shared page and context between tests let authenticatedPage: Page; +let browserContext: BrowserContext; /** * Helper to login with credentials @@ -57,8 +58,8 @@ async function loginWithCredentials(page: Page): Promise { test.describe("Analytics Tests", () => { test.beforeAll(async ({ browser }) => { // Create a new context and page - const context = await browser.newContext(); - authenticatedPage = await context.newPage(); + browserContext = await browser.newContext(); + authenticatedPage = await browserContext.newPage(); // Login once await loginWithCredentials(authenticatedPage); @@ -69,8 +70,8 @@ test.describe("Analytics Tests", () => { }); test.afterAll(async () => { - if (authenticatedPage) { - await authenticatedPage.close(); + if (browserContext) { + await browserContext.close(); } }); diff --git a/package-lock.json b/package-lock.json index de3af8bb..d613e847 100644 --- a/package-lock.json +++ b/package-lock.json @@ -275,7 +275,6 @@ "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.5", @@ -813,7 +812,6 @@ } ], "license": "MIT", - "peer": true, "engines": { "node": ">=18" }, @@ -855,7 +853,6 @@ } ], "license": "MIT", - "peer": true, "engines": { "node": ">=18" } @@ -883,7 +880,6 @@ "resolved": "https://registry.npmjs.org/@dnd-kit/core/-/core-6.3.1.tgz", "integrity": "sha512-xkGBRQQab4RLwgXxoqETICr6S5JlogafbhNsidmrkVv2YRs5MLwpjoF2qpiGjQt8S9AoxtIV603s0GIUpY5eYQ==", "license": "MIT", - "peer": true, "dependencies": { "@dnd-kit/accessibility": "^3.1.1", "@dnd-kit/utilities": "^3.2.2", @@ -1104,7 +1100,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -2766,7 +2761,6 @@ "integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": "^14.21.3 || >=16" }, @@ -2917,7 +2911,6 @@ "integrity": "sha512-6TyEnHgd6SArQO8UO2OMTxshln3QMWBtPGrOCgs3wVEmQmwyuNtB10IZMfmYDE0riwNR1cu4q+pPcxMVtaG3TA==", "devOptional": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "playwright": "1.57.0" }, @@ -2954,7 +2947,6 @@ "integrity": "sha512-QXFT+N/bva/QI2qoXmjBzL7D6aliPffIwP+81AdTGq0FXDoLxLkWivGMawG8iM5B9BKfxLIXxfWWAF6wbuJU6g==", "hasInstallScript": true, "license": "Apache-2.0", - "peer": true, "engines": { "node": ">=18.18" }, @@ -5384,7 +5376,6 @@ "integrity": "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.10.4", "@babel/runtime": "^7.12.5", @@ -5758,7 +5749,6 @@ "integrity": "sha512-ZsJzA5thDQMSQO788d7IocwwQbI8B5OPzmqNvpf3NY/+MHDAS759Wo0gd2WQeXYt5AAAQjzcrTVC6SKCuYgoCQ==", "devOptional": true, "license": "MIT", - "peer": true, "dependencies": { "undici-types": "~6.21.0" } @@ -5791,7 +5781,6 @@ "integrity": "sha512-MWtvHrGZLFttgeEj28VXHxpmwYbor/ATPYbBfSFZEIRK0ecCFLl2Qo55z52Hss+UV9CRN7trSeq1zbgx7YDWWg==", "devOptional": true, "license": "MIT", - "peer": true, "dependencies": { "csstype": "^3.2.2" } @@ -5802,7 +5791,6 @@ "integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==", "devOptional": true, "license": "MIT", - "peer": true, "peerDependencies": { "@types/react": "^19.2.0" } @@ -5867,7 +5855,6 @@ "integrity": "sha512-PC0PDZfJg8sP7cmKe6L3QIL8GZwU5aRvUFedqSIpw3B+QjRSUZeeITC2M5XKeMXEzL6wccN196iy3JLwKNvDVA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.48.1", "@typescript-eslint/types": "8.48.1", @@ -6629,7 +6616,6 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -7044,7 +7030,6 @@ "integrity": "sha512-Ixm8tFfoKKIPYdCCKYTsqv+Fd4IJ0DQqMyEimo+pxUOMUR9cVPlwTrFt9Avu+3cb6Zp3mAzl+t1MrG2fxxKsxw==", "devOptional": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/types": "^7.26.0" } @@ -7178,7 +7163,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -8306,8 +8290,7 @@ "version": "8.6.0", "resolved": "https://registry.npmjs.org/embla-carousel/-/embla-carousel-8.6.0.tgz", "integrity": "sha512-SjWyZBHJPbqxHOzckOfo8lHisEaJWmwd23XppYFYVh10bU66/Pn5tkVkbkCMZVdbUE5eTCI2nD8OyIP4Z+uwkA==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/embla-carousel-react": { "version": "8.6.0", @@ -8674,7 +8657,6 @@ "integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -8860,7 +8842,6 @@ "integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@rtsao/scc": "^1.1.0", "array-includes": "^3.1.9", @@ -9200,7 +9181,6 @@ "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.1", @@ -11807,7 +11787,6 @@ "resolved": "https://registry.npmjs.org/next/-/next-16.1.0.tgz", "integrity": "sha512-Y+KbmDbefYtHDDQKLNrmzE/YYzG2msqo2VXhzh5yrJ54tx/6TmGdkR5+kP9ma7i7LwZpZMfoY3m/AoPPPKxtVw==", "license": "MIT", - "peer": true, "dependencies": { "@next/env": "16.1.0", "@swc/helpers": "0.5.15", @@ -12005,7 +11984,6 @@ "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-7.0.11.tgz", "integrity": "sha512-gnXhNRE0FNhD7wPSCGhdNh46Hs6nm+uTyg+Kq0cZukNQiYdnCsoQjodNP9BQVG9XrcK/v6/MgpAPBUFyzh9pvw==", "license": "MIT-0", - "peer": true, "engines": { "node": ">=6.0.0" } @@ -12592,7 +12570,6 @@ "resolved": "https://registry.npmjs.org/pg/-/pg-8.16.3.tgz", "integrity": "sha512-enxc1h0jA/aq5oSDMvqyW3q89ra6XIIDZgCX9vkMrnz5DFTw/Ny3Li2lFQ+pt3L6MCgm/5o2o8HW9hiJji+xvw==", "license": "MIT", - "peer": true, "dependencies": { "pg-connection-string": "^2.9.1", "pg-pool": "^3.10.1", @@ -12874,7 +12851,6 @@ "resolved": "https://registry.npmjs.org/preact/-/preact-10.24.3.tgz", "integrity": "sha512-Z2dPnBnMUfyQfSQ+GBdsGa16hz35YmLmtTLhM169uW944hYL6xzTYkJjC07j+Wosz733pMWx0fgON3JNw1jJQA==", "license": "MIT", - "peer": true, "funding": { "type": "opencollective", "url": "https://opencollective.com/preact" @@ -12927,7 +12903,6 @@ "integrity": "sha512-F3eX7K+tWpkbhl3l4+VkFtrwJlLXbAM+f9jolgoUZbFcm1DgHZ4cq9AgVEgUym2au5Ad/TDLN8lg83D+M10ycw==", "hasInstallScript": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "@prisma/config": "6.19.0", "@prisma/engines": "6.19.0" @@ -13121,7 +13096,6 @@ "resolved": "https://registry.npmjs.org/react/-/react-19.2.3.tgz", "integrity": "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==", "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -13152,7 +13126,6 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.3.tgz", "integrity": "sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==", "license": "MIT", - "peer": true, "dependencies": { "scheduler": "^0.27.0" }, @@ -13165,7 +13138,6 @@ "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.68.0.tgz", "integrity": "sha512-oNN3fjrZ/Xo40SWlHf1yCjlMK417JxoSJVUXQjGdvdRCU07NTFei1i1f8ApUAts+IVh14e4EdakeLEA+BEAs/Q==", "license": "MIT", - "peer": true, "engines": { "node": ">=18.0.0" }, @@ -14660,7 +14632,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -14841,7 +14812,6 @@ "integrity": "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "~0.27.0", "get-tsconfig": "^4.7.5" @@ -14994,7 +14964,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "devOptional": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -15300,7 +15269,6 @@ "integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", @@ -15414,7 +15382,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -15428,7 +15395,6 @@ "integrity": "sha512-E4t7DJ9pESL6E3I8nFjPa4xGUd3PmiWDLsDztS2qXSJWfHtbQnwAWylaBvSNY48I3vr8PTqIZlyK8TE3V3CA4Q==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@vitest/expect": "4.0.16", "@vitest/mocker": "4.0.16", @@ -15989,7 +15955,6 @@ "resolved": "https://registry.npmjs.org/zod/-/zod-4.1.13.tgz", "integrity": "sha512-AvvthqfqrAhNH9dnfmrfKzX5upOdjUVJYFqNSlkmGf64gRaTzlPwz99IHYnVs28qYAybvAlBV+H7pn0saFY4Ig==", "license": "MIT", - "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/src/components/analytics/analytics-dashboard.tsx b/src/components/analytics/analytics-dashboard.tsx index 0ce0accd..588771ba 100644 --- a/src/components/analytics/analytics-dashboard.tsx +++ b/src/components/analytics/analytics-dashboard.tsx @@ -116,8 +116,6 @@ export function AnalyticsDashboard({ storeId: propStoreId }: AnalyticsDashboardP to, }); - console.log(`[Analytics] Fetching dashboard for ${timeRange}: ${from} to ${to}`); - const response = await fetch(`/api/analytics/dashboard?${params}`, { signal: abortController.signal, cache: 'no-store', @@ -125,13 +123,11 @@ export function AnalyticsDashboard({ storeId: propStoreId }: AnalyticsDashboardP if (!response.ok) throw new Error('Failed to fetch analytics'); const data = await response.json(); - console.log(`[Analytics] Received dashboard data:`, data); setMetrics(data); setActiveTimeRange(timeRange); } catch (error) { if ((error as Error).name !== 'AbortError') { toast.error('Failed to load analytics data'); - console.error('Analytics error:', error); } } finally { setLoading(false); diff --git a/src/components/ui/enhanced-data-table.tsx b/src/components/ui/enhanced-data-table.tsx index f7dd3633..e6238aee 100644 --- a/src/components/ui/enhanced-data-table.tsx +++ b/src/components/ui/enhanced-data-table.tsx @@ -237,8 +237,10 @@ export function EnhancedDataTable({ return [selectColumn, ...columns]; }, [columns, enableRowSelection]); - // React Compiler note: disable the incompatible-library check for useReactTable - + // The react compiler warns about memoizing functions returned from TanStack's useReactTable API. + // This is intentional: disable the incompatible-library check for this call so the compiler + // doesn't try to memoize the returned functions and trigger stale UI errors. + // eslint-disable-next-line react-hooks/incompatible-library const table = useReactTable({ data, columns: tableColumns, diff --git a/src/lib/services/analytics.service.ts b/src/lib/services/analytics.service.ts index 02bcf80f..24190cab 100644 --- a/src/lib/services/analytics.service.ts +++ b/src/lib/services/analytics.service.ts @@ -494,7 +494,8 @@ export class AnalyticsService { // Retention: customers from previous period who also ordered in current period let retainedCustomers = 0; if (previousPeriodCustomerIds.length > 0) { - const retained = customerIdsInPeriod.filter(id => previousPeriodCustomerIds.includes(id)); + const previousPeriodSet = new Set(previousPeriodCustomerIds); + const retained = customerIdsInPeriod.filter(id => previousPeriodSet.has(id)); retainedCustomers = retained.length; } diff --git a/src/lib/services/checkout.service.ts b/src/lib/services/checkout.service.ts index 7ae2efd6..ebd26874 100644 --- a/src/lib/services/checkout.service.ts +++ b/src/lib/services/checkout.service.ts @@ -282,7 +282,7 @@ export class CheckoutService { ]; // Add free shipping for domestic orders over ৳5,000 - if (isDomestic && cartSubtotal >= 50) { + if (isDomestic && cartSubtotal >= 5000) { options.push({ id: 'free', name: 'Free Shipping', diff --git a/src/lib/services/store.service.ts b/src/lib/services/store.service.ts index 3a577347..a19d2245 100644 --- a/src/lib/services/store.service.ts +++ b/src/lib/services/store.service.ts @@ -25,7 +25,7 @@ export const CreateStoreSchema = z.object({ country: z.string().default('BD'), currency: z.string().default('BDT'), timezone: z.string().default('Asia/Dhaka'), - locale: z.string().default('en'), + locale: z.string().default('bn'), subscriptionPlan: z.nativeEnum(SubscriptionPlan).default(SubscriptionPlan.FREE), organizationId: z.string().optional(), // Optional - will be derived from session if not provided });