admin user and ui panel

This commit is contained in:
s.esmaeili
2026-09-21 08:32:31 +03:30
parent 79226c9f13
commit ef1d4638cc
341 changed files with 2270 additions and 657 deletions
@@ -0,0 +1,11 @@
-- AlterTable
ALTER TABLE "ProductVariant" ADD COLUMN "imageId" TEXT;
-- CreateIndex
CREATE INDEX "ProductVariant_imageId_idx" ON "ProductVariant"("imageId");
-- AddForeignKey
-- ON DELETE SET NULL: removing a gallery image must never cascade into the
-- variant, because OrderItem rows reference variants and losing one would
-- break order history. The variant simply loses its picture.
ALTER TABLE "ProductVariant" ADD CONSTRAINT "ProductVariant_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "ProductImage"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -0,0 +1,36 @@
-- Sales agents ("کارشناس فروش") are modelled as AdminUser rows
-- (role=SALES_EXPERT), not Customer rows — see admin-users.service.ts and
-- admin-customers.service.ts's listReagents(). ReagentCustomer.vue used to
-- post agent data at the Customer endpoints instead, so agents ended up as
-- Customer rows (kind SALES_AGENT), which then leaked into every
-- Customer-backed list, including "لیست مشتریان تک" (listSingle had no kind
-- filter at all). Fixed at the application layer alongside this migration;
-- this migration only adds what that fix needs:
--
-- 1. CustomerKind.RETAIL — legacy kept retail ("تک") customers in an
-- entirely separate table (SingleCustomer/`login`) that could never
-- contain a wholesale/agent/shopkeeper/banker row. The redesigned
-- schema folded everything into one Customer model, so listSingle()
-- needs an explicit kind to filter on to reproduce that separation.
-- 2. AdminUser gets the handful of Customer-only columns
-- (ReagentCustomer.vue) that a sales agent's form actually collects:
-- avatar, address, store/pasazh name, member code. Only ever set when
-- role=SALES_EXPERT; every other AdminUser leaves them null.
-- AlterEnum
ALTER TYPE "CustomerKind" ADD VALUE IF NOT EXISTS 'RETAIL';
-- AlterTable
ALTER TABLE "AdminUser"
ADD COLUMN "avatarFileId" TEXT,
ADD COLUMN "address" TEXT,
ADD COLUMN "storeName" TEXT,
ADD COLUMN "pasazhName" TEXT,
ADD COLUMN "memberCode" TEXT;
-- CreateIndex
CREATE INDEX "AdminUser_avatarFileId_idx" ON "AdminUser"("avatarFileId");
-- AddForeignKey
ALTER TABLE "AdminUser" ADD CONSTRAINT "AdminUser_avatarFileId_fkey"
FOREIGN KEY ("avatarFileId") REFERENCES "UploadedFile"("id") ON DELETE SET NULL ON UPDATE CASCADE;