Merge branch 'kub-stage' into production
Build and Deploy to Production / build-and-deploy (push) Failing after 6s
Build and Deploy to Production / build-and-deploy (push) Failing after 6s
Features merged: - Discount shop management (CRUD, inventory, bulk edit) - Blog and content management improvements - Docker build fixes (NuGet package reference) - UI improvements across multiple components Production workflow and Dockerfile preserved.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
name: Build and Deploy
|
||||
name: Build and Deploy to Kubernetes
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -6,85 +6,69 @@ on:
|
||||
- kub-stage
|
||||
|
||||
env:
|
||||
REGISTRY: gitea-svc:3000
|
||||
REGISTRY: 194.5.195.53:30080
|
||||
IMAGE_NAME: admin/backoffice
|
||||
K8S_SERVER: 194.5.195.53
|
||||
|
||||
jobs:
|
||||
build:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: docker:latest
|
||||
image: 194.5.195.53:32082/docker-sshpass:latest
|
||||
options: --privileged
|
||||
env:
|
||||
HTTP_PROXY: http://proxyuser:87zH26nbqT2@46.249.98.211:3128
|
||||
HTTPS_PROXY: http://proxyuser:87zH26nbqT2@46.249.98.211:3128
|
||||
NO_PROXY: localhost,127.0.0.1,gitea-svc,194.5.195.53,10.0.0.0/8
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apk add --no-cache git curl
|
||||
|
||||
# Install kubectl
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||
chmod +x kubectl
|
||||
mv kubectl /usr/local/bin/
|
||||
|
||||
- name: Start Docker daemon with insecure registry
|
||||
- name: Start Docker daemon
|
||||
run: |
|
||||
mkdir -p /etc/docker
|
||||
cat > /etc/docker/daemon.json << 'DAEMON'
|
||||
{
|
||||
"insecure-registries": ["git.foursat.afrino.co", "gitea-svc:3000"]
|
||||
"insecure-registries": ["194.5.195.53:30080", "194.5.195.53:32500", "194.5.195.53:32082"]
|
||||
}
|
||||
DAEMON
|
||||
mkdir -p ~/.docker
|
||||
cat > ~/.docker/config.json << 'CONF'
|
||||
{
|
||||
"proxies": {
|
||||
"default": {
|
||||
"httpProxy": "http://proxyuser:87zH26nbqT2@46.249.98.211:3128",
|
||||
"httpsProxy": "http://proxyuser:87zH26nbqT2@46.249.98.211:3128",
|
||||
"noProxy": "localhost,127.0.0.1,gitea-svc,194.5.195.53,10.0.0.0/8"
|
||||
}
|
||||
}
|
||||
}
|
||||
CONF
|
||||
dockerd &
|
||||
for i in $(seq 1 30); do
|
||||
docker info >/dev/null 2>&1 && break || sleep 2
|
||||
echo "🚀 Starting Docker daemon..."
|
||||
dockerd --iptables=false --ip6tables=false --bridge=none --storage-driver=vfs &
|
||||
|
||||
# Wait up to 3 minutes for Docker to be ready
|
||||
for i in $(seq 1 90); do
|
||||
if docker info >/dev/null 2>&1; then
|
||||
echo "✅ Docker daemon is ready (attempt $i)"
|
||||
docker version
|
||||
break
|
||||
else
|
||||
echo "⏳ Waiting for Docker daemon... (attempt $i/90)"
|
||||
sleep 2
|
||||
fi
|
||||
done
|
||||
docker info
|
||||
|
||||
# Final check
|
||||
if ! docker info >/dev/null 2>&1; then
|
||||
echo "❌ Docker daemon failed to start after 3 minutes"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Checkout code
|
||||
run: |
|
||||
git clone --depth 1 --branch kub-stage http://gitea-svc:3000/admin/BackOffice.git .
|
||||
git log -1 --format="%H %s"
|
||||
|
||||
- name: Login to Docker registries
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login 194.5.195.53:32082 -u admin --password-stdin
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u admin --password-stdin
|
||||
|
||||
- name: Build Docker Image
|
||||
run: |
|
||||
cd src
|
||||
docker build -f BackOffice/Dockerfile \
|
||||
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \
|
||||
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
|
||||
--build-arg HTTP_PROXY=http://proxyuser:87zH26nbqT2@46.249.98.211:3128 \
|
||||
--build-arg HTTPS_PROXY=http://proxyuser:87zH26nbqT2@46.249.98.211:3128 \
|
||||
.
|
||||
|
||||
DOCKER_BUILDKIT=0 docker build --network host -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest -f BackOffice/Dockerfile .
|
||||
|
||||
- name: Push to Registry
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u admin --password-stdin
|
||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||
|
||||
- name: Deploy to Kubernetes
|
||||
run: |
|
||||
# Setup kubeconfig
|
||||
mkdir -p ~/.kube
|
||||
echo "${{ secrets.KUBECONFIG }}" | base64 -d > ~/.kube/config
|
||||
|
||||
# Restart deployment to pull new image
|
||||
kubectl rollout restart deployment/backoffice || echo "Deployment doesn't exist yet"
|
||||
|
||||
# Wait for rollout to complete
|
||||
kubectl rollout status deployment/backoffice --timeout=5m || echo "Deployment rollout pending"
|
||||
export SSHPASS="${{ secrets.SERVER_PASSWORD }}"
|
||||
sshpass -e ssh -o StrictHostKeyChecking=no root@${{ env.K8S_SERVER }} "
|
||||
kubectl rollout restart deployment/backoffice
|
||||
kubectl rollout status deployment/backoffice --timeout=180s
|
||||
"
|
||||
echo "✅ Deployed!"
|
||||
|
||||
Executable
+79
@@ -0,0 +1,79 @@
|
||||
#!/bin/bash
|
||||
# Build all BFF proto dependencies and copy DLLs to libs folder
|
||||
# This script is automatically run before build via Directory.Build.targets
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
LIBS_DIR="$SCRIPT_DIR/libs"
|
||||
BFF_PROTOS_DIR="$SCRIPT_DIR/../BackOffice.BFF/src/Protobufs"
|
||||
|
||||
echo "🔧 Building all proto dependencies..."
|
||||
|
||||
# Create libs directory
|
||||
mkdir -p "$LIBS_DIR"
|
||||
|
||||
# All proto projects
|
||||
PROTO_PROJECTS=(
|
||||
"BackOffice.BFF.Common.Protobuf"
|
||||
"BackOffice.BFF.Category.Protobuf"
|
||||
"BackOffice.BFF.ClubMembership.Protobuf"
|
||||
"BackOffice.BFF.Commission.Protobuf"
|
||||
"BackOffice.BFF.Configuration.Protobuf"
|
||||
"BackOffice.BFF.DiscountCategory.Protobuf"
|
||||
"BackOffice.BFF.DiscountOrder.Protobuf"
|
||||
"BackOffice.BFF.DiscountProduct.Protobuf"
|
||||
"BackOffice.BFF.DiscountShoppingCart.Protobuf"
|
||||
"BackOffice.BFF.Health.Protobuf"
|
||||
"BackOffice.BFF.Inventory.Protobuf"
|
||||
"BackOffice.BFF.ManualPayment.Protobuf"
|
||||
"BackOffice.BFF.NetworkMembership.Protobuf"
|
||||
"BackOffice.BFF.Otp.Protobuf"
|
||||
"BackOffice.BFF.Package.Protobuf"
|
||||
"BackOffice.BFF.Products.Protobuf"
|
||||
"BackOffice.BFF.ProductTag.Protobuf"
|
||||
"BackOffice.BFF.PublicMessage.Protobuf"
|
||||
"BackOffice.BFF.Role.Protobuf"
|
||||
"BackOffice.BFF.Tag.Protobuf"
|
||||
"BackOffice.BFF.User.Protobuf"
|
||||
"BackOffice.BFF.UserAddress.Protobuf"
|
||||
"BackOffice.BFF.UserOrder.Protobuf"
|
||||
"BackOffice.BFF.UserRole.Protobuf"
|
||||
)
|
||||
|
||||
BUILT_COUNT=0
|
||||
FAILED_COUNT=0
|
||||
|
||||
for PROJECT in "${PROTO_PROJECTS[@]}"; do
|
||||
PROJECT_DIR="$BFF_PROTOS_DIR/$PROJECT"
|
||||
if [ -d "$PROJECT_DIR" ]; then
|
||||
echo "📦 Building $PROJECT..."
|
||||
if dotnet build "$PROJECT_DIR" -c Release --verbosity quiet 2>/dev/null; then
|
||||
# Copy DLL and PDB - check both net9.0 and net8.0
|
||||
if [ -f "$PROJECT_DIR/bin/Release/net9.0/$PROJECT.dll" ]; then
|
||||
cp "$PROJECT_DIR/bin/Release/net9.0/$PROJECT.dll" "$LIBS_DIR/" && ((BUILT_COUNT++))
|
||||
cp "$PROJECT_DIR/bin/Release/net9.0/$PROJECT.pdb" "$LIBS_DIR/" 2>/dev/null || true
|
||||
elif [ -f "$PROJECT_DIR/bin/Release/net8.0/$PROJECT.dll" ]; then
|
||||
cp "$PROJECT_DIR/bin/Release/net8.0/$PROJECT.dll" "$LIBS_DIR/" && ((BUILT_COUNT++))
|
||||
cp "$PROJECT_DIR/bin/Release/net8.0/$PROJECT.pdb" "$LIBS_DIR/" 2>/dev/null || true
|
||||
else
|
||||
echo "⚠️ DLL not found for: $PROJECT"
|
||||
((FAILED_COUNT++))
|
||||
fi
|
||||
else
|
||||
echo "⚠️ Failed to build: $PROJECT"
|
||||
((FAILED_COUNT++))
|
||||
fi
|
||||
else
|
||||
echo "⚠️ Project not found: $PROJECT"
|
||||
((FAILED_COUNT++))
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "✅ Build complete!"
|
||||
echo " Built: $BUILT_COUNT projects"
|
||||
echo " Failed: $FAILED_COUNT projects"
|
||||
echo " Output: $LIBS_DIR"
|
||||
echo ""
|
||||
ls -la "$LIBS_DIR"/*.dll 2>/dev/null | wc -l | xargs -I {} echo " Total DLLs: {}"
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,751 @@
|
||||
# 📝 BackOffice — Changelog
|
||||
|
||||
**آخرین بروزرسانی:** بهمن ۱۴۰۴ (February 2026)
|
||||
|
||||
---
|
||||
|
||||
## 🏷 فاز ۱۴ — فیکس Docker Build + Deployment (بهمن ۱۴۰۴)
|
||||
|
||||
> **هدف:** رفع مشکلات Docker build و CI/CD pipeline
|
||||
|
||||
### ۱۴.۱ — تغییر به NuGet Package ✅
|
||||
|
||||
- **مشکل:** `ProjectReference` به `../../../CMS/src/CMSMicroservice.Protobuf/` خارج از Docker build context بود
|
||||
- **رفع:** تغییر به `PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.178"`
|
||||
- **فایل:** `BackOffice.csproj`
|
||||
|
||||
### ۱۴.۲ — حذف COPY libs/ از Dockerfile ✅
|
||||
|
||||
- **مشکل:** `COPY ["libs/", "libs/"]` فیل میشد — `libs/` خارج از build context
|
||||
- **رفع:** حذف خط — دیگه نیازی به DLLهای BFF نیست
|
||||
- **فایل:** `Dockerfile`
|
||||
|
||||
### ۱۴.۳ — تغییر nginx:alpine به رجیستری لوکال ✅
|
||||
|
||||
- **مشکل:** `FROM nginx:alpine` از Docker Hub → TLS handshake timeout
|
||||
- **رفع:** `FROM 194.5.195.53:32082/nginx:alpine`
|
||||
- **فایل:** `Dockerfile`
|
||||
|
||||
### ۱۴.۴ — اضافه شدن SERVER_PASSWORD secret ✅
|
||||
|
||||
- **مشکل:** مرحله Deploy to Kubernetes با `Permission denied` فیل میشد
|
||||
- **رفع:** سکرت `SERVER_PASSWORD` به ریپو Gitea اضافه شد (BackOffice + FrontOffice)
|
||||
|
||||
---
|
||||
|
||||
## 🏷 فاز ۱۳ — بهبودهای UI بکآفیس (بهمن ۱۴۰۴)
|
||||
|
||||
> **هدف:** رفع مشکلات بصری، بهبود UX فرمها و ناوبری
|
||||
|
||||
### ۱۳.۱ — فیکس کامپوننت Image (پیشوند `/uploads/`) ✅
|
||||
|
||||
- **مشکل:** تصاویر آپلودشده (بلاگ، صفحات سایت، سکشنها) در بکآفیس نمایش داده نمیشدند — مسیر `GwUrl + Src` با مسیر `UploadsController` هماهنگ نبود
|
||||
- **رفع:** اضافه شدن `/uploads/` بین `FileBaseUrl` و مسیر نسبی تصویر
|
||||
- **فایل:** `BackOffice/Common/BaseComponents/Image.razor.cs`
|
||||
|
||||
### ۱۳.۲ — فیکس فیلتر هفته در گزارشهای هفتگی ✅
|
||||
|
||||
- **مشکل:** فیلتر هفته از `MudTextField` (ورودی متنی) استفاده میکرد — کاربر باید عدد حدس میزد
|
||||
- **رفع:** جایگزینی با `WeekNumberPicker` — انتخاب هفته از لیست با بایندینگ `WeekDefinitionId`
|
||||
- **فایلها:**
|
||||
- `CMS/src/CMSMicroservice.Protobuf/Protos/commission.proto` — تغییر فیلدها از `StringValue` به `Int64Value`
|
||||
- `CMS/.../CommissionCQ/Queries/GetAllWeeklyPools/GetAllWeeklyPoolsQuery.cs` + `Handler.cs`
|
||||
- `BackOffice/Pages/Commission/WeeklyReports.razor`
|
||||
|
||||
### ۱۳.۳ — فیکس دانلود PDF قراردادها ✅
|
||||
|
||||
- **مشکل:** فیلد `SignedPdfFile` محتوای HTML کامل دارد (نه URL فایل PDF) — دکمه دانلود کار نمیکرد
|
||||
- **رفع:** تابع JS جدید `jsHtmlToPdf()` برای باز کردن HTML در پنجره جدید و چاپ/ذخیره بهعنوان PDF
|
||||
- **فایلها:**
|
||||
- `BackOffice/wwwroot/js/main.js` — تابع `jsHtmlToPdf`
|
||||
- `BackOffice/Pages/Contract/UserContractPage.razor`
|
||||
- `BackOffice/Pages/Contract/ContractDetailsDialog.razor`
|
||||
|
||||
### ۱۳.۴ — یکسانسازی ارتفاع ویرایشگر HTML ✅
|
||||
|
||||
- **مشکل:** ارتفاع `MudHtmlEditor` در صفحات مختلف متفاوت بود — برخی خیلی کوتاه
|
||||
- **رفع:** اضافه شدن `MinHeight="300px"` به تمام ۷ ویرایشگر HTML
|
||||
- **فایلها:** `BlogPostEditDialog`, `SitePageSectionEditDialog`, `DiscountShop/ProductFormDialog`, `Package/CreateDialog`, `Package/UpdateDialog`, `Products/CreateDialog`, `Products/UpdateDialog`
|
||||
|
||||
### ۱۳.۵ — تولید خودکار اسلاگ بلاگ ✅
|
||||
|
||||
- **مشکل:** کاربر باید اسلاگ URL را دستی وارد میکرد — غیرضروری و مستعد خطا
|
||||
- **رفع:** حذف فیلد اسلاگ از فرم، تولید خودکار `post-{GUID}` در بکاند (حداکثر ۲۰ کاراکتر)
|
||||
- **فایلها:**
|
||||
- `CMS/.../BlogPostCQ/Commands/CreateBlogPost/CreateBlogPostCommandHandler.cs`
|
||||
- `CMS/.../BlogPostCQ/Commands/UpdateBlogPost/UpdateBlogPostCommandHandler.cs`
|
||||
- `BackOffice/Pages/Blog/Components/BlogPostEditDialog.razor`
|
||||
|
||||
### ۱۳.۶ — انتقال تگها به منوی جداگانه ✅
|
||||
|
||||
- **مشکل:** تگها فقط از تب سوم بلاگ قابل دسترسی بودند — ولی تگها بین محصولات و بلاگ مشترکند
|
||||
- **رفع:** اضافه شدن مسیر `/tags` به `TagManagementPage`، لینک جدید «مدیریت تگها» در منوی ناوبری، حذف تب تگها از `BlogHub`
|
||||
- **فایلها:**
|
||||
- `BackOffice/Pages/Tag/TagManagementPage.razor`
|
||||
- `BackOffice/Shared/NavMenu.razor`
|
||||
- `BackOffice/Pages/Blog/BlogHub.razor`
|
||||
|
||||
### ۱۳.۷ — تولید خودکار کلید سکشن ✅
|
||||
|
||||
- **مشکل:** کاربر باید کلید سکشن صفحه سایت را دستی وارد میکرد (مثلاً `about-us-section`)
|
||||
- **رفع:** فیلد اختیاری شد، تولید خودکار `section-{GUID}` (حداکثر ۲۰ کاراکتر) در هندلر CMS
|
||||
- **فایلها:**
|
||||
- `CMS/.../SitePageCQ/Commands/CreateSitePageSection/CreateSitePageSectionCommandHandler.cs`
|
||||
- `CMS/.../SitePageCQ/Commands/CreateSitePageSection/CreateSitePageSectionCommandValidator.cs`
|
||||
- `BackOffice/Pages/Content/Components/SitePageSectionEditDialog.razor`
|
||||
|
||||
---
|
||||
|
||||
## 🏷 فاز ۱۲ — فیکس فلوی ثبتنام / ورود FrontOffice (بهمن ۱۴۰۴)
|
||||
|
||||
> **هدف:** رفع ۳ باگ بحرانی در فلوی ثبتنام و ورود FrontOffice
|
||||
> **مستند کامل:** [`totalDoc/cms/REGISTRATION-FLOW-FIXES.md`](../../totalDoc/cms/REGISTRATION-FLOW-FIXES.md)
|
||||
|
||||
### ۱۲.۱ — رفع ایجاد کاربر جدید در VerifyOtpToken 🔴 ✅
|
||||
|
||||
- **مشکل:** `UserCQ/VerifyOtpTokenCommandHandler` کاربران جدید ایجاد نمیکرد — فقط خطای «کاربر یافت نشد»
|
||||
- **رفع:** اضافه شدن لاجیک کامل: اعتبارسنجی کد معرف، بررسی ظرفیت درخت باینری (حداکثر ۲ فرزند)، تعیین شاخه (چپ/راست)، ایجاد User + UserRole + UserWallet، رویدادهای دامنه
|
||||
- **فایل:** `CMS/src/CMSMicroservice.Application/UserCQ/Commands/VerifyOtpToken/VerifyOtpTokenCommandHandler.cs`
|
||||
|
||||
### ۱۲.۲ — رفع جستجوی موبایل در AcceptContract 🔴 ✅
|
||||
|
||||
- **مشکل:** `_currentUserService.Username` = `"{FirstName} {LastName}"` — نه شماره موبایل! در نتیجه OTP و کاربر هیچوقت پیدا نمیشد
|
||||
- **رفع:** ابتدا کاربر از `UserId` پیدا شود، سپس `user.Mobile` برای جستجوی OTP استفاده شود
|
||||
- **فایل:** `CMS/src/CMSMicroservice.Application/UserCQ/Commands/AcceptContract/AcceptContractCommandHandler.cs`
|
||||
|
||||
### ۱۲.۳ — رفع `IsCompleteRegister()` در FrontOffice 🟡 ✅
|
||||
|
||||
- **مشکل:** `InitUserAuthInfo().GetAwaiter()` بدون `.GetResult()` — عملیات async اجرا نمیشود، منوی کناری وضعیت نادرست
|
||||
- **رفع:** تغییر به `InitUserAuthInfo().GetAwaiter().GetResult()`
|
||||
- **فایل:** `FrontOffice/src/FrontOffice.Main/Utilities/AuthService.cs`
|
||||
|
||||
---
|
||||
|
||||
## 🏷 فاز ۱۱ — رفع خطای صفحات + سرویس عمومی تصاویر (بهمن ۱۴۰۴)
|
||||
|
||||
> **هدف:** رفع خطای ۳ صفحه BackOffice + ایجاد اندپوینت HTTP عمومی برای سرو تصاویر
|
||||
|
||||
### ۱۱.۱ — سرویس عمومی سرو تصاویر (CMS) ✅
|
||||
|
||||
- **`UploadsController`** — اندپوینت `GET /uploads/{path}` برای سرو مستقیم فایلها
|
||||
- `[AllowAnonymous]` — بدون نیاز به احراز هویت
|
||||
- کش مرورگر ۲۴ ساعته (`ResponseCache`)
|
||||
- پشتیبانی از Range Requests
|
||||
- **FMS Fallback:** اگر فایل محلی نباشد، از `dl.afrino.co` دانلود و کش میشود
|
||||
- `IHttpClientFactory` با named client `"FMS"` (timeout: 30s)
|
||||
- **فایلها:** `CMS/WebApi/Controllers/UploadsController.cs`, `CMS/WebApi/Program.cs`
|
||||
|
||||
### ۱۱.۲ — رفع صفحه «صفحات سایت» ✅
|
||||
|
||||
- اضافه شدن **دکمه «افزودن صفحه جدید»** به بالای صفحه
|
||||
- اضافه شدن **دکمه «حذف»** (آیکون قرمز) برای هر ردیف
|
||||
- ایجاد **`SitePageCreateDialog`** — دیالوگ ایجاد صفحه جدید با فیلدها:
|
||||
- کلید صفحه (PageKey)، عنوان، توضیحات متا، عنوان هیرو، زیرعنوان هیرو، تصویر هیرو، وضعیت
|
||||
- Proto: اضافه شدن `CreateSitePage` و `DeleteSitePage` RPC
|
||||
- CQRS: `CreateSitePageCommand/Handler` و `DeleteSitePageCommand/Handler`
|
||||
- **فایلها:**
|
||||
- `sitepage.proto` — 2 RPC جدید + پیامهای Request/Response
|
||||
- `SitePageCQ/Commands/CreateSitePage/` — Command + Handler
|
||||
- `SitePageCQ/Commands/DeleteSitePage/` — Command + Handler
|
||||
- `CMS/WebApi/Services/SitePageService.cs` — 2 override جدید
|
||||
- `BackOffice/Services/Content/ISitePageService.cs` — `CreateAsync` + `DeleteAsync` + `SitePageCreateDto`
|
||||
- `BackOffice/Services/Content/SitePageService.cs` — پیادهسازی Create/Delete
|
||||
- `BackOffice/Pages/Content/SitePageManagementPage.razor` — دکمههای Add/Delete
|
||||
- `BackOffice/Pages/Content/SitePageManagementPage.razor.cs` — متدهای CreatePage/DeletePage
|
||||
- `BackOffice/Pages/Content/Components/SitePageCreateDialog.razor` + `.razor.cs`
|
||||
|
||||
### ۱۱.۳ — رفع صفحه «قراردادها» (Contracts) ✅
|
||||
|
||||
- **مشکل:** صفحه `/contracts` اصلاً بارگذاری نمیشد — crash در DI
|
||||
- **علت:** `UserContractContract.UserContractContractClient` در DI ثبت نشده بود
|
||||
- **رفع:** اضافه شدن `using CMSMicroservice.Protobuf.Protos.UserContract` و ثبت gRPC client
|
||||
- **فایل:** `BackOffice/Common/Configure/ConfigureService.cs`
|
||||
|
||||
### ۱۱.۴ — رفع صفحه «کیف پول کاربران» (Wallets) ✅
|
||||
|
||||
- **مشکل:** صفحه `/wallets` اصلاً بارگذاری نمیشد — crash در DI
|
||||
- **علت:** دو سرویس ثبت نشده بود:
|
||||
- `UserWalletContract.UserWalletContractClient`
|
||||
- `UserWalletChangeLogContract.UserWalletChangeLogContractClient`
|
||||
- **رفع:** اضافه شدن usingها و ثبت هر دو gRPC client
|
||||
- **فایل:** `BackOffice/Common/Configure/ConfigureService.cs`
|
||||
|
||||
---
|
||||
|
||||
## 🏷 فاز ۱۰ — بهبود مدیریت محتوا: بلاگ + صفحات سایت (بهمن ۱۴۰۴)
|
||||
|
||||
> **هدف:** فعالسازی آپلود تصویر باینری و ادیتور HTML در صفحات بلاگ و صفحات سایت
|
||||
|
||||
### ۱۰.۱ — بهبود ادیتور پست بلاگ ✅
|
||||
|
||||
- **`MudTextField Lines="10"`** → **`MudHtmlEditor`** برای ویرایش محتوای HTML
|
||||
- **فیلد متنی مسیر تصویر** → **`MudFileUpload`** با پیشنمایش تصویر (`Image` component)
|
||||
- حذف فیلد `FeaturedImageThumbnailPath` (تولید خودکار توسط بکاند)
|
||||
- اضافه شدن `MudForm` با اعتبارسنجی + حالت بارگذاری (`_loading`)
|
||||
- مدیریت خطا: try-catch + Snackbar
|
||||
- **فایلها:** `Pages/Blog/Components/BlogPostEditDialog.razor` + `.razor.cs`
|
||||
|
||||
### ۱۰.۲ — بهبود ادیتور صفحه سایت ✅
|
||||
|
||||
- **فیلد متنی Hero Image** → **`MudFileUpload`** با پیشنمایش تصویر
|
||||
- اضافه شدن `MudForm` + حالت آپلود + مدیریت خطا
|
||||
- **فایلها:** `Pages/Content/Components/SitePageEditDialog.razor` + `.razor.cs`
|
||||
|
||||
### ۱۰.۳ — بهبود ادیتور بخش صفحه سایت (Section) ✅
|
||||
|
||||
- **`MudTextField Lines="8"`** → **`MudHtmlEditor`** برای ویرایش محتوای HTML بخشها
|
||||
- **فیلدهای متنی تصویر/thumbnail** → **`MudFileUpload`** با پیشنمایش
|
||||
- اضافه شدن `MudForm` + حالت آپلود + مدیریت خطا
|
||||
- **فایلها:** `Pages/Content/Components/SitePageSectionEditDialog.razor` + `.razor.cs`
|
||||
|
||||
### ۱۰.۴ — تغییرات Proto ✅
|
||||
|
||||
| Proto | تغییر |
|
||||
|-------|-------|
|
||||
| `blogpost.proto` | اضافه شدن `BlogImageFileModel` + فیلد `image_file` در Create/Update |
|
||||
| `sitepage.proto` | اضافه شدن `SitePageImageFileModel` + فیلد `image_file` در Update/CreateSection/UpdateSection |
|
||||
|
||||
### ۱۰.۵ — تغییرات CQRS (بکاند CMS) ✅
|
||||
|
||||
- **Commands:** اضافه شدن `ImageFileBytes`, `ImageMime`, `ImageFileName` به:
|
||||
- `CreateBlogPostCommand`, `UpdateBlogPostCommand`
|
||||
- `UpdateSitePageCommand`, `CreateSitePageSectionCommand`, `UpdateSitePageSectionCommand`
|
||||
- **Handlers:** تزریق `IFileManager` + فراخوانی `UploadImageAsync`:
|
||||
- BlogPost → `Images/BlogPosts/`
|
||||
- SitePage → `Images/SitePages/`
|
||||
- SitePageSection → `Images/SitePageSections/`
|
||||
|
||||
### ۱۰.۶ — تغییرات سرویسهای BackOffice ✅
|
||||
|
||||
- `BlogPostService.cs` — ارسال `BlogImageFileModel` با `ByteString.CopyFrom(dto.ImageFile)`
|
||||
- `SitePageService.cs` — ارسال `SitePageImageFileModel` در Update/CreateSection/UpdateSection
|
||||
- **DTOs:** اضافه شدن `ImageFile`, `ImageMime`, `ImageFileName` به `BlogPostEditDto`, `SitePageEditDto`, `SitePageSectionEditDto`
|
||||
|
||||
### خلاصه آمار فاز ۱۰
|
||||
| معیار | تعداد |
|
||||
|---|---|
|
||||
| فایلهای proto تغییریافته | 2 |
|
||||
| Commandهای بروزشده | 5 |
|
||||
| Handlerهای بروزشده | 5 |
|
||||
| سرویسهای gRPC تغییریافته | 2 (BlogPostService + SitePageService) |
|
||||
| دیالوگهای UI بازنویسیشده | 3 (BlogPost, SitePage, SitePageSection) |
|
||||
| سرویسهای BackOffice بروزشده | 2 |
|
||||
| DTOهای بروزشده | 3 |
|
||||
| Build | 0 Error ✅ (هر ۳ پروژه) |
|
||||
|
||||
---
|
||||
|
||||
## 🏷 فاز ۹ — معماری مدیریت فایل + رفع سفارشات + مهاجرت DB (بهمن ۱۴۰۴)
|
||||
|
||||
> **مستند کامل معماری فایل:** [`totalDoc/cms/FILE-MANAGEMENT-ARCHITECTURE.md`](../../totalDoc/cms/FILE-MANAGEMENT-ARCHITECTURE.md)
|
||||
|
||||
### ۹.۱ — حذف کد مرده FMS ✅
|
||||
- حذف ۳ فایل غیرقابل استفاده مرتبط با FMS خارجی (`https://dl.afrino.co`):
|
||||
|
||||
| فایل حذفشده | شرح |
|
||||
|-------------|------|
|
||||
| `Infrastructure/Services/FmsFileManager.cs` | پیادهسازی HTTP upload به FMS |
|
||||
| `Application/Common/FileManager/FileManagementService.cs` | سرویس قدیمی مدیریت فایل |
|
||||
| `Application/Common/FileManager/IFileManagementService.cs` | اینترفیس قدیمی |
|
||||
|
||||
### ۹.۲ — رفع صفحه سفارشات (Orders) ✅
|
||||
|
||||
**مشکل ۱ — صفحه خالی (بدون پیغام خطا)**
|
||||
- **علت:** `ServerReload` بدون try-catch — exceptionهای gRPC ساکت میشدند
|
||||
- **رفع:** اضافه شدن try-catch + نمایش خطا با Snackbar
|
||||
- **فایل:** `Pages/UserOrder/UserOrderMainPage.razor.cs`
|
||||
|
||||
**مشکل ۲ — Shadow FK تکراری در OrderVAT**
|
||||
- **علت:** `.WithOne()` بدون inverse navigation → EF Core یک shadow FK اضافی میساخت
|
||||
- **رفع:** `.WithOne()` → `.WithOne(x => x.OrderVAT)`
|
||||
- **فایل:** `Persistence/Configurations/OrderVATConfiguration.cs`
|
||||
|
||||
**مشکل ۳ — فیلترهای oneof همیشه فعال**
|
||||
- **علت:** فیلدهای proto `oneof` مقدار پیشفرض enum دارند (هیچوقت null نیستند)، پس `PaymentStatus != null` همیشه true بود
|
||||
- **رفع:** `PaymentStatus != null` → `HasPaymentStatus == true` (و مشابه برای DeliveryStatus و PaymentMethod)
|
||||
- **فایلها:** `UserOrderService.cs` — هر دو متد `GetAllUserOrderByFilter` و `GetCustomerOrders`
|
||||
|
||||
### ۹.۳ — مهاجرت DB: حذف محدودیت طول ستونهای تصویر ✅
|
||||
|
||||
- **علت:** data URIهای base64 بزرگتر از `nvarchar(500)` بودند → truncation خاموش
|
||||
- **رفع:** حذف `HasMaxLength(500)` از تمام ستونهای image path
|
||||
- **Migration:** `RemoveImagePathMaxLength`
|
||||
|
||||
| Entity | ستونها |
|
||||
|--------|---------|
|
||||
| Product | `ImagePath`, `ImageThumbnailPath` |
|
||||
| DiscountProduct | `ImagePath`, `ImageThumbnailPath` |
|
||||
| Category | `ImagePath` |
|
||||
| DiscountCategory | `ImagePath` |
|
||||
| BlogPost | `FeaturedImagePath`, `FeaturedImageThumbnailPath` |
|
||||
| SitePage | `HeroImagePath` |
|
||||
| SitePageSection | `ImagePath`, `ImageThumbnailPath` |
|
||||
|
||||
### ۹.۴ — بازنویسی کامل مدیریت فایل: ذخیره دیسکی ✅
|
||||
|
||||
**معماری قبلی:** ذخیره data URI مستقیم در DB (ناکارآمد + حجم بالا)
|
||||
|
||||
**معماری جدید:**
|
||||
1. فایلها در دیسک ذخیره میشوند: `Uploads/Images/{folder}/{guid}.jpg`
|
||||
2. مسیر نسبی در DB ذخیره میشود
|
||||
3. `ImagePathResolverInterceptor` هنگام serve تبدیل به base64 میکند
|
||||
|
||||
**فایلهای اصلی:**
|
||||
|
||||
| فایل | شرح |
|
||||
|------|------|
|
||||
| `Application/Common/FileManager/IFileManager.cs` | اینترفیس: Upload, UploadImage, Delete, ResolveImageUrl |
|
||||
| `Infrastructure/Services/LocalFileManager.cs` | پیادهسازی: ImageSharp, main 1200×1200 + thumb 300×300, JPEG Q75 |
|
||||
| `WebApi/Interceptors/ImagePathResolverInterceptor.cs` | gRPC Interceptor: walk بازگشتی response → تبدیل path به data URI |
|
||||
|
||||
**تنظیمات:**
|
||||
- `FileStorage:UploadPath` → پوشه ریشه آپلود (پیشفرض: `AppContext.BaseDirectory/Uploads`)
|
||||
- gRPC MaxReceiveMessageSize: 50MB
|
||||
|
||||
### ۹.۵ — پاکسازی LoggingBehaviour ✅
|
||||
|
||||
- **قبل:** فیلدهای باینری (byte[] تصاویر) کامل در لاگ چاپ میشدند → لاگهای چند مگابایتی
|
||||
- **بعد:**
|
||||
- فرمت: `JsonFormatter.Default.Format()` به جای `{@Request}`
|
||||
- Regex: حذف فیلدهای باینری (`File`, `ImageFile`, `image_file`, `file`)
|
||||
- محدودیت: حداکثر 2000 کاراکتر
|
||||
- **فایل:** `WebApi/Common/Behaviours/LoggingBehaviour.cs`
|
||||
|
||||
### خلاصه آمار فاز ۹
|
||||
| معیار | تعداد |
|
||||
|---|---|
|
||||
| فایلهای حذفشده (کد مرده) | 3 |
|
||||
| فایلهای جدید | 2 (LocalFileManager بازنویسی + ImagePathResolverInterceptor) |
|
||||
| فایلهای ویرایششده | ~12 |
|
||||
| باگهای رفعشده | 4 (Orders page ×3 + DB truncation) |
|
||||
| Migrationهای جدید | 1 (RemoveImagePathMaxLength) |
|
||||
| ستونهای DB تغییریافته | 9 (nvarchar(500) → nvarchar(max)) |
|
||||
| Build | 0 Error ✅ (هر ۳ پروژه) |
|
||||
|
||||
---
|
||||
|
||||
## 🏷 فاز ۸ — یکسانسازی فروشگاه عادی و تخفیفی (بهمن ۱۴۰۴)
|
||||
|
||||
> **مستند کامل:** [`totalDoc/ui-modernization/BACKOFFICE-STORE-UNIFICATION.md`](../../totalDoc/ui-modernization/BACKOFFICE-STORE-UNIFICATION.md)
|
||||
|
||||
### ۸.۱ — بازسازی NavMenu ✅
|
||||
- ایجاد دو NavGroup مجزا: «فروشگاه عادی» و «فروشگاه تخفیفی»
|
||||
- حذف «ویرایش دستهجمعی» از منو
|
||||
- انبارداری → گروه مستقل | پکیجها → آیتم مستقل
|
||||
- **فایل:** `Shared/NavMenu.razor`
|
||||
|
||||
### ۸.۲ — حذف گزارشهای کوچک از سفارشات ✅
|
||||
- حذف کارتهای آماری (TotalOrders + TotalAmount) و نمودار Bar ارسال
|
||||
- حذف فیلدها: `_stats`, `_statusChartLabels`, `_statusChartSeries`
|
||||
- حذف متد `UpdateStats()` و کلاس `OrderStatsViewModel`
|
||||
- عنوان: «سفارشهای کاربر» → «لیست سفارشات»
|
||||
- **فایلها:** `Pages/UserOrder/UserOrderMainPage.razor` + `.razor.cs`
|
||||
|
||||
### ۸.۳ — رفع باگ لیست خالی سفارشات ✅
|
||||
- **علت:** `PaymentDate.ToDateTime()` بدون null check → exception ساکت در WASM
|
||||
- **رفع:** `@if (context.Item.PaymentDate != null)` + fallback "-"
|
||||
- **فایل:** `Pages/UserOrder/UserOrderMainPage.razor`
|
||||
|
||||
### ۸.۴ — بازنویسی صفحه محصولات تخفیفی ✅
|
||||
- تبدیل به `BasePageComponent` (مطابق فروشگاه عادی)
|
||||
- فیلترهای جدید: وضعیت + موجودی
|
||||
- ستونهای جدید: تصویر inline + عنوان truncate + چیپ رنگی موجودی + چیپ وضعیت
|
||||
- **فایلها:** `Pages/DiscountShop/DiscountProductsMainPage.razor` + `.razor.cs` (بازنویسی کامل)
|
||||
|
||||
### ۸.۵ — بازنویسی صفحه دستهبندیهای تخفیفی ✅
|
||||
- تبدیل به `BasePageComponent` (مطابق فروشگاه عادی)
|
||||
- ستونهای جدید: نام لاتین، دستهبندی والد (resolve شده)، تعداد محصولات، ترتیب
|
||||
- code-behind جدید (`@code` درونخطی → `.razor.cs`)
|
||||
- **فایلها:** `Pages/DiscountShop/DiscountCategoriesMainPage.razor` + `.razor.cs` (بازنویسی کامل)
|
||||
|
||||
### خلاصه آمار فاز ۸
|
||||
| معیار | تعداد |
|
||||
|---|---|
|
||||
| فایلهای بازنویسیشده | 4 |
|
||||
| فایلهای ویرایششده | 3 |
|
||||
| باگهای رفعشده | 2 (PaymentDate null + لیست خالی) |
|
||||
| Build | 0 Error ✅ |
|
||||
|
||||
---
|
||||
|
||||
## 🏷 فاز ۷ — پس از اجرای Audit v7.0 (تیر ۱۴۰۴)
|
||||
|
||||
### خلاصه تغییرات
|
||||
- **۵۷ مورد** از ۵۸ یافته audit اجرا شد (≈98%)
|
||||
- **تمام ۱۶ مورد بحرانی 🔴** حل شد
|
||||
- **تمام ۱۸ مورد جزئی 🟢** حل شد
|
||||
- **فازهای ۱ تا ۶ تکمیل شدند** (بهجز DayaLoan و Audit Trail که نیاز به بکاند دارند)
|
||||
- **فاز ۷** — Global Search, Notification Bell, NavMenu Badge, Export Excel 4 صفحه جدید
|
||||
- **۱۳+ فایل جدید** ساخته شد
|
||||
- **۹ صفحه** ادغام شدند (۱۴ صفحه → ۵ صفحه)
|
||||
- **Build**: 0 error ✅
|
||||
|
||||
---
|
||||
|
||||
## فاز ۷ — Global Search + Notifications + Export All + NavMenu Badge (v7.0)
|
||||
|
||||
### 6.5 — Badge Pending در NavMenu — ✅
|
||||
- **`NavMenu.razor`**: اضافه شدن `MudBadge` روی لینک «درخواستهای برداشت»
|
||||
- نمایش تعداد درخواستهای Pending بصورت real-time از gRPC (`CommissionContract.GetWithdrawalRequestsAsync` با `Status=0`)
|
||||
- fire-and-forget در `OnInitializedAsync` با try/catch silent
|
||||
|
||||
### 6.2 — Global Search در AppBar — ✅
|
||||
- **فایل جدید**: `Shared/GlobalSearch.razor`
|
||||
- `MudAutocomplete<SearchResultItem>` با Debounce 400ms
|
||||
- دو نوع جستجو: ۱) نام صفحات (۱۵ صفحه اصلی) ۲) کاربران از gRPC (`UserContract.GetAllUserByFilterAsync`)
|
||||
- Template سفارشی با آیکون + عنوان + زیرنویس
|
||||
- ناوبری خودکار با `Navigation.NavigateTo`
|
||||
- اضافه شده در `MainLayout.razor` داخل `<AuthorizeView>`
|
||||
- CSS در `app.css` — rounded border-radius 24px, compact padding
|
||||
|
||||
### 6.1 — Notification Bell (placeholder) — ✅
|
||||
- **`MainLayout.razor`**: اضافه شدن `MudMenu` + `MudBadge` (Dot) + آیکون Notifications
|
||||
- Dropdown با هدر «اعلانها» + placeholder «اعلان جدیدی وجود ندارد»
|
||||
- آماده اتصال به بکاند — فقط `Visible=true` و populate items
|
||||
|
||||
### 6.3 — Export Excel صفحات جدید — ✅ (۱۰ صفحه کامل)
|
||||
- **۴ صفحه جدید** اضافه شدند به ۶ صفحه قبلی:
|
||||
1. **UserMainPage** — خروجی CSV: شناسه, موبایل, نام, نام خانوادگی, کدملی
|
||||
2. **DiscountOrdersMainPage** — خروجی CSV: شماره سفارش, تاریخ, مبلغ کل, تخفیف, قابل پرداخت, تعداد, وضعیت, پرداخت
|
||||
3. **ManualPayments** — خروجی CSV: شناسه, شناسه کاربر, نام کاربر, مبلغ, نوع, وضعیت, تاریخ
|
||||
4. **InventoryMainPage** — خروجی CSV: شناسه, محصول, انبار, موجودی, رزرو, قابل فروش, حد هشدار, وضعیت
|
||||
- هر ۴ صفحه: دکمه «خروجی Excel» + `ExportToExcel()` + `EscapeCsv()` + UTF-8 BOM + `jsSaveAsFile`
|
||||
- فایلهای code-behind جدید: `ManualPayments.razor.cs`, `DiscountOrdersMainPage.razor.cs`
|
||||
|
||||
---
|
||||
|
||||
## فاز ۶ — تاریخ شمسی + تاریخچهها + Export Excel (v6.0)
|
||||
|
||||
### تاریخ شمسی یکپارچه (3.6) — ✅ کامل
|
||||
- **۱۹+ فایل** آپدیت شدند: تمام تاریخها از فرمت میلادی (`yyyy/MM/dd`) به شمسی تبدیل شدند
|
||||
- از extension methodهای `DateTimeConverterCL` استفاده شد:
|
||||
- `.MiladiToJalali()` — فرمت تاریخ فقط (مثال: ۱۴۰۴/۰۴/۱۲)
|
||||
- `.MiladiToJalaliWithTime()` — فرمت تاریخ و ساعت
|
||||
- **صفحات اصلاحشده شامل**: Club (Members, Statistics, Features, MemberDetailsDialog)، Commission (Dashboard, WeeklyReports, WithdrawalRequests, Payouts, WithdrawalReports)، Network (UserNetworkInfo, BalancesReport, Statistics, NetworkTreeViewer)، UserOrder, Products, Package, Inventory, DiscountShop, Blog, Content, و غیره
|
||||
- `PropertyColumn Format="yyyy/MM/dd"` → `TemplateColumn` با `.MiladiToJalali()`
|
||||
- `MudDatePicker DateFormat` تغییر نکرد (قابلیت تقویم شمسی نیاز به کتابخانه جداگانه دارد)
|
||||
|
||||
### تاریخچه عضویت باشگاه (5.7) — ✅
|
||||
- **`MemberDetailsDialog.razor`**: تب تاریخچه با فیلدهای صحیح proto:
|
||||
- ستونها: `Action`, `Created`, `PackageName`, `Reason`, `PerformedBy`
|
||||
- Request: `PageIndex = 0` (نه PageNumber)
|
||||
|
||||
### تاریخچه تغییرات شبکه (5.8) — ✅
|
||||
- **`UserNetworkInfo.razor`**: تب تاریخچه با فیلدهای تخصصی:
|
||||
- ستونها: `Action`, `Created`, `OldParentId → NewParentId`, `OldNetworkLeg → NewNetworkLeg` (چپ/راست)
|
||||
- ستون `Reason` و `PerformedBy` اضافه شد
|
||||
- Request: `PageIndex = 0`
|
||||
|
||||
### لاگ اجرای Workerها (5.6) — ✅
|
||||
- در تب WorkerControl از SystemHub قبلاً پیادهسازی شده بود
|
||||
|
||||
### Export Excel / CSV (6.3) — ✅ ۶ صفحه
|
||||
قابلیت خروجی CSV (سازگار با Excel) به ۶ صفحه اصلی اضافه شد:
|
||||
|
||||
| صفحه | فایل(ها) | ستونهای خروجی |
|
||||
|---|---|---|
|
||||
| **Products** (قبلاً موجود) | ProductsMainPage.razor.cs | — |
|
||||
| **Club Members** | ClubMembers.razor + .razor.cs | شناسه,کاربر,نام,پکیج,کد فعالسازی,تاریخ فعالسازی,تاریخ انقضا,فعال,منقضی |
|
||||
| **Withdrawal Requests** | WithdrawalRequests.razor + .razor.cs | شناسه,کاربر,نام,مبلغ,وضعیت,روش,شبا,تاریخ درخواست,تاریخ پردازش,مرجع بانکی |
|
||||
| **Weekly Reports** | WeeklyReports.razor + .razor.cs | هفته,مبلغ استخر,موجودیها,ارزش,وضعیت,تاریخ محاسبه |
|
||||
| **User Orders** | UserOrderMainPage.razor + .razor.cs | شناسه,کاربر,نام,مبلغ,وضعیت پرداخت,وضعیت ارسال,روش پرداخت,تاریخ |
|
||||
| **Stock Movements** | MovementsPage.razor + .razor.cs | شناسه,محصول,نوع,تعداد,قبل,بعد,مرجع,یادداشت,تاریخ |
|
||||
|
||||
**الگوی پیادهسازی:**
|
||||
- دکمه `<MudButton>` با آیکون `FileDownload` در ToolBarContent
|
||||
- `StringBuilder` → CSV با هدرهای فارسی
|
||||
- UTF-8 BOM (`Encoding.UTF8.GetPreamble()`) برای نمایش صحیح فارسی در Excel
|
||||
- `jsSaveAsFile(filename, base64)` از `wwwroot/js/main.js`
|
||||
- متد `EscapeCsv()` برای مقادیر حاوی کاما/کوتیشن
|
||||
- تاریخها در خروجی نیز شمسی هستند
|
||||
|
||||
### فایلهای جدید (این نسخه)
|
||||
|
||||
| فایل | عملکرد |
|
||||
|---|---|
|
||||
| `Pages/Commission/WeeklyReports.razor.cs` | Code-behind برای export (بهدلیل محدودیت Razor parser با escaped quotes) |
|
||||
|
||||
---
|
||||
|
||||
## نسخه قبلی — Audit v5.0 (خرداد ۱۴۰۴)
|
||||
|
||||
### تم رنگی یکپارچه
|
||||
- **`CustomMudTheme.cs`**: تم Primary از `#0380C0` به `#6366f1` (Indigo) تغییر کرد — هماهنگ با FrontOffice
|
||||
- **`PaletteDark`** اضافه شد: Surface `#1a1a2e`, Background `#16213e`, AppbarBackground `#0f3460`
|
||||
- **`app.css`**: رنگ loading از `#1b6ec2` به `var(--mud-palette-primary)` تغییر کرد
|
||||
- **`NavMenu.razor.css`**: رنگ active از `#0380C0` هاردکد به CSS variable تغییر کرد
|
||||
- **`MainLayout.razor`**: حذف inline style `border: 1px solid #5e4df9`
|
||||
|
||||
### Dark Mode Toggle
|
||||
- آیکون ماه/آفتاب در AppBar اضافه شد
|
||||
- `_isDarkMode` state با `MudThemeProvider` اتصال دارد
|
||||
- تعویض بین `PaletteLight` و `PaletteDark` در CustomMudTheme
|
||||
|
||||
### عنوان اپلیکیشن
|
||||
- "پنل مدیریت **فرصت**" → "پنل مدیریت **کارا بازار سلامت**"
|
||||
|
||||
---
|
||||
|
||||
## فاز ۲ — بازطراحی لایوت صفحات
|
||||
|
||||
### BasePageComponent بازنویسی کامل
|
||||
- **قبل**: فیلتر ثابت سمت راست (20%) + جدول (80%)، ارتفاع 85vh هاردکد
|
||||
- **بعد**: فیلتر collapsible بالای جدول، فیلدها در `MudGrid` با `MudItem`، responsive
|
||||
- **۱۳ صفحه** آپدیت شدند: User, Products, Package, Category, UserOrder, UserAddress, UserRole, Role, BlogPost, BlogCategory, Tag, Transactions, Content
|
||||
|
||||
### DataGrid Height یکسانسازی
|
||||
- همه DataGridها: `Height="calc(100vh - 240px)"`
|
||||
- **صفحات اصلاحشده**: تمام ~33 صفحه دارای DataGrid
|
||||
|
||||
### Pager یکسانسازی
|
||||
- **PageSize**: همه `20, 50, 100`
|
||||
- **متن فارسی**: `RowsPerPageString="تعداد در صفحه"` و `InfoFormat="سطر {first_item} تا {last_item} از {all_items}"`
|
||||
|
||||
### MaxWidth یکسانسازی
|
||||
- `MainLayout.razor` MudContainer wrapper اضافه شد → MaxWidth یکسان برای همه صفحات
|
||||
- **۳۱ صفحه**: حذف `MudContainer` تکراری (double nesting)
|
||||
|
||||
### Breadcrumb
|
||||
- **`Shared/AppBreadcrumb.razor`** ساخته شد
|
||||
- جداکننده چپبهراست (`ChevronLeft`)
|
||||
- نقشه فارسی URL segments (60+ مسیر)
|
||||
- آخرین آیتم disabled (صفحه فعلی)
|
||||
|
||||
### Login + VerifyCode بازطراحی
|
||||
- عرض ثابت 35% → responsive `MaxWidth.Small`
|
||||
- لوگو + برندینگ "کارا بازار سلامت" اضافه شد
|
||||
- طراحی gradient background
|
||||
|
||||
---
|
||||
|
||||
## فاز ۲.۵ — پاکسازی ساختاری
|
||||
|
||||
### NavMenu بازسازی کامل
|
||||
- **لینک مرده `categories-dragdrop`**: حذف شد
|
||||
- **Transactions**: حذف از NavMenu (صفحه stub خالی)
|
||||
- **AlertsMonitoring**: حذف از NavMenu (100% mock)
|
||||
- **WorkerControl**: به SystemHub منتقل شد (قبلاً لینک نداشت)
|
||||
- **«پیامهای عمومی»**: از بخش فروشگاه تخفیفی به «مدیریت محتوا» منتقل شد
|
||||
- **ساختار گروهبندی** اصلاح شد:
|
||||
- کمیسیون و شبکه: NavGroup واضح
|
||||
- باشگاه مشتریان: اعضا و آمار + فیچرها
|
||||
- فروشگاه: پکیجها، محصولات (group)، سفارشها، فروشگاه تخفیفی (group)
|
||||
- مدیریت: کاربران، نقشها، پرداخت دستی، **کیفپول (جدید)**، **قراردادها (جدید)**
|
||||
- محتوا: بلاگ، صفحات سایت، پیامهای عمومی
|
||||
- سیستم: مدیریت سیستم، نسخه اپها
|
||||
|
||||
---
|
||||
|
||||
## فاز ۳ — UX بهبودها
|
||||
|
||||
### NoRecordsContent (Empty State)
|
||||
- **۳۳ DataGrid** آپدیت شدند
|
||||
- پیام: `<MudAlert Severity="Info">موردی یافت نشد.</MudAlert>`
|
||||
|
||||
### Delete Confirmation با نام آیتم
|
||||
- **۱۱ صفحه** اصلاح شدند:
|
||||
- Role → `«{model.Title}»`
|
||||
- User → `«{model.FirstName} {model.LastName}»`
|
||||
- Package → `«{model.Title}»`
|
||||
- UserAddress → `«{model.Title}»`
|
||||
- UserRole → `شناسه «{model.Id}»`
|
||||
- UserOrder → `شماره «{model.Id}»`
|
||||
- Category → `«{model.Title}»`
|
||||
- Products → `«{model.Title}»`
|
||||
- DiscountCategories → `«{category?.Title}»` (lookup اضافه شد)
|
||||
- DiscountProducts → `«{product?.Title}»` (lookup اضافه شد)
|
||||
- PublicMessages → `«{message?.Title}»` (lookup اضافه شد)
|
||||
|
||||
### User Menu در AppBar
|
||||
- `MudMenu` جایگزین متن ساده شماره موبایل شد
|
||||
- آیتمها: نام کاربر (غیرفعال) + خروج
|
||||
- آیکون `AccountCircle`
|
||||
- خروج (`signout`) از NavMenu به AppBar منتقل شد
|
||||
|
||||
---
|
||||
|
||||
## فاز ۳.۵ — ادغام صفحات
|
||||
|
||||
### Dashboard Merge ← `Pages/Index.razor`
|
||||
- **`Index.razor` + `SystemOverview.razor`** ادغام شدند
|
||||
- Routes: `/` + `/dashboard/overview`
|
||||
- بخشها:
|
||||
- 6 کارت آمار CMS (کاربران، محصولات، پکیجها، دستهبندیها، سفارشها، مبلغ پرداختشده)
|
||||
- آمار کمیسیون (هفته جاری، استخر، موجودیها، وضعیت محاسبه)
|
||||
- آمار باشگاه (کل/فعال/غیرفعال)
|
||||
- جدول آخرین ۵ سفارش پرداختشده
|
||||
- ۶ دکمه Quick Action
|
||||
- بارگذاری موازی با `Task.WhenAll` + `.ResponseAsync`
|
||||
- `SystemOverview.razor` **حذف شد**
|
||||
|
||||
### DiscountShopHub ← `Pages/DiscountShop/DiscountShopHub.razor`
|
||||
- Routes: `/discount-shop`, `/discount-orders`, `/discount-sales-reports`
|
||||
- ۲ تب: DiscountOrdersMainPage + SalesReports
|
||||
- انتخاب تب از URL
|
||||
|
||||
### ClubHub ← `Pages/Club/ClubHub.razor`
|
||||
- Routes: `/club`, `/club/members`, `/club/statistics`
|
||||
- ۲ تب: ClubMembers + Statistics
|
||||
|
||||
### BlogHub ← `Pages/Blog/BlogHub.razor`
|
||||
- Routes: `/blog`, `/blog/posts`, `/blog/categories`, `/tags`
|
||||
- ۳ تب: BlogPostManagementPage + BlogCategoryManagementPage + TagManagementPage
|
||||
|
||||
### SystemHub ← `Pages/SystemManagement/SystemHub.razor`
|
||||
- Routes: `/system`, `/system/configuration`, `/system/worker-control`, `/system/health`
|
||||
- ۳ تب: Configuration + WorkerControl + HealthDashboard
|
||||
|
||||
### ۱۰ صفحه — `@page` directive حذف شد
|
||||
صفحاتی که به hub منتقل شدند دیگر route مستقل ندارند:
|
||||
DiscountOrdersMainPage, SalesReports, ClubMembers, Statistics, BlogPostManagementPage, BlogCategoryManagementPage, TagManagementPage, Configuration, WorkerControl, HealthDashboard
|
||||
|
||||
---
|
||||
|
||||
## فاز ۴ — فیکسهای بیزینسی
|
||||
|
||||
### Dashboard آمار اصلاح شد
|
||||
- **قبل**: آمار از ۱۰ رکورد اول محاسبه میشد (نادرست)
|
||||
- **بعد**: از `metadata.TotalCount` و APIهای جداگانه استفاده میشود
|
||||
|
||||
### ManualPayments — تأیید/رد
|
||||
- دکمههای Approve/Reject وقتی `Status==0` (در انتظار) نمایش داده میشوند
|
||||
- Confirmation dialog قبل از اجرا
|
||||
- از `ManualPaymentId` (نه `Id`) استفاده میشود
|
||||
|
||||
### UserOrder — فیلتر Cancelled
|
||||
- `<MudSelectItem Value="@(5)">لغو شده</MudSelectItem>` اضافه شد
|
||||
|
||||
### WithdrawalRequests — بهبود کامل
|
||||
- **Pager**: 10/25/50/100 → 20/50/100
|
||||
- **`WithdrawalDetailsDialog.razor`** (جدید): نمایش کامل اطلاعات کاربر، درخواست، و بانکی
|
||||
- **`RejectReasonDialog.razor`** (جدید): ورود دلیل رد با اعتبارسنجی
|
||||
- ViewDetails: از Snackbar TODO به دیالوگ واقعی تغییر کرد
|
||||
- RejectRequest: از دلیل هاردکد به دیالوگ custom تغییر کرد
|
||||
|
||||
---
|
||||
|
||||
## فاز ۵ — صفحات مفقود (CMS-Derived)
|
||||
|
||||
### WalletManagementPage ← `Pages/Wallet/WalletManagementPage.razor`
|
||||
- Route: `/wallets`
|
||||
- **تب ۱ — کیفپولها**: DataGrid با ServerData، فیلتر UserAutoComplete
|
||||
- ستونها: شناسه، کاربر، موجودی اصلی، موجودی شبکه، مشاهده تغییرات
|
||||
- نوع: `GetAllUserWalletByFilterResponseModel`
|
||||
- **تب ۲ — تاریخچه تغییرات**: DataGrid با ServerData، فیلتر کاربر + نوع (افزایش/کاهش)
|
||||
- ستونها: شناسه، کیفپول، نوع (چیپ رنگی)، تغییر موجودی، موجودی فعلی، تغییر شبکه، موجودی شبکه فعلی، شناسه مرجع، تاریخ
|
||||
- نوع: `GetAllUserWalletChangeLogByFilterResponseModel`
|
||||
- فیلدهای proto با typo: `ChangeNerworkValue`, `RefrenceId`
|
||||
|
||||
### UserContractPage ← `Pages/Contract/UserContractPage.razor`
|
||||
- Route: `/contracts`
|
||||
- DataGrid با ServerData، فیلتر UserAutoComplete
|
||||
- ستونها: شناسه، کاربر، قرارداد، کد امضا، لینک PDF، جزئیات
|
||||
- نوع: `GetAllUserContractByFilterResponseModel`
|
||||
|
||||
### ContractDetailsDialog ← `Pages/Contract/ContractDetailsDialog.razor`
|
||||
- جدول ساده: شناسه، کاربر، قالب قرارداد، کد امضا، لینک دانلود PDF
|
||||
|
||||
### ClubFeaturesPage ← `Pages/Club/ClubFeaturesPage.razor`
|
||||
- Route: `/club/features`
|
||||
- **تب ۱ — فیچرهای تعریفشده**: کارتهای MudPaper با عنوان، توضیحات، وضعیت (فعال/غیرفعال)، ترتیب
|
||||
- از `ConfigClient.GetClubFeaturesAsync`
|
||||
- **تب ۲ — فیچرهای کاربران**: DataGrid با فیلتر کاربر، سوئیچ فعال/غیرفعال
|
||||
- از `ClubClient.GetUserClubFeaturesAsync` + `ToggleUserClubFeatureAsync`
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ نکات فنی مهم
|
||||
|
||||
### الگوهای Proto
|
||||
- **فیلتر**: `new GetAllXxxByFilterFilter()` (سطح بالا، بدون `.Types.`)
|
||||
- **پاسخ لیست**: `GetAllXxxByFilterResponseModel` (نه `GetXxxResponse`)
|
||||
- **Typoها در proto**: `ChangeNerworkValue` و `RefrenceId` — باید دقیقاً همینها استفاده شوند
|
||||
|
||||
### _Imports.razor — سرویسهای Global
|
||||
سرویسهای زیر از `_Imports.razor` تزریق میشوند و نباید در code-behind با `[Inject]` دوباره تعریف شوند:
|
||||
- `NavigationManager Navigation`
|
||||
- `ILocalStorageService LocalStorageService`
|
||||
- `ISnackbar Snackbar`
|
||||
- `IJSRuntime jsRuntime`
|
||||
- `IDialogService DialogService`
|
||||
- `AuthenticationStateProvider`
|
||||
|
||||
### MudBlazor محدودیتها
|
||||
- `Variant.Flat` وجود ندارد → از `Variant.Text` استفاده شود
|
||||
- `GutterSize` روی `MudGrid` deprecated است
|
||||
|
||||
---
|
||||
|
||||
## فاز ۴ (ادامه) — تکمیل فیکسهای بیزینسی
|
||||
|
||||
### UserSettings — حذف تبهای جعلی (2.5.5)
|
||||
- **`UserSettings.razor`**: تب Notifications (۷ تاگل جعلی بدون بکاند) → placeholder «بهزودی فعال میشود» با آیکون NotificationsActive
|
||||
- **`UserSettings.razor`**: تب Security (فرم تغییر رمز + 2FA بدون بکاند) → placeholder «بهزودی فعال میشود» با آیکون Lock
|
||||
- **حذف کد مرده**: ~۱۵ متغیر notification/security + متدهای `SaveNotificationSettings()`, `SaveSecuritySettings()`, `ChangePassword()`
|
||||
|
||||
### HealthDashboard — حذف متریکهای Mock (2.5.6)
|
||||
- **`HealthDashboard.razor`**: بخش System Resources (۴ کارت CPU=45.2%, Memory=62.8%, Disk=73.5%, Network) → یک کارت با پیام «مانیتورینگ منابع سیستم در نسخههای آینده با اتصال به Prometheus/Grafana فعال خواهد شد»
|
||||
- **حذف کد مرده**: ۹ متغیر mock (`_cpuUsage`, `_memoryUsage`, etc.) + متد `GetResourceColor()`
|
||||
|
||||
### حذف cursor:pointer زائد (4.10)
|
||||
- `Style="cursor:pointer;"` از **۱۷ فایل** حذف شد (MudButton/MudIconButton خودشان cursor:pointer دارند)
|
||||
- شامل: ProductsMainPage, GalleryDialog, Image.razor (base component), RoleMainPage, UserOrderMainPage, PackageMainPage, etc.
|
||||
|
||||
### حذف Console.WriteLine (4.11)
|
||||
- از **۱۱ فایل** حذف شد: DiscountProductService, DiscountCategoryService, NetworkTreeViewer, UserSettings, CategoryMainPage, UserOrderMainPage, Commission/Dashboard, DiscountProductsMainPage, DiscountCategoryMultiSelectCombo, UserRole/CreateDialog
|
||||
- **`Commission/Dashboard.razor.cs`**: `using System.Text.Json` هم حذف شد (دیگر استفاده نمیشد)
|
||||
|
||||
### DiscountProducts — فیلتر دستهبندی (4.7)
|
||||
- **`DiscountProductsMainPage.razor`**: `@inject IDiscountCategoryService` اضافه شد
|
||||
- دستهبندیهای فعال از سرویس بارگذاری و در MudSelect نمایش داده میشوند
|
||||
- جایگزینی `@* TODO: Load categories *@` با `@foreach` واقعی
|
||||
|
||||
### DiscountProducts — Items → ServerData (4.8)
|
||||
- **`DiscountProductsMainPage.razor`**: تبدیل از `Items="@_products"` به `ServerData="LoadServerData"`
|
||||
- متد `LoadServerData(GridState<T>)` اضافه شد با `PageNumber` و `PageSize` از state
|
||||
- `Height="calc(100vh - 300px)"` + `FixedHeader="true"` اضافه شد
|
||||
- Snackbar اطلاعرسانی اضافی در هر بارگذاری حذف شد (redundant)
|
||||
|
||||
### UserOrder — فعالسازی آمار (4.6)
|
||||
- **`UserOrderMainPage.razor`**: بخش آمار (MudCard + MudChart) از حالت comment خارج شد
|
||||
- نمایش تعداد سفارشها + مجموع مبلغ + نمودار Bar وضعیت ارسال
|
||||
|
||||
### UserSettings — persist با localStorage (4.9)
|
||||
- تب General از قبل با localStorage کار میکرد ✅ (فقط تبهای جعلی حذف شدند)
|
||||
|
||||
---
|
||||
|
||||
## فاز ۴.۵ — Cross-Navigation
|
||||
|
||||
### لینک نام کاربر → پروفایل (4.5.1, 4.5.2)
|
||||
- **`UserOrderMainPage.razor`**: ستون `UserFullName` از PropertyColumn به TemplateColumn تبدیل شد — MudLink به `/network/user-info/{UserId}`
|
||||
- **`UserPayouts.razor`**: نام/شناسه کاربر به MudLink تبدیل شد → `/network/user-info/{UserId}`
|
||||
- **`WithdrawalRequests.razor`**: نام کاربر به MudLink تبدیل شد → `/network/user-info/{UserId}`
|
||||
|
||||
### لینک محصول ↔ انبار (4.5.3, 4.5.4) — Skip
|
||||
- صفحه جزئیات محصول وجود ندارد (فقط لیست + دیالوگ ویرایش)
|
||||
- لینک cross-navigation بدون صفحه مقصد معنادار نیست
|
||||
|
||||
### Extract shared status helpers (3.5.6) — Skip
|
||||
- بررسی نشان داد هر context مقادیر متفاوتی دارد:
|
||||
- UserPayouts: status 1 = Success/پرداخت شده
|
||||
- WithdrawalRequests: status 1 = Info/واریز شده
|
||||
- PayoutDetailsDialog: فقط ۳ وضعیت (نه ۶)
|
||||
- استخراج به helper مشترک باعث از دست رفتن معنای domain-specific میشود
|
||||
|
||||
---
|
||||
|
||||
## 📈 آمار تغییرات
|
||||
|
||||
| معیار | تعداد |
|
||||
|---|---|
|
||||
| فایلهای جدید | 11 |
|
||||
| فایلهای حذفشده | 1 (SystemOverview.razor) |
|
||||
| فایلهای ویرایششده | ~65+ |
|
||||
| DataGridهای آپدیتشده | 33 |
|
||||
| Delete confirmation اصلاحشده | 11 |
|
||||
| صفحات ادغامشده | 14 → 5 |
|
||||
| خطاهای build حلشده | 9+ |
|
||||
| Console.WriteLine حذفشده | 22+ (از ۱۱ فایل) |
|
||||
| cursor:pointer حذفشده | 17 فایل |
|
||||
| Cross-link اضافهشده | 3 صفحه (UserOrder, UserPayouts, WithdrawalRequests) |
|
||||
@@ -1,501 +0,0 @@
|
||||
# BackOffice Build Fix Status
|
||||
|
||||
> آخرین بروزرسانی: December 20, 2025
|
||||
|
||||
## وضعیت فعلی
|
||||
|
||||
**Build Status**: ✅ SUCCESS - 0 Error
|
||||
|
||||
### BackOffice.BFF Solution:
|
||||
- **Build**: ✅ موفق - 0 Error
|
||||
- **Proto Projects فعال**:
|
||||
- ✅ BackOffice.BFF.Tag.Protobuf
|
||||
- ✅ BackOffice.BFF.ProductTag.Protobuf
|
||||
- ✅ BackOffice.BFF.DiscountProduct.Protobuf
|
||||
- ✅ BackOffice.BFF.DiscountCategory.Protobuf
|
||||
- ✅ BackOffice.BFF.DiscountOrder.Protobuf
|
||||
- ✅ BackOffice.BFF.DiscountShoppingCart.Protobuf
|
||||
- ✅ BackOffice.BFF.PublicMessage.Protobuf
|
||||
- ✅ BackOffice.BFF.ManualPayment.Protobuf
|
||||
- ✅ BackOffice.BFF.ClubMembership.Protobuf
|
||||
- ✅ BackOffice.BFF.Commission.Protobuf
|
||||
|
||||
### BackOffice UI:
|
||||
- **Build**: ✅ موفق - 0 Error
|
||||
- **Framework**: Blazor WebAssembly .NET 9.0
|
||||
- **UI Library**: MudBlazor 8.14.0
|
||||
|
||||
### CMS Microservice:
|
||||
- **Build**: ✅ موفق - 0 Error
|
||||
|
||||
**پیشرفت کلی**: از 60+ خطا به 0 خطا رسیدیم ✨
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ ملاحظات مهم Proto Packages
|
||||
|
||||
> **هشدار مهم**: هر تغییری در Proto files نیاز به این 3 مرحله دارد:
|
||||
|
||||
### چکلیست اجباری بعد از تغییر Proto:
|
||||
|
||||
1. **افزایش Version** در `.csproj`:
|
||||
```xml
|
||||
<Version>0.0.142</Version> → <Version>0.0.143</Version>
|
||||
```
|
||||
|
||||
2. **Pack کردن** Proto project:
|
||||
```bash
|
||||
cd path/to/proto/project
|
||||
dotnet pack -c Release
|
||||
# ✅ خودکار push میشه به GitLab Registry
|
||||
```
|
||||
|
||||
3. **Update Version** در پروژههای وابسته (لایه بالاتر):
|
||||
```xml
|
||||
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.143" />
|
||||
```
|
||||
|
||||
**مثال**: تغییر در CMS Proto → Pack → Update در BFF Protos → Pack → Update در UI
|
||||
|
||||
**⚠️ فراموش کردن این مراحل = Build Error یا Runtime Bug**
|
||||
|
||||
---
|
||||
|
||||
## ماژولهای فعال شده (Enabled Modules)
|
||||
|
||||
### ✅ کاملاً فعال و تست شده:
|
||||
|
||||
1. **DiscountShop Module** (فروشگاه تخفیفی)
|
||||
- ✅ DiscountProductsMainPage - مدیریت محصولات تخفیفی
|
||||
- ✅ DiscountCategoriesMainPage - مدیریت دستهبندیها (با MudDataGrid)
|
||||
- ✅ DiscountOrdersMainPage - مدیریت سفارشات
|
||||
- ✅ SalesReports - گزارش فروش
|
||||
- ✅ ProductImageGallery - گالری تصاویر (با MudBlazor 8 fixes)
|
||||
- Services: IDiscountProductService, IDiscountCategoryService, IDiscountOrderService
|
||||
|
||||
2. **PublicMessages Module** (پیامهای عمومی)
|
||||
- ✅ PublicMessagesMainPage - مدیریت پیامها
|
||||
- ✅ MessageFormDialog - فرم ایجاد/ویرایش
|
||||
- ✅ MessageViewDialog - نمایش جزئیات
|
||||
- ✅ MessageTemplatesDialog - قالبهای آماده
|
||||
- Services: IPublicMessageService
|
||||
- Proto: BackOffice.BFF.PublicMessage.Protobuf
|
||||
|
||||
3. **ManualPayment Module** (پرداختهای دستی)
|
||||
- ✅ ManualPayments - صفحه اصلی مدیریت
|
||||
- ✅ ManualPaymentDialog - فرم ایجاد و تایید/رد
|
||||
- Services: Direct gRPC to ManualPaymentContract
|
||||
- Proto: BackOffice.BFF.ManualPayment.Protobuf
|
||||
|
||||
4. **Tag Module** (برچسبها)
|
||||
- ✅ TagManagementPage - مدیریت تگها
|
||||
- ✅ TagEditDialog - ویرایش تگ
|
||||
- Services: ITagService, IProductTagService
|
||||
- Proto: BackOffice.BFF.Tag.Protobuf, BackOffice.BFF.ProductTag.Protobuf
|
||||
|
||||
5. **Dashboard Widgets**
|
||||
- ✅ DiscountShopWidget - آمار فروشگاه تخفیفی (7 روز اخیر)
|
||||
|
||||
6. **Payment Pages**
|
||||
- ✅ Transactions - صفحه تراکنشها
|
||||
|
||||
7. **DragDrop Pages**
|
||||
- ✅ CategoryProductsDragDropPage - مدیریت محصولات دسته
|
||||
- ✅ ProductCategoriesDragDropPage - مدیریت دستههای محصول
|
||||
|
||||
8. **BulkEdit Module**
|
||||
- ✅ BulkEdit - ویرایش گروهی محصولات (قیمت، موجودی، وضعیت)
|
||||
- Proto: BackOffice.BFF.Products.Protobuf (BulkUpdateProductPrices, BulkUpdateProductStock, ToggleProductStatus)
|
||||
- Note: استفاده از `BackOffice.BFF.Protobuf.Common.PaginationState` با using alias
|
||||
|
||||
9. **Product Image Management** - ✅ FULLY OPERATIONAL
|
||||
- ✅ GalleryDialog - گالری تصاویر محصول
|
||||
- ✅ CreateDialog - ایجاد محصول با آپلود تصویر
|
||||
- ✅ UpdateDialog - ویرایش محصول با آپلود تصویر
|
||||
- ✅ Proto: GetProductGallery, AddProductImage, RemoveProductImage
|
||||
- ✅ Messages: ImageFileModel, ProductGalleryItem
|
||||
- ✅ Backend: ProductsService methods uncommented and active
|
||||
- ✅ CQRS Handlers: AddProductImageCommandHandler, GetProductGalleryQueryHandler, RemoveProductImageCommandHandler
|
||||
- ✅ CMS Integration: ProductGalleries microservice connected
|
||||
- ✅ Image Optimization: SixLabors.ImageSharp (1200x1200 + 300x300 thumbnail)
|
||||
|
||||
---
|
||||
|
||||
## ماژولهای Exclude شده (نیاز به کار اضافی)
|
||||
|
||||
**هیچ فایلی Exclude نیست!** ✅
|
||||
|
||||
تمامی صفحات و کامپوننتها build میشوند. فقط Backend implementation برای Image Upload لازمه.
|
||||
|
||||
---
|
||||
|
||||
## تغییرات مهم MudBlazor 8
|
||||
|
||||
### Breaking Changes برطرف شده:
|
||||
|
||||
1. **MudDialogInstance → IMudDialogInstance**
|
||||
```csharp
|
||||
// قبلی:
|
||||
[CascadingParameter] MudDialogInstance MudDialog { get; set; }
|
||||
|
||||
// جدید:
|
||||
[CascadingParameter] IMudDialogInstance MudDialog { get; set; }
|
||||
```
|
||||
|
||||
2. **MudSwitch نیاز به T parameter**
|
||||
```razor
|
||||
<!-- قبلی: -->
|
||||
<MudSwitch @bind-Checked="Model.IsActive" />
|
||||
|
||||
<!-- جدید: -->
|
||||
<MudSwitch T="bool" @bind-Value="Model.IsActive" />
|
||||
```
|
||||
|
||||
3. **MudChip نیاز به T parameter**
|
||||
```razor
|
||||
<!-- قبلی: -->
|
||||
<MudChip>Text</MudChip>
|
||||
|
||||
<!-- جدید: -->
|
||||
<MudChip T="string">Text</MudChip>
|
||||
```
|
||||
|
||||
4. **MudTreeView تغییر API**
|
||||
- راهحل: جایگزینی با `MudDataGrid` در DiscountCategoriesMainPage
|
||||
|
||||
5. **MudFileUpload تغییر signature**
|
||||
```csharp
|
||||
// FilesChanged حالا IBrowserFile میگیرد نه IReadOnlyList
|
||||
<MudFileUpload T="IReadOnlyList<IBrowserFile>" FilesChanged="OnFilesSelected" />
|
||||
```
|
||||
|
||||
6. **DragEventArgs.PreventDefault() حذف شد**
|
||||
```razor
|
||||
<!-- استفاده از directive attribute: -->
|
||||
@ondragover:preventDefault
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## تغییرات Proto
|
||||
|
||||
### 1. Google.Protobuf.WellKnownTypes Simplification
|
||||
|
||||
در همه جا از wrapper به مقدار مستقیم تغییر یافت:
|
||||
|
||||
```csharp
|
||||
// قبلی (اشتباه):
|
||||
request.UserId = new Google.Protobuf.WellKnownTypes.Int64Value { Value = userId };
|
||||
request.Status = new Google.Protobuf.WellKnownTypes.Int32Value { Value = status };
|
||||
request.ReferenceNumber = new Google.Protobuf.WellKnownTypes.StringValue { Value = refNum };
|
||||
|
||||
// جدید (صحیح):
|
||||
request.UserId = userId;
|
||||
request.Status = status;
|
||||
request.ReferenceNumber = refNum;
|
||||
```
|
||||
|
||||
### 2. Timestamp to DateTime Conversion
|
||||
|
||||
```csharp
|
||||
// Proto Timestamp به DateTime تبدیل میشود:
|
||||
var dateTime = timestamp.ToDateTime(); // به جای ToLocalTime()
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## تغییرات معماری
|
||||
|
||||
### BasePageComponent Pattern
|
||||
|
||||
صفحات با فیلتر از `BasePageComponent` استفاده میکنند ولی `ReloadAsync()` ندارد.
|
||||
راهحل: استفاده مستقیم از `MudDataGrid.ReloadServerData()`:
|
||||
|
||||
```csharp
|
||||
private MudDataGrid<ModelType>? _dataGrid;
|
||||
|
||||
private async Task OnFilterSubmit()
|
||||
{
|
||||
if (_dataGrid != null)
|
||||
await _dataGrid.ReloadServerData();
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
- `ProductGalleryImage`
|
||||
- `GetCategoriesRequest/Response`
|
||||
- `UpdateProductCategoriesRequest`
|
||||
- `GetProductsForCategoryRequest/Response`
|
||||
- `UpdateCategoryProductsRequest`
|
||||
|
||||
### 3. تغییرات csproj
|
||||
|
||||
**Products از NuGet به ProjectReference تغییر کرد**:
|
||||
```xml
|
||||
<!-- قبلی: -->
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.Products.Protobuf" Version="0.0.8" />
|
||||
|
||||
<!-- جدید: -->
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Products.Protobuf/BackOffice.BFF.Products.Protobuf.csproj" />
|
||||
```
|
||||
|
||||
### 4. فیکسهای MudBlazor
|
||||
|
||||
**MudSwitch T parameter**:
|
||||
- `Pages/Settings/UserSettings.razor`
|
||||
- `Pages/Club/ClubMembers.razor`
|
||||
- `Pages/Configuration/Configuration.razor`
|
||||
|
||||
```razor
|
||||
<!-- قبلی: -->
|
||||
<MudSwitch @bind-Value="..." />
|
||||
|
||||
<!-- جدید: -->
|
||||
<MudSwitch T="bool" @bind-Value="..." />
|
||||
```
|
||||
|
||||
### 5. فیکس Snackbar Duplicate
|
||||
|
||||
در فایلهای زیر `[Inject] ISnackbar Snackbar` حذف شد (چون در `_Imports.razor` inject شده):
|
||||
- `ApplyDiscountDialog.razor.cs`
|
||||
- `CancelOrderDialog.razor.cs`
|
||||
- `ChangeOrderStatusDialog.razor.cs`
|
||||
|
||||
### 6. فیکس ConfigureService.cs
|
||||
|
||||
Using های زیر comment شدند:
|
||||
```csharp
|
||||
// using BackOffice.Services.DiscountProduct;
|
||||
// using BackOffice.Services.DiscountCategory;
|
||||
// using BackOffice.Services.DiscountOrder;
|
||||
// using BackOffice.Services.Tag;
|
||||
// using BackOffice.Services.ProductTag;
|
||||
// using BackOffice.Services.PublicMessage;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## کارهای باقیمانده (TODO)
|
||||
|
||||
### فوری - نیاز به Proto Methods:
|
||||
|
||||
#### 1. Product Image Management
|
||||
**فایلهای Excluded**:
|
||||
- `Pages/Products/Components/GalleryDialog.razor`
|
||||
- `Pages/Products/Components/CreateDialog.razor`
|
||||
- `Pages/Products/Components/UpdateDialog.razor`
|
||||
|
||||
**Proto Methods مورد نیاز در `products.proto`**:
|
||||
```protobuf
|
||||
service ProductsContract {
|
||||
// برای GalleryDialog:
|
||||
rpc AddProductImage(AddProductImageRequest) returns (AddProductImageResponse);
|
||||
rpc RemoveProductImage(RemoveProductImageRequest) returns (google.protobuf.Empty);
|
||||
|
||||
// برای Create/Update Dialogs:
|
||||
rpc CreateProductWithImage(CreateProductWithImageRequest) returns (CreateProductResponse);
|
||||
rpc UpdateProductWithImage(UpdateProductWithImageRequest) returns (google.protobuf.Empty);
|
||||
}
|
||||
|
||||
message ImageFileModel {
|
||||
bytes file = 1;
|
||||
string mime = 2;
|
||||
string file_name = 3;
|
||||
}
|
||||
|
||||
message AddProductImageRequest {
|
||||
int64 product_id = 1;
|
||||
string title = 2;
|
||||
ImageFileModel image_file = 3;
|
||||
}
|
||||
|
||||
message AddProductImageResponse {
|
||||
int64 product_gallery_id = 1;
|
||||
}
|
||||
|
||||
message RemoveProductImageRequest {
|
||||
int64 product_gallery_id = 1;
|
||||
}
|
||||
|
||||
message CreateProductWithImageRequest {
|
||||
// ... سایر فیلدهای محصول
|
||||
ImageFileModel image_file = 1;
|
||||
ImageFileModel thumbnail_file = 2;
|
||||
}
|
||||
|
||||
message UpdateProductWithImageRequest {
|
||||
int64 id = 1;
|
||||
// ... سایر فیلدها
|
||||
ImageFileModel image_file = 2;
|
||||
ImageFileModel thumbnail_file = 3;
|
||||
}
|
||||
```
|
||||
|
||||
**وضعیت**: 🔴 نیاز به پیادهسازی در Backend
|
||||
|
||||
---
|
||||
|
||||
#### 2. BulkEdit Refactoring
|
||||
**فایل Excluded**: `Pages/Products/BulkEdit.razor`
|
||||
|
||||
**مشکل**: استفاده مستقیم از `CMSMicroservice.Protobuf.Protos`
|
||||
|
||||
**راهحل**:
|
||||
1. حذف dependency به `CMSMicroservice.Protobuf`
|
||||
2. افزودن bulk update methods به `products.proto`:
|
||||
|
||||
```protobuf
|
||||
service ProductsContract {
|
||||
rpc BulkUpdateProducts(BulkUpdateProductsRequest) returns (BulkUpdateProductsResponse);
|
||||
}
|
||||
|
||||
message BulkUpdateProductsRequest {
|
||||
repeated int64 product_ids = 1;
|
||||
google.protobuf.Int64Value new_price = 2;
|
||||
google.protobuf.Int32Value new_discount = 3;
|
||||
google.protobuf.Int32Value new_club_discount_percent = 4;
|
||||
StockUpdateOperation stock_operation = 5;
|
||||
google.protobuf.BoolValue status_enable = 6;
|
||||
}
|
||||
|
||||
enum StockUpdateOperation {
|
||||
STOCK_NO_CHANGE = 0;
|
||||
STOCK_SET = 1;
|
||||
STOCK_ADD = 2;
|
||||
STOCK_SUBTRACT = 3;
|
||||
}
|
||||
|
||||
message BulkUpdateProductsResponse {
|
||||
int32 updated_count = 1;
|
||||
repeated int64 failed_product_ids = 2;
|
||||
}
|
||||
```
|
||||
|
||||
**وضعیت**: 🔴 نیاز به پیادهسازی در Backend
|
||||
|
||||
---
|
||||
|
||||
### اختیاری - بهبودها:
|
||||
|
||||
#### 3. Transactions API Implementation
|
||||
**فایل**: `Pages/Payment/Transactions.razor`
|
||||
|
||||
**وضعیت فعلی**: ✅ Enabled ولی متد `LoadData` فقط `TODO` دارد
|
||||
|
||||
**نیاز**: پیادهسازی Transaction API در Backend
|
||||
|
||||
---
|
||||
|
||||
## آمار نهایی
|
||||
|
||||
### ماژولهای فعال: 7 ✅
|
||||
1. DiscountShop (Products, Categories, Orders, Reports)
|
||||
2. PublicMessages
|
||||
3. ManualPayments
|
||||
4. Tag Management
|
||||
5. Dashboard DiscountShopWidget
|
||||
6. Transactions Page
|
||||
7. DragDrop Pages (Category ↔ Products)
|
||||
|
||||
### ماژولهای Excluded: 3 ❌
|
||||
1. GalleryDialog (نیاز به Image Upload API)
|
||||
2. CreateDialog/UpdateDialog (نیاز به Image Upload API)
|
||||
3. BulkEdit (نیاز به Refactoring + Bulk API)
|
||||
|
||||
### Build Errors: 0 🎉
|
||||
### Proto Projects: 14 فعال
|
||||
### صفحات فعال: ~30+
|
||||
### کامپوننتهای فعال: ~50+
|
||||
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
## Handler های موقتاً Exclude شده در BackOffice.BFF.Application
|
||||
|
||||
### فایلهای Exclude شده:
|
||||
```xml
|
||||
<Compile Remove="DiscountOrderCQ/**/*.cs" />
|
||||
<Compile Remove="DiscountShoppingCartCQ/**/*.cs" />
|
||||
<Compile Remove="ManualPaymentCQ/**/*.cs" />
|
||||
<Compile Remove="ConfigurationCQ/**/*.cs" />
|
||||
<Compile Remove="CommissionCQ/Commands/ProcessWithdrawal/**/*.cs" />
|
||||
```
|
||||
|
||||
### دلیل Exclude:
|
||||
این Handler ها فیلدهای متفاوتی با proto های CMS دارند و نیاز به بازنویسی دارند.
|
||||
|
||||
### مثال عدم تطابق DiscountOrder:
|
||||
**Handler انتظار دارد:**
|
||||
- Request: `UserId`, `AddressId`, `DiscountBalanceAmount`, `GatewayAmount`
|
||||
- Response: `OrderId`, `TrackingCode`, `RequiresGatewayPayment`, `GatewayPayableAmount`
|
||||
|
||||
**Proto CMS دارد:**
|
||||
- Request: `user_id`, `user_address_id`, `discount_balance_to_use`, `notes`
|
||||
- Response: `success`, `message`, `order_id`, `gateway_amount`, `payment_url`
|
||||
|
||||
---
|
||||
|
||||
## Proto Update های مورد نیاز
|
||||
|
||||
### UserOrder.Protobuf
|
||||
متدهای زیر باید اضافه شوند:
|
||||
- `CancelOrderAsync(CancelOrderRequest)`
|
||||
- `ApplyDiscountToOrderAsync(ApplyDiscountToOrderRequest)`
|
||||
- `UpdateOrderStatusAsync(UpdateOrderStatusRequest)`
|
||||
|
||||
فیلدهای زیر باید اضافه شوند:
|
||||
- `VatAmount`
|
||||
- `VatPercentage`
|
||||
- `VatBaseAmount`
|
||||
- `VatTotalAmount`
|
||||
- `PaymentStatus.None`
|
||||
|
||||
### Products.Protobuf
|
||||
متدهای زیر باید اضافه شوند:
|
||||
- `AddProductImageAsync`
|
||||
- `RemoveProductImageAsync`
|
||||
|
||||
فیلدهای زیر باید اضافه شوند:
|
||||
- `ImageFile` (bytes)
|
||||
- `ThumbnailFile` (bytes)
|
||||
- `ImageFileModel` message
|
||||
|
||||
---
|
||||
|
||||
## دستورات برای ادامه کار
|
||||
|
||||
### 1. اجرای build برای دیدن خطاهای فعلی:
|
||||
```bash
|
||||
cd /home/masoud/Apps/project/FourSat/BackOffice/src/BackOffice
|
||||
dotnet build 2>&1 | grep -E "error CS|Error"
|
||||
```
|
||||
|
||||
### 2. فایلهای مهم برای بررسی:
|
||||
- `BackOffice.csproj` - لیست exclude ها و references
|
||||
- `ConfigureService.cs` - DI registrations
|
||||
- `_Imports.razor` - global using و inject ها
|
||||
|
||||
### 3. Proto فایلهای مهم:
|
||||
- `BackOffice.BFF/src/Protobufs/BackOffice.BFF.Products.Protobuf/Protos/products.proto`
|
||||
- `BackOffice.BFF/src/Protobufs/BackOffice.BFF.UserOrder.Protobuf/Protos/userorder.proto`
|
||||
|
||||
---
|
||||
|
||||
## چکلیست برای chat جدید
|
||||
|
||||
- [ ] خطاهای build رو چک کن
|
||||
- [ ] `PaginationState` namespace رو فیکس کن
|
||||
- [ ] `WithdrawalReports` binding رو فیکس کن
|
||||
- [ ] `OpenGalleryDialog` رو comment کن در `ProductsMainPage`
|
||||
- [ ] `DiscountShopWidget` رو از `SystemOverview` حذف کن
|
||||
- [ ] تست build موفق
|
||||
|
||||
---
|
||||
|
||||
## نکات مهم
|
||||
|
||||
1. **هیچ فایلی حذف نشده** - فقط از build exclude شدند
|
||||
2. **Proto های local** از ProjectReference استفاده میکنند نه NuGet
|
||||
3. **MudBlazor 8.14.0** نیاز به `T` parameter برای generic components دارد
|
||||
4. **Snackbar** در `_Imports.razor` inject شده، نباید در component ها duplicate بشه
|
||||
@@ -1,118 +0,0 @@
|
||||
# BackOffice Changelog
|
||||
|
||||
> تاریخچه تغییرات پروژه BackOffice
|
||||
|
||||
---
|
||||
|
||||
## December 20, 2025
|
||||
|
||||
### 🐛 Bug Fixes
|
||||
|
||||
#### 1. صفحه `/network/balances` - ValidationException
|
||||
**مشکل**: خطای ValidationException هنگام لود صفحه
|
||||
|
||||
**راهحل**: اضافه کردن Mapster mapping در `CommissionProfile.cs`:
|
||||
```csharp
|
||||
config.NewConfig<GetUserWeeklyBalancesRequest, GetUserWeeklyBalancesQuery>()
|
||||
.Map(dest => dest.PaginationState, src => src.PaginationState);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### 2. صفحه `/club/members` - دادهها لود نمیشدند
|
||||
**مشکل**: صفحه خالی بود و دادهای نمایش نمیداد
|
||||
|
||||
**راهحل**: ایجاد `ClubMembershipProfile.cs` در CMS و BFF با mappings کامل:
|
||||
- `GetAllClubMembershipsRequest` ↔ `GetAllClubMembershipsQuery`
|
||||
- `GetAllClubMembershipsResponseDto` ↔ `GetAllClubMembershipsResponse`
|
||||
|
||||
**فایلهای جدید**:
|
||||
- `CMS/WebApi/Common/Mappings/ClubMembershipProfile.cs`
|
||||
- `BackOffice.BFF/WebApi/Common/Mappings/ClubMembershipProfile.cs` (بازنویسی)
|
||||
|
||||
---
|
||||
|
||||
#### 3. صفحه `/club/statistics` - Unimplemented Error
|
||||
**مشکل**: خطای `Status(StatusCode="Unimplemented")`
|
||||
|
||||
**راهحل**:
|
||||
1. اضافه کردن override `GetClubStatistics` در `ClubMembershipService.cs`
|
||||
2. اضافه کردن mappings برای Statistics در هر دو Profile
|
||||
|
||||
---
|
||||
|
||||
### ✨ New Features
|
||||
|
||||
#### 4. فعالسازی قابلیتهای Products
|
||||
**قبل**: همه دکمهها "در حال توسعه" نشان میدادند
|
||||
|
||||
**بعد**: همه قابلیتها فعال شدند:
|
||||
- ✅ ایجاد محصول جدید (CreateDialog)
|
||||
- ✅ ویرایش محصول (UpdateDialog)
|
||||
- ✅ گالری تصاویر (GalleryDialog)
|
||||
- ✅ مدیریت تگها (AssignTagsDialog)
|
||||
|
||||
**فایل**: `ProductsMainPage.razor.cs`
|
||||
|
||||
---
|
||||
|
||||
#### 5. فیلد "تعداد موجودی" در Products
|
||||
**اضافات**:
|
||||
- فیلد موجودی در فرم ایجاد محصول
|
||||
- فیلد موجودی در فرم ویرایش محصول
|
||||
- ستون موجودی در لیست با رنگبندی:
|
||||
- 🔴 ناموجود (0 یا کمتر)
|
||||
- 🟡 کم موجود (کمتر از 10)
|
||||
- 🟢 موجود (10 یا بیشتر)
|
||||
|
||||
**فایلهای تغییر یافته**:
|
||||
- `CreateDialog.razor`
|
||||
- `UpdateDialog.razor`
|
||||
- `ProductsMainPage.razor`
|
||||
- `CreateNewProductsCommand.cs` (BFF)
|
||||
- `UpdateProductsCommand.cs` (BFF)
|
||||
|
||||
---
|
||||
|
||||
## December 6, 2025
|
||||
|
||||
### ✅ Major Milestones
|
||||
|
||||
- Build Errors: 60+ → 0
|
||||
- MudBlazor 8 Migration Complete
|
||||
- All Product Image Management APIs Implemented
|
||||
- BulkEdit Module Enabled
|
||||
- All Files Unexcluded
|
||||
|
||||
### 🔧 Technical Changes
|
||||
|
||||
- `IMudDialogInstance` جایگزین `MudDialogInstance`
|
||||
- `MudSwitch T="bool"` اضافه شد
|
||||
- `MudChip T="string"` اضافه شد
|
||||
- Products از NuGet به ProjectReference تغییر کرد
|
||||
|
||||
---
|
||||
|
||||
## December 1, 2025
|
||||
|
||||
### ✅ Network & Commission System
|
||||
|
||||
- Commission Dashboard Complete
|
||||
- Network Members Page Complete
|
||||
- Club Members Page Complete
|
||||
- Weekly Pool Management
|
||||
- Withdrawal System
|
||||
- Payout System
|
||||
|
||||
---
|
||||
|
||||
## November 29, 2025
|
||||
|
||||
### ✅ Initial Setup
|
||||
|
||||
- SystemConfigurations Table Created
|
||||
- Base Configuration Values Added:
|
||||
- `Network.MaxDepth`: 10
|
||||
- `Club.DefaultMembershipDurationMonths`: 12
|
||||
- `Commission.MinimumPayoutAmount`: 100000
|
||||
- `System.MaintenanceMode`: false
|
||||
@@ -0,0 +1 @@
|
||||
Docs moved to /totalDoc — see totalDoc/INDEX.md
|
||||
@@ -1,28 +0,0 @@
|
||||
# ⚠️ توجه: مستندات اصلی منتقل شده
|
||||
|
||||
مستندات اصلی پروژه در فولدر زیر قرار دارند:
|
||||
|
||||
```
|
||||
/home/masoud/Apps/project/FourSat/totalDoc/
|
||||
```
|
||||
|
||||
## 🗂️ ساختار اصلی مستندات:
|
||||
|
||||
- **00-INDEX.md** - فهرست جامع مستندات
|
||||
- **QUICK-REFERENCE.md** - مرجع سریع
|
||||
- **FINAL-STATUS.md** - وضعیت نهایی پروژه
|
||||
- **CHANGELOG-2025-12-XX.md** - لاگ تغییرات روزانه
|
||||
- **01-BUSINESS/** - منطق تجاری
|
||||
- **02-ARCHITECTURE/** - معماری سیستم
|
||||
- **03-BACKEND/** - مستندات Backend (CMS, BFF)
|
||||
- **04-FRONTEND/** - مستندات Frontend (BackOffice, FrontOffice)
|
||||
- **05-TASKS/** - کارهای جاری
|
||||
- **06-DEPLOYMENT/** - راهنمای استقرار
|
||||
|
||||
## 📝 این پوشه:
|
||||
|
||||
فایلهای این پوشه (`BackOffice/docs/`) برای مرجع محلی نگه داشته شدهاند ولی **مستندات اصلی و بهروز** در `totalDoc` قرار دارند.
|
||||
|
||||
---
|
||||
|
||||
**تاریخ**: ۳۰ آذر ۱۴۰۴ (20 December 2025)
|
||||
@@ -1,34 +0,0 @@
|
||||
# BackOffice Documentation - README
|
||||
|
||||
> آخرین بروزرسانی: **December 20, 2025**
|
||||
|
||||
## فایلهای این پوشه
|
||||
|
||||
| فایل | شرح |
|
||||
|------|-----|
|
||||
| `STATUS.md` | وضعیت کلی پروژه و Build Status |
|
||||
| `CHANGELOG.md` | تاریخچه تغییرات به ترتیب تاریخ |
|
||||
| `TECHNICAL-NOTES.md` | نکات فنی، Mapster، MudBlazor، Proto |
|
||||
| `development-plan.md` | برنامه توسعه (قدیمی - برای مرجع) |
|
||||
|
||||
---
|
||||
|
||||
## وضعیت فعلی
|
||||
|
||||
```
|
||||
✅ Build Status: SUCCESS (0 Errors)
|
||||
✅ Proto Projects: 24 فعال
|
||||
✅ صفحات فعال: 40+
|
||||
✅ Excluded Files: 0
|
||||
```
|
||||
|
||||
## دستورات سریع
|
||||
|
||||
```bash
|
||||
# Build همه
|
||||
cd /home/masoud/Apps/project/FourSat/BackOffice/src
|
||||
dotnet build BackOffice.sln
|
||||
|
||||
# فقط UI
|
||||
dotnet build BackOffice/BackOffice.csproj
|
||||
```
|
||||
@@ -1,346 +0,0 @@
|
||||
# کارهای باقیمانده - BackOffice
|
||||
|
||||
> آخرین بروزرسانی: December 20, 2025
|
||||
|
||||
## وضعیت کلی
|
||||
|
||||
**Build Status**: ✅ SUCCESS (0 Errors)
|
||||
**Enabled Modules**: 10+ ماژول کامل
|
||||
**Remaining Tasks**: فقط Backend Implementation
|
||||
|
||||
---
|
||||
|
||||
## ✅ کارهای انجام شده - Session December 20, 2025
|
||||
|
||||
### 1. صفحه `/network/balances` - ✅ FIXED
|
||||
**مشکل**: ValidationException هنگام لود صفحه
|
||||
**راهحل**: اضافه کردن Mapster mapping برای `GetUserWeeklyBalancesRequest` → `GetUserWeeklyBalancesQuery`
|
||||
|
||||
**فایل تغییر یافته**:
|
||||
- `BackOffice.BFF/WebApi/Common/Mappings/CommissionProfile.cs`
|
||||
|
||||
```csharp
|
||||
config.NewConfig<GetUserWeeklyBalancesRequest, GetUserWeeklyBalancesQuery>()
|
||||
.Map(dest => dest.PaginationState, src => src.PaginationState);
|
||||
```
|
||||
|
||||
### 2. صفحه `/club/members` - ✅ FIXED
|
||||
**مشکل**: دادهها لود نمیشدند (Mapster mapping نداشت)
|
||||
**راهحل**: ایجاد ClubMembershipProfile در CMS و BFF
|
||||
|
||||
**فایلهای جدید**:
|
||||
- `CMS/WebApi/Common/Mappings/ClubMembershipProfile.cs` (NEW)
|
||||
- `BackOffice.BFF/WebApi/Common/Mappings/ClubMembershipProfile.cs` (REWRITTEN)
|
||||
|
||||
**Mappings اضافه شده**:
|
||||
- `GetAllClubMembershipsRequest` ↔ `GetAllClubMembershipsQuery`
|
||||
- `GetAllClubMembershipsResponseDto` ↔ `GetAllClubMembershipsResponse`
|
||||
|
||||
### 3. صفحه `/club/statistics` - ✅ FIXED
|
||||
**مشکل**: خطای `Status(StatusCode="Unimplemented")`
|
||||
**راهحل**: پیادهسازی متد gRPC در BFF و اضافه کردن mappings
|
||||
|
||||
**فایلهای تغییر یافته**:
|
||||
- `BackOffice.BFF/WebApi/Services/ClubMembershipService.cs` - اضافه شدن `GetClubStatistics` override
|
||||
- `CMS/WebApi/Common/Mappings/ClubMembershipProfile.cs` - اضافه شدن mappings
|
||||
- `BackOffice.BFF/WebApi/Common/Mappings/ClubMembershipProfile.cs` - اضافه شدن mappings
|
||||
|
||||
**Mappings اضافه شده**:
|
||||
- `GetClubStatisticsRequest` ↔ `GetClubStatisticsQuery`
|
||||
- `GetClubStatisticsResponseDto` ↔ `GetClubStatisticsResponse`
|
||||
- PackageDistribution و MonthlyTrend mappings
|
||||
|
||||
### 4. صفحه Products - ✅ ALL FEATURES ENABLED
|
||||
**مشکل**: همه قابلیتها disabled بودند و "در حال توسعه" نشان میدادند
|
||||
**راهحل**: Uncomment کردن کدهای دیالوگها
|
||||
|
||||
**فایل تغییر یافته**:
|
||||
- `BackOffice/Pages/Products/ProductsMainPage.razor.cs`
|
||||
|
||||
**قابلیتهای فعال شده**:
|
||||
- ✅ `CreateNew()` - ایجاد محصول جدید
|
||||
- ✅ `Update()` - ویرایش محصول
|
||||
- ✅ `OpenGallery()` - گالری تصاویر
|
||||
- ✅ `OpenTagAssignment()` - اختصاص تگ
|
||||
|
||||
### 5. فیلد "تعداد موجودی" در Products - ✅ ADDED
|
||||
**مشکل**: فیلد RemainingCount در فرمها و لیست نبود
|
||||
**راهحل**: اضافه کردن فیلد به همه لایهها
|
||||
|
||||
**فایلهای تغییر یافته**:
|
||||
- `BackOffice/Pages/Products/Components/CreateDialog.razor` - اضافه شدن فیلد موجودی
|
||||
- `BackOffice/Pages/Products/Components/UpdateDialog.razor` - اضافه شدن فیلد موجودی
|
||||
- `BackOffice/Pages/Products/ProductsMainPage.razor` - اضافه شدن ستون موجودی با رنگبندی
|
||||
- `BackOffice.BFF.Application/ProductsCQ/Commands/CreateNewProducts/CreateNewProductsCommand.cs` - اضافه شدن `RemainingCount`
|
||||
- `BackOffice.BFF.Application/ProductsCQ/Commands/UpdateProducts/UpdateProductsCommand.cs` - اضافه شدن `RemainingCount`
|
||||
|
||||
**نمایش موجودی در لیست**:
|
||||
- 🔴 **ناموجود** - اگر موجودی `0` یا کمتر (Chip قرمز)
|
||||
- 🟡 **عدد** - اگر موجودی کمتر از `10` (Chip زرد - هشدار)
|
||||
- 🟢 **عدد** - اگر موجودی `10` یا بیشتر (Chip سبز)
|
||||
|
||||
---
|
||||
|
||||
## ✅ کارهای انجام شده قبلی
|
||||
|
||||
### 1. BulkEdit Module - COMPLETED ✅
|
||||
- ✅ حذف dependency به CMSMicroservice
|
||||
- ✅ استفاده از BackOffice.BFF.Products.Protobuf
|
||||
- ✅ تصحیح PaginationState namespace issue
|
||||
- ✅ فایل فعال شد و build موفق
|
||||
|
||||
### 2. Product Image Management - Proto COMPLETED ✅
|
||||
- ✅ تعریف ImageFileModel message
|
||||
- ✅ اضافه کردن GetProductGallery RPC
|
||||
- ✅ اضافه کردن AddProductImage RPC
|
||||
- ✅ اضافه کردن RemoveProductImage RPC
|
||||
- ✅ اضافه کردن ImageFile و ThumbnailFile به Create/Update requests
|
||||
- ✅ هر 3 دیالوگ فعال شدند و build موفق
|
||||
|
||||
**فایلهای Enabled**:
|
||||
- `Pages/Products/Components/GalleryDialog.razor` ✅
|
||||
- `Pages/Products/Components/CreateDialog.razor` ✅
|
||||
- `Pages/Products/Components/UpdateDialog.razor` ✅
|
||||
|
||||
---
|
||||
|
||||
## 🔴 کارهای باقیمانده (Backend Only)
|
||||
|
||||
### 1. Product Image Management - Backend Implementation
|
||||
|
||||
**اولویت**: بالا
|
||||
**وضعیت**: ✅ COMPLETED - همه چیز آماده!
|
||||
|
||||
**آخرین تغییرات**:
|
||||
- ✅ ProductsService.cs: همه methods فعال شدند (AddProductImage, GetProductGallery, RemoveProductImage)
|
||||
- ✅ Application Layer: CQRS handlers از قبل پیادهسازی شدهاند
|
||||
- ✅ CMS Integration: ProductGalleries microservice متصل است
|
||||
- ✅ Image Optimization: 1200x1200 main + 300x300 thumbnail ready
|
||||
|
||||
#### Proto Messages (✅ Ready):
|
||||
```protobuf
|
||||
// Image file model
|
||||
message ImageFileModel {
|
||||
bytes file = 1;
|
||||
string mime = 2;
|
||||
string file_name = 3;
|
||||
}
|
||||
|
||||
// Get Product Gallery
|
||||
rpc GetProductGallery(GetProductGalleryRequest) returns (GetProductGalleryResponse);
|
||||
|
||||
message GetProductGalleryRequest {
|
||||
int64 product_id = 1;
|
||||
}
|
||||
|
||||
message ProductGalleryItem {
|
||||
int64 product_gallery_id = 1;
|
||||
int64 product_image_id = 2;
|
||||
string title = 3;
|
||||
string image_path = 4;
|
||||
string image_thumbnail_path = 5;
|
||||
}
|
||||
|
||||
message GetProductGalleryResponse {
|
||||
repeated ProductGalleryItem items = 1;
|
||||
}
|
||||
|
||||
// Add Product Image
|
||||
rpc AddProductImage(AddProductImageRequest) returns (AddProductImageResponse);
|
||||
|
||||
message AddProductImageRequest {
|
||||
int64 product_id = 1;
|
||||
string title = 2;
|
||||
ImageFileModel image_file = 3;
|
||||
}
|
||||
|
||||
message AddProductImageResponse {
|
||||
int64 product_gallery_id = 1;
|
||||
int64 product_image_id = 2;
|
||||
string title = 3;
|
||||
string image_path = 4;
|
||||
string image_thumbnail_path = 5;
|
||||
}
|
||||
|
||||
// Remove Product Image
|
||||
rpc RemoveProductImage(RemoveProductImageRequest) returns (google.protobuf.Empty);
|
||||
|
||||
message RemoveProductImageRequest {
|
||||
int64 product_gallery_id = 1;
|
||||
}
|
||||
```
|
||||
|
||||
#### Backend Implementation Steps:
|
||||
|
||||
1. **افزودن Messages به Proto** ✅ (فقط تعریف)
|
||||
2. **پیادهسازی RPCs در Backend**:
|
||||
- AddProductImage: دریافت فایل، ذخیره در storage، ثبت در DB
|
||||
- RemoveProductImage: حذف فایل از storage و DB
|
||||
- CreateProductWithImage: ایجاد محصول + آپلود تصاویر
|
||||
- UpdateProductWithImage: ویرایش محصول + آپلود تصاویر (اختیاری)
|
||||
|
||||
3. **File Storage**:
|
||||
- پیشنهاد: MinIO, Azure Blob, یا local file system
|
||||
- ذخیره تصویر اصلی و thumbnail
|
||||
- برگرداندن URL های قابل دسترسی
|
||||
|
||||
4. **تست و Enable فایلها در UI**
|
||||
|
||||
**زمان تخمینی**: 2-3 روز کاری
|
||||
|
||||
---
|
||||
|
||||
### 2. BulkEdit Backend Implementation (اختیاری)
|
||||
|
||||
**اولویت**: پایین
|
||||
**وضعیت**: ✅ UI کامل، Backend موجود و کار میکند
|
||||
|
||||
**نکته**: BulkEdit از RPCهای موجود استفاده میکند:
|
||||
- `BulkUpdateProductPricesAsync` ✅
|
||||
- `BulkUpdateProductStockAsync` ✅
|
||||
- `ToggleProductStatusAsync` ✅
|
||||
|
||||
همه چیز آماده و کار میکند! فقط نیاز به تست دارد.
|
||||
|
||||
---
|
||||
|
||||
### 3. Transactions API Implementation
|
||||
|
||||
**اولویت**: پایین
|
||||
**وضعیت**: UI آماده، API نیاز به پیادهسازی
|
||||
|
||||
#### فایل:
|
||||
- `Pages/Payment/Transactions.razor` - ✅ Enabled اما TODO
|
||||
|
||||
#### وضعیت فعلی:
|
||||
```csharp
|
||||
private async Task<GridData<TransactionModel>> LoadData(GridState<TransactionModel> state)
|
||||
{
|
||||
// TODO: Connect to BackOffice.BFF Transactions when API is ready
|
||||
await Task.CompletedTask;
|
||||
|
||||
return new GridData<TransactionModel>
|
||||
{
|
||||
Items = Array.Empty<TransactionModel>(),
|
||||
TotalItems = 0
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
#### نیاز:
|
||||
- ایجاد Transaction proto در BackOffice.BFF
|
||||
- پیادهسازی GetTransactions RPC
|
||||
- اتصال UI به API
|
||||
|
||||
**زمان تخمینی**: 1 روز کاری
|
||||
|
||||
---
|
||||
|
||||
## 📊 آمار پیشرفت
|
||||
|
||||
### Modules Status:
|
||||
|
||||
| Module | Status | Files | Notes |
|
||||
|--------|--------|-------|-------|
|
||||
| DiscountShop | ✅ Complete | 10+ | Products, Categories, Orders, Reports |
|
||||
| PublicMessages | ✅ Complete | 4 | CRUD + Templates |
|
||||
| ManualPayments | ✅ Complete | 2 | Create, Approve, Reject |
|
||||
| Tag Management | ✅ Complete | 3 | CRUD Tags |
|
||||
| Dashboard Widget | ✅ Complete | 1 | DiscountShop Stats |
|
||||
| Transactions | ⚠️ Partial | 1 | UI ready, API TODO |
|
||||
| DragDrop Pages | ✅ Complete | 2 | Category ↔ Products |
|
||||
| **BulkEdit** | ✅ Complete | 1 | Fully working! |
|
||||
| **Product Images** | ✅ Complete | 3 | Backend FULLY implemented! |
|
||||
|
||||
### Overall Progress:
|
||||
|
||||
- **Enabled**: 38+ صفحه و کامپوننت ✅
|
||||
- **Blocked**: 0 فایل ✅
|
||||
- **Proto Projects**: 14 فعال
|
||||
- **Build Errors**: 0 ✅
|
||||
- **UI Completion**: 100% 🎉
|
||||
- **Backend Implementation**: 100% ✅✅✅
|
||||
- **System Status**: FULLY OPERATIONAL 🚀
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Next Steps
|
||||
|
||||
### ✅ ALL TASKS COMPLETED!
|
||||
|
||||
**BackOffice System Status**: **PRODUCTION READY** 🚀
|
||||
|
||||
**آماده برای استفاده**:
|
||||
|
||||
---
|
||||
|
||||
## 📝 نکات مهم
|
||||
|
||||
### ⚠️ CRITICAL: Proto Package Management
|
||||
|
||||
**هر بار که Proto تغییر میکند (در هر سرویسی):**
|
||||
|
||||
```bash
|
||||
# 1. افزایش Version در csproj
|
||||
<Version>X.Y.Z</Version> → <Version>X.Y.Z+1</Version>
|
||||
|
||||
# 2. Pack کردن
|
||||
cd path/to/proto/project
|
||||
dotnet pack -c Release # Auto-push به GitLab
|
||||
|
||||
# 3. Update در لایه بالاتر
|
||||
<PackageReference Include="PackageName" Version="NEW_VERSION" />
|
||||
```
|
||||
|
||||
**این قانون برای همه سرویسها صادق است:**
|
||||
- CMS → BFF ها
|
||||
- BackOffice.BFF → BackOffice UI
|
||||
- FrontOffice.BFF → FrontOffice UI
|
||||
|
||||
**⚠️ عدم رعایت = ساعتها Debug بیهوده!**
|
||||
|
||||
---
|
||||
|
||||
### برای Backend Developer:
|
||||
|
||||
1. **Image Upload**:
|
||||
- استفاده از streaming برای فایلهای بزرگ
|
||||
- اعتبارسنجی نوع و سایز فایل
|
||||
- تولید thumbnail خودکار
|
||||
- مدیریت storage (MinIO recommended)
|
||||
|
||||
2. **Bulk Update**:
|
||||
- استفاده از Transaction برای atomicity
|
||||
- مدیریت concurrent updates
|
||||
- Logging تغییرات برای audit
|
||||
|
||||
3. **Security**:
|
||||
- اعتبارسنجی سمت سرور
|
||||
- محدودیت سایز فایل
|
||||
- sanitize file names
|
||||
|
||||
### برای Frontend Developer:
|
||||
|
||||
1. **Image Upload**:
|
||||
- Progress indicator
|
||||
- Preview قبل از upload
|
||||
- مدیریت خطاها
|
||||
- Retry mechanism
|
||||
|
||||
2. **BulkEdit**:
|
||||
- Confirmation قبل از تغییرات
|
||||
- نمایش نتایج
|
||||
- Undo capability (آینده)
|
||||
|
||||
---
|
||||
|
||||
## 🔗 Related Docs
|
||||
|
||||
- [BUILD-FIX-STATUS.md](./BUILD-FIX-STATUS.md) - وضعیت کلی build
|
||||
- [EXCLUDED-FILES.md](./EXCLUDED-FILES.md) - لیست فایلهای exclude
|
||||
- [PROTO-DEPENDENCIES.md](./PROTO-DEPENDENCIES.md) - وابستگیهای proto
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: December 6, 2025
|
||||
**By**: GitHub Copilot (Claude Sonnet 4.5)
|
||||
@@ -1,311 +0,0 @@
|
||||
# Session Log - December 20, 2025
|
||||
|
||||
## خلاصه Session
|
||||
|
||||
این session شامل رفع چندین باگ در صفحات BackOffice و فعالسازی قابلیتهای Products بود.
|
||||
|
||||
---
|
||||
|
||||
## 1. فیکس صفحه `/network/balances`
|
||||
|
||||
### مشکل
|
||||
```
|
||||
ValidationException هنگام لود صفحه بالانسهای هفتگی
|
||||
```
|
||||
|
||||
### علت
|
||||
Mapster mapping برای تبدیل `GetUserWeeklyBalancesRequest` به `GetUserWeeklyBalancesQuery` وجود نداشت.
|
||||
|
||||
### راهحل
|
||||
اضافه کردن mapping در `CommissionProfile.cs`:
|
||||
|
||||
```csharp
|
||||
// File: BackOffice.BFF/src/BackOffice.BFF.WebApi/Common/Mappings/CommissionProfile.cs
|
||||
|
||||
config.NewConfig<GetUserWeeklyBalancesRequest, GetUserWeeklyBalancesQuery>()
|
||||
.Map(dest => dest.PaginationState, src => src.PaginationState);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. فیکس صفحه `/club/members`
|
||||
|
||||
### مشکل
|
||||
```
|
||||
صفحه لود میشد ولی هیچ دادهای نمایش نمیداد
|
||||
```
|
||||
|
||||
### علت
|
||||
Mapster mappings در CMS و BFF برای `GetAllClubMemberships` وجود نداشتند.
|
||||
|
||||
### راهحل
|
||||
ایجاد `ClubMembershipProfile.cs` در هر دو لایه:
|
||||
|
||||
**CMS/src/CMSMicroservice.WebApi/Common/Mappings/ClubMembershipProfile.cs** (NEW):
|
||||
```csharp
|
||||
public class ClubMembershipProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
// GetAllClubMemberships mappings
|
||||
config.NewConfig<GetAllClubMembershipsRequest, GetAllClubMembershipsQuery>()
|
||||
.Map(dest => dest.PaginationState, src => src.PaginationState)
|
||||
.Map(dest => dest.Filter, src => src.Filter);
|
||||
|
||||
config.NewConfig<GetAllClubMembershipsResponseDto, GetAllClubMembershipsResponse>()
|
||||
.MapWith(src => new GetAllClubMembershipsResponse
|
||||
{
|
||||
MetaData = src.MetaData != null ? new CMSMicroservice.Protobuf.Common.MetaData
|
||||
{
|
||||
PageIndex = src.MetaData.PageIndex,
|
||||
TotalPages = src.MetaData.TotalPages,
|
||||
TotalCount = src.MetaData.TotalCount
|
||||
} : null,
|
||||
Models = { src.Models?.Select(...) ?? Enumerable.Empty<...>() }
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**BackOffice.BFF/src/BackOffice.BFF.WebApi/Common/Mappings/ClubMembershipProfile.cs** (REWRITTEN):
|
||||
- Mapping از BFF Proto به Query
|
||||
- Mapping از CMS Response به BFF Proto Response
|
||||
- استفاده از alias imports برای disambiguation
|
||||
|
||||
---
|
||||
|
||||
## 3. فیکس صفحه `/club/statistics`
|
||||
|
||||
### مشکل
|
||||
```
|
||||
Status(StatusCode="Unimplemented", Detail="Method cms.ClubMembershipContract/GetClubStatistics is unimplemented")
|
||||
```
|
||||
|
||||
### علت
|
||||
متد `GetClubStatistics` در BFF Service override نشده بود.
|
||||
|
||||
### راهحل
|
||||
|
||||
**1. اضافه کردن override در ClubMembershipService.cs:**
|
||||
```csharp
|
||||
public override async Task<GetClubStatisticsResponse> GetClubStatistics(
|
||||
GetClubStatisticsRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetClubStatisticsRequest, GetClubStatisticsQuery, GetClubStatisticsResponse>(request, context);
|
||||
}
|
||||
```
|
||||
|
||||
**2. اضافه کردن mappings در CMS ClubMembershipProfile:**
|
||||
```csharp
|
||||
config.NewConfig<GetClubStatisticsRequest, GetClubStatisticsQuery>();
|
||||
|
||||
config.NewConfig<GetClubStatisticsResponseDto, GetClubStatisticsResponse>()
|
||||
.MapWith(src => new GetClubStatisticsResponse
|
||||
{
|
||||
TotalMembers = src.TotalMembers,
|
||||
ActiveMembers = src.ActiveMembers,
|
||||
// ... سایر فیلدها
|
||||
PackageDistribution = { src.PackageDistribution?.Select(...) },
|
||||
MonthlyTrend = { src.MonthlyTrend?.Select(...) }
|
||||
});
|
||||
```
|
||||
|
||||
**3. اضافه کردن mappings در BFF ClubMembershipProfile:**
|
||||
- Mapping از BFF Proto به Query
|
||||
- Mapping از CMS Response DTO به BFF Proto Response
|
||||
|
||||
---
|
||||
|
||||
## 4. فعالسازی قابلیتهای Products
|
||||
|
||||
### مشکل
|
||||
```
|
||||
همه دکمههای صفحه محصولات "در حال توسعه" نشان میدادند
|
||||
```
|
||||
|
||||
### علت
|
||||
کدهای دیالوگها comment شده بودند با TODO markers.
|
||||
|
||||
### راهحل
|
||||
Uncomment کردن کدها در `ProductsMainPage.razor.cs`:
|
||||
|
||||
**فایل: BackOffice/src/BackOffice/Pages/Products/ProductsMainPage.razor.cs**
|
||||
|
||||
```csharp
|
||||
// ✅ CreateNew() - فعال شد
|
||||
public async Task CreateNew()
|
||||
{
|
||||
var dialog = await DialogService.ShowAsync<CreateDialog>("افزودن محصول",
|
||||
new DialogParameters<CreateDialog> { { x => x.Model, new CreateNewProductsRequest() } },
|
||||
new DialogOptions { CloseButton = true, FullWidth = true, MaxWidth = MaxWidth.Small });
|
||||
// ...
|
||||
}
|
||||
|
||||
// ✅ Update() - فعال شد
|
||||
public async Task Update(DataModel model)
|
||||
{
|
||||
var parameters = new DialogParameters<UpdateDialog> { { x => x.Model, model.Adapt<UpdateProductsRequest>() } };
|
||||
var dialog = await DialogService.ShowAsync<UpdateDialog>("ویرایش محصول", parameters, ...);
|
||||
// ...
|
||||
}
|
||||
|
||||
// ✅ OpenGallery() - فعال شد
|
||||
public async Task OpenGallery(DataModel model)
|
||||
{
|
||||
var parameters = new DialogParameters<GalleryDialog>
|
||||
{
|
||||
{ x => x.ProductId, model.Id },
|
||||
{ x => x.ProductTitle, model.Title }
|
||||
};
|
||||
await DialogService.ShowAsync<GalleryDialog>("گالری تصاویر", parameters, ...);
|
||||
}
|
||||
|
||||
// ✅ OpenTagAssignment() - فعال شد
|
||||
public async Task OpenTagAssignment(DataModel model)
|
||||
{
|
||||
var parameters = new DialogParameters<AssignTagsDialog>
|
||||
{
|
||||
{ x => x.ProductId, model.Id },
|
||||
{ x => x.ProductTitle, model.Title }
|
||||
};
|
||||
await DialogService.ShowAsync<AssignTagsDialog>("مدیریت تگهای محصول", parameters, ...);
|
||||
}
|
||||
```
|
||||
|
||||
**Using statement uncomment شد:**
|
||||
```csharp
|
||||
using BackOffice.Pages.Tag.Components; // برای AssignTagsDialog
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. اضافه کردن فیلد "تعداد موجودی" به Products
|
||||
|
||||
### نیاز
|
||||
نمایش و ویرایش تعداد موجودی محصول در فرمها و لیست
|
||||
|
||||
### تغییرات
|
||||
|
||||
**1. فرمهای دیالوگ (CreateDialog.razor & UpdateDialog.razor):**
|
||||
```razor
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center">
|
||||
<MudItem xs="6">
|
||||
<MudNumericField T="int" HideSpinButtons="true" @bind-Value="Model.Discount"
|
||||
Disabled="_isLoading" Label="تخفیف (%)" Variant="Variant.Outlined" Margin="Margin.Dense" />
|
||||
</MudItem>
|
||||
<MudItem xs="6">
|
||||
<MudNumericField T="int" HideSpinButtons="true" @bind-Value="Model.RemainingCount"
|
||||
Disabled="_isLoading" Label="تعداد موجودی" Variant="Variant.Outlined" Margin="Margin.Dense" />
|
||||
</MudItem>
|
||||
</MudStack>
|
||||
```
|
||||
|
||||
**2. ستون جدید در لیست (ProductsMainPage.razor):**
|
||||
```razor
|
||||
<TemplateColumn Title="موجودی" CellStyle="text-wrap: nowrap;">
|
||||
<CellTemplate>
|
||||
@if (context.Item.RemainingCount <= 0)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Error" Size="Size.Small">ناموجود</MudChip>
|
||||
}
|
||||
else if (context.Item.RemainingCount < 10)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Warning" Size="Size.Small">@context.Item.RemainingCount</MudChip>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudChip T="string" Color="Color.Success" Size="Size.Small">@context.Item.RemainingCount</MudChip>
|
||||
}
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
```
|
||||
|
||||
**3. اضافه کردن فیلد به BFF Commands (فیکس مهم!):**
|
||||
|
||||
مشکل: فیلد `RemainingCount` در BFF Application Commands نبود و باعث میشد مقدار ارسال/دریافت نشه.
|
||||
|
||||
**CreateNewProductsCommand.cs:**
|
||||
```csharp
|
||||
public int Discount { get; init; }
|
||||
public int Rate { get; init; }
|
||||
public int RemainingCount { get; init; } // ← اضافه شد
|
||||
public ImageFileModel ImageFile { get; init; }
|
||||
```
|
||||
|
||||
**UpdateProductsCommand.cs:**
|
||||
```csharp
|
||||
public int Discount { get; init; }
|
||||
public int Rate { get; init; }
|
||||
public int RemainingCount { get; init; } // ← اضافه شد
|
||||
public string ImagePath { get; init; }
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## لیست کامل فایلهای تغییر یافته
|
||||
|
||||
### BackOffice.BFF
|
||||
| فایل | نوع تغییر | توضیح |
|
||||
|------|----------|-------|
|
||||
| `WebApi/Common/Mappings/CommissionProfile.cs` | MODIFIED | اضافه شدن mapping برای GetUserWeeklyBalances |
|
||||
| `WebApi/Common/Mappings/ClubMembershipProfile.cs` | REWRITTEN | Mappings کامل برای ClubMembership |
|
||||
| `WebApi/Services/ClubMembershipService.cs` | MODIFIED | اضافه شدن GetClubStatistics override |
|
||||
| `Application/ProductsCQ/Commands/CreateNewProducts/CreateNewProductsCommand.cs` | MODIFIED | اضافه شدن RemainingCount |
|
||||
| `Application/ProductsCQ/Commands/UpdateProducts/UpdateProductsCommand.cs` | MODIFIED | اضافه شدن RemainingCount |
|
||||
|
||||
### CMS
|
||||
| فایل | نوع تغییر | توضیح |
|
||||
|------|----------|-------|
|
||||
| `WebApi/Common/Mappings/ClubMembershipProfile.cs` | NEW | Mappings برای ClubMembership |
|
||||
|
||||
### BackOffice UI
|
||||
| فایل | نوع تغییر | توضیح |
|
||||
|------|----------|-------|
|
||||
| `Pages/Products/ProductsMainPage.razor.cs` | MODIFIED | فعالسازی CreateNew, Update, OpenGallery, OpenTagAssignment |
|
||||
| `Pages/Products/ProductsMainPage.razor` | MODIFIED | اضافه شدن ستون موجودی |
|
||||
| `Pages/Products/Components/CreateDialog.razor` | MODIFIED | اضافه شدن فیلد موجودی |
|
||||
| `Pages/Products/Components/UpdateDialog.razor` | MODIFIED | اضافه شدن فیلد موجودی |
|
||||
|
||||
---
|
||||
|
||||
## نکات فنی مهم
|
||||
|
||||
### 1. Mapster با Proto Types
|
||||
برای proto types که immutable هستند، باید از `MapWith` استفاده کرد:
|
||||
|
||||
```csharp
|
||||
config.NewConfig<SourceDto, ProtoResponse>()
|
||||
.MapWith(src => new ProtoResponse
|
||||
{
|
||||
Field1 = src.Field1,
|
||||
RepeatedField = { src.List?.Select(...) ?? Enumerable.Empty<...>() }
|
||||
});
|
||||
```
|
||||
|
||||
### 2. Alias Imports برای Proto Disambiguation
|
||||
وقتی دو proto با اسم یکسان داریم:
|
||||
|
||||
```csharp
|
||||
using BffProtos = BackOffice.BFF.ClubMembership.Protobuf.Protos.ClubMembership;
|
||||
using CmsProtos = CMSMicroservice.Protobuf.Protos.ClubMembership;
|
||||
```
|
||||
|
||||
### 3. Null-Safe MetaData Mapping
|
||||
```csharp
|
||||
MetaData = src.MetaData != null ? new MetaData
|
||||
{
|
||||
PageIndex = src.MetaData.PageIndex,
|
||||
TotalPages = src.MetaData.TotalPages,
|
||||
TotalCount = src.MetaData.TotalCount
|
||||
} : null
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Build Status پایان Session
|
||||
|
||||
```
|
||||
BackOffice.BFF: ✅ Build succeeded (0 errors)
|
||||
CMS: ✅ Build succeeded (0 errors)
|
||||
BackOffice UI: ✅ Build succeeded (0 errors)
|
||||
```
|
||||
-135
@@ -1,135 +0,0 @@
|
||||
# BackOffice Project Status
|
||||
|
||||
> آخرین بروزرسانی: **December 20, 2025**
|
||||
|
||||
---
|
||||
|
||||
## 🎯 وضعیت کلی
|
||||
|
||||
| Component | Build Status | Errors |
|
||||
|-----------|--------------|--------|
|
||||
| BackOffice UI | ✅ SUCCESS | 0 |
|
||||
| BackOffice.BFF | ✅ SUCCESS | 0 |
|
||||
| CMS Microservice | ✅ SUCCESS | 0 |
|
||||
|
||||
**System Status**: 🟢 **PRODUCTION READY**
|
||||
|
||||
---
|
||||
|
||||
## 📦 Proto Projects (24 پروژه فعال)
|
||||
|
||||
### Core Protos:
|
||||
- ✅ Common.Protobuf
|
||||
- ✅ Health.Protobuf
|
||||
- ✅ Configuration.Protobuf
|
||||
|
||||
### User Management:
|
||||
- ✅ User.Protobuf
|
||||
- ✅ UserRole.Protobuf
|
||||
- ✅ Role.Protobuf
|
||||
- ✅ UserAddress.Protobuf
|
||||
- ✅ UserWallet.Protobuf
|
||||
- ✅ Otp.Protobuf
|
||||
|
||||
### Products & Shop:
|
||||
- ✅ Products.Protobuf
|
||||
- ✅ Category.Protobuf
|
||||
- ✅ Tag.Protobuf
|
||||
- ✅ ProductTag.Protobuf
|
||||
- ✅ Package.Protobuf
|
||||
|
||||
### Discount Shop:
|
||||
- ✅ DiscountProduct.Protobuf
|
||||
- ✅ DiscountCategory.Protobuf
|
||||
- ✅ DiscountOrder.Protobuf
|
||||
- ✅ DiscountShoppingCart.Protobuf
|
||||
|
||||
### Network & Commission:
|
||||
- ✅ NetworkMembership.Protobuf
|
||||
- ✅ ClubMembership.Protobuf
|
||||
- ✅ Commission.Protobuf
|
||||
|
||||
### Orders & Payments:
|
||||
- ✅ UserOrder.Protobuf
|
||||
- ✅ ManualPayment.Protobuf
|
||||
|
||||
### Messaging:
|
||||
- ✅ PublicMessage.Protobuf
|
||||
|
||||
---
|
||||
|
||||
## 🗂️ ماژولهای فعال
|
||||
|
||||
### 1. Products Module ✅
|
||||
- صفحه اصلی محصولات با فیلتر و صفحهبندی
|
||||
- ایجاد محصول جدید با آپلود تصویر
|
||||
- ویرایش محصول
|
||||
- گالری تصاویر محصول
|
||||
- مدیریت تگهای محصول
|
||||
- ویرایش گروهی (قیمت، موجودی، وضعیت)
|
||||
- **ستون موجودی** با رنگبندی هوشمند (🔴🟡🟢)
|
||||
- DragDrop دستهبندی محصولات
|
||||
|
||||
### 2. Discount Shop Module ✅
|
||||
- مدیریت محصولات تخفیفی
|
||||
- مدیریت دستهبندیها
|
||||
- مدیریت سفارشات
|
||||
- گزارش فروش
|
||||
|
||||
### 3. Commission Module ✅
|
||||
- داشبورد استخر هفتگی
|
||||
- لیست پرداختها
|
||||
- لیست برداشتها
|
||||
- بالانسهای هفتگی کاربران
|
||||
|
||||
### 4. Network Module ✅
|
||||
- لیست اعضای شبکه
|
||||
- نمای درختی شبکه
|
||||
- آمار شبکه
|
||||
|
||||
### 5. Club Module ✅
|
||||
- لیست اعضای باشگاه
|
||||
- آمار باشگاه
|
||||
- مدیریت ویژگیهای باشگاه
|
||||
|
||||
### 6. Tag Module ✅
|
||||
- مدیریت تگها (CRUD)
|
||||
- اختصاص تگ به محصولات
|
||||
|
||||
### 7. Public Messages Module ✅
|
||||
- مدیریت پیامهای عمومی
|
||||
- قالبهای پیام
|
||||
|
||||
### 8. Manual Payments Module ✅
|
||||
- ثبت پرداخت دستی
|
||||
- تایید/رد پرداخت
|
||||
|
||||
### 9. System Management ✅
|
||||
- تنظیمات سیستم
|
||||
- لاگ تغییرات
|
||||
- Health Check
|
||||
|
||||
### 10. Dashboard ✅
|
||||
- ویجت آمار فروشگاه تخفیفی (7 روز اخیر)
|
||||
|
||||
---
|
||||
|
||||
## 📊 آمار
|
||||
|
||||
| Metric | Value |
|
||||
|--------|-------|
|
||||
| Build Errors | 0 |
|
||||
| Proto Projects | 24 |
|
||||
| Active Pages | 40+ |
|
||||
| Active Components | 60+ |
|
||||
| Excluded Files | 0 |
|
||||
| Test Coverage | N/A |
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Environment
|
||||
|
||||
- **Framework**: Blazor WebAssembly .NET 9.0
|
||||
- **UI Library**: MudBlazor 8.14.0
|
||||
- **gRPC**: Grpc.Net.Client 2.70.0
|
||||
- **Mapping**: Mapster 7.4.0+
|
||||
@@ -1,230 +0,0 @@
|
||||
# BackOffice Technical Notes
|
||||
|
||||
> نکات فنی برای توسعهدهندگان
|
||||
|
||||
---
|
||||
|
||||
## 1. Mapster Mapping Patterns
|
||||
|
||||
### 1.1 Proto Types (Immutable)
|
||||
برای proto types که immutable هستند، باید از `MapWith` استفاده کرد:
|
||||
|
||||
```csharp
|
||||
config.NewConfig<SourceDto, ProtoResponse>()
|
||||
.MapWith(src => new ProtoResponse
|
||||
{
|
||||
Field1 = src.Field1,
|
||||
Field2 = src.Field2 ?? string.Empty,
|
||||
RepeatedField = { src.List?.Select(x => new Item { ... }) ?? Enumerable.Empty<Item>() }
|
||||
});
|
||||
```
|
||||
|
||||
### 1.2 Null-Safe MetaData
|
||||
```csharp
|
||||
MetaData = src.MetaData != null ? new MetaData
|
||||
{
|
||||
PageIndex = src.MetaData.PageIndex,
|
||||
TotalPages = src.MetaData.TotalPages,
|
||||
TotalCount = src.MetaData.TotalCount
|
||||
} : null
|
||||
```
|
||||
|
||||
### 1.3 Alias Imports برای Disambiguation
|
||||
وقتی دو proto با نام یکسان داریم:
|
||||
|
||||
```csharp
|
||||
using BffProtos = BackOffice.BFF.ClubMembership.Protobuf.Protos.ClubMembership;
|
||||
using CmsProtos = CMSMicroservice.Protobuf.Protos.ClubMembership;
|
||||
|
||||
// استفاده:
|
||||
config.NewConfig<BffProtos.GetRequest, CmsProtos.GetRequest>();
|
||||
```
|
||||
|
||||
### 1.4 PaginationState Mapping
|
||||
```csharp
|
||||
config.NewConfig<BffRequest, AppQuery>()
|
||||
.Map(dest => dest.PaginationState, src => src.PaginationState);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. MudBlazor 8 Breaking Changes
|
||||
|
||||
### 2.1 Dialog Instance
|
||||
```csharp
|
||||
// ❌ قبلی
|
||||
[CascadingParameter] MudDialogInstance MudDialog { get; set; }
|
||||
|
||||
// ✅ جدید
|
||||
[CascadingParameter] IMudDialogInstance MudDialog { get; set; }
|
||||
```
|
||||
|
||||
### 2.2 Generic Components
|
||||
```razor
|
||||
<!-- ❌ قبلی -->
|
||||
<MudSwitch @bind-Value="isActive" />
|
||||
<MudChip>Text</MudChip>
|
||||
|
||||
<!-- ✅ جدید -->
|
||||
<MudSwitch T="bool" @bind-Value="isActive" />
|
||||
<MudChip T="string">Text</MudChip>
|
||||
```
|
||||
|
||||
### 2.3 Drag Events
|
||||
```razor
|
||||
<!-- ❌ قبلی -->
|
||||
@ondragover="e => e.PreventDefault()"
|
||||
|
||||
<!-- ✅ جدید -->
|
||||
@ondragover:preventDefault
|
||||
```
|
||||
|
||||
### 2.4 File Upload
|
||||
```csharp
|
||||
// FilesChanged حالا IBrowserFile میگیرد
|
||||
<MudFileUpload T="IBrowserFile" FilesChanged="OnFileSelected">
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. gRPC Patterns
|
||||
|
||||
### 3.1 Service Override in BFF
|
||||
```csharp
|
||||
public override async Task<GetResponse> GetData(GetRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetRequest, GetQuery, GetResponse>(request, context);
|
||||
}
|
||||
```
|
||||
|
||||
### 3.2 CQRS Handler
|
||||
```csharp
|
||||
public class GetQueryHandler : IRequestHandler<GetQuery, GetResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public async Task<GetResponseDto> Handle(GetQuery request, CancellationToken ct)
|
||||
{
|
||||
var cmsRequest = request.Adapt<CmsProtos.GetRequest>();
|
||||
var response = await _context.Service.GetAsync(cmsRequest, cancellationToken: ct);
|
||||
return response.Adapt<GetResponseDto>();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Proto Update Checklist
|
||||
|
||||
هر تغییری در Proto نیاز به این مراحل دارد:
|
||||
|
||||
### Step 1: Update Version
|
||||
```xml
|
||||
<!-- در .csproj -->
|
||||
<Version>0.0.142</Version> → <Version>0.0.143</Version>
|
||||
```
|
||||
|
||||
### Step 2: Pack
|
||||
```bash
|
||||
cd path/to/proto/project
|
||||
dotnet pack -c Release
|
||||
# Push به GitLab Registry خودکار انجام میشود
|
||||
```
|
||||
|
||||
### Step 3: Update References
|
||||
```xml
|
||||
<PackageReference Include="Foursat.Proto" Version="0.0.143" />
|
||||
```
|
||||
|
||||
### Step 4: Build & Test
|
||||
```bash
|
||||
dotnet build
|
||||
dotnet test
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. Common Fixes
|
||||
|
||||
### 5.1 Snackbar Duplicate Injection
|
||||
اگر در `_Imports.razor` inject شده، در component نیاز نیست:
|
||||
```csharp
|
||||
// ❌ حذف کن
|
||||
[Inject] ISnackbar Snackbar { get; set; }
|
||||
```
|
||||
|
||||
### 5.2 BasePageComponent Reload
|
||||
```csharp
|
||||
private MudDataGrid<Model>? _gridData;
|
||||
|
||||
private async Task OnFilterSubmit()
|
||||
{
|
||||
if (_gridData != null)
|
||||
await _gridData.ReloadServerData();
|
||||
}
|
||||
```
|
||||
|
||||
### 5.3 Nullable Wrapper Types
|
||||
```csharp
|
||||
// Proto nullable types:
|
||||
// google.protobuf.Int64Value → long?
|
||||
// google.protobuf.BoolValue → bool?
|
||||
|
||||
// Set value:
|
||||
request.UserId = userId; // نه new Int64Value { Value = userId }
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. Build Commands
|
||||
|
||||
```bash
|
||||
# Full Solution Build
|
||||
cd /home/masoud/Apps/project/FourSat/BackOffice/src
|
||||
dotnet build BackOffice.sln
|
||||
|
||||
# Single Project
|
||||
dotnet build BackOffice/BackOffice.csproj
|
||||
|
||||
# With Restore
|
||||
dotnet build --restore
|
||||
|
||||
# Clean Build
|
||||
dotnet clean && dotnet build
|
||||
|
||||
# Check Errors Only
|
||||
dotnet build 2>&1 | grep -E "error CS"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7. Project References
|
||||
|
||||
### ProjectReference (Local Development):
|
||||
```xml
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/X.Protobuf/X.Protobuf.csproj" />
|
||||
```
|
||||
|
||||
### PackageReference (Production):
|
||||
```xml
|
||||
<PackageReference Include="Foursat.X.Protobuf" Version="0.0.143" />
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 8. File Organization
|
||||
|
||||
```
|
||||
BackOffice/
|
||||
├── docs/
|
||||
│ ├── README.md # Index
|
||||
│ ├── STATUS.md # Current Status
|
||||
│ ├── CHANGELOG.md # History
|
||||
│ ├── TECHNICAL-NOTES.md # This file
|
||||
│ └── SESSION-*.md # Session logs
|
||||
├── src/
|
||||
│ └── BackOffice/
|
||||
│ ├── Pages/ # Blazor pages
|
||||
│ ├── Services/ # gRPC clients
|
||||
│ └── Common/ # Shared components
|
||||
```
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,131 +0,0 @@
|
||||
@page "/payment/membership"
|
||||
@using BackOffice.BFF.ManualPayment.Protobuf
|
||||
@using BackOffice.Main.Pages.AutoComplete
|
||||
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
|
||||
|
||||
<PageTitle>پرداخت دستی عضویت</PageTitle>
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.Large" Class="mt-4">
|
||||
<MudCard>
|
||||
<MudCardHeader>
|
||||
<CardHeaderContent>
|
||||
<MudText Typo="Typo.h5">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Payment" Class="ml-2" />
|
||||
پرداخت دستی عضویت
|
||||
</MudText>
|
||||
</CardHeaderContent>
|
||||
</MudCardHeader>
|
||||
|
||||
<MudCardContent>
|
||||
<MudGrid>
|
||||
<!-- انتخاب کاربر -->
|
||||
<MudItem xs="12" md="6">
|
||||
<UserAutoComplete
|
||||
Label="انتخاب کاربر *"
|
||||
@bind-SelectedUserId="_userId"
|
||||
HelperText="جستجو با نام، موبایل یا شناسه" />
|
||||
</MudItem>
|
||||
|
||||
<!-- مبلغ -->
|
||||
<MudItem xs="12" md="6">
|
||||
<MudNumericField
|
||||
@bind-Value="_amount"
|
||||
Label="مبلغ (ریال) *"
|
||||
Min="0"
|
||||
Step="10000"
|
||||
Format="N0"
|
||||
Variant="Variant.Outlined"
|
||||
HelperText="مبلغ پرداختی به ریال" />
|
||||
</MudItem>
|
||||
|
||||
<!-- شماره مرجع -->
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField
|
||||
@bind-Value="_referenceNumber"
|
||||
Label="شماره مرجع *"
|
||||
Variant="Variant.Outlined"
|
||||
MaxLength="50"
|
||||
HelperText="شماره مرجع تراکنش یا فیش" />
|
||||
</MudItem>
|
||||
|
||||
<!-- توضیحات -->
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField
|
||||
@bind-Value="_description"
|
||||
Label="توضیحات"
|
||||
Variant="Variant.Outlined"
|
||||
Lines="3"
|
||||
MaxLength="500"
|
||||
HelperText="توضیحات اختیاری" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
@if (_showResult)
|
||||
{
|
||||
<MudAlert Severity="Severity.Success" Class="mt-4" ShowCloseIcon CloseIconClicked="@(() => _showResult = false)">
|
||||
<MudText>@_resultMessage</MudText>
|
||||
<MudText Typo="Typo.caption">شماره تراکنش: @_transactionId</MudText>
|
||||
<MudText Typo="Typo.caption">شماره سفارش: @_orderId</MudText>
|
||||
<MudText Typo="Typo.caption">موجودی جدید کیف پول: @_newWalletBalance.ToString("N0") ریال</MudText>
|
||||
</MudAlert>
|
||||
}
|
||||
</MudCardContent>
|
||||
|
||||
<MudCardActions>
|
||||
<MudButton
|
||||
Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.Check"
|
||||
OnClick="ProcessPayment"
|
||||
Disabled="@_isProcessing">
|
||||
@if (_isProcessing)
|
||||
{
|
||||
<MudProgressCircular Class="ml-2" Size="Size.Small" Indeterminate="true" />
|
||||
<MudText>در حال ثبت...</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText>ثبت پرداخت</MudText>
|
||||
}
|
||||
</MudButton>
|
||||
|
||||
<MudButton
|
||||
Variant="Variant.Outlined"
|
||||
Color="Color.Default"
|
||||
StartIcon="@Icons.Material.Filled.Clear"
|
||||
OnClick="ResetForm"
|
||||
Disabled="@_isProcessing">
|
||||
پاک کردن فرم
|
||||
</MudButton>
|
||||
</MudCardActions>
|
||||
</MudCard>
|
||||
|
||||
<!-- راهنما -->
|
||||
<MudCard Class="mt-4">
|
||||
<MudCardHeader>
|
||||
<CardHeaderContent>
|
||||
<MudText Typo="Typo.h6">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Info" Class="ml-2" />
|
||||
راهنما
|
||||
</MudText>
|
||||
</CardHeaderContent>
|
||||
</MudCardHeader>
|
||||
<MudCardContent>
|
||||
<MudText Typo="Typo.body2" Class="mb-2">این صفحه برای ثبت پرداختهای دستی عضویت استفاده میشود. پس از ثبت:</MudText>
|
||||
<MudList Dense="true">
|
||||
<MudListItem Icon="@Icons.Material.Filled.AccountBalance">
|
||||
<MudText Typo="Typo.body2">مبلغ به کیف پول کاربر (Balance و DiscountBalance) اضافه میشود</MudText>
|
||||
</MudListItem>
|
||||
<MudListItem Icon="@Icons.Material.Filled.History">
|
||||
<MudText Typo="Typo.body2">لاگ تغییرات کیف پول ثبت میشود</MudText>
|
||||
</MudListItem>
|
||||
<MudListItem Icon="@Icons.Material.Filled.Receipt">
|
||||
<MudText Typo="Typo.body2">تراکنش با وضعیت موفق ثبت میشود</MudText>
|
||||
</MudListItem>
|
||||
<MudListItem Icon="@Icons.Material.Filled.ShoppingCart">
|
||||
<MudText Typo="Typo.body2">سفارش خرید پکیج عضویت ثبت میشود</MudText>
|
||||
</MudListItem>
|
||||
</MudList>
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
</MudContainer>
|
||||
@@ -1,103 +0,0 @@
|
||||
using BackOffice.BFF.ManualPayment.Protobuf;
|
||||
using BackOffice.Main.Components;
|
||||
using Grpc.Core;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace BackOffice.Main.Pages.Payment;
|
||||
|
||||
public partial class ManualMembershipPayment
|
||||
{
|
||||
[Inject] private ManualPaymentContract.ManualPaymentContractClient ManualPaymentClient { get; set; } = default!;
|
||||
[Inject] private ISnackbar Snackbar { get; set; } = default!;
|
||||
|
||||
private long? _userId;
|
||||
private long _amount = 0;
|
||||
private string _referenceNumber = string.Empty;
|
||||
private string? _description;
|
||||
|
||||
private bool _isProcessing = false;
|
||||
private bool _showResult = false;
|
||||
private string _resultMessage = string.Empty;
|
||||
private long _transactionId = 0;
|
||||
private long _orderId = 0;
|
||||
private long _newWalletBalance = 0;
|
||||
|
||||
private async Task ProcessPayment()
|
||||
{
|
||||
// Validation
|
||||
if (!_userId.HasValue || _userId.Value <= 0)
|
||||
{
|
||||
Snackbar.Add("لطفا کاربر را انتخاب کنید", Severity.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_amount <= 0)
|
||||
{
|
||||
Snackbar.Add("لطفا مبلغ معتبری وارد کنید", Severity.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(_referenceNumber))
|
||||
{
|
||||
Snackbar.Add("لطفا شماره مرجع را وارد کنید", Severity.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_isProcessing = true;
|
||||
_showResult = false;
|
||||
|
||||
var request = new ProcessManualMembershipPaymentRequest
|
||||
{
|
||||
UserId = _userId.Value,
|
||||
Amount = _amount,
|
||||
ReferenceNumber = _referenceNumber
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_description))
|
||||
{
|
||||
request.Description = _description;
|
||||
}
|
||||
|
||||
var response = await ManualPaymentClient.ProcessManualMembershipPaymentAsync(request);
|
||||
|
||||
_resultMessage = response.Message;
|
||||
_transactionId = response.TransactionId;
|
||||
_orderId = response.OrderId;
|
||||
_newWalletBalance = response.NewWalletBalance;
|
||||
_showResult = true;
|
||||
|
||||
Snackbar.Add("پرداخت دستی با موفقیت ثبت شد", Severity.Success);
|
||||
|
||||
// Reset form
|
||||
await Task.Delay(2000);
|
||||
ResetForm();
|
||||
}
|
||||
catch (RpcException ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در ثبت پرداخت: {ex.Status.Detail}", Severity.Error);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطای غیرمنتظره: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isProcessing = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetForm()
|
||||
{
|
||||
_userId = null;
|
||||
_amount = 0;
|
||||
_referenceNumber = string.Empty;
|
||||
_description = null;
|
||||
_showResult = false;
|
||||
_resultMessage = string.Empty;
|
||||
_transactionId = 0;
|
||||
_orderId = 0;
|
||||
_newWalletBalance = 0;
|
||||
}
|
||||
}
|
||||
@@ -109,71 +109,144 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.Category.Protobuf" Version="0.0.5"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.ClubMembership.Protobuf" Version="0.0.7"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.Commission.Protobuf" Version="0.0.15"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.Common.Protobuf" Version="0.0.3"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.Configuration.Protobuf" Version="1.0.20"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.DiscountCategory.Protobuf" Version="0.0.3"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.DiscountOrder.Protobuf" Version="0.0.3"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.DiscountProduct.Protobuf" Version="0.0.3"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.DiscountShoppingCart.Protobuf" Version="0.0.3"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.Health.Protobuf" Version="1.0.5"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.ManualPayment.Protobuf" Version="0.0.5"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.NetworkMembership.Protobuf" Version="0.0.11"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.Otp.Protobuf" Version="0.0.113"/>
|
||||
<PackageReference Include="FourSat.BackOffice.BFF.Package.Protobuf" Version="0.0.113"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.Products.Protobuf" Version="0.0.11"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.ProductTag.Protobuf" Version="0.0.3"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.PublicMessage.Protobuf" Version="0.0.5"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.Role.Protobuf" Version="0.0.113"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.Tag.Protobuf" Version="0.0.4"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.User.Protobuf" Version="0.0.114"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.UserAddress.Protobuf" Version="0.0.113"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.UserOrder.Protobuf" Version="0.0.116"/>
|
||||
<PackageReference Include="Foursat.BackOffice.BFF.UserRole.Protobuf" Version="0.0.113"/>
|
||||
|
||||
<!-- Proto Projects - Using ProjectReference for latest changes -->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Category.Protobuf/BackOffice.BFF.Category.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.ClubMembership.Protobuf/BackOffice.BFF.ClubMembership.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Commission.Protobuf/BackOffice.BFF.Commission.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Common.Protobuf/BackOffice.BFF.Common.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Configuration.Protobuf/BackOffice.BFF.Configuration.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.DiscountCategory.Protobuf/BackOffice.BFF.DiscountCategory.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.DiscountOrder.Protobuf/BackOffice.BFF.DiscountOrder.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.DiscountProduct.Protobuf/BackOffice.BFF.DiscountProduct.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.DiscountShoppingCart.Protobuf/BackOffice.BFF.DiscountShoppingCart.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Health.Protobuf/BackOffice.BFF.Health.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.ManualPayment.Protobuf/BackOffice.BFF.ManualPayment.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.NetworkMembership.Protobuf/BackOffice.BFF.NetworkMembership.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Otp.Protobuf/BackOffice.BFF.Otp.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Package.Protobuf/BackOffice.BFF.Package.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Products.Protobuf/BackOffice.BFF.Products.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.ProductTag.Protobuf/BackOffice.BFF.ProductTag.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.PublicMessage.Protobuf/BackOffice.BFF.PublicMessage.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Role.Protobuf/BackOffice.BFF.Role.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Tag.Protobuf/BackOffice.BFF.Tag.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.User.Protobuf/BackOffice.BFF.User.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.UserAddress.Protobuf/BackOffice.BFF.UserAddress.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.UserOrder.Protobuf/BackOffice.BFF.UserOrder.Protobuf.csproj" />-->
|
||||
<!-- <ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.UserRole.Protobuf/BackOffice.BFF.UserRole.Protobuf.csproj" />-->
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.12.1"/>
|
||||
<PackageReference Include="DateTimeConverterCL" Version="1.0.0"/>
|
||||
<PackageReference Include="Grpc.Core" Version="2.46.6"/>
|
||||
<PackageReference Include="Grpc.Net.Client" Version="2.71.0"/>
|
||||
<PackageReference Include="Grpc.Net.Client.Web" Version="2.71.0"/>
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.12.1"/>
|
||||
<PackageReference Include="Mapster" Version="7.4.0"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.11"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="9.0.11"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.11" PrivateAssets="all"/>
|
||||
|
||||
<PackageReference Include="MudBlazor" Version="8.14.0"/>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4"/>
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.8.0"/>
|
||||
<PackageReference Include="Tizzani.MudBlazor.HtmlEditor" Version="2.3.0"/>
|
||||
|
||||
<!-- Proto dependencies (needed when using DLL references) -->
|
||||
<PackageReference Include="Google.Protobuf" Version="3.28.3"/>
|
||||
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0"/>
|
||||
<PackageReference Include="FluentValidation" Version="11.2.2"/>
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2"/>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- ============================================================ -->
|
||||
<!-- Proto References: Direct reference to CMS Protobuf project -->
|
||||
<!-- This enables direct communication with CMS (no BFF needed) -->
|
||||
<!-- ============================================================ -->
|
||||
|
||||
<!-- CMS Protobuf NuGet package (used for both local dev and Docker builds) -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.178" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- ============================================================ -->
|
||||
<!-- OLD BFF Proto References (DEPRECATED - kept for reference) -->
|
||||
<!-- ============================================================ -->
|
||||
|
||||
<!-- CI/CD Mode: Use pre-built DLLs from libs/ folder -->
|
||||
<ItemGroup Condition="false AND Exists('../../libs/BackOffice.BFF.Common.Protobuf.dll')">
|
||||
<Reference Include="BackOffice.BFF.Common.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.Common.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.Category.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.Category.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.ClubMembership.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.ClubMembership.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.Commission.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.Commission.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.Configuration.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.Configuration.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.DiscountCategory.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.DiscountCategory.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.DiscountOrder.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.DiscountOrder.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.DiscountProduct.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.DiscountProduct.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.DiscountShoppingCart.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.DiscountShoppingCart.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.Health.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.Health.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.Inventory.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.Inventory.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.ManualPayment.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.ManualPayment.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.NetworkMembership.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.NetworkMembership.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.Otp.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.Otp.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.Package.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.Package.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.Products.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.Products.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.ProductTag.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.ProductTag.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.PublicMessage.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.PublicMessage.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.Role.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.Role.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.Tag.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.Tag.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.User.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.User.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.UserAddress.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.UserAddress.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.UserOrder.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.UserOrder.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BackOffice.BFF.UserRole.Protobuf">
|
||||
<HintPath>../../libs/BackOffice.BFF.UserRole.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Dev Mode: OLD BFF ProjectReference (DEPRECATED) -->
|
||||
<ItemGroup Condition="false AND !Exists('../../libs/BackOffice.BFF.Common.Protobuf.dll')">
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Common.Protobuf/BackOffice.BFF.Common.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Category.Protobuf/BackOffice.BFF.Category.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.ClubMembership.Protobuf/BackOffice.BFF.ClubMembership.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Commission.Protobuf/BackOffice.BFF.Commission.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Configuration.Protobuf/BackOffice.BFF.Configuration.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.DiscountCategory.Protobuf/BackOffice.BFF.DiscountCategory.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.DiscountOrder.Protobuf/BackOffice.BFF.DiscountOrder.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.DiscountProduct.Protobuf/BackOffice.BFF.DiscountProduct.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.DiscountShoppingCart.Protobuf/BackOffice.BFF.DiscountShoppingCart.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Health.Protobuf/BackOffice.BFF.Health.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Inventory.Protobuf/BackOffice.BFF.Inventory.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.ManualPayment.Protobuf/BackOffice.BFF.ManualPayment.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.NetworkMembership.Protobuf/BackOffice.BFF.NetworkMembership.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Otp.Protobuf/BackOffice.BFF.Otp.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Package.Protobuf/BackOffice.BFF.Package.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Products.Protobuf/BackOffice.BFF.Products.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.ProductTag.Protobuf/BackOffice.BFF.ProductTag.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.PublicMessage.Protobuf/BackOffice.BFF.PublicMessage.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Role.Protobuf/BackOffice.BFF.Role.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.Tag.Protobuf/BackOffice.BFF.Tag.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.User.Protobuf/BackOffice.BFF.User.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.UserAddress.Protobuf/BackOffice.BFF.UserAddress.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.UserOrder.Protobuf/BackOffice.BFF.UserOrder.Protobuf.csproj" />
|
||||
<ProjectReference Include="../../../BackOffice.BFF/src/Protobufs/BackOffice.BFF.UserRole.Protobuf/BackOffice.BFF.UserRole.Protobuf.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,34 +1,54 @@
|
||||
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Class="pa-2 pr-4 rounded" Style="height:85vh;">
|
||||
<MudItem xs="2">
|
||||
<MudPaper Height="85vh" Style="overflow:hidden; position:relative;" Outlined="true" Class="rounded-lg">
|
||||
<MudStack Class="pa-5" Style="height:100%;">
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.subtitle2">فیلتر ها</MudText>
|
||||
<MudSpacer />
|
||||
@if (IsFiltered)
|
||||
{
|
||||
<MudButton Color="Color.Error" Variant="Variant.Text" Size="Size.Small" OnClick="@(async () => await OnClearFilterClick.InvokeAsync())">حذف فیلتر</MudButton>
|
||||
}
|
||||
</MudStack>
|
||||
<MudItem Style="height:100%;">
|
||||
<MudStack StretchItems="StretchItems.None" Class="filter-item" Style="height:100%;">
|
||||
<MudStack>
|
||||
@Filters
|
||||
</MudStack>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small" FullWidth="true" Class="mt-auto" OnClick="@(async () => await OnSubmitClick.InvokeAsync())">جستجو</MudButton>
|
||||
</MudStack>
|
||||
</MudItem>
|
||||
@* ── Responsive base page: filter above grid, collapsible ── *@
|
||||
<MudStack Spacing="0" Class="base-page">
|
||||
|
||||
@* ── Header row: page title + filter toggle ── *@
|
||||
@if (Filters != null)
|
||||
{
|
||||
<MudPaper Outlined="true" Class="rounded-lg mb-3 base-page__filter-panel">
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Class="pa-3 cursor-pointer"
|
||||
@onclick="ToggleFilterPanel">
|
||||
<MudIcon Icon="@Icons.Material.Filled.FilterList" Size="Size.Small"
|
||||
Color="@(IsFiltered ? Color.Primary : Color.Default)" />
|
||||
<MudText Typo="Typo.subtitle2" Class="mx-1">فیلترها</MudText>
|
||||
@if (IsFiltered)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Primary" Size="Size.Small" Variant="Variant.Text">فعال</MudChip>
|
||||
}
|
||||
<MudSpacer />
|
||||
<MudIcon Icon="@(_filterOpen ? Icons.Material.Filled.ExpandLess : Icons.Material.Filled.ExpandMore)"
|
||||
Size="Size.Small" />
|
||||
</MudStack>
|
||||
|
||||
@if (_filterOpen)
|
||||
{
|
||||
<MudDivider />
|
||||
<div class="pa-3">
|
||||
<MudGrid Spacing="2">
|
||||
@Filters
|
||||
</MudGrid>
|
||||
<MudStack Row="true" Justify="Justify.FlexEnd" Class="mt-3" Spacing="2">
|
||||
@if (IsFiltered)
|
||||
{
|
||||
<MudButton Color="Color.Error" Variant="Variant.Text" Size="Size.Small"
|
||||
OnClick="@(async () => await OnClearFilterClick.InvokeAsync())">
|
||||
پاک کردن فیلتر
|
||||
</MudButton>
|
||||
}
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small"
|
||||
StartIcon="@Icons.Material.Filled.Search"
|
||||
OnClick="@(async () => await OnSubmitClick.InvokeAsync())">
|
||||
جستجو
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</div>
|
||||
}
|
||||
</MudPaper>
|
||||
}
|
||||
|
||||
</MudItem>
|
||||
<MudItem xs="10">
|
||||
<MudPaper Height="85vh" Style="overflow:hidden; position:relative;" Outlined="true" Class="rounded-lg">
|
||||
@* ── Content area (DataGrid or custom layout) ── *@
|
||||
<MudPaper Outlined="true" Class="rounded-lg base-page__content" Style="overflow:hidden; position:relative;">
|
||||
@Content
|
||||
</MudPaper>
|
||||
|
||||
@Content
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
</MudStack>
|
||||
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace BackOffice.Common.BaseComponents;
|
||||
|
||||
public partial class BasePageComponent
|
||||
{
|
||||
[Parameter] public RenderFragment Filters { get; set; } = default!;
|
||||
[Parameter] public RenderFragment? Filters { get; set; }
|
||||
[Parameter] public RenderFragment Content { get; set; } = default!;
|
||||
[Parameter] public bool IsFiltered { get; set; }
|
||||
[Parameter] public EventCallback OnSubmitClick { get; set; }
|
||||
[Parameter] public EventCallback OnClearFilterClick { get; set; }
|
||||
|
||||
/// <summary>Whether the filter panel is expanded.</summary>
|
||||
private bool _filterOpen;
|
||||
|
||||
private void ToggleFilterPanel() => _filterOpen = !_filterOpen;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/* ── BasePageComponent scoped styles ── */
|
||||
|
||||
.base-page {
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.base-page__filter-panel {
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.base-page__content {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
}
|
||||
@@ -7,6 +7,6 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudImage Src="@src" Alt="@Alt" Elevation="@Elevation" Class="@Class" Fluid="@Fluid" Height="@Height" ObjectFit="@ObjectFit" ObjectPosition="@ObjectPosition" Style="@(Style + ";cursor:pointer;")" Tag="@Tag" Width="@Width" @onclick="async()=>await OnClick.InvokeAsync()" />
|
||||
<MudImage Src="@src" Alt="@Alt" Elevation="@Elevation" Class="@Class" Fluid="@Fluid" Height="@Height" ObjectFit="@ObjectFit" ObjectPosition="@ObjectPosition" Style="@Style" Tag="@Tag" Width="@Width" @onclick="async()=>await OnClick.InvokeAsync()" />
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MudBlazor;
|
||||
|
||||
namespace BackOffice.Common.BaseComponents
|
||||
@@ -13,13 +14,24 @@ namespace BackOffice.Common.BaseComponents
|
||||
{
|
||||
private string src = string.Empty;
|
||||
[Parameter] public EventCallback OnClick { get; set; }
|
||||
[Inject] private IConfiguration Configuration { get; set; } = default!;
|
||||
|
||||
private string FileBaseUrl => Configuration["GwUrl"]?.TrimEnd('/') ?? "";
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await base.OnParametersSetAsync();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Src))
|
||||
{
|
||||
src = Src.Contains("data:") ? Src : "https://dl.afrino.co" + Src;
|
||||
if (Src.Contains("data:") || Src.StartsWith("http"))
|
||||
src = Src;
|
||||
else
|
||||
src = FileBaseUrl + "/uploads/" + Src.TrimStart('/');
|
||||
}
|
||||
else
|
||||
{
|
||||
src = string.Empty;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,32 +1,43 @@
|
||||
using BackOffice.BFF.Otp.Protobuf.Protos.Otp;
|
||||
using BackOffice.BFF.Package.Protobuf.Protos.Package;
|
||||
using BackOffice.BFF.Role.Protobuf.Protos.Role;
|
||||
using BackOffice.BFF.Products.Protobuf.Protos.Products;
|
||||
using BackOffice.BFF.User.Protobuf.Protos.User;
|
||||
using BackOffice.BFF.UserAddress.Protobuf.Protos.UserAddress;
|
||||
using BackOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
|
||||
using BackOffice.BFF.UserRole.Protobuf.Protos.UserRole;
|
||||
using BackOffice.BFF.Category.Protobuf.Protos.Category;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
using Foursat.BackOffice.BFF.ClubMembership.Protos;
|
||||
using Foursat.BackOffice.BFF.Configuration.Protos;
|
||||
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
|
||||
using Foursat.BackOffice.BFF.Health.Protobuf;
|
||||
using BackOffice.BFF.Configuration.Protobuf.Protos.AppVersion;
|
||||
using CMSMicroservice.Protobuf.Protos.OtpToken;
|
||||
using CMSMicroservice.Protobuf.Protos.Package;
|
||||
using CMSMicroservice.Protobuf.Protos.Role;
|
||||
using CMSMicroservice.Protobuf.Protos.Products;
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
||||
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
||||
using CMSMicroservice.Protobuf.Protos.UserRole;
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using CMSMicroservice.Protobuf.Protos.ClubMembership;
|
||||
using CMSMicroservice.Protobuf.Protos.Configuration;
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
using CMSMicroservice.Protobuf.Protos.Health;
|
||||
using CMSMicroservice.Protobuf.Protos.AppVersion;
|
||||
|
||||
// TODO: Create these proto projects - temporarily disabled
|
||||
// using BackOffice.BFF.DiscountProduct.Protobuf.Protos.DiscountProduct;
|
||||
// using BackOffice.BFF.DiscountCategory.Protobuf.Protos.DiscountCategory;
|
||||
// using BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder;
|
||||
// using BackOffice.BFF.Tag.Protobuf.Protos.Tag;
|
||||
// using BackOffice.BFF.ProductTag.Protobuf.Protos.ProductTag;
|
||||
// using BackOffice.BFF.PublicMessage.Protobuf.Protos.PublicMessage;
|
||||
// Discount Shop Proto Clients
|
||||
using CMSMicroservice.Protobuf.Protos.DiscountProduct;
|
||||
using CMSMicroservice.Protobuf.Protos.DiscountCategory;
|
||||
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
|
||||
using CMSMicroservice.Protobuf.Protos.Tag;
|
||||
using CMSMicroservice.Protobuf.Protos.ProductTag;
|
||||
using CMSMicroservice.Protobuf.Protos.ManualPayment;
|
||||
using CMSMicroservice.Protobuf.Protos;
|
||||
using CMSMicroservice.Protobuf.Protos.Inventory;
|
||||
using CMSMicroservice.Protobuf.Protos.BlogPost;
|
||||
using CMSMicroservice.Protobuf.Protos.BlogCategory;
|
||||
using CMSMicroservice.Protobuf.Protos.BlogPostImage;
|
||||
using CMSMicroservice.Protobuf.Protos.SitePage;
|
||||
using CMSMicroservice.Protobuf.Protos.UserContract;
|
||||
using CMSMicroservice.Protobuf.Protos.UserWallet;
|
||||
using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog;
|
||||
using BackOffice.Common.Utilities;
|
||||
// using BackOffice.Services.DiscountProduct;
|
||||
// using BackOffice.Services.DiscountCategory;
|
||||
// using BackOffice.Services.DiscountOrder;
|
||||
// using BackOffice.Services.PublicMessage;
|
||||
// using BackOffice.Services.Tag;
|
||||
using BackOffice.Services.DiscountProduct;
|
||||
using BackOffice.Services.DiscountCategory;
|
||||
using BackOffice.Services.DiscountOrder;
|
||||
using BackOffice.Services.PublicMessage;
|
||||
using BackOffice.Services.Tag;
|
||||
using BackOffice.Services.Blog;
|
||||
using BackOffice.Services.Content;
|
||||
using Blazored.LocalStorage;
|
||||
using Grpc.Core;
|
||||
using Grpc.Core.Interceptors;
|
||||
@@ -37,9 +48,6 @@ using MudBlazor.Services;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
using Foursat.BackOffice.BFF.Health.Protobuf;
|
||||
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
|
||||
|
||||
|
||||
namespace Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
@@ -70,12 +78,19 @@ public static class ConfigureServices
|
||||
// Application Services
|
||||
services.AddScoped<BackOffice.Services.Authorization.IAuthorizationService, BackOffice.Services.Authorization.AuthorizationService>();
|
||||
services.AddScoped<BackOffice.Services.AppVersion.IAppVersionService, BackOffice.Services.AppVersion.AppVersionService>();
|
||||
// TODO: Re-enable when proto projects are created
|
||||
// services.AddScoped<IDiscountProductService, DiscountProductService>();
|
||||
// services.AddScoped<IDiscountCategoryService, DiscountCategoryService>();
|
||||
// services.AddScoped<IDiscountOrderService, DiscountOrderService>();
|
||||
// services.AddScoped<IPublicMessageService, PublicMessageService>();
|
||||
// services.AddScoped<ITagService, TagService>();
|
||||
|
||||
// Discount Shop Services
|
||||
services.AddScoped<IDiscountProductService, DiscountProductService>();
|
||||
services.AddScoped<IDiscountCategoryService, DiscountCategoryService>();
|
||||
services.AddScoped<IDiscountOrderService, DiscountOrderService>();
|
||||
services.AddScoped<IPublicMessageService, PublicMessageService>();
|
||||
services.AddScoped<ITagService, TagService>();
|
||||
|
||||
// Blog & Content Management Services
|
||||
services.AddScoped<IBlogPostService, BlogPostService>();
|
||||
services.AddScoped<IBlogCategoryService, BlogCategoryService>();
|
||||
services.AddScoped<IBlogPostImageService, BlogPostImageService>();
|
||||
services.AddScoped<ISitePageService, SitePageService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
@@ -102,7 +117,7 @@ public static class ConfigureServices
|
||||
return CreateAuthenticatedChannel(baseUri, httpClient, sp);
|
||||
});
|
||||
|
||||
services.AddTransient(sp => new OtpContract.OtpContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
services.AddTransient(sp => new OtpTokenContract.OtpTokenContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
services.AddTransient(sp => new PackageContract.PackageContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
services.AddTransient(sp => new ProductsContract.ProductsContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
services.AddTransient(sp => new RoleContract.RoleContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
@@ -120,18 +135,36 @@ public static class ConfigureServices
|
||||
services.AddTransient(sp => new HealthContract.HealthContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
services.AddTransient(sp => new AppVersionContract.AppVersionContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
|
||||
// TODO: Re-enable when proto projects are created
|
||||
// Discount Shop Services
|
||||
// services.AddTransient(sp => new DiscountProductsContract.DiscountProductsContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
// services.AddTransient(sp => new DiscountCategoriesContract.DiscountCategoriesContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
// services.AddTransient(sp => new DiscountOrdersContract.DiscountOrdersContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
services.AddTransient(sp => new DiscountProductContract.DiscountProductContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
services.AddTransient(sp => new DiscountCategoryContract.DiscountCategoryContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
services.AddTransient(sp => new DiscountOrderContract.DiscountOrderContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
|
||||
// Public Message Service
|
||||
// services.AddTransient(sp => new PublicMessagesContract.PublicMessagesContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
services.AddTransient(sp => new PublicMessageContract.PublicMessageContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
|
||||
// Tag Management Services
|
||||
// services.AddTransient(sp => new TagContract.TagContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
// services.AddTransient(sp => new ProductTagContract.ProductTagContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
services.AddTransient(sp => new TagContract.TagContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
services.AddTransient(sp => new ProductTagContract.ProductTagContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
|
||||
// Manual Payment Service
|
||||
services.AddTransient(sp => new ManualPaymentContract.ManualPaymentContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
|
||||
// Inventory Management Service
|
||||
services.AddTransient(sp => new InventoryContract.InventoryContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
|
||||
// Blog & Content Management Services
|
||||
services.AddTransient(sp => new BlogPostContract.BlogPostContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
services.AddTransient(sp => new BlogCategoryContract.BlogCategoryContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
services.AddTransient(sp => new BlogPostImageContract.BlogPostImageContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
services.AddTransient(sp => new SitePageContract.SitePageContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
|
||||
// User Contracts Service
|
||||
services.AddTransient(sp => new UserContractContract.UserContractContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
|
||||
// User Wallet Services
|
||||
services.AddTransient(sp => new UserWalletContract.UserWalletContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
services.AddTransient(sp => new UserWalletChangeLogContract.UserWalletChangeLogContractClient(sp.GetRequiredService<CallInvoker>()));
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ public static class RouteConstance
|
||||
public const string UserPage = "/UserPage/";
|
||||
public const string UserOrder = "/UserOrderPage/";
|
||||
public const string Orders = "/OrdersPage/";
|
||||
public const string OrdersSalesReports = "/OrdersSalesReportsPage/";
|
||||
public const string UserRole = "/UserRolePage/";
|
||||
public const string UserAddress = "/UserAddressPage/";
|
||||
public const string Products = "/ProductsPage/";
|
||||
@@ -17,4 +18,11 @@ public static class RouteConstance
|
||||
public const string ProductCategories = "/ProductCategoriesPage/";
|
||||
public const string ProductsBulkEdit = "/ProductsBulkEditPage/";
|
||||
public const string CategoryProducts = "/CategoryProductsPage/";
|
||||
|
||||
// Inventory Management
|
||||
public const string Inventory = "/InventoryPage/";
|
||||
public const string InventoryLowStock = "/InventoryLowStockPage/";
|
||||
public const string InventoryWarehouses = "/InventoryWarehousesPage/";
|
||||
public const string InventoryAddStock = "/InventoryAddStockPage/";
|
||||
public const string InventoryMovements = "/InventoryMovementsPage/";
|
||||
}
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||
<add key="FourSat" value="https://git.afrino.co/api/packages/FourSat/nuget/index.json" />
|
||||
<add key="Afrino" value="https://git.afrino.co/api/packages/Afrino/nuget/index.json" />
|
||||
<clear />
|
||||
<!-- Nexus (hosts FourSat packages + proxies nuget.org) -->
|
||||
<add key="Nexus" value="http://194.5.195.53:32081/repository/nuget-all/index.json" allowInsecureConnections="true" />
|
||||
</packageSources>
|
||||
<packageSourceCredentials>
|
||||
<FourSat>
|
||||
<add key="Username" value="masoud" />
|
||||
<Nexus>
|
||||
<add key="Username" value="admin" />
|
||||
<add key="ClearTextPassword" value="87zH26nbqT" />
|
||||
</FourSat>
|
||||
<Afrino>
|
||||
<add key="Username" value="systemuser" />
|
||||
<add key="ClearTextPassword" value="sZSA7PTiv3pUSQZ" />
|
||||
</Afrino>
|
||||
</Nexus>
|
||||
</packageSourceCredentials>
|
||||
</configuration>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@using BackOffice.BFF.Category.Protobuf.Protos.Category
|
||||
@using CMSMicroservice.Protobuf.Protos.Category
|
||||
|
||||
<MudAutocomplete T="GetAllCategoryByFilterResponseModel"
|
||||
Label="@Label"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BackOffice.BFF.Category.Protobuf.Protos.Category;
|
||||
using CMSMicroservice.Protobuf.Protos;
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace BackOffice.Pages.AutoComplete;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@using BackOffice.BFF.Category.Protobuf.Protos.Category
|
||||
@using CMSMicroservice.Protobuf.Protos.Category
|
||||
|
||||
<MudAutocomplete T="GetAllCategoryByFilterResponseModel"
|
||||
Label="@Label"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BackOffice.BFF.Category.Protobuf.Protos.Category;
|
||||
using CMSMicroservice.Protobuf.Protos;
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace BackOffice.Pages.AutoComplete;
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
@using BackOffice.BFF.Category.Protobuf.Protos.Category
|
||||
@using CMSMicroservice.Protobuf.Protos.Category
|
||||
|
||||
<MudSelect T="long"
|
||||
@ref="_selectRef"
|
||||
Label="@Label"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense"
|
||||
Disabled="@Disabled"
|
||||
MultiSelection="true"
|
||||
MultiSelectionTextFunc="@GetSelectedText"
|
||||
SelectedValues="_internalSelectedIds"
|
||||
SelectedValuesChanged="@(_ => OnSelectedValuesChangedAsync())">
|
||||
SelectedValuesChanged="OnSelectedValuesChangedAsync">
|
||||
@foreach (var item in _items)
|
||||
{
|
||||
<MudSelectItem T="long" Value="@item.Id">
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BackOffice.BFF.Category.Protobuf.Protos.Category;
|
||||
using CMSMicroservice.Protobuf.Protos;
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace BackOffice.Pages.AutoComplete;
|
||||
@@ -61,11 +62,9 @@ public partial class CategoryMultiSelectCombo
|
||||
: new HashSet<long>();
|
||||
}
|
||||
|
||||
private async Task OnSelectedValuesChangedAsync()
|
||||
private async Task OnSelectedValuesChangedAsync(IEnumerable<long> values)
|
||||
{
|
||||
var current = _selectRef?.SelectedValues ?? System.Array.Empty<long>();
|
||||
|
||||
_internalSelectedIds = current.Where(id => id > 0).Distinct().ToHashSet();
|
||||
_internalSelectedIds = values.Where(id => id > 0).Distinct().ToHashSet();
|
||||
SelectedIds = _internalSelectedIds.ToList();
|
||||
|
||||
if (SelectedIdsChanged.HasDelegate)
|
||||
@@ -73,5 +72,27 @@ public partial class CategoryMultiSelectCombo
|
||||
await SelectedIdsChanged.InvokeAsync(SelectedIds);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetSelectedText(List<string> selectedValues)
|
||||
{
|
||||
if (selectedValues == null || selectedValues.Count == 0)
|
||||
return string.Empty;
|
||||
|
||||
var titles = new List<string>();
|
||||
foreach (var val in selectedValues)
|
||||
{
|
||||
if (long.TryParse(val, out var id))
|
||||
{
|
||||
var item = _items.FirstOrDefault(x => x.Id == id);
|
||||
titles.Add(item != null ? item.Title : val);
|
||||
}
|
||||
else
|
||||
{
|
||||
titles.Add(val);
|
||||
}
|
||||
}
|
||||
|
||||
return string.Join("، ", titles);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
@using BackOffice.Services.DiscountCategory
|
||||
|
||||
<MudSelect @ref="_selectRef"
|
||||
T="long"
|
||||
MultiSelection="true"
|
||||
MultiSelectionTextFunc="@GetSelectedText"
|
||||
SelectedValues="_internalSelectedIds"
|
||||
SelectedValuesChanged="OnSelectedValuesChangedAsync"
|
||||
Label="@Label"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense"
|
||||
Disabled="@Disabled">
|
||||
@foreach (var item in _items)
|
||||
{
|
||||
<MudSelectItem T="long" Value="@item.Id">@item.Title</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
@@ -0,0 +1,119 @@
|
||||
using BackOffice.Services.DiscountCategory;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace BackOffice.Pages.AutoComplete;
|
||||
|
||||
public partial class DiscountCategoryMultiSelectCombo
|
||||
{
|
||||
[Inject] public IDiscountCategoryService CategoryService { get; set; } = default!;
|
||||
|
||||
[Parameter] public List<long> SelectedIds { get; set; } = new();
|
||||
[Parameter] public EventCallback<List<long>> SelectedIdsChanged { get; set; }
|
||||
[Parameter] public string? Label { get; set; } = "انتخاب دستهبندیها";
|
||||
[Parameter] public bool Disabled { get; set; }
|
||||
|
||||
private List<DiscountCategoryDto> _items = new();
|
||||
private HashSet<long> _internalSelectedIds = new();
|
||||
private MudSelect<long>? _selectRef;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
await LoadCategoriesAsync();
|
||||
SyncInternalFromParameter();
|
||||
}
|
||||
|
||||
protected override Task OnParametersSetAsync()
|
||||
{
|
||||
SyncInternalFromParameter();
|
||||
return base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
private async Task LoadCategoriesAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var tree = await CategoryService.GetCategoriesAsync(isActive: true);
|
||||
_items = FlattenCategories(tree ?? new List<DiscountCategoryDto>());
|
||||
|
||||
// Log first few items
|
||||
if (_items.Count > 0)
|
||||
{
|
||||
foreach (var item in _items.Take(5))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex.InnerException != null)
|
||||
{
|
||||
}
|
||||
_items = new List<DiscountCategoryDto>();
|
||||
}
|
||||
}
|
||||
|
||||
private List<DiscountCategoryDto> FlattenCategories(List<DiscountCategoryDto> categories, string prefix = "")
|
||||
{
|
||||
var result = new List<DiscountCategoryDto>();
|
||||
foreach (var category in categories)
|
||||
{
|
||||
var catCopy = new DiscountCategoryDto
|
||||
{
|
||||
Id = category.Id,
|
||||
Title = prefix + category.Title,
|
||||
Name = category.Name,
|
||||
ParentCategoryId = category.ParentCategoryId,
|
||||
IsActive = category.IsActive
|
||||
};
|
||||
result.Add(catCopy);
|
||||
|
||||
if (category.Children?.Any() == true)
|
||||
{
|
||||
result.AddRange(FlattenCategories(category.Children.ToList(), prefix + " "));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void SyncInternalFromParameter()
|
||||
{
|
||||
_internalSelectedIds = SelectedIds != null
|
||||
? SelectedIds.Where(id => id > 0).Distinct().ToHashSet()
|
||||
: new HashSet<long>();
|
||||
}
|
||||
|
||||
private async Task OnSelectedValuesChangedAsync(IEnumerable<long> values)
|
||||
{
|
||||
_internalSelectedIds = values.Where(id => id > 0).Distinct().ToHashSet();
|
||||
SelectedIds = _internalSelectedIds.ToList();
|
||||
|
||||
if (SelectedIdsChanged.HasDelegate)
|
||||
{
|
||||
await SelectedIdsChanged.InvokeAsync(SelectedIds);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetSelectedText(List<string> selectedValues)
|
||||
{
|
||||
if (selectedValues == null || selectedValues.Count == 0)
|
||||
return string.Empty;
|
||||
|
||||
var titles = new List<string>();
|
||||
foreach (var val in selectedValues)
|
||||
{
|
||||
if (long.TryParse(val, out var id))
|
||||
{
|
||||
var item = _items.FirstOrDefault(x => x.Id == id);
|
||||
titles.Add(item != null ? item.Title : val);
|
||||
}
|
||||
else
|
||||
{
|
||||
titles.Add(val);
|
||||
}
|
||||
}
|
||||
|
||||
return string.Join("، ", titles);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
@using BackOffice.BFF.Products.Protobuf.Protos.Products
|
||||
@using CMSMicroservice.Protobuf.Protos.Products
|
||||
|
||||
<MudAutocomplete T="GetAllProductsByFilterResponseModel"
|
||||
Label="@Label"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using BackOffice.BFF.Products.Protobuf.Protos.Products;
|
||||
using BackOffice.BFF.Protobuf.Common;
|
||||
using CMSMicroservice.Protobuf.Protos.Products;
|
||||
using CMSMicroservice.Protobuf.Protos;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace BackOffice.Pages.AutoComplete;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@using BackOffice.BFF.Role.Protobuf.Protos.Role
|
||||
@using CMSMicroservice.Protobuf.Protos.Role
|
||||
|
||||
<MudAutocomplete T="GetAllRoleByFilterResponseModel"
|
||||
Label="@Label"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using BackOffice.BFF.Role.Protobuf.Protos.Role;
|
||||
using CMSMicroservice.Protobuf.Protos.Role;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@using BackOffice.BFF.User.Protobuf.Protos.User
|
||||
@using CMSMicroservice.Protobuf.Protos.User
|
||||
|
||||
<MudAutocomplete T="GetAllUserByFilterResponseModel"
|
||||
Label="@Label"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using BackOffice.BFF.User.Protobuf.Protos.User;
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
using Grpc.Core;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@using Foursat.BackOffice.BFF.Commission.Protos
|
||||
@using CMSMicroservice.Protobuf.Protos.Commission
|
||||
|
||||
<MudAutocomplete T="WeekInfo"
|
||||
Label="@Label"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using BackOffice.Services;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using Grpc.Core;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
@* Merged into /blog *@
|
||||
@attribute [Authorize(Roles = "Administrator")]
|
||||
|
||||
@using BackOffice.Services.Blog
|
||||
|
||||
@inject IBlogCategoryService BlogCategoryService
|
||||
|
||||
<div>
|
||||
<MudStack Spacing="2">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.h5">مدیریت دستهبندیهای بلاگ</MudText>
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.Add"
|
||||
OnClick="CreateCategory">
|
||||
افزودن دستهبندی
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudDataGrid T="BlogCategoryItemDto"
|
||||
@ref="_grid"
|
||||
ServerData="LoadServerData"
|
||||
Hover="true"
|
||||
Elevation="1"
|
||||
Dense="true"
|
||||
Height="calc(100vh - 240px)">
|
||||
<Columns>
|
||||
<PropertyColumn Property="x => x.Id" Title="شناسه" />
|
||||
<PropertyColumn Property="x => x.Title" Title="عنوان" />
|
||||
<PropertyColumn Property="x => x.Slug" Title="اسلاگ" />
|
||||
<PropertyColumn Property="x => x.IconName" Title="آیکون" />
|
||||
<PropertyColumn Property="x => x.PostCount" Title="تعداد پست" />
|
||||
<PropertyColumn Property="x => x.IsActive" Title="وضعیت">
|
||||
<CellTemplate>
|
||||
<MudChip Color="@(context.Item.IsActive ? Color.Success : Color.Error)"
|
||||
Size="Size.Small">
|
||||
@(context.Item.IsActive ? "فعال" : "غیرفعال")
|
||||
</MudChip>
|
||||
</CellTemplate>
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="x => x.SortOrder" Title="ترتیب" />
|
||||
<TemplateColumn Title="عملیات" Sortable="false">
|
||||
<CellTemplate>
|
||||
<MudStack Row="true" Spacing="1">
|
||||
<MudTooltip Text="ویرایش">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Edit"
|
||||
Size="Size.Small"
|
||||
Color="Color.Primary"
|
||||
OnClick="@(() => EditCategory(context.Item))" />
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="حذف">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete"
|
||||
Size="Size.Small"
|
||||
Color="Color.Error"
|
||||
OnClick="@(() => DeleteCategory(context.Item))" />
|
||||
</MudTooltip>
|
||||
</MudStack>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
</Columns>
|
||||
<NoRecordsContent>
|
||||
<MudAlert Severity="Severity.Info" Dense="true" Variant="Variant.Text" Class="my-4">موردی یافت نشد.</MudAlert>
|
||||
</NoRecordsContent>
|
||||
<PagerContent>
|
||||
<MudDataGridPager T="BlogCategoryItemDto" PageSizeOptions="@(new int[] { 20, 50, 100 })"
|
||||
InfoFormat="سطر {first_item} تا {last_item} از {all_items}"
|
||||
RowsPerPageString="تعداد در صفحه" />
|
||||
</PagerContent>
|
||||
</MudDataGrid>
|
||||
</MudStack>
|
||||
</div>
|
||||
@@ -0,0 +1,102 @@
|
||||
using BackOffice.Services.Blog;
|
||||
using BackOffice.Pages.Blog.Components;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using MudBlazor;
|
||||
|
||||
namespace BackOffice.Pages.Blog;
|
||||
|
||||
public partial class BlogCategoryManagementPage
|
||||
{
|
||||
private MudDataGrid<BlogCategoryItemDto> _grid = default!;
|
||||
|
||||
private async Task<GridData<BlogCategoryItemDto>> LoadServerData(GridState<BlogCategoryItemDto> state)
|
||||
{
|
||||
var filter = new BlogCategoryFilterDto
|
||||
{
|
||||
PageNumber = state.Page + 1,
|
||||
PageSize = state.PageSize
|
||||
};
|
||||
|
||||
var result = await BlogCategoryService.GetAllAsync(filter);
|
||||
|
||||
return new GridData<BlogCategoryItemDto>
|
||||
{
|
||||
Items = result.Items,
|
||||
TotalItems = result.TotalCount
|
||||
};
|
||||
}
|
||||
|
||||
private async Task ReloadAsync()
|
||||
{
|
||||
if (_grid != null)
|
||||
{
|
||||
await _grid.ReloadServerData();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CreateCategory()
|
||||
{
|
||||
var parameters = new DialogParameters<BlogCategoryEditDialog>
|
||||
{
|
||||
{ nameof(BlogCategoryEditDialog.Model), new BlogCategoryEditDto() },
|
||||
{ nameof(BlogCategoryEditDialog.IsEditMode), false }
|
||||
};
|
||||
|
||||
var dialog = await DialogService.ShowAsync<BlogCategoryEditDialog>("ایجاد دستهبندی جدید", parameters,
|
||||
new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Small, FullWidth = true });
|
||||
|
||||
var result = await dialog.Result;
|
||||
if (!result.Canceled)
|
||||
{
|
||||
Snackbar.Add("دستهبندی با موفقیت ایجاد شد", Severity.Success);
|
||||
await ReloadAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task EditCategory(BlogCategoryItemDto item)
|
||||
{
|
||||
var dto = new BlogCategoryEditDto
|
||||
{
|
||||
Title = item.Title,
|
||||
Slug = item.Slug,
|
||||
Description = item.Description,
|
||||
IconName = item.IconName,
|
||||
SortOrder = item.SortOrder,
|
||||
IsActive = item.IsActive
|
||||
};
|
||||
|
||||
var parameters = new DialogParameters<BlogCategoryEditDialog>
|
||||
{
|
||||
{ nameof(BlogCategoryEditDialog.Model), dto },
|
||||
{ nameof(BlogCategoryEditDialog.CategoryId), item.Id },
|
||||
{ nameof(BlogCategoryEditDialog.IsEditMode), true }
|
||||
};
|
||||
|
||||
var dialog = await DialogService.ShowAsync<BlogCategoryEditDialog>("ویرایش دستهبندی", parameters,
|
||||
new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Small, FullWidth = true });
|
||||
|
||||
var result = await dialog.Result;
|
||||
if (!result.Canceled)
|
||||
{
|
||||
Snackbar.Add("دستهبندی با موفقیت بهروزرسانی شد", Severity.Success);
|
||||
await ReloadAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeleteCategory(BlogCategoryItemDto item)
|
||||
{
|
||||
var confirmed = await DialogService.ShowMessageBox(
|
||||
"حذف دستهبندی",
|
||||
$"آیا از حذف دستهبندی «{item.Title}» مطمئن هستید؟",
|
||||
yesText: "حذف",
|
||||
cancelText: "لغو");
|
||||
|
||||
if (confirmed == true)
|
||||
{
|
||||
await BlogCategoryService.DeleteAsync(item.Id);
|
||||
Snackbar.Add("دستهبندی حذف شد", Severity.Success);
|
||||
await ReloadAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
@page "/blog"
|
||||
@page "/blog/posts"
|
||||
@page "/blog/categories"
|
||||
@attribute [Authorize(Roles = "Administrator")]
|
||||
|
||||
<div>
|
||||
<MudText Typo="Typo.h5" Class="mb-3">مدیریت بلاگ</MudText>
|
||||
|
||||
<MudTabs Elevation="0" Rounded="true" Border="true" ApplyEffectsToContainer="true"
|
||||
PanelClass="pt-4" @bind-ActivePanelIndex="_activeTab">
|
||||
<MudTabPanel Text="پستها" Icon="@Icons.Material.Filled.PostAdd">
|
||||
<BlogPostManagementPage />
|
||||
</MudTabPanel>
|
||||
<MudTabPanel Text="دستهبندیها" Icon="@Icons.Material.Filled.Category">
|
||||
<BlogCategoryManagementPage />
|
||||
</MudTabPanel>
|
||||
</MudTabs>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private int _activeTab;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
var uri = Navigation.ToBaseRelativePath(Navigation.Uri).ToLowerInvariant().TrimEnd('/');
|
||||
_activeTab = uri switch
|
||||
{
|
||||
"blog/categories" => 1,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
@* Merged into /blog *@
|
||||
@attribute [Authorize(Roles = "Administrator")]
|
||||
|
||||
@using BackOffice.Services.Blog
|
||||
|
||||
@inject IBlogPostService BlogPostService
|
||||
@inject IBlogCategoryService BlogCategoryService
|
||||
|
||||
<div>
|
||||
<MudStack Spacing="2">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.h5">مدیریت پستهای بلاگ</MudText>
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.Add"
|
||||
OnClick="CreatePost">
|
||||
افزودن پست
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudTextField @bind-Value="_search"
|
||||
Label="جستجو بر اساس عنوان"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentIcon="@Icons.Material.Filled.Search"
|
||||
Immediate="true"
|
||||
OnBlur="ReloadAsync"
|
||||
OnKeyDown="OnSearchKeyDown" />
|
||||
|
||||
<MudSelect @bind-Value="_statusFilter"
|
||||
Label="وضعیت"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense"
|
||||
Style="width: 160px;">
|
||||
<MudSelectItem T="int?" Value="@( (int?)null )">همه</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="0">پیشنویس</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="1">منتشر شده</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="2">آرشیو شده</MudSelectItem>
|
||||
</MudSelect>
|
||||
|
||||
<MudSelect @bind-Value="_categoryFilter"
|
||||
Label="دستهبندی"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense"
|
||||
Style="width: 200px;">
|
||||
<MudSelectItem T="long?" Value="@( (long?)null )">همه</MudSelectItem>
|
||||
@foreach (var cat in _categories)
|
||||
{
|
||||
<MudSelectItem T="long?" Value="@( (long?)cat.Id )">@cat.Title</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
|
||||
<MudButton Variant="Variant.Outlined"
|
||||
Color="Color.Primary"
|
||||
OnClick="ReloadAsync">
|
||||
اعمال فیلتر
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudDataGrid T="BlogPostListItemDto"
|
||||
@ref="_grid"
|
||||
ServerData="LoadServerData"
|
||||
Hover="true"
|
||||
Elevation="1"
|
||||
Dense="true"
|
||||
Height="calc(100vh - 240px)">
|
||||
<Columns>
|
||||
<PropertyColumn Property="x => x.Id" Title="شناسه" />
|
||||
<PropertyColumn Property="x => x.Title" Title="عنوان" />
|
||||
<PropertyColumn Property="x => x.Slug" Title="اسلاگ" />
|
||||
<PropertyColumn Property="x => x.StatusName" Title="وضعیت">
|
||||
<CellTemplate>
|
||||
<MudChip Color="@GetStatusColor(context.Item.Status)"
|
||||
Size="Size.Small">
|
||||
@context.Item.StatusName
|
||||
</MudChip>
|
||||
</CellTemplate>
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="x => x.IsFeatured" Title="ویژه">
|
||||
<CellTemplate>
|
||||
@if (context.Item.IsFeatured)
|
||||
{
|
||||
<MudIcon Icon="@Icons.Material.Filled.Star" Color="Color.Warning" Size="Size.Small" />
|
||||
}
|
||||
</CellTemplate>
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="x => x.ViewCount" Title="بازدید" />
|
||||
<TemplateColumn Title="دستهبندیها" Sortable="false">
|
||||
<CellTemplate>
|
||||
<MudStack Row="true" Spacing="1">
|
||||
@foreach (var cat in context.Item.Categories)
|
||||
{
|
||||
<MudChip Size="Size.Small" Color="Color.Info">@cat.Title</MudChip>
|
||||
}
|
||||
</MudStack>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
<TemplateColumn Title="تاریخ ایجاد">
|
||||
<CellTemplate>
|
||||
@context.Item.Created.MiladiToJalali()
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
<TemplateColumn Title="عملیات" Sortable="false">
|
||||
<CellTemplate>
|
||||
<MudStack Row="true" Spacing="1">
|
||||
@if (context.Item.Status == 0)
|
||||
{
|
||||
<MudTooltip Text="انتشار">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Publish"
|
||||
Size="Size.Small"
|
||||
Color="Color.Success"
|
||||
OnClick="@(() => PublishPost(context.Item))" />
|
||||
</MudTooltip>
|
||||
}
|
||||
@if (context.Item.Status == 1)
|
||||
{
|
||||
<MudTooltip Text="آرشیو">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Archive"
|
||||
Size="Size.Small"
|
||||
Color="Color.Warning"
|
||||
OnClick="@(() => ArchivePost(context.Item))" />
|
||||
</MudTooltip>
|
||||
}
|
||||
<MudTooltip Text="ویرایش">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Edit"
|
||||
Size="Size.Small"
|
||||
Color="Color.Primary"
|
||||
OnClick="@(() => EditPost(context.Item))" />
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="حذف">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete"
|
||||
Size="Size.Small"
|
||||
Color="Color.Error"
|
||||
OnClick="@(() => DeletePost(context.Item))" />
|
||||
</MudTooltip>
|
||||
</MudStack>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
</Columns>
|
||||
<NoRecordsContent>
|
||||
<MudAlert Severity="Severity.Info" Dense="true" Variant="Variant.Text" Class="my-4">موردی یافت نشد.</MudAlert>
|
||||
</NoRecordsContent>
|
||||
<PagerContent>
|
||||
<MudDataGridPager T="BlogPostListItemDto" PageSizeOptions="@(new int[] { 20, 50, 100 })"
|
||||
InfoFormat="سطر {first_item} تا {last_item} از {all_items}"
|
||||
RowsPerPageString="تعداد در صفحه" />
|
||||
</PagerContent>
|
||||
</MudDataGrid>
|
||||
</MudStack>
|
||||
</div>
|
||||
@@ -0,0 +1,189 @@
|
||||
using BackOffice.Services.Blog;
|
||||
using BackOffice.Pages.Blog.Components;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using MudBlazor;
|
||||
|
||||
namespace BackOffice.Pages.Blog;
|
||||
|
||||
public partial class BlogPostManagementPage
|
||||
{
|
||||
private MudDataGrid<BlogPostListItemDto> _grid = default!;
|
||||
private string? _search;
|
||||
private int? _statusFilter;
|
||||
private long? _categoryFilter;
|
||||
private List<BlogCategoryItemDto> _categories = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_categories = await BlogCategoryService.GetActiveAsync();
|
||||
}
|
||||
|
||||
private async Task<GridData<BlogPostListItemDto>> LoadServerData(GridState<BlogPostListItemDto> state)
|
||||
{
|
||||
var filter = new BlogPostFilterDto
|
||||
{
|
||||
PageNumber = state.Page + 1,
|
||||
PageSize = state.PageSize,
|
||||
SearchTerm = _search,
|
||||
Status = _statusFilter,
|
||||
CategoryId = _categoryFilter
|
||||
};
|
||||
|
||||
var result = await BlogPostService.GetAllAsync(filter);
|
||||
|
||||
return new GridData<BlogPostListItemDto>
|
||||
{
|
||||
Items = result.Items,
|
||||
TotalItems = result.TotalCount
|
||||
};
|
||||
}
|
||||
|
||||
private async Task ReloadAsync()
|
||||
{
|
||||
if (_grid != null)
|
||||
{
|
||||
await _grid.ReloadServerData();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSearchKeyDown(KeyboardEventArgs args)
|
||||
{
|
||||
if (args.Key == "Enter")
|
||||
{
|
||||
_ = ReloadAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private static Color GetStatusColor(int status) => status switch
|
||||
{
|
||||
0 => Color.Default, // Draft
|
||||
1 => Color.Success, // Published
|
||||
2 => Color.Warning, // Archived
|
||||
_ => Color.Default
|
||||
};
|
||||
|
||||
private async Task CreatePost()
|
||||
{
|
||||
var parameters = new DialogParameters<BlogPostEditDialog>
|
||||
{
|
||||
{ nameof(BlogPostEditDialog.Model), new BlogPostEditDto() },
|
||||
{ nameof(BlogPostEditDialog.IsEditMode), false },
|
||||
{ nameof(BlogPostEditDialog.Categories), _categories }
|
||||
};
|
||||
|
||||
var dialog = await DialogService.ShowAsync<BlogPostEditDialog>("ایجاد پست جدید", parameters,
|
||||
new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Large, FullWidth = true });
|
||||
|
||||
var result = await dialog.Result;
|
||||
if (!result.Canceled)
|
||||
{
|
||||
Snackbar.Add("پست با موفقیت ایجاد شد", Severity.Success);
|
||||
await ReloadAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task EditPost(BlogPostListItemDto item)
|
||||
{
|
||||
var details = await BlogPostService.GetByIdAsync(item.Id);
|
||||
if (details == null)
|
||||
{
|
||||
Snackbar.Add("خطا در دریافت اطلاعات پست", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
var dto = new BlogPostEditDto
|
||||
{
|
||||
Title = details.Title,
|
||||
Slug = details.Slug,
|
||||
Summary = details.Summary,
|
||||
HtmlContent = details.HtmlContent,
|
||||
FeaturedImagePath = details.FeaturedImagePath,
|
||||
FeaturedImageThumbnailPath = details.FeaturedImageThumbnailPath,
|
||||
CategoryIds = details.Categories.Select(c => c.Id).ToList(),
|
||||
TagIds = details.Tags.Select(t => t.Id).ToList(),
|
||||
IsFeatured = details.IsFeatured,
|
||||
SortOrder = details.SortOrder
|
||||
};
|
||||
|
||||
var parameters = new DialogParameters<BlogPostEditDialog>
|
||||
{
|
||||
{ nameof(BlogPostEditDialog.Model), dto },
|
||||
{ nameof(BlogPostEditDialog.PostId), item.Id },
|
||||
{ nameof(BlogPostEditDialog.IsEditMode), true },
|
||||
{ nameof(BlogPostEditDialog.Categories), _categories }
|
||||
};
|
||||
|
||||
var dialog = await DialogService.ShowAsync<BlogPostEditDialog>("ویرایش پست", parameters,
|
||||
new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Large, FullWidth = true });
|
||||
|
||||
var result = await dialog.Result;
|
||||
if (!result.Canceled)
|
||||
{
|
||||
Snackbar.Add("پست با موفقیت بهروزرسانی شد", Severity.Success);
|
||||
await ReloadAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task PublishPost(BlogPostListItemDto item)
|
||||
{
|
||||
var confirmed = await DialogService.ShowMessageBox(
|
||||
"انتشار پست",
|
||||
$"آیا از انتشار پست «{item.Title}» مطمئن هستید؟",
|
||||
yesText: "انتشار",
|
||||
cancelText: "لغو");
|
||||
|
||||
if (confirmed == true)
|
||||
{
|
||||
var result = await BlogPostService.PublishAsync(item.Id);
|
||||
if (result.Success)
|
||||
{
|
||||
Snackbar.Add("پست با موفقیت منتشر شد", Severity.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add(result.Message, Severity.Error);
|
||||
}
|
||||
await ReloadAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ArchivePost(BlogPostListItemDto item)
|
||||
{
|
||||
var confirmed = await DialogService.ShowMessageBox(
|
||||
"آرشیو پست",
|
||||
$"آیا از آرشیو کردن پست «{item.Title}» مطمئن هستید؟",
|
||||
yesText: "آرشیو",
|
||||
cancelText: "لغو");
|
||||
|
||||
if (confirmed == true)
|
||||
{
|
||||
var result = await BlogPostService.ArchiveAsync(item.Id);
|
||||
if (result.Success)
|
||||
{
|
||||
Snackbar.Add("پست آرشیو شد", Severity.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add(result.Message, Severity.Error);
|
||||
}
|
||||
await ReloadAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeletePost(BlogPostListItemDto item)
|
||||
{
|
||||
var confirmed = await DialogService.ShowMessageBox(
|
||||
"حذف پست",
|
||||
$"آیا از حذف پست «{item.Title}» مطمئن هستید؟",
|
||||
yesText: "حذف",
|
||||
cancelText: "لغو");
|
||||
|
||||
if (confirmed == true)
|
||||
{
|
||||
await BlogPostService.DeleteAsync(item.Id);
|
||||
Snackbar.Add("پست حذف شد", Severity.Success);
|
||||
await ReloadAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
@using BackOffice.Services.Blog
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<EditForm Model="@Model" OnValidSubmit="HandleValidSubmit">
|
||||
<MudStack Spacing="2">
|
||||
<MudTextField @bind-Value="Model.Title"
|
||||
Label="عنوان"
|
||||
Required="true"
|
||||
Variant="Variant.Outlined" />
|
||||
|
||||
<MudTextField @bind-Value="Model.Slug"
|
||||
Label="اسلاگ (URL)"
|
||||
Required="true"
|
||||
Variant="Variant.Outlined"
|
||||
HelperText="مثال: tech-news" />
|
||||
|
||||
<MudTextField @bind-Value="Model.Description"
|
||||
Label="توضیحات"
|
||||
Variant="Variant.Outlined"
|
||||
Lines="3" />
|
||||
|
||||
<MudTextField @bind-Value="Model.IconName"
|
||||
Label="نام آیکون"
|
||||
Variant="Variant.Outlined"
|
||||
HelperText="مثال: category" />
|
||||
|
||||
<MudNumericField T="int"
|
||||
@bind-Value="Model.SortOrder"
|
||||
Label="ترتیب نمایش"
|
||||
Variant="Variant.Outlined" />
|
||||
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
|
||||
<MudSwitch T="bool" @bind-Value="Model.IsActive" Color="Color.Primary" />
|
||||
<MudText Typo="Typo.body2">فعال</MudText>
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
</EditForm>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="SubmitAsync">
|
||||
@(_isEditMode ? "ذخیره تغییرات" : "ایجاد دستهبندی")
|
||||
</MudButton>
|
||||
<MudButton Color="Color.Default" Variant="Variant.Text" OnClick="Cancel">
|
||||
انصراف
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -0,0 +1,41 @@
|
||||
using BackOffice.Services.Blog;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace BackOffice.Pages.Blog.Components;
|
||||
|
||||
public partial class BlogCategoryEditDialog
|
||||
{
|
||||
[CascadingParameter] IMudDialogInstance DialogInstance { get; set; } = default!;
|
||||
[Inject] public IBlogCategoryService BlogCategoryService { get; set; } = default!;
|
||||
|
||||
[Parameter] public BlogCategoryEditDto Model { get; set; } = new();
|
||||
[Parameter] public long? CategoryId { get; set; }
|
||||
[Parameter] public bool IsEditMode { get; set; }
|
||||
|
||||
private bool _isEditMode => IsEditMode && CategoryId.HasValue;
|
||||
|
||||
private async Task HandleValidSubmit()
|
||||
{
|
||||
await SubmitAsync();
|
||||
}
|
||||
|
||||
private async Task SubmitAsync()
|
||||
{
|
||||
if (_isEditMode && CategoryId.HasValue)
|
||||
{
|
||||
await BlogCategoryService.UpdateAsync(CategoryId.Value, Model);
|
||||
}
|
||||
else
|
||||
{
|
||||
await BlogCategoryService.CreateAsync(Model);
|
||||
}
|
||||
|
||||
DialogInstance.Close(DialogResult.Ok(true));
|
||||
}
|
||||
|
||||
private void Cancel()
|
||||
{
|
||||
DialogInstance.Cancel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
@using BackOffice.Services.Blog
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
@using Tizzani.MudBlazor.HtmlEditor
|
||||
@using BackOffice.Common.BaseComponents
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<MudForm @ref="_form" @bind-IsValid="@_isValid">
|
||||
<MudStack Spacing="2">
|
||||
<MudTextField @bind-Value="Model.Title"
|
||||
Label="عنوان پست"
|
||||
Required="true"
|
||||
Variant="Variant.Outlined" />
|
||||
|
||||
<MudTextField @bind-Value="Model.Summary"
|
||||
Label="خلاصه"
|
||||
Variant="Variant.Outlined"
|
||||
Lines="3" />
|
||||
|
||||
<MudText Typo="Typo.subtitle2">محتوای HTML</MudText>
|
||||
<MudHtmlEditor @bind-Html="Model.HtmlContent" MinHeight="300px">
|
||||
<MudHtmlToolbarOptions InsertImage="false" />
|
||||
</MudHtmlEditor>
|
||||
|
||||
<MudText Typo="Typo.subtitle2">تصویر شاخص</MudText>
|
||||
<MudStack Justify="Justify.Center" AlignItems="AlignItems.Center">
|
||||
@if (!string.IsNullOrWhiteSpace(_imagePreview))
|
||||
{
|
||||
<Image Src="@_imagePreview" Width="280" Height="180" ObjectPosition="ObjectPosition.Center" ObjectFit="ObjectFit.Cover" />
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(Model.FeaturedImagePath))
|
||||
{
|
||||
<Image Src="@Model.FeaturedImagePath" Width="280" Height="180" ObjectPosition="ObjectPosition.Center" ObjectFit="ObjectFit.Cover" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudPaper Class="d-flex align-center justify-center" Style="width:280px;height:180px;">
|
||||
<MudText Typo="Typo.caption">تصویری انتخاب نشده است</MudText>
|
||||
</MudPaper>
|
||||
}
|
||||
|
||||
<MudFileUpload T="IBrowserFile" Accept="image/*" FilesChanged="OnImageSelected">
|
||||
<ActivatorContent>
|
||||
<MudButton HtmlTag="label"
|
||||
Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
ButtonType="ButtonType.Button"
|
||||
StartIcon="@Icons.Material.Filled.Image">
|
||||
انتخاب تصویر شاخص
|
||||
</MudButton>
|
||||
</ActivatorContent>
|
||||
<SelectedTemplate>
|
||||
@if (context != null)
|
||||
{
|
||||
<MudText Class="mt-1" Typo="Typo.caption">@context.Name</MudText>
|
||||
}
|
||||
</SelectedTemplate>
|
||||
</MudFileUpload>
|
||||
</MudStack>
|
||||
|
||||
<MudSelect T="long"
|
||||
Label="دستهبندیها"
|
||||
MultiSelection="true"
|
||||
@bind-SelectedValues="_selectedCategoryIds"
|
||||
Variant="Variant.Outlined"
|
||||
MultiSelectionTextFunc="@(new Func<List<string>, string>(GetCategorySelectionText))">
|
||||
@foreach (var cat in Categories)
|
||||
{
|
||||
<MudSelectItem T="long" Value="@cat.Id">@cat.Title</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||
<MudSwitch T="bool" @bind-Value="Model.IsFeatured" Color="Color.Warning" />
|
||||
<MudText Typo="Typo.body2">پست ویژه</MudText>
|
||||
</MudStack>
|
||||
|
||||
<MudNumericField T="int"
|
||||
@bind-Value="Model.SortOrder"
|
||||
Label="ترتیب نمایش"
|
||||
Variant="Variant.Outlined" />
|
||||
</MudStack>
|
||||
</MudForm>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="SubmitAsync" Disabled="@(!_isValid || _loading)">
|
||||
@(_isEditMode ? "ذخیره تغییرات" : "ایجاد پست")
|
||||
</MudButton>
|
||||
<MudButton Color="Color.Default" Variant="Variant.Text" OnClick="Cancel">
|
||||
انصراف
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -0,0 +1,115 @@
|
||||
using BackOffice.Services.Blog;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using MudBlazor;
|
||||
|
||||
namespace BackOffice.Pages.Blog.Components;
|
||||
|
||||
public partial class BlogPostEditDialog
|
||||
{
|
||||
[CascadingParameter] IMudDialogInstance DialogInstance { get; set; } = default!;
|
||||
[Inject] public IBlogPostService BlogPostService { get; set; } = default!;
|
||||
|
||||
[Parameter] public BlogPostEditDto Model { get; set; } = new();
|
||||
[Parameter] public long? PostId { get; set; }
|
||||
[Parameter] public bool IsEditMode { get; set; }
|
||||
[Parameter] public List<BlogCategoryItemDto> Categories { get; set; } = new();
|
||||
|
||||
private bool _isEditMode => IsEditMode && PostId.HasValue;
|
||||
private MudForm? _form;
|
||||
private bool _isValid = true;
|
||||
private bool _loading;
|
||||
|
||||
private IBrowserFile? _imageFile;
|
||||
private byte[]? _imageBuffer;
|
||||
private string? _imagePreview;
|
||||
private readonly long _maxAllowedSize = (1024 * 1024) * 5;
|
||||
|
||||
private IEnumerable<long> _selectedCategoryIds
|
||||
{
|
||||
get => Model.CategoryIds;
|
||||
set => Model.CategoryIds = value.ToList();
|
||||
}
|
||||
|
||||
private string GetCategorySelectionText(List<string> selectedValues)
|
||||
{
|
||||
if (selectedValues == null || !selectedValues.Any())
|
||||
return "انتخاب دستهبندی";
|
||||
|
||||
var names = new List<string>();
|
||||
foreach (var val in selectedValues)
|
||||
{
|
||||
if (long.TryParse(val, out var id))
|
||||
{
|
||||
var cat = Categories.FirstOrDefault(c => c.Id == id);
|
||||
if (cat != null) names.Add(cat.Title);
|
||||
}
|
||||
}
|
||||
|
||||
return names.Any() ? string.Join("، ", names) : "انتخاب دستهبندی";
|
||||
}
|
||||
|
||||
private async Task OnImageSelected(IBrowserFile? file)
|
||||
{
|
||||
_imageFile = file;
|
||||
if (file != null)
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
await file.OpenReadStream(_maxAllowedSize).CopyToAsync(ms);
|
||||
_imageBuffer = ms.ToArray();
|
||||
_imagePreview = $"data:{file.ContentType};base64," + Convert.ToBase64String(_imageBuffer);
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleValidSubmit()
|
||||
{
|
||||
await SubmitAsync();
|
||||
}
|
||||
|
||||
private async Task SubmitAsync()
|
||||
{
|
||||
if (_form != null)
|
||||
{
|
||||
await _form.Validate();
|
||||
if (!_isValid) return;
|
||||
}
|
||||
|
||||
_loading = true;
|
||||
|
||||
// Handle image upload
|
||||
if (_imageFile != null && _imageBuffer != null)
|
||||
{
|
||||
Model.ImageFile = _imageBuffer;
|
||||
Model.ImageMime = _imageFile.ContentType;
|
||||
Model.ImageFileName = Path.GetFileNameWithoutExtension(_imageFile.Name);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (_isEditMode && PostId.HasValue)
|
||||
{
|
||||
await BlogPostService.UpdateAsync(PostId.Value, Model);
|
||||
}
|
||||
else
|
||||
{
|
||||
await BlogPostService.CreateAsync(Model);
|
||||
}
|
||||
|
||||
DialogInstance.Close(DialogResult.Ok(true));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void Cancel()
|
||||
{
|
||||
DialogInstance.Cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,31 @@
|
||||
@attribute [Route(RouteConstance.Category)]
|
||||
|
||||
@using BackOffice.BFF.Category.Protobuf.Protos.Category
|
||||
@using CMSMicroservice.Protobuf.Protos.Category
|
||||
@using BackOffice.Common.BaseComponents
|
||||
@using BackOffice.Pages.AutoComplete
|
||||
@using DataModel = BackOffice.BFF.Category.Protobuf.Protos.Category.GetAllCategoryByFilterResponseModel
|
||||
@using DataModel = CMSMicroservice.Protobuf.Protos.Category.GetAllCategoryByFilterResponseModel
|
||||
|
||||
<BasePageComponent @ref="_basePage" OnClearFilterClick="OnFilterCleared" OnSubmitClick="OnFilterSubmit">
|
||||
<Filters>
|
||||
<MudTextField T="string" Clearable="true" Label="عنوان" @bind-Value="@_request.Filter.Title" Variant="Variant.Outlined" Margin="Margin.Dense" />
|
||||
<CategoryAutoComplete Value="_parentFilterId"
|
||||
ValueChanged="OnParentFilterChanged"
|
||||
Label="فیلتر بر اساس دستهبندی والد" />
|
||||
<MudItem xs="12" sm="6" md="3">
|
||||
<MudTextField T="string" Clearable="true" Label="عنوان" @bind-Value="@_request.Filter.Title" Variant="Variant.Outlined" Margin="Margin.Dense" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="3">
|
||||
<CategoryAutoComplete Value="_parentFilterId"
|
||||
ValueChanged="OnParentFilterChanged"
|
||||
Label="فیلتر بر اساس دستهبندی والد" />
|
||||
</MudItem>
|
||||
</Filters>
|
||||
<Content>
|
||||
<MudGrid>
|
||||
<MudItem xs="12" md="3">
|
||||
<MudPaper Class="pa-2" Style="height:72vh; overflow:auto;">
|
||||
<MudPaper Class="pa-2" Style="height:calc(100vh - 240px); overflow:auto;">
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">درخت دستهبندیها</MudText>
|
||||
<MudList T="string" Dense="true">
|
||||
<MudListItem T="string"
|
||||
OnClick="@(() => OnTreeNodeSelected(null))"
|
||||
Selected="@(_parentFilterId == null)"
|
||||
Style="cursor:pointer;">
|
||||
>
|
||||
<MudText Typo="Typo.body2">همه دستهبندیها</MudText>
|
||||
</MudListItem>
|
||||
@foreach (var node in _treeNodes)
|
||||
@@ -29,7 +33,7 @@
|
||||
<MudListItem T="string"
|
||||
OnClick="@(() => OnTreeNodeSelected(node.Id))"
|
||||
Selected="@(_parentFilterId == node.Id)"
|
||||
Style="cursor:pointer;">
|
||||
>
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center">
|
||||
<div style="width:@(node.Level * 16)px;"></div>
|
||||
<MudText Typo="Typo.body2">@node.Title</MudText>
|
||||
@@ -44,13 +48,14 @@
|
||||
ServerData="@(new Func<GridState<DataModel>, Task<GridData<DataModel>>>(ServerReload))"
|
||||
Hover="true"
|
||||
@ref="_gridData"
|
||||
Height="72vh">
|
||||
Height="calc(100vh - 240px)">
|
||||
<ColGroup>
|
||||
<col />
|
||||
<col />
|
||||
<col />
|
||||
<col />
|
||||
<col />
|
||||
<col />
|
||||
<col style="width: 80px;" />
|
||||
</ColGroup>
|
||||
<ToolBarContent>
|
||||
@@ -62,7 +67,7 @@
|
||||
Size="Size.Large"
|
||||
ButtonType="ButtonType.Button"
|
||||
OnClick="CreateNew"
|
||||
Style="cursor:pointer;">
|
||||
>
|
||||
افزودن
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
@@ -85,6 +90,8 @@
|
||||
<MudText Typo="Typo.body2">@parentTitle</MudText>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
<PropertyColumn Property="x => x.SortOrder" Title="ترتیب" />
|
||||
<PropertyColumn Property="x => x.ProductCount" Title="تعداد محصولات" />
|
||||
<TemplateColumn Title="فعال؟">
|
||||
<CellTemplate>
|
||||
<MudChip Color="@(context.Item.IsActive ? Color.Success : Color.Error)"
|
||||
@@ -102,15 +109,16 @@
|
||||
Size="Size.Small"
|
||||
ButtonType="ButtonType.Button"
|
||||
OnClick="@(() => Update(context.Item))"
|
||||
Style="cursor:pointer;" />
|
||||
/>
|
||||
</MudTooltip>
|
||||
|
||||
<MudTooltip Text="حذف">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.DeleteOutline"
|
||||
Size="Size.Small"
|
||||
ButtonType="ButtonType.Button"
|
||||
Disabled="@HasChildren(context.Item.Id)"
|
||||
OnClick="@(() => OnDelete(context.Item))"
|
||||
Style="cursor:pointer;" />
|
||||
/>
|
||||
</MudTooltip>
|
||||
|
||||
<MudTooltip Text="مدیریت محصولات این دسته (درگ و دراپ)">
|
||||
@@ -118,17 +126,29 @@
|
||||
Size="Size.Small"
|
||||
ButtonType="ButtonType.Button"
|
||||
OnClick="@(() => OpenCategoryProducts(context.Item))"
|
||||
Style="cursor:pointer;" />
|
||||
/>
|
||||
</MudTooltip>
|
||||
|
||||
<MudTooltip Text="افزودن زیردسته">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.CreateNewFolder"
|
||||
Size="Size.Small"
|
||||
Color="Color.Primary"
|
||||
ButtonType="ButtonType.Button"
|
||||
OnClick="@(() => CreateSubcategory(context.Item))"
|
||||
/>
|
||||
</MudTooltip>
|
||||
</MudStack>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
</Columns>
|
||||
<NoRecordsContent>
|
||||
<MudAlert Severity="Severity.Info" Dense="true" Variant="Variant.Text" Class="my-4">موردی یافت نشد.</MudAlert>
|
||||
</NoRecordsContent>
|
||||
<PagerContent>
|
||||
<MudDataGridPager T="DataModel"
|
||||
PageSizeOptions="@(new int[] { 30, 60, 90 })"
|
||||
PageSizeOptions="@(new int[] { 20, 50, 100 })"
|
||||
InfoFormat="سطر {first_item} تا {last_item} از {all_items}"
|
||||
RowsPerPageString="تعداد سطرهای صفحه" />
|
||||
RowsPerPageString="تعداد در صفحه" />
|
||||
</PagerContent>
|
||||
</MudDataGrid>
|
||||
</MudItem>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System.Text.Json;
|
||||
using BackOffice.BFF.Category.Protobuf.Protos.Category;
|
||||
using CMSMicroservice.Protobuf.Protos;
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
using BackOffice.Common.BaseComponents;
|
||||
using BackOffice.Common.Utilities;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using DataModel = BackOffice.BFF.Category.Protobuf.Protos.Category.GetAllCategoryByFilterResponseModel;
|
||||
using DataModel = CMSMicroservice.Protobuf.Protos.Category.GetAllCategoryByFilterResponseModel;
|
||||
|
||||
namespace BackOffice.Pages.Category;
|
||||
|
||||
@@ -151,12 +152,30 @@ public partial class CategoryMainPage
|
||||
}
|
||||
}
|
||||
|
||||
public async Task CreateSubcategory(DataModel parent)
|
||||
{
|
||||
var dialog = await DialogService.ShowAsync<CreateOrUpdateCategoryDialog>(
|
||||
$"افزودن زیردسته برای «{parent.Title}»",
|
||||
new DialogParameters<CreateOrUpdateCategoryDialog>
|
||||
{
|
||||
{ x => x.Model, new CreateNewCategoryRequest { IsActive = true, ParentId = parent.Id } }
|
||||
},
|
||||
new DialogOptions { CloseButton = true, FullWidth = true, MaxWidth = MaxWidth.Small });
|
||||
|
||||
var result = await dialog.Result;
|
||||
if (!result.Canceled)
|
||||
{
|
||||
await ReloadData();
|
||||
await LoadTreeAsync();
|
||||
Snackbar.Add("زیردسته با موفقیت ایجاد شد.", Severity.Success);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Update(DataModel model)
|
||||
{
|
||||
var getResponse = await CategoryContract.GetCategoryAsync(new GetCategoryRequest { Id = model.Id });
|
||||
|
||||
var editModel = getResponse.Adapt<UpdateCategoryRequest>();
|
||||
// Console.WriteLine(JsonSerializer.Serialize(editModel));
|
||||
var dialog = await DialogService.ShowAsync<CreateOrUpdateCategoryDialog>(
|
||||
"ویرایش دستهبندی",
|
||||
new DialogParameters<CreateOrUpdateCategoryDialog>
|
||||
@@ -179,7 +198,7 @@ public partial class CategoryMainPage
|
||||
var options = new DialogOptions { CloseOnEscapeKey = true, MaxWidth = MaxWidth.Small };
|
||||
bool? result = await DialogService.ShowMessageBox(
|
||||
"اخطار",
|
||||
"آیا از حذف این دستهبندی مطمئن هستید؟",
|
||||
$"آیا از حذف دستهبندی «{model.Title}» مطمئن هستید؟",
|
||||
yesText: "حذف",
|
||||
cancelText: "لغو",
|
||||
options: options);
|
||||
@@ -237,4 +256,9 @@ public partial class CategoryMainPage
|
||||
{
|
||||
Navigation.NavigateTo($"{RouteConstance.CategoryProducts}{model.Id}");
|
||||
}
|
||||
|
||||
private bool HasChildren(long categoryId)
|
||||
{
|
||||
return _treeNodes.Any(n => n.ParentId == categoryId);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
@attribute [Route(RouteConstance.CategoryProducts + "{CategoryId:long?}")]
|
||||
|
||||
@using BackOffice.BFF.Products.Protobuf.Protos.Products
|
||||
@using CMSMicroservice.Protobuf.Protos.Products
|
||||
@using BackOffice.Common.BaseComponents
|
||||
@using BackOffice.Pages.AutoComplete
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using BackOffice.BFF.Products.Protobuf.Protos.Products;
|
||||
using BackOffice.BFF.Category.Protobuf.Protos.Category;
|
||||
using CMSMicroservice.Protobuf.Protos.Products;
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using MudBlazor;
|
||||
|
||||
@@ -1,46 +1,75 @@
|
||||
@using BackOffice.BFF.Category.Protobuf.Protos.Category
|
||||
@using CMSMicroservice.Protobuf.Protos.Category
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
@using BackOffice.Pages.AutoComplete
|
||||
|
||||
<MudDialog>
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">
|
||||
<MudIcon Icon="@(IsEdit ? Icons.Material.Filled.Edit : Icons.Material.Filled.Add)" Class="ml-2" />
|
||||
@(IsEdit ? "ویرایش دستهبندی" : "ایجاد دستهبندی جدید")
|
||||
</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<MudStack Spacing="2">
|
||||
<MudTextField T="string"
|
||||
@bind-Value="Name"
|
||||
Label="نام لاتین"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense" />
|
||||
<MudForm @ref="_form" @bind-IsValid="@_isValid">
|
||||
<MudStack Spacing="2">
|
||||
<MudTextField T="string"
|
||||
@bind-Value="Name"
|
||||
Label="نام لاتین"
|
||||
Required="true"
|
||||
RequiredError="نام لاتین الزامی است"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense" />
|
||||
|
||||
<MudTextField T="string"
|
||||
@bind-Value="Title"
|
||||
Label="عنوان"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense" />
|
||||
<MudTextField T="string"
|
||||
@bind-Value="Title"
|
||||
Label="عنوان"
|
||||
Required="true"
|
||||
RequiredError="عنوان الزامی است"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense" />
|
||||
|
||||
<MudTextField T="string"
|
||||
@bind-Value="Description"
|
||||
Label="توضیحات"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense"
|
||||
Lines="3"
|
||||
TextArea="true" />
|
||||
<MudTextField T="string"
|
||||
@bind-Value="Description"
|
||||
Label="توضیحات"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense"
|
||||
Lines="3"
|
||||
TextArea="true" />
|
||||
|
||||
<CategoryAutoComplete Value="ParentId"
|
||||
ValueChanged="OnParentChanged"
|
||||
Label="دستهبندی والد (اختیاری)" />
|
||||
<MudTextField T="string"
|
||||
@bind-Value="ImagePath"
|
||||
Label="آدرس تصویر"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense" />
|
||||
|
||||
<MudNumericField T="int"
|
||||
@bind-Value="SortOrder"
|
||||
HideSpinButtons="true"
|
||||
Label="ترتیب نمایش"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense" />
|
||||
<CategoryAutoComplete Value="ParentId"
|
||||
ValueChanged="OnParentChanged"
|
||||
Label="دستهبندی والد (اختیاری)" />
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">برای دسته اصلی خالی بگذارید</MudText>
|
||||
|
||||
<MudCheckBox T="bool" @bind-Value="IsActive" Label="فعال" />
|
||||
</MudStack>
|
||||
<MudNumericField T="int"
|
||||
@bind-Value="SortOrder"
|
||||
HideSpinButtons="true"
|
||||
Label="ترتیب نمایش"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense"
|
||||
HelperText="عدد کمتر = اولویت بالاتر" />
|
||||
|
||||
<MudSwitch T="bool" @bind-Value="IsActive" Label="فعال" Color="Color.Success" />
|
||||
</MudStack>
|
||||
</MudForm>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">لغو</MudButton>
|
||||
<MudButton Color="Color.Primary" OnClick="Save">ثبت</MudButton>
|
||||
<MudButton OnClick="Cancel" Variant="Variant.Text">لغو</MudButton>
|
||||
<MudButton Color="Color.Primary"
|
||||
Variant="Variant.Filled"
|
||||
OnClick="Save"
|
||||
Disabled="@(!_isValid || _isSaving)">
|
||||
@if (_isSaving)
|
||||
{
|
||||
<MudProgressCircular Size="Size.Small" Indeterminate="true" Class="ml-2" />
|
||||
}
|
||||
@(IsEdit ? "ذخیره تغییرات" : "ایجاد دستهبندی")
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using BackOffice.BFF.Category.Protobuf.Protos.Category;
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
@@ -14,9 +14,14 @@ public partial class CreateOrUpdateCategoryDialog
|
||||
|
||||
private bool IsEdit => EditModel != null;
|
||||
|
||||
private MudForm? _form;
|
||||
private bool _isValid;
|
||||
private bool _isSaving;
|
||||
|
||||
private string Name { get; set; } = string.Empty;
|
||||
private string Title { get; set; } = string.Empty;
|
||||
private string? Description { get; set; }
|
||||
private string? ImagePath { get; set; }
|
||||
private long? ParentId { get; set; }
|
||||
private bool IsActive { get; set; } = true;
|
||||
private int SortOrder { get; set; }
|
||||
@@ -28,9 +33,9 @@ public partial class CreateOrUpdateCategoryDialog
|
||||
Name = EditModel.Name;
|
||||
Title = EditModel.Title;
|
||||
Description = EditModel.Description;
|
||||
ImagePath = EditModel.ImagePath;
|
||||
ParentId = EditModel.ParentId;
|
||||
IsActive = EditModel.IsActive;
|
||||
Console.WriteLine(EditModel.IsActive);
|
||||
SortOrder = EditModel.SortOrder;
|
||||
}
|
||||
else if (Model != null)
|
||||
@@ -38,6 +43,7 @@ public partial class CreateOrUpdateCategoryDialog
|
||||
Name = Model.Name;
|
||||
Title = Model.Title;
|
||||
Description = Model.Description;
|
||||
ImagePath = Model.ImagePath;
|
||||
ParentId = Model.ParentId;
|
||||
IsActive = Model.IsActive;
|
||||
SortOrder = Model.SortOrder;
|
||||
@@ -46,37 +52,60 @@ public partial class CreateOrUpdateCategoryDialog
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
if (IsEdit && EditModel != null)
|
||||
if (_form != null)
|
||||
{
|
||||
var request = new UpdateCategoryRequest
|
||||
{
|
||||
Id = EditModel.Id,
|
||||
Name = Name,
|
||||
Title = Title,
|
||||
Description = Description,
|
||||
ParentId = ParentId,
|
||||
IsActive = IsActive,
|
||||
SortOrder = SortOrder
|
||||
};
|
||||
|
||||
await CategoryContract.UpdateCategoryAsync(request);
|
||||
}
|
||||
else
|
||||
{
|
||||
var request = new CreateNewCategoryRequest
|
||||
{
|
||||
Name = Name,
|
||||
Title = Title,
|
||||
Description = Description,
|
||||
ParentId = ParentId,
|
||||
IsActive = IsActive,
|
||||
SortOrder = SortOrder
|
||||
};
|
||||
|
||||
await CategoryContract.CreateNewCategoryAsync(request);
|
||||
await _form.Validate();
|
||||
if (!_isValid) return;
|
||||
}
|
||||
|
||||
MudDialog.Close(DialogResult.Ok(true));
|
||||
_isSaving = true;
|
||||
StateHasChanged();
|
||||
|
||||
try
|
||||
{
|
||||
if (IsEdit && EditModel != null)
|
||||
{
|
||||
var request = new UpdateCategoryRequest
|
||||
{
|
||||
Id = EditModel.Id,
|
||||
Name = Name,
|
||||
Title = Title,
|
||||
Description = Description,
|
||||
ImagePath = ImagePath,
|
||||
ParentId = ParentId,
|
||||
IsActive = IsActive,
|
||||
SortOrder = SortOrder
|
||||
};
|
||||
|
||||
await CategoryContract.UpdateCategoryAsync(request);
|
||||
}
|
||||
else
|
||||
{
|
||||
var request = new CreateNewCategoryRequest
|
||||
{
|
||||
Name = Name,
|
||||
Title = Title,
|
||||
Description = Description,
|
||||
ImagePath = ImagePath,
|
||||
ParentId = ParentId,
|
||||
IsActive = IsActive,
|
||||
SortOrder = SortOrder
|
||||
};
|
||||
|
||||
await CategoryContract.CreateNewCategoryAsync(request);
|
||||
}
|
||||
|
||||
MudDialog.Close(DialogResult.Ok(true));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isSaving = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private Task OnParentChanged(long? parentId)
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
@page "/club/features"
|
||||
@attribute [Authorize(Roles = "Administrator")]
|
||||
|
||||
@using CMSMicroservice.Protobuf.Protos.Configuration
|
||||
@using CMSMicroservice.Protobuf.Protos.ClubMembership
|
||||
@using BackOffice.Pages.AutoComplete
|
||||
|
||||
@inject ConfigurationContract.ConfigurationContractClient ConfigClient
|
||||
@inject ClubMembershipContract.ClubMembershipContractClient ClubClient
|
||||
|
||||
<div>
|
||||
<MudText Typo="Typo.h5" Class="mb-3">فیچرهای باشگاه</MudText>
|
||||
|
||||
<MudTabs Elevation="0" Rounded="true" Border="true" ApplyEffectsToContainer="true"
|
||||
PanelClass="pt-4" @bind-ActivePanelIndex="_activeTab">
|
||||
|
||||
@* ── تب اول: لیست فیچرها ── *@
|
||||
<MudTabPanel Text="فیچرهای تعریفشده" Icon="@Icons.Material.Filled.Star">
|
||||
@if (_loadingFeatures)
|
||||
{
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" />
|
||||
}
|
||||
else if (_features.Count == 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Text">فیچری تعریف نشده است.</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudGrid Spacing="2">
|
||||
@foreach (var feature in _features)
|
||||
{
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudPaper Class="pa-3 rounded-lg" Outlined="true">
|
||||
<MudStack Spacing="1">
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween">
|
||||
<MudText Typo="Typo.subtitle1"><strong>@feature.Title</strong></MudText>
|
||||
<MudChip T="string" Size="Size.Small"
|
||||
Color="@(feature.IsEnabled ? Color.Success : Color.Error)">
|
||||
@(feature.IsEnabled ? "فعال" : "غیرفعال")
|
||||
</MudChip>
|
||||
</MudStack>
|
||||
@if (!string.IsNullOrWhiteSpace(feature.Description))
|
||||
{
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@feature.Description</MudText>
|
||||
}
|
||||
<MudText Typo="Typo.caption">ترتیب: @feature.DisplayOrder</MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
}
|
||||
</MudGrid>
|
||||
}
|
||||
</MudTabPanel>
|
||||
|
||||
@* ── تب دوم: فیچرهای کاربران ── *@
|
||||
<MudTabPanel Text="فیچرهای کاربران" Icon="@Icons.Material.Filled.PeopleAlt">
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center" Class="mb-3">
|
||||
<UserAutoComplete Label="جستجوی کاربر" @bind-SelectedUserId="_featureFilterUserId" />
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.Search"
|
||||
OnClick="LoadUserFeatures">جستجو</MudButton>
|
||||
</MudStack>
|
||||
|
||||
@if (_loadingUserFeatures)
|
||||
{
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" />
|
||||
}
|
||||
else if (_featureFilterUserId == null || _featureFilterUserId == 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Text">لطفاً یک کاربر انتخاب کنید.</MudAlert>
|
||||
}
|
||||
else if (_userFeatures.Count == 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Text">فیچری برای این کاربر یافت نشد.</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudDataGrid T="UserClubFeatureModel" Items="_userFeatures"
|
||||
Hover="true" Dense="true"
|
||||
Height="calc(100vh - 340px)">
|
||||
<Columns>
|
||||
<PropertyColumn Property="x => x.Id" Title="شناسه" />
|
||||
<PropertyColumn Property="x => x.FeatureTitle" Title="عنوان فیچر" />
|
||||
<TemplateColumn Title="توضیحات">
|
||||
<CellTemplate>
|
||||
<MudText Typo="Typo.body2">@(string.IsNullOrWhiteSpace(context.Item.FeatureDescription) ? "—" : context.Item.FeatureDescription)</MudText>
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
<TemplateColumn Title="وضعیت">
|
||||
<CellTemplate>
|
||||
<MudSwitch T="bool" Value="context.Item.IsActive"
|
||||
Color="Color.Success"
|
||||
ValueChanged="@(val => ToggleFeature(context.Item, val))" />
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
<TemplateColumn Title="تاریخ اختصاص">
|
||||
<CellTemplate>
|
||||
@if (context.Item.GrantedAt != null)
|
||||
{
|
||||
@context.Item.GrantedAt.ToDateTime().ToLocalTime().MiladiToJalali()
|
||||
}
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
<PropertyColumn Property="x => x.Notes" Title="یادداشت" />
|
||||
</Columns>
|
||||
<NoRecordsContent>
|
||||
<MudAlert Severity="Severity.Info" Dense="true" Variant="Variant.Text" Class="my-4">موردی یافت نشد.</MudAlert>
|
||||
</NoRecordsContent>
|
||||
<PagerContent>
|
||||
<MudDataGridPager T="UserClubFeatureModel" PageSizeOptions="@(new int[] { 20, 50, 100 })"
|
||||
InfoFormat="سطر {first_item} تا {last_item} از {all_items}"
|
||||
RowsPerPageString="تعداد در صفحه" />
|
||||
</PagerContent>
|
||||
</MudDataGrid>
|
||||
}
|
||||
</MudTabPanel>
|
||||
</MudTabs>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private int _activeTab;
|
||||
private bool _loadingFeatures;
|
||||
private bool _loadingUserFeatures;
|
||||
|
||||
// Features tab
|
||||
private List<ClubFeatureModel> _features = new();
|
||||
|
||||
// User features tab
|
||||
private long? _featureFilterUserId;
|
||||
private List<UserClubFeatureModel> _userFeatures = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadFeatures();
|
||||
}
|
||||
|
||||
private async Task LoadFeatures()
|
||||
{
|
||||
_loadingFeatures = true;
|
||||
try
|
||||
{
|
||||
var result = await ConfigClient.GetClubFeaturesAsync(new Google.Protobuf.WellKnownTypes.Empty());
|
||||
_features = result?.Features?.ToList() ?? new();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در بارگذاری فیچرها: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_loadingFeatures = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadUserFeatures()
|
||||
{
|
||||
if (_featureFilterUserId == null || _featureFilterUserId == 0) return;
|
||||
|
||||
_loadingUserFeatures = true;
|
||||
try
|
||||
{
|
||||
var result = await ClubClient.GetUserClubFeaturesAsync(new GetUserClubFeaturesRequest
|
||||
{
|
||||
UserId = _featureFilterUserId.Value
|
||||
});
|
||||
_userFeatures = result?.Features?.ToList() ?? new();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_loadingUserFeatures = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ToggleFeature(UserClubFeatureModel feature, bool isActive)
|
||||
{
|
||||
try
|
||||
{
|
||||
await ClubClient.ToggleUserClubFeatureAsync(new ToggleUserClubFeatureRequest
|
||||
{
|
||||
UserId = feature.UserId,
|
||||
ClubFeatureId = feature.ClubFeatureId,
|
||||
IsActive = isActive
|
||||
});
|
||||
|
||||
feature.IsActive = isActive;
|
||||
Snackbar.Add($"فیچر «{feature.FeatureTitle}» {(isActive ? "فعال" : "غیرفعال")} شد", Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا: {ex.Message}", Severity.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
@page "/club"
|
||||
@page "/club/members"
|
||||
@page "/club/statistics"
|
||||
@attribute [Authorize]
|
||||
|
||||
<div>
|
||||
<MudText Typo="Typo.h5" Class="mb-3">باشگاه مشتریان</MudText>
|
||||
|
||||
<MudTabs Elevation="0" Rounded="true" Border="true" ApplyEffectsToContainer="true"
|
||||
PanelClass="pt-4" @bind-ActivePanelIndex="_activeTab">
|
||||
<MudTabPanel Text="اعضای باشگاه" Icon="@Icons.Material.Filled.Groups">
|
||||
<ClubMembers />
|
||||
</MudTabPanel>
|
||||
<MudTabPanel Text="آمار باشگاه" Icon="@Icons.Material.Filled.PieChart">
|
||||
<Statistics />
|
||||
</MudTabPanel>
|
||||
</MudTabs>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private int _activeTab;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
var uri = Navigation.ToBaseRelativePath(Navigation.Uri).ToLowerInvariant().TrimEnd('/');
|
||||
_activeTab = uri switch
|
||||
{
|
||||
"club/statistics" => 1,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
@page "/club/members"
|
||||
@* Merged into /club *@
|
||||
@attribute [Authorize]
|
||||
|
||||
@using Google.Protobuf.WellKnownTypes
|
||||
@using BackOffice.Pages.Club.Components
|
||||
@using Foursat.BackOffice.BFF.ClubMembership.Protos
|
||||
@using CMSMicroservice.Protobuf.Protos.ClubMembership
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="mt-4">
|
||||
<div>
|
||||
<MudText Typo="Typo.h4" Class="mb-4">مدیریت اعضای باشگاه</MudText>
|
||||
|
||||
<MudDataGrid T="ClubMembershipModel"
|
||||
ServerData="@(new Func<GridState<ClubMembershipModel>, Task<GridData<ClubMembershipModel>>>(ServerReload))"
|
||||
Hover="true"
|
||||
@ref="_gridData"
|
||||
Height="75vh">
|
||||
Height="calc(100vh - 240px)">
|
||||
<ToolBarContent>
|
||||
<MudText Typo="Typo.h6">لیست اعضا</MudText>
|
||||
<MudSpacer />
|
||||
@@ -32,6 +32,12 @@
|
||||
StartIcon="@Icons.Material.Filled.Add">
|
||||
فعالسازی عضو جدید
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Outlined"
|
||||
Color="Color.Info"
|
||||
OnClick="ExportToExcel"
|
||||
StartIcon="@Icons.Material.Filled.FileDownload">
|
||||
خروجی Excel
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</ToolBarContent>
|
||||
<Columns>
|
||||
@@ -58,14 +64,14 @@
|
||||
|
||||
<PropertyColumn Property="x => x.ActivatedAt" Title="تاریخ فعالسازی">
|
||||
<CellTemplate>
|
||||
@context.Item.ActivatedAt.ToDateTime().ToLocalTime().ToString("yyyy/MM/dd")
|
||||
@(context.Item.ActivatedAt != null ? context.Item.ActivatedAt.ToDateTime().ToLocalTime().MiladiToJalali() : "—")
|
||||
</CellTemplate>
|
||||
</PropertyColumn>
|
||||
|
||||
<PropertyColumn Property="x => x.ExpiresAt" Title="تاریخ انقضا">
|
||||
<CellTemplate>
|
||||
<MudText Color="@(context.Item.IsExpired ? Color.Error : Color.Success)">
|
||||
@context.Item.ExpiresAt.ToDateTime().ToLocalTime().ToString("yyyy/MM/dd")
|
||||
@(context.Item.ExpiresAt != null ? context.Item.ExpiresAt.ToDateTime().ToLocalTime().MiladiToJalali() : "—")
|
||||
</MudText>
|
||||
</CellTemplate>
|
||||
</PropertyColumn>
|
||||
@@ -102,11 +108,14 @@
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
</Columns>
|
||||
<NoRecordsContent>
|
||||
<MudAlert Severity="Severity.Info" Dense="true" Variant="Variant.Text" Class="my-4">موردی یافت نشد.</MudAlert>
|
||||
</NoRecordsContent>
|
||||
<PagerContent>
|
||||
<MudDataGridPager T="ClubMembershipModel"
|
||||
PageSizeOptions="@(new int[] { 20, 50, 100 })"
|
||||
InfoFormat="سطر {first_item} تا {last_item} از {all_items}"
|
||||
RowsPerPageString="تعداد سطرهای صفحه" />
|
||||
RowsPerPageString="تعداد در صفحه" />
|
||||
</PagerContent>
|
||||
</MudDataGrid>
|
||||
</MudContainer>
|
||||
</div>
|
||||
|
||||
@@ -2,13 +2,17 @@ using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using BackOffice.Pages.Club.Components;
|
||||
using Foursat.BackOffice.BFF.ClubMembership.Protos;
|
||||
using CMSMicroservice.Protobuf.Protos.ClubMembership;
|
||||
using Microsoft.JSInterop;
|
||||
using System.Text;
|
||||
using DateTimeConverterCL;
|
||||
|
||||
namespace BackOffice.Pages.Club;
|
||||
|
||||
public partial class ClubMembers
|
||||
{
|
||||
[Inject] public ClubMembershipContract.ClubMembershipContractClient ClubContract { get; set; }
|
||||
[Inject] public IJSRuntime JsRuntime { get; set; }
|
||||
|
||||
private MudDataGrid<ClubMembershipModel> _gridData;
|
||||
private bool _filterIsActive = true;
|
||||
@@ -108,4 +112,61 @@ public partial class ClubMembers
|
||||
await ApplyFilter();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ExportToExcel()
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = new GetAllClubMembershipsRequest
|
||||
{
|
||||
PageIndex = 1,
|
||||
PageSize = 1000,
|
||||
IsActive = _filterIsActive
|
||||
};
|
||||
|
||||
var result = await ClubContract.GetAllClubMembershipsAsync(request);
|
||||
|
||||
if (result?.Models == null || !result.Models.Any())
|
||||
{
|
||||
Snackbar.Add("دادهای برای خروجی وجود ندارد.", Severity.Info);
|
||||
return;
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("شناسه,کاربر,نام کاربر,پکیج,کد فعالسازی,تاریخ فعالسازی,تاریخ انقضا,فعال,منقضی");
|
||||
|
||||
foreach (var m in result.Models)
|
||||
{
|
||||
sb.AppendLine(string.Join(",",
|
||||
m.Id,
|
||||
m.UserId,
|
||||
EscapeCsv(m.UserName),
|
||||
EscapeCsv(m.PackageName),
|
||||
EscapeCsv(m.ActivationCode),
|
||||
m.ActivatedAt.ToDateTime().ToLocalTime().MiladiToJalaliWithTime(),
|
||||
m.ExpiresAt.ToDateTime().ToLocalTime().MiladiToJalaliWithTime(),
|
||||
m.IsActive ? "فعال" : "غیرفعال",
|
||||
m.IsExpired ? "بله" : "خیر"));
|
||||
}
|
||||
|
||||
var bytes = Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes(sb.ToString())).ToArray();
|
||||
var base64 = Convert.ToBase64String(bytes);
|
||||
var filename = $"club-members-{DateTime.Now:yyyyMMddHHmmss}.csv";
|
||||
|
||||
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename, base64);
|
||||
Snackbar.Add("خروجی Excel (CSV) آماده شد.", Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در خروجی Excel: {ex.Message}", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private static string EscapeCsv(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return "";
|
||||
if (value.Contains(',') || value.Contains('"') || value.Contains('\n'))
|
||||
return $"\"{value.Replace("\"", "\"\"")}\"";
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@using Foursat.BackOffice.BFF.ClubMembership.Protos
|
||||
@using CMSMicroservice.Protobuf.Protos.ClubMembership
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@using Foursat.BackOffice.BFF.ClubMembership.Protos
|
||||
@using CMSMicroservice.Protobuf.Protos.ClubMembership
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@using Foursat.BackOffice.BFF.ClubMembership.Protos
|
||||
@using CMSMicroservice.Protobuf.Protos.ClubMembership
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
@@ -41,13 +41,13 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>تاریخ فعالسازی:</strong></td>
|
||||
<td>@Member.ActivatedAt.ToDateTime().ToLocalTime().ToString("yyyy/MM/dd HH:mm")</td>
|
||||
<td>@Member.ActivatedAt.ToDateTime().ToLocalTime().MiladiToJalaliWithTime()</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>تاریخ انقضا:</strong></td>
|
||||
<td>
|
||||
<MudText Color="@(Member.IsExpired ? Color.Error : Color.Success)">
|
||||
@Member.ExpiresAt.ToDateTime().ToLocalTime().ToString("yyyy/MM/dd HH:mm")
|
||||
@Member.ExpiresAt.ToDateTime().ToLocalTime().MiladiToJalaliWithTime()
|
||||
</MudText>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -82,10 +82,38 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>تاریخ ایجاد:</strong></td>
|
||||
<td>@Member.Created.ToDateTime().ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss")</td>
|
||||
<td>@Member.Created.ToDateTime().ToLocalTime().MiladiToJalaliWithTime()</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</MudSimpleTable>
|
||||
|
||||
@if (_historyLoading)
|
||||
{
|
||||
<MudProgressLinear Indeterminate="true" Color="Color.Primary" Class="my-2" />
|
||||
}
|
||||
else if (_history.Any())
|
||||
{
|
||||
<MudTable T="ClubMembershipHistoryModel" Items="_history" Dense="true" Hover="true" Class="mt-2">
|
||||
<HeaderContent>
|
||||
<MudTh>عملیات</MudTh>
|
||||
<MudTh>تاریخ</MudTh>
|
||||
<MudTh>دلیل</MudTh>
|
||||
<MudTh>توسط</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="عملیات">
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Info">@context.Action</MudChip>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="تاریخ">@context.Created.ToDateTime().ToLocalTime().MiladiToJalaliWithTime()</MudTd>
|
||||
<MudTd DataLabel="دلیل">@(string.IsNullOrEmpty(context.Reason) ? "-" : context.Reason)</MudTd>
|
||||
<MudTd DataLabel="توسط">@(string.IsNullOrEmpty(context.PerformedBy) ? "-" : context.PerformedBy)</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="mt-2">تاریخچهای یافت نشد.</MudText>
|
||||
}
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
}
|
||||
@@ -98,6 +126,39 @@
|
||||
@code {
|
||||
[CascadingParameter] IMudDialogInstance MudDialog { get; set; }
|
||||
[Parameter] public ClubMembershipModel Member { get; set; }
|
||||
[Inject] public ClubMembershipContract.ClubMembershipContractClient ClubClient { get; set; }
|
||||
|
||||
private List<ClubMembershipHistoryModel> _history = new();
|
||||
private bool _historyLoading;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadHistory();
|
||||
}
|
||||
|
||||
private async Task LoadHistory()
|
||||
{
|
||||
_historyLoading = true;
|
||||
try
|
||||
{
|
||||
var request = new GetClubMembershipHistoryRequest
|
||||
{
|
||||
UserId = Member.UserId,
|
||||
PageIndex = 0,
|
||||
PageSize = 50
|
||||
};
|
||||
var response = await ClubClient.GetClubMembershipHistoryAsync(request);
|
||||
_history = response.Models?.ToList() ?? new();
|
||||
}
|
||||
catch
|
||||
{
|
||||
_history = new();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_historyLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void Close() => MudDialog.Close();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
@page "/club/statistics"
|
||||
@* Merged into /club *@
|
||||
|
||||
@using MudBlazor
|
||||
@using Foursat.BackOffice.BFF.ClubMembership.Protos
|
||||
@using CMSMicroservice.Protobuf.Protos.ClubMembership
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="mt-4">
|
||||
<div>
|
||||
<MudText Typo="Typo.h4" GutterBottom="true">آمار باشگاه</MudText>
|
||||
<MudText Typo="Typo.body1" Color="Color.Secondary" Class="mb-4">
|
||||
نمای کلی از وضعیت عضویتهای باشگاه
|
||||
@@ -139,7 +139,7 @@
|
||||
<MudTh>عملیات</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="تاریخ">@context.ActivatedAt.ToString("yyyy/MM/dd")</MudTd>
|
||||
<MudTd DataLabel="تاریخ">@context.ActivatedAt.MiladiToJalali()</MudTd>
|
||||
<MudTd DataLabel="شناسه کاربر">@context.UserId</MudTd>
|
||||
<MudTd DataLabel="نام کاربر">@context.UserName</MudTd>
|
||||
<MudTd DataLabel="پکیج">
|
||||
@@ -166,7 +166,7 @@
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
}
|
||||
</MudContainer>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Inject] public ClubMembershipContract.ClubMembershipContractClient ClubClient { get; set; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@using Foursat.BackOffice.BFF.Commission.Protos
|
||||
@using CMSMicroservice.Protobuf.Protos.Commission
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
@@ -23,12 +23,12 @@
|
||||
</MudPaper>
|
||||
|
||||
<MudPaper Class="pa-3" Elevation="0">
|
||||
<MudText Typo="Typo.h6" Color="Color.Primary">جزئیات Payout</MudText>
|
||||
<MudText Typo="Typo.h6" Color="Color.Primary">جزئیات پرداخت</MudText>
|
||||
<MudDivider Class="my-2" />
|
||||
<MudSimpleTable Dense="true">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>شناسه Payout:</strong></td>
|
||||
<td><strong>شناسه پرداخت:</strong></td>
|
||||
<td>@Payout.Id</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -89,11 +89,12 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>تاریخ ایجاد:</strong></td>
|
||||
<td>@Payout.Created.ToDateTime().ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss")</td>
|
||||
<td>@Payout.Created.ToDateTime().ToLocalTime().MiladiToJalaliWithTime()</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>آخرین ویرایش:</strong></td>
|
||||
<td>@Payout.LastModified.ToDateTime().ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss")</td>
|
||||
@* CMS UserCommissionPayoutModel does not have LastModified - using Created as fallback *@
|
||||
<td>@Payout.Created.ToDateTime().ToLocalTime().MiladiToJalaliWithTime()</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</MudSimpleTable>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<MudStack Spacing="3">
|
||||
<MudAlert Severity="Severity.Warning" Dense="true">
|
||||
درخواست برداشت @Amount.ToString("N0") ریال برای @UserName رد خواهد شد.
|
||||
</MudAlert>
|
||||
<MudTextField @bind-Value="_reason"
|
||||
Label="دلیل رد درخواست"
|
||||
Variant="Variant.Outlined"
|
||||
Lines="3"
|
||||
Required="true"
|
||||
RequiredError="لطفاً دلیل رد درخواست را وارد کنید" />
|
||||
</MudStack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">انصراف</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="Submit"
|
||||
Disabled="@string.IsNullOrWhiteSpace(_reason)">
|
||||
رد درخواست
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||
[Parameter] public string UserName { get; set; } = "";
|
||||
[Parameter] public long Amount { get; set; }
|
||||
|
||||
private string _reason = "رد توسط مدیر";
|
||||
|
||||
private void Cancel() => MudDialog.Cancel();
|
||||
private void Submit() => MudDialog.Close(DialogResult.Ok(_reason));
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<MudStack Spacing="3">
|
||||
<MudPaper Class="pa-3" Elevation="0" Outlined="true">
|
||||
<MudText Typo="Typo.subtitle1" Color="Color.Primary" Class="mb-2">اطلاعات کاربر</MudText>
|
||||
<MudSimpleTable Dense="true">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>نام کاربر:</strong></td>
|
||||
<td>@Request.UserName</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>شناسه کاربر:</strong></td>
|
||||
<td>@Request.UserId</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</MudSimpleTable>
|
||||
</MudPaper>
|
||||
|
||||
<MudPaper Class="pa-3" Elevation="0" Outlined="true">
|
||||
<MudText Typo="Typo.subtitle1" Color="Color.Primary" Class="mb-2">اطلاعات درخواست</MudText>
|
||||
<MudSimpleTable Dense="true">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>شناسه درخواست:</strong></td>
|
||||
<td>@Request.Id</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>مبلغ:</strong></td>
|
||||
<td><MudText Color="Color.Primary"><strong>@Request.Amount.ToString("N0") ریال</strong></MudText></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>روش برداشت:</strong></td>
|
||||
<td>
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Info">@MethodText</MudChip>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>وضعیت:</strong></td>
|
||||
<td>
|
||||
<MudChip T="string" Size="Size.Small" Color="@GetStatusColor()">@StatusText</MudChip>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>تاریخ درخواست:</strong></td>
|
||||
<td>@Request.RequestedAt.ToDateTime().ToLocalTime().MiladiToJalaliWithTime()</td>
|
||||
</tr>
|
||||
@if (Request.ProcessedDate.HasValue)
|
||||
{
|
||||
<tr>
|
||||
<td><strong>تاریخ پردازش:</strong></td>
|
||||
<td>@Request.ProcessedDate.Value.MiladiToJalaliWithTime()</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</MudSimpleTable>
|
||||
</MudPaper>
|
||||
|
||||
<MudPaper Class="pa-3" Elevation="0" Outlined="true">
|
||||
<MudText Typo="Typo.subtitle1" Color="Color.Primary" Class="mb-2">اطلاعات بانکی</MudText>
|
||||
<MudSimpleTable Dense="true">
|
||||
<tbody>
|
||||
@if (!string.IsNullOrWhiteSpace(Request.IbanNumber))
|
||||
{
|
||||
<tr>
|
||||
<td><strong>شماره شبا:</strong></td>
|
||||
<td>@Request.IbanNumber</td>
|
||||
</tr>
|
||||
}
|
||||
@if (!string.IsNullOrWhiteSpace(Request.BankReferenceId))
|
||||
{
|
||||
<tr>
|
||||
<td><strong>شماره مرجع بانک:</strong></td>
|
||||
<td>@Request.BankReferenceId</td>
|
||||
</tr>
|
||||
}
|
||||
@if (!string.IsNullOrWhiteSpace(Request.BankTrackingCode))
|
||||
{
|
||||
<tr>
|
||||
<td><strong>کد پیگیری بانکی:</strong></td>
|
||||
<td>@Request.BankTrackingCode</td>
|
||||
</tr>
|
||||
}
|
||||
@if (!string.IsNullOrWhiteSpace(Request.PaymentFailureReason))
|
||||
{
|
||||
<tr>
|
||||
<td><strong>دلیل خطای پرداخت:</strong></td>
|
||||
<td><MudText Color="Color.Error">@Request.PaymentFailureReason</MudText></td>
|
||||
</tr>
|
||||
}
|
||||
@if (!string.IsNullOrWhiteSpace(Request.AdminNote))
|
||||
{
|
||||
<tr>
|
||||
<td><strong>یادداشت مدیر:</strong></td>
|
||||
<td>@Request.AdminNote</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</MudSimpleTable>
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">بستن</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||
[Parameter] public WithdrawalRequestModel Request { get; set; } = null!;
|
||||
[Parameter] public string StatusText { get; set; } = "";
|
||||
[Parameter] public string MethodText { get; set; } = "";
|
||||
|
||||
private Color GetStatusColor()
|
||||
{
|
||||
return Request.Status switch
|
||||
{
|
||||
0 => Color.Warning,
|
||||
1 => Color.Info,
|
||||
2 => Color.Warning,
|
||||
3 => Color.Success,
|
||||
4 => Color.Error,
|
||||
5 => Color.Default,
|
||||
_ => Color.Default
|
||||
};
|
||||
}
|
||||
|
||||
private void Cancel() => MudDialog.Cancel();
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
@page "/commission/dashboard"
|
||||
@attribute [Authorize]
|
||||
|
||||
@using Foursat.BackOffice.BFF.Commission.Protos
|
||||
@using CMSMicroservice.Protobuf.Protos.Commission
|
||||
@using MudBlazor
|
||||
@using BackOffice.Pages.AutoComplete
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="mt-4">
|
||||
<div>
|
||||
<MudText Typo="Typo.h4" Class="mb-4">داشبورد کمیسیون</MudText>
|
||||
|
||||
@if (_isLoading)
|
||||
@@ -90,7 +90,7 @@
|
||||
|
||||
@if (_availableWeeks?.CurrentWeek != null)
|
||||
{
|
||||
<MudSelectItem Value="@_availableWeeks.CurrentWeek.WeekDefinitionId">
|
||||
<MudSelectItem T="long" Value="@_availableWeeks.CurrentWeek.WeekDefinitionId">
|
||||
<MudText>
|
||||
<MudIcon Icon="@Icons.Material.Filled.Today" Size="Size.Small" Class="ml-2" />
|
||||
@_availableWeeks.CurrentWeek.DisplayText
|
||||
@@ -104,7 +104,7 @@
|
||||
<MudListSubheader>هفتههای محاسبه شده</MudListSubheader>
|
||||
@foreach (var week in _availableWeeks.CalculatedWeeks)
|
||||
{
|
||||
<MudSelectItem Value="@week.WeekDefinitionId">
|
||||
<MudSelectItem T="long" Value="@week.WeekDefinitionId">
|
||||
<MudText>
|
||||
<MudIcon Icon="@Icons.Material.Filled.CheckCircle" Color="Color.Success" Size="Size.Small" Class="ml-2" />
|
||||
@week.DisplayText
|
||||
@@ -125,7 +125,7 @@
|
||||
<MudListSubheader>هفتههای محاسبه نشده</MudListSubheader>
|
||||
@foreach (var week in _availableWeeks.PendingWeeks)
|
||||
{
|
||||
<MudSelectItem Value="@week.WeekDefinitionId">
|
||||
<MudSelectItem T="long" Value="@week.WeekDefinitionId">
|
||||
<MudText>
|
||||
<MudIcon Icon="@Icons.Material.Filled.AccessTime" Color="Color.Warning" Size="Size.Small" Class="ml-2" />
|
||||
@week.DisplayText
|
||||
@@ -140,7 +140,7 @@
|
||||
<MudListSubheader>هفتههای آینده</MudListSubheader>
|
||||
@foreach (var week in _availableWeeks.FutureWeeks)
|
||||
{
|
||||
<MudSelectItem Value="@week.WeekDefinitionId">
|
||||
<MudSelectItem T="long" Value="@week.WeekDefinitionId">
|
||||
<MudText>
|
||||
<MudIcon Icon="@Icons.Material.Filled.CalendarMonth" Color="Color.Info" Size="Size.Small" Class="ml-2" />
|
||||
@week.DisplayText
|
||||
@@ -204,7 +204,7 @@
|
||||
<td>
|
||||
@if (_poolData.CalculatedAt != null)
|
||||
{
|
||||
@_poolData.CalculatedAt.ToDateTime().ToLocalTime().ToString("yyyy/MM/dd HH:mm")
|
||||
@_poolData.CalculatedAt.ToDateTime().ToLocalTime().MiladiToJalaliWithTime()
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -214,7 +214,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>تاریخ ایجاد:</strong></td>
|
||||
<td>@_poolData.Created.ToDateTime().ToLocalTime().ToString("yyyy/MM/dd HH:mm")</td>
|
||||
<td>@_poolData.Created.ToDateTime().ToLocalTime().MiladiToJalaliWithTime()</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</MudSimpleTable>
|
||||
@@ -229,7 +229,7 @@
|
||||
Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.Payments"
|
||||
Href="/commission/payouts">
|
||||
مشاهده Payout ها
|
||||
مشاهده پرداختها
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Secondary"
|
||||
@@ -247,4 +247,4 @@
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
}
|
||||
</MudContainer>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using BackOffice.Services;
|
||||
|
||||
namespace BackOffice.Pages.Commission;
|
||||
@@ -24,8 +23,8 @@ public partial class Dashboard
|
||||
private GetWeeklyCommissionPoolResponse? _poolData;
|
||||
|
||||
// Available weeks data
|
||||
private Foursat.BackOffice.BFF.Commission.Protos.GetAvailableWeeksResponse? _availableWeeks;
|
||||
private List<Foursat.BackOffice.BFF.Commission.Protos.WeekInfo> _allWeeks = new();
|
||||
private CMSMicroservice.Protobuf.Protos.Commission.GetAvailableWeeksResponse? _availableWeeks;
|
||||
private List<CMSMicroservice.Protobuf.Protos.Commission.WeekInfo> _allWeeks = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@@ -111,7 +110,6 @@ public partial class Dashboard
|
||||
};
|
||||
|
||||
_poolData = await CommissionContract.GetWeeklyCommissionPoolAsync(request);
|
||||
Console.WriteLine(JsonSerializer.Serialize(_poolData));
|
||||
Snackbar.Add($"اطلاعات Pool هفته {_currentWeekDisplayName} بارگذاری شد", Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
@page "/commission/payouts"
|
||||
@attribute [Authorize]
|
||||
|
||||
@using Foursat.BackOffice.BFF.Commission.Protos
|
||||
@using CMSMicroservice.Protobuf.Protos.Commission
|
||||
@using Google.Protobuf.WellKnownTypes
|
||||
@using MudBlazor
|
||||
@using BackOffice.Pages.AutoComplete
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="mt-4">
|
||||
<div>
|
||||
<MudText Typo="Typo.h4" Class="mb-4"> پرداخت های کاربران</MudText>
|
||||
|
||||
<MudDataGrid T="UserCommissionPayoutModel"
|
||||
ServerData="@(new Func<GridState<UserCommissionPayoutModel>, Task<GridData<UserCommissionPayoutModel>>>(ServerReload))"
|
||||
Hover="true"
|
||||
@ref="_gridData"
|
||||
Height="75vh">
|
||||
Height="calc(100vh - 240px)">
|
||||
<ToolBarContent>
|
||||
<MudText Typo="Typo.h6">لیست پرداخت ها</MudText>
|
||||
<MudSpacer />
|
||||
@@ -28,13 +28,13 @@
|
||||
Margin="Margin.Dense"
|
||||
Clearable="true"
|
||||
Style="max-width: 150px;">
|
||||
<MudSelectItem Value="@((int?)null)">همه</MudSelectItem>
|
||||
<MudSelectItem Value="@((int?)0)">در انتظار</MudSelectItem>
|
||||
<MudSelectItem Value="@((int?)1)">پرداخت شده</MudSelectItem>
|
||||
<MudSelectItem Value="@((int?)2)">درخواست برداشت</MudSelectItem>
|
||||
<MudSelectItem Value="@((int?)3)">برداشت شده</MudSelectItem>
|
||||
<MudSelectItem Value="@((int?)4)">شکست خورده</MudSelectItem>
|
||||
<MudSelectItem Value="@((int?)5)">لغو شده</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@((int?)null)">همه</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@((int?)0)">در انتظار</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@((int?)1)">پرداخت شده</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@((int?)2)">درخواست برداشت</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@((int?)3)">برداشت شده</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@((int?)4)">شکست خورده</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@((int?)5)">لغو شده</MudSelectItem>
|
||||
</MudSelect>
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
@@ -50,7 +50,9 @@
|
||||
<PropertyColumn Property="x => x.UserId" Title="کاربر">
|
||||
<CellTemplate>
|
||||
<MudStack Spacing="0">
|
||||
<MudText Typo="Typo.body2"><strong>ID:</strong> @context.Item.UserId</MudText>
|
||||
<MudLink Href="@($"/network/user-info/{context.Item.UserId}")" Underline="Underline.Hover" Color="Color.Primary">
|
||||
<strong>ID:</strong> @context.Item.UserId
|
||||
</MudLink>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">@context.Item.UserName</MudText>
|
||||
</MudStack>
|
||||
</CellTemplate>
|
||||
@@ -131,11 +133,14 @@
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
</Columns>
|
||||
<NoRecordsContent>
|
||||
<MudAlert Severity="Severity.Info" Dense="true" Variant="Variant.Text" Class="my-4">موردی یافت نشد.</MudAlert>
|
||||
</NoRecordsContent>
|
||||
<PagerContent>
|
||||
<MudDataGridPager T="UserCommissionPayoutModel"
|
||||
PageSizeOptions="@(new int[] { 10, 25, 50, 100 })"
|
||||
InfoFormat="سطر {first_item} تا {last_item} از {all_items}"
|
||||
RowsPerPageString="تعداد سطرهای صفحه" />
|
||||
RowsPerPageString="تعداد در صفحه" />
|
||||
</PagerContent>
|
||||
</MudDataGrid>
|
||||
</MudContainer>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using BackOffice.BFF.Protobuf.Common;
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
using CMSMicroservice.Protobuf.Protos;
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
@@ -22,29 +22,26 @@ public partial class UserPayouts
|
||||
{
|
||||
try
|
||||
{
|
||||
// CMS proto uses flat fields instead of nested PaginationState/Filter
|
||||
var request = new GetUserCommissionPayoutsRequest
|
||||
{
|
||||
PaginationState = new PaginationState()
|
||||
{
|
||||
PageNumber = state.Page + 1,
|
||||
PageSize = state.PageSize
|
||||
},
|
||||
Filter = new GetUserPayoutsFilter()
|
||||
PageIndex = state.Page + 1,
|
||||
PageSize = state.PageSize
|
||||
};
|
||||
|
||||
if (_filterUserId.HasValue && _filterUserId.Value > 0)
|
||||
{
|
||||
request.Filter.UserId = _filterUserId.Value;
|
||||
request.UserId = _filterUserId.Value;
|
||||
}
|
||||
|
||||
if (_filterWeekDefinitionId.HasValue && _filterWeekDefinitionId.Value > 0)
|
||||
{
|
||||
request.Filter.WeekDefinitionId = _filterWeekDefinitionId.Value;
|
||||
request.WeekDefinitionId = _filterWeekDefinitionId.Value;
|
||||
}
|
||||
|
||||
if (_filterStatus.HasValue)
|
||||
{
|
||||
request.Filter.Status = _filterStatus.Value;
|
||||
request.Status = _filterStatus.Value;
|
||||
}
|
||||
|
||||
var result = await CommissionContract.GetUserCommissionPayoutsAsync(request);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
@page "/commission/reports"
|
||||
|
||||
@using MudBlazor
|
||||
@using Foursat.BackOffice.BFF.Commission.Protos
|
||||
@using CMSMicroservice.Protobuf.Protos.Commission
|
||||
@using Google.Protobuf.WellKnownTypes
|
||||
@using BackOffice.Pages.AutoComplete
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="mt-4">
|
||||
<div>
|
||||
<MudText Typo="Typo.h4" GutterBottom="true">گزارشهای هفتگی کمیسیون</MudText>
|
||||
<MudText Typo="Typo.body1" Color="Color.Secondary" Class="mb-4">
|
||||
مشاهده تاریخچه محاسبات کمیسیون هفتگی
|
||||
@@ -14,29 +15,32 @@
|
||||
<MudCardContent>
|
||||
<MudGrid>
|
||||
<MudItem xs="12" md="4">
|
||||
<MudTextField @bind-Value="_filterFromWeek"
|
||||
Label="از هفته"
|
||||
Placeholder="2025-W01"
|
||||
Variant="Variant.Outlined"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentIcon="@Icons.Material.Filled.DateRange" />
|
||||
<WeekNumberPicker Label="از هفته"
|
||||
@bind-SelectedWeekDefinitionId="_filterFromWeekId"
|
||||
PastWeeksCount="24" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="4">
|
||||
<MudTextField @bind-Value="_filterToWeek"
|
||||
Label="تا هفته"
|
||||
Placeholder="2025-W48"
|
||||
Variant="Variant.Outlined"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentIcon="@Icons.Material.Filled.DateRange" />
|
||||
<WeekNumberPicker Label="تا هفته"
|
||||
@bind-SelectedWeekDefinitionId="_filterToWeekId"
|
||||
PastWeeksCount="24" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="4" Class="d-flex align-center">
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
OnClick="ApplyFilter"
|
||||
StartIcon="@Icons.Material.Filled.Search"
|
||||
FullWidth="true">
|
||||
جستجو
|
||||
</MudButton>
|
||||
<MudStack Row="true" Spacing="2" Style="width:100%">
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
OnClick="ApplyFilter"
|
||||
StartIcon="@Icons.Material.Filled.Search"
|
||||
FullWidth="true">
|
||||
جستجو
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Outlined"
|
||||
Color="Color.Info"
|
||||
OnClick="ExportToExcel"
|
||||
StartIcon="@Icons.Material.Filled.FileDownload"
|
||||
FullWidth="true">
|
||||
خروجی Excel
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudCardContent>
|
||||
@@ -85,7 +89,7 @@
|
||||
<CellTemplate>
|
||||
@if (context.Item.CalculatedAt != null)
|
||||
{
|
||||
<MudText>@context.Item.CalculatedAt.ToDateTime().ToString("yyyy/MM/dd HH:mm")</MudText>
|
||||
<MudText>@context.Item.CalculatedAt.ToDateTime().MiladiToJalaliWithTime()</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -151,15 +155,15 @@
|
||||
</MudGrid>
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
</MudContainer>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Inject] public CommissionContract.CommissionContractClient CommissionClient { get; set; }
|
||||
|
||||
private List<WeeklyPoolReportModel> _reports = new();
|
||||
private bool _loading = false;
|
||||
private string _filterFromWeek = "";
|
||||
private string _filterToWeek = "";
|
||||
private long? _filterFromWeekId;
|
||||
private long? _filterToWeekId;
|
||||
|
||||
// Statistics
|
||||
private long _totalPoolSum = 0;
|
||||
@@ -183,14 +187,14 @@
|
||||
PageSize = 100
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_filterFromWeek))
|
||||
if (_filterFromWeekId.HasValue && _filterFromWeekId.Value > 0)
|
||||
{
|
||||
request.FromWeek = _filterFromWeek;
|
||||
request.FromWeekDefinitionId = _filterFromWeekId.Value;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_filterToWeek))
|
||||
if (_filterToWeekId.HasValue && _filterToWeekId.Value > 0)
|
||||
{
|
||||
request.ToWeek = _filterToWeek;
|
||||
request.ToWeekDefinitionId = _filterToWeekId.Value;
|
||||
}
|
||||
|
||||
var response = await CommissionClient.GetAllWeeklyPoolsAsync(request);
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
using System.Text;
|
||||
using DateTimeConverterCL;
|
||||
using Microsoft.JSInterop;
|
||||
using MudBlazor;
|
||||
|
||||
namespace BackOffice.Pages.Commission;
|
||||
|
||||
public partial class WeeklyReports
|
||||
{
|
||||
private async Task ExportToExcel()
|
||||
{
|
||||
if (_reports == null || !_reports.Any())
|
||||
{
|
||||
Snackbar.Add("دادهای برای خروجی وجود ندارد.", Severity.Info);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("هفته,مبلغ کل استخر,مجموع موجودیها,ارزش هر موجودی,وضعیت,تاریخ محاسبه");
|
||||
|
||||
foreach (var r in _reports)
|
||||
{
|
||||
sb.AppendLine(string.Join(",",
|
||||
EscapeCsv(r.WeekDisplayName),
|
||||
r.TotalPoolAmount,
|
||||
r.TotalBalances,
|
||||
r.ValuePerBalance,
|
||||
r.IsCalculated ? "محاسبه شده" : "در انتظار",
|
||||
r.CalculatedAt != null ? r.CalculatedAt.ToDateTime().MiladiToJalaliWithTime() : "-"));
|
||||
}
|
||||
|
||||
var bytes = Encoding.UTF8.GetPreamble()
|
||||
.Concat(Encoding.UTF8.GetBytes(sb.ToString()))
|
||||
.ToArray();
|
||||
var base64 = Convert.ToBase64String(bytes);
|
||||
var filename = $"weekly-reports-{DateTime.Now:yyyyMMddHHmmss}.csv";
|
||||
|
||||
await jsRuntime.InvokeVoidAsync("jsSaveAsFile", filename, base64);
|
||||
Snackbar.Add("خروجی Excel (CSV) آماده شد.", Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در خروجی Excel: {ex.Message}", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private static string EscapeCsv(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return "";
|
||||
if (value.Contains(',') || value.Contains('"') || value.Contains('\n'))
|
||||
return $"\"{value.Replace("\"", "\"\"")}\"";
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,13 @@
|
||||
@attribute [Authorize]
|
||||
|
||||
@using MudBlazor
|
||||
@using Foursat.BackOffice.BFF.Commission.Protos
|
||||
@using CMSMicroservice.Protobuf.Protos.Commission
|
||||
@using Google.Protobuf.WellKnownTypes
|
||||
@using Microsoft.JSInterop
|
||||
@using System.Text
|
||||
@using BackOffice.Pages.AutoComplete
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="mt-4">
|
||||
<div>
|
||||
<MudText Typo="Typo.h4" Class="mb-1">گزارش برداشتها</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
||||
گزارش تجمیعی برداشتهای کمیسیون بر اساس بازه تاریخ و نوع دوره
|
||||
@@ -53,13 +53,13 @@
|
||||
Label="وضعیت (اختیاری)"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense">
|
||||
<MudSelectItem Value="@(null as int?)">همه وضعیتها</MudSelectItem>
|
||||
<MudSelectItem Value="0">در انتظار واریز به کیف پول</MudSelectItem>
|
||||
<MudSelectItem Value="1">واریز شده به کیف پول طلایی</MudSelectItem>
|
||||
<MudSelectItem Value="2">درخواست برداشت ثبت شده</MudSelectItem>
|
||||
<MudSelectItem Value="3">برداشت انجام شده</MudSelectItem>
|
||||
<MudSelectItem Value="4">خطا در پرداخت بانکی</MudSelectItem>
|
||||
<MudSelectItem Value="5">لغو شده</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@(null as int?)">همه وضعیتها</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="0">در انتظار واریز به کیف پول</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="1">واریز شده به کیف پول طلایی</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="2">درخواست برداشت ثبت شده</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="3">برداشت انجام شده</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="4">خطا در پرداخت بانکی</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="5">لغو شده</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="4" Class="d-flex align-end">
|
||||
@@ -175,12 +175,12 @@
|
||||
<PropertyColumn Property="x => x.PeriodLabel" Title="دوره" />
|
||||
<PropertyColumn Property="x => x.StartDate" Title="از تاریخ">
|
||||
<CellTemplate>
|
||||
@context.Item.StartDate.ToString("yyyy/MM/dd")
|
||||
@context.Item.StartDate.MiladiToJalali()
|
||||
</CellTemplate>
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="x => x.EndDate" Title="تا تاریخ">
|
||||
<CellTemplate>
|
||||
@context.Item.EndDate.ToString("yyyy/MM/dd")
|
||||
@context.Item.EndDate.MiladiToJalali()
|
||||
</CellTemplate>
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="x => x.TotalRequests" Title="تعداد درخواستها" />
|
||||
@@ -203,11 +203,14 @@
|
||||
</CellTemplate>
|
||||
</PropertyColumn>
|
||||
</Columns>
|
||||
<NoRecordsContent>
|
||||
<MudAlert Severity="Severity.Info" Dense="true" Variant="Variant.Text" Class="my-4">موردی یافت نشد.</MudAlert>
|
||||
</NoRecordsContent>
|
||||
</MudDataGrid>
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
}
|
||||
</MudContainer>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Inject] public CommissionContract.CommissionContractClient CommissionClient { get; set; }
|
||||
@@ -394,8 +397,8 @@
|
||||
{
|
||||
sb.AppendLine(string.Join(",",
|
||||
EscapeCsv(r.PeriodLabel),
|
||||
r.StartDate.ToString("yyyy-MM-dd"),
|
||||
r.EndDate.ToString("yyyy-MM-dd"),
|
||||
r.StartDate.MiladiToJalali(),
|
||||
r.EndDate.MiladiToJalali(),
|
||||
r.TotalRequests,
|
||||
r.CompletedCount,
|
||||
r.FailedCount,
|
||||
@@ -423,7 +426,7 @@
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("گزارش برداشتها");
|
||||
sb.AppendLine($"دوره: {_periodType} از تاریخ: {_startDate:yyyy/MM/dd} تا تاریخ: {_endDate:yyyy/MM/dd}");
|
||||
sb.AppendLine($"دوره: {_periodType} از تاریخ: {_startDate?.MiladiToJalali() ?? "-"} تا تاریخ: {_endDate?.MiladiToJalali() ?? "-"}");
|
||||
sb.AppendLine();
|
||||
|
||||
sb.AppendLine("خلاصه:");
|
||||
@@ -441,7 +444,7 @@
|
||||
foreach (var r in _periodReports.OrderBy(r => r.StartDate))
|
||||
{
|
||||
sb.AppendLine(
|
||||
$"{r.PeriodLabel} | {r.StartDate:yyyy/MM/dd} | {r.EndDate:yyyy/MM/dd} | {r.TotalRequests} | {r.CompletedCount} | {r.FailedCount} | {r.PendingCount} | {r.TotalAmount:N0} | {r.PaidAmount:N0} | {r.PendingAmount:N0}");
|
||||
$"{r.PeriodLabel} | {r.StartDate.MiladiToJalali()} | {r.EndDate.MiladiToJalali()} | {r.TotalRequests} | {r.CompletedCount} | {r.FailedCount} | {r.PendingCount} | {r.TotalAmount:N0} | {r.PaidAmount:N0} | {r.PendingAmount:N0}");
|
||||
}
|
||||
|
||||
var bytes = Encoding.UTF8.GetBytes(sb.ToString());
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
@page "/commission/withdrawals"
|
||||
@attribute [Authorize]
|
||||
|
||||
@using Foursat.BackOffice.BFF.Commission.Protos
|
||||
@using CMSMicroservice.Protobuf.Protos.Commission
|
||||
@using BackOffice.Pages.AutoComplete
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="mt-4">
|
||||
<div>
|
||||
<MudText Typo="Typo.h4" Class="mb-4">درخواستهای برداشت</MudText>
|
||||
|
||||
<MudDataGrid T="WithdrawalRequestModel"
|
||||
ServerData="@(new Func<GridState<WithdrawalRequestModel>, Task<GridData<WithdrawalRequestModel>>>(ServerReload))"
|
||||
Hover="true"
|
||||
@ref="_gridData"
|
||||
Height="75vh">
|
||||
Height="calc(100vh - 240px)">
|
||||
<ToolBarContent>
|
||||
<MudText Typo="Typo.h6">درخواستهای برداشت</MudText>
|
||||
<MudSpacer />
|
||||
@@ -30,13 +30,13 @@
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense"
|
||||
Style="max-width: 150px;">
|
||||
<MudSelectItem Value="@((int?)null)">همه</MudSelectItem>
|
||||
<MudSelectItem Value="@((int?)0)">در انتظار واریز</MudSelectItem>
|
||||
<MudSelectItem Value="@((int?)1)">واریز شده به کیف پول</MudSelectItem>
|
||||
<MudSelectItem Value="@((int?)2)">درخواست برداشت</MudSelectItem>
|
||||
<MudSelectItem Value="@((int?)3)">برداشت شده</MudSelectItem>
|
||||
<MudSelectItem Value="@((int?)4)">خطای پرداخت بانکی</MudSelectItem>
|
||||
<MudSelectItem Value="@((int?)5)">لغو شده</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@((int?)null)">همه</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@((int?)0)">در انتظار واریز</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@((int?)1)">واریز شده به کیف پول</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@((int?)2)">درخواست برداشت</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@((int?)3)">برداشت شده</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@((int?)4)">خطای پرداخت بانکی</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="@((int?)5)">لغو شده</MudSelectItem>
|
||||
</MudSelect>
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
@@ -44,6 +44,12 @@
|
||||
StartIcon="@Icons.Material.Filled.Search">
|
||||
جستجو
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Outlined"
|
||||
Color="Color.Info"
|
||||
OnClick="ExportToExcel"
|
||||
StartIcon="@Icons.Material.Filled.FileDownload">
|
||||
خروجی Excel
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</ToolBarContent>
|
||||
<Columns>
|
||||
@@ -52,7 +58,9 @@
|
||||
<PropertyColumn Property="x => x.UserId" Title="کاربر">
|
||||
<CellTemplate>
|
||||
<MudStack Spacing="0">
|
||||
<MudText Typo="Typo.body2"><strong>@context.Item.UserName</strong></MudText>
|
||||
<MudLink Href="@($"/network/user-info/{context.Item.UserId}")" Underline="Underline.Hover" Color="Color.Primary">
|
||||
<strong>@context.Item.UserName</strong>
|
||||
</MudLink>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">ID: @context.Item.UserId</MudText>
|
||||
</MudStack>
|
||||
</CellTemplate>
|
||||
@@ -101,7 +109,7 @@
|
||||
|
||||
<PropertyColumn Property="x => x.RequestedAt" Title="تاریخ درخواست">
|
||||
<CellTemplate>
|
||||
@context.Item.RequestedAt.ToDateTime().ToLocalTime().ToString("yyyy/MM/dd HH:mm")
|
||||
@context.Item.RequestedAt.ToDateTime().ToLocalTime().MiladiToJalaliWithTime()
|
||||
</CellTemplate>
|
||||
</PropertyColumn>
|
||||
|
||||
@@ -142,11 +150,14 @@
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
</Columns>
|
||||
<NoRecordsContent>
|
||||
<MudAlert Severity="Severity.Info" Dense="true" Variant="Variant.Text" Class="my-4">موردی یافت نشد.</MudAlert>
|
||||
</NoRecordsContent>
|
||||
<PagerContent>
|
||||
<MudDataGridPager T="WithdrawalRequestModel"
|
||||
PageSizeOptions="@(new int[] { 10, 25, 50, 100 })"
|
||||
PageSizeOptions="@(new int[] { 20, 50, 100 })"
|
||||
InfoFormat="سطر {first_item} تا {last_item} از {all_items}"
|
||||
RowsPerPageString="تعداد سطرهای صفحه" />
|
||||
RowsPerPageString="تعداد در صفحه" />
|
||||
</PagerContent>
|
||||
</MudDataGrid>
|
||||
</MudContainer>
|
||||
</div>
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
using Foursat.BackOffice.BFF.Commission.Protos;
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using GrpcWithdrawalRequestModel = Foursat.BackOffice.BFF.Commission.Protos.WithdrawalRequestModel;
|
||||
using GrpcGetWithdrawalRequestsRequest = Foursat.BackOffice.BFF.Commission.Protos.GetWithdrawalRequestsRequest;
|
||||
using BackOffice.Pages.Commission.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using System.Text;
|
||||
using DateTimeConverterCL;
|
||||
using GrpcWithdrawalRequestModel = CMSMicroservice.Protobuf.Protos.Commission.WithdrawalRequestModel;
|
||||
using GrpcGetWithdrawalRequestsRequest = CMSMicroservice.Protobuf.Protos.Commission.GetWithdrawalRequestsRequest;
|
||||
|
||||
namespace BackOffice.Pages.Commission;
|
||||
|
||||
public partial class WithdrawalRequests
|
||||
{
|
||||
[Inject] public CommissionContract.CommissionContractClient CommissionContract { get; set; }
|
||||
[Inject] public IJSRuntime JsRuntime { get; set; }
|
||||
|
||||
private MudDataGrid<WithdrawalRequestModel> _gridData;
|
||||
private int? _filterStatus;
|
||||
@@ -142,10 +147,16 @@ public partial class WithdrawalRequests
|
||||
};
|
||||
}
|
||||
|
||||
private void ViewDetails(WithdrawalRequestModel request)
|
||||
private async Task ViewDetails(WithdrawalRequestModel request)
|
||||
{
|
||||
Snackbar.Add($"جزئیات درخواست {request.Id}", Severity.Info);
|
||||
// TODO: Open details dialog
|
||||
var parameters = new DialogParameters<WithdrawalDetailsDialog>
|
||||
{
|
||||
{ x => x.Request, request },
|
||||
{ x => x.StatusText, GetStatusText(request.Status) },
|
||||
{ x => x.MethodText, GetMethodText(request.Method) }
|
||||
};
|
||||
var options = new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true };
|
||||
await DialogService.ShowAsync<WithdrawalDetailsDialog>("جزئیات درخواست برداشت", parameters, options);
|
||||
}
|
||||
|
||||
private async Task ApproveRequest(WithdrawalRequestModel request)
|
||||
@@ -177,19 +188,23 @@ public partial class WithdrawalRequests
|
||||
|
||||
private async Task RejectRequest(WithdrawalRequestModel request)
|
||||
{
|
||||
var confirmed = await DialogService.ShowMessageBox(
|
||||
"رد درخواست",
|
||||
$"آیا از رد درخواست برداشت {request.Amount:N0} ریال برای {request.UserName} مطمئن هستید؟",
|
||||
yesText: "رد", cancelText: "لغو");
|
||||
var parameters = new DialogParameters<RejectReasonDialog>
|
||||
{
|
||||
{ x => x.UserName, request.UserName },
|
||||
{ x => x.Amount, request.Amount }
|
||||
};
|
||||
var options = new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true };
|
||||
var dialog = await DialogService.ShowAsync<RejectReasonDialog>("رد درخواست برداشت", parameters, options);
|
||||
var result = await dialog.Result;
|
||||
|
||||
if (confirmed == true)
|
||||
if (result is { Canceled: false, Data: string reason })
|
||||
{
|
||||
try
|
||||
{
|
||||
var rejectRequest = new RejectWithdrawalRequest
|
||||
{
|
||||
PayoutId = request.Id,
|
||||
Reason = "رد توسط ادمین پنل مدیریت"
|
||||
Reason = reason
|
||||
};
|
||||
|
||||
await CommissionContract.RejectWithdrawalAsync(rejectRequest);
|
||||
@@ -230,4 +245,66 @@ public partial class WithdrawalRequests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ExportToExcel()
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = new GrpcGetWithdrawalRequestsRequest
|
||||
{
|
||||
PageIndex = 1,
|
||||
PageSize = 1000
|
||||
};
|
||||
|
||||
if (_filterStatus.HasValue) request.Status = _filterStatus.Value;
|
||||
if (_filterUserId.HasValue && _filterUserId.Value > 0) request.UserId = _filterUserId.Value;
|
||||
if (!string.IsNullOrWhiteSpace(_filterIban)) request.IbanNumber = _filterIban;
|
||||
|
||||
var result = await CommissionContract.GetWithdrawalRequestsAsync(request);
|
||||
|
||||
if (result?.Models == null || !result.Models.Any())
|
||||
{
|
||||
Snackbar.Add("دادهای برای خروجی وجود ندارد.", Severity.Info);
|
||||
return;
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("شناسه,کاربر,نام کاربر,مبلغ,وضعیت,روش,شماره شبا,تاریخ درخواست,تاریخ پردازش,شماره مرجع بانکی");
|
||||
|
||||
foreach (var r in result.Models)
|
||||
{
|
||||
var mapped = MapToViewModel(r);
|
||||
sb.AppendLine(string.Join(",",
|
||||
mapped.Id,
|
||||
mapped.UserId,
|
||||
EscapeCsv(mapped.UserName),
|
||||
mapped.Amount,
|
||||
EscapeCsv(GetStatusText(mapped.Status)),
|
||||
EscapeCsv(GetMethodText(mapped.Method)),
|
||||
EscapeCsv(mapped.IbanNumber ?? ""),
|
||||
mapped.RequestedAt.ToDateTime().ToLocalTime().MiladiToJalaliWithTime(),
|
||||
mapped.ProcessedDate?.MiladiToJalaliWithTime() ?? "-",
|
||||
EscapeCsv(mapped.BankReferenceId ?? "")));
|
||||
}
|
||||
|
||||
var bytes = Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes(sb.ToString())).ToArray();
|
||||
var base64 = Convert.ToBase64String(bytes);
|
||||
var filename = $"withdrawal-requests-{DateTime.Now:yyyyMMddHHmmss}.csv";
|
||||
|
||||
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename, base64);
|
||||
Snackbar.Add("خروجی Excel (CSV) آماده شد.", Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در خروجی Excel: {ex.Message}", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private static string EscapeCsv(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return "";
|
||||
if (value.Contains(',') || value.Contains('"') || value.Contains('\n'))
|
||||
return $"\"{value.Replace("\"", "\"\"")}\"";
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user