Compare commits
95 Commits
c89d4027d6
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 93ebc80da3 | |||
| 4e4cc08224 | |||
| e5f53c2265 | |||
| b57d6b4e4b | |||
| ea458c7b72 | |||
| 151eff2f7c | |||
| 1a0c40ecde | |||
| d1dd67aee7 | |||
| f7f8a91a85 | |||
| 2c90f8091e | |||
| d6aa165592 | |||
| 5ee03cf761 | |||
| 72954fb5d1 | |||
| b4cd4c05f2 | |||
| 88f45eee38 | |||
| 5fa07c7ee8 | |||
| 788f4023f3 | |||
| 2f67801700 | |||
| cd09b09e3b | |||
| eb39f42b8c | |||
| 560b3516e1 | |||
| 694b2ec946 | |||
| 8d6fa8860b | |||
| 1f9166bed3 | |||
| ae963a60ce | |||
| d44004d555 | |||
| c271a36f7e | |||
| 4ec6143068 | |||
| f50219a094 | |||
| f2a496134b | |||
| 90c51edad4 | |||
| d678b6c699 | |||
| 550db47b88 | |||
| 9fdd5e451c | |||
| eb671d5949 | |||
| cdd2bd6bee | |||
| f18d7a1f04 | |||
| 12752f37d5 | |||
| 7f07bf53c2 | |||
| 6ad1a73c16 | |||
| 8c07dc7c3f | |||
| 1b4ac0789c | |||
| c5e1fab09b | |||
| 2e1ad77946 | |||
| c135e1a85f | |||
| 79c00e0149 | |||
| 78501b907b | |||
| 6f1ad20cff | |||
| b2a7fa7f70 | |||
| 73df354f9b | |||
| 60ee6a0c24 | |||
| 112d558986 | |||
| db595708f7 | |||
| 938baa5833 | |||
| 5098c26c96 | |||
| 29c5c50d62 | |||
| fda318add5 | |||
| d996aacc29 | |||
| fe09aa4931 | |||
| 3f75d82295 | |||
| 8c98e53427 | |||
| 4f76056ac0 | |||
| 42b8476b96 | |||
| dba960c454 | |||
| d9e74da0e2 | |||
| ebd2aa46dc | |||
| cee708209e | |||
| cd973aa1a0 | |||
| 219d2c201e | |||
| 561aca32d3 | |||
| fecdf4a06b | |||
| dba6162427 | |||
| d513ea381e | |||
| ff9bbad336 | |||
| e10a91813e | |||
| 68996ed39d | |||
| 9bcb917d3b | |||
| 88adb566eb | |||
| 3e48e8fd5c | |||
| 7b3a27110a | |||
| 8e1a021eec | |||
| 13c791d86f | |||
| cb6be84cb9 | |||
| 9a33809f70 | |||
| 3ad88f7dea | |||
| 048e292bdd | |||
| a138034c06 | |||
| ce40bd8c75 | |||
| b2a1eb8e5b | |||
| 54d00e19ae | |||
| d130a83bd4 | |||
| ec452bca22 | |||
| 797aecd489 | |||
| 83f124b910 | |||
| 8104f1b7a7 |
@@ -0,0 +1,9 @@
|
|||||||
|
TENANT=default
|
||||||
|
DIST_DIR=default
|
||||||
|
PRODUCTION=false
|
||||||
|
API_BASE_URL=https://psp-api.shift-am.ir
|
||||||
|
HOST=localhost
|
||||||
|
PORT=5001
|
||||||
|
ENABLE_LOGGING=false
|
||||||
|
ENABLE_DEBUG=false
|
||||||
|
ENABLE_NATIVE_BRIDGE=false
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
TENANT=tis
|
||||||
|
DIST_DIR=tis
|
||||||
|
# TIS_BUILD_DATE=
|
||||||
|
# TIS_APP_VERSION=
|
||||||
|
# TIS_BUILD_NUMBER=
|
||||||
|
PRODUCTION=true
|
||||||
|
API_BASE_URL=http://192.168.128.73:5002
|
||||||
|
HOST=localhost
|
||||||
|
PORT=5000
|
||||||
|
ENABLE_LOGGING=false
|
||||||
|
ENABLE_DEBUG=false
|
||||||
|
ENABLE_NATIVE_BRIDGE=true
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
name: Manual Deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
target:
|
||||||
|
description: "Target service"
|
||||||
|
required: true
|
||||||
|
default: "app_default"
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- app_default
|
||||||
|
- app_tis
|
||||||
|
- both
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Deploy locally (manual trigger only)
|
||||||
|
run: |
|
||||||
|
if [ "${{ inputs.target }}" = "app_default" ]; then
|
||||||
|
docker compose build app_default
|
||||||
|
docker compose up -d app_default
|
||||||
|
elif [ "${{ inputs.target }}" = "app_tis" ]; then
|
||||||
|
docker compose build app_tis
|
||||||
|
docker compose up -d app_tis
|
||||||
|
else
|
||||||
|
docker compose build app_default app_tis
|
||||||
|
docker compose up -d app_default app_tis
|
||||||
|
fi
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
name: Production CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
validate-and-build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
cache: pnpm
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
- name: TypeScript check
|
||||||
|
run: pnpm -s exec tsc -p tsconfig.app.json --noEmit
|
||||||
|
|
||||||
|
- name: Build default tenant
|
||||||
|
run: pnpm build
|
||||||
|
|
||||||
|
- name: Build tis tenant
|
||||||
|
run: pnpm build:tis
|
||||||
|
|
||||||
|
- name: Docker build default
|
||||||
|
run: docker compose build app_default
|
||||||
|
|
||||||
|
- name: Docker build tis
|
||||||
|
run: docker compose build app_tis
|
||||||
@@ -42,5 +42,5 @@ testem.log
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
|
.env.*
|
||||||
/false
|
.env
|
||||||
|
|||||||
@@ -5,28 +5,28 @@
|
|||||||
"endOfLine": "lf",
|
"endOfLine": "lf",
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
{
|
||||||
"files": "*.html",
|
"files": "**/*.html",
|
||||||
"options": {
|
"options": {
|
||||||
"bracketSameLine": true,
|
"bracketSameLine": true,
|
||||||
"printWidth": 120
|
"printWidth": 120
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"files": "*.scss",
|
"files": "**/*.scss",
|
||||||
"options": {
|
"options": {
|
||||||
"printWidth": 120,
|
"printWidth": 120,
|
||||||
"singleQuote": false
|
"singleQuote": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"files": "*.less",
|
"files": "**/*.less",
|
||||||
"options": {
|
"options": {
|
||||||
"printWidth": 120,
|
"printWidth": 120,
|
||||||
"singleQuote": false
|
"singleQuote": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"files": "*.json",
|
"files": "**/*.json",
|
||||||
"options": {
|
"options": {
|
||||||
"printWidth": 100
|
"printWidth": 100
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,10 @@
|
|||||||
"semi": true,
|
"semi": true,
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
|
"tailwindAttributes": [
|
||||||
|
"class",
|
||||||
|
"ngClass"
|
||||||
|
],
|
||||||
"trailingComma": "es5",
|
"trailingComma": "es5",
|
||||||
"useTabs": false
|
"useTabs": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# Build stage
|
# ---------- Build stage ----------
|
||||||
FROM node:20 AS builder
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
ARG TENANT=tis
|
ARG TENANT=tis
|
||||||
ARG DIST_DIR=tis
|
ARG DIST_DIR=tis
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# RUN npm config set registry "https://hub.megan.ir/npm/"
|
RUN npm config set registry "https://hub.megan.ir/npm/"
|
||||||
|
|
||||||
RUN npm install -g pnpm
|
RUN npm install -g pnpm
|
||||||
|
|
||||||
COPY package.json pnpm-lock.yaml ./
|
COPY package.json pnpm-lock.yaml ./
|
||||||
RUN pnpm install
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
@@ -20,14 +20,23 @@ RUN if [ "$TENANT" = "default" ]; then \
|
|||||||
pnpm run build:$TENANT; \
|
pnpm run build:$TENANT; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# ---------- Runtime stage ----------
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
# Remove default config
|
||||||
|
RUN rm -rf /etc/nginx/conf.d/*
|
||||||
|
|
||||||
|
# Copy optimized config
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
ARG DIST_DIR=tis
|
ARG DIST_DIR=tis
|
||||||
|
|
||||||
COPY nginx.conf /etc/nginx/nginx.conf
|
|
||||||
|
|
||||||
COPY --from=builder /app/dist/${DIST_DIR}/browser /usr/share/nginx/html
|
COPY --from=builder /app/dist/${DIST_DIR}/browser /usr/share/nginx/html
|
||||||
|
|
||||||
EXPOSE 5000
|
# Optional: reduce image size
|
||||||
|
# RUN apk add --no-cache brotli
|
||||||
|
|
||||||
|
EXPOSE 8090
|
||||||
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# syntax=docker/dockerfile:1.4
|
||||||
# Development Dockerfile with hot reload support
|
# Development Dockerfile with hot reload support
|
||||||
FROM node:20-alpine
|
FROM node:20-alpine
|
||||||
|
|
||||||
@@ -10,7 +11,8 @@ RUN npm install -g pnpm
|
|||||||
COPY package.json pnpm-lock.yaml ./
|
COPY package.json pnpm-lock.yaml ./
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN pnpm install --frozen-lockfile
|
RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \
|
||||||
|
pnpm config set store-dir /pnpm/store && pnpm install --frozen-lockfile
|
||||||
|
|
||||||
# Copy source code
|
# Copy source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# syntax=docker/dockerfile:1.4
|
||||||
# Build stage for staging environment
|
# Build stage for staging environment
|
||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
@@ -10,7 +11,8 @@ RUN npm install -g pnpm
|
|||||||
COPY package.json pnpm-lock.yaml ./
|
COPY package.json pnpm-lock.yaml ./
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN pnpm install --frozen-lockfile
|
RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \
|
||||||
|
pnpm config set store-dir /pnpm/store && pnpm install --frozen-lockfile
|
||||||
|
|
||||||
# Copy source code
|
# Copy source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
@@ -0,0 +1,254 @@
|
|||||||
|
# AGENT.md
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
Applies to the full repository unless overridden by a deeper `AGENT.md`.
|
||||||
|
|
||||||
|
Stack:
|
||||||
|
- Angular 20
|
||||||
|
- Standalone components
|
||||||
|
- pnpm
|
||||||
|
- Docker
|
||||||
|
- RTK
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
# RTK RULES (MANDATORY)
|
||||||
|
|
||||||
|
Always prefer RTK commands.
|
||||||
|
|
||||||
|
Use:
|
||||||
|
|
||||||
|
- `rtk ls`
|
||||||
|
- `rtk grep`
|
||||||
|
- `rtk smart`
|
||||||
|
- `rtk read`
|
||||||
|
- `rtk git diff`
|
||||||
|
- `rtk git status`
|
||||||
|
|
||||||
|
Avoid raw:
|
||||||
|
- `cat`
|
||||||
|
- `grep`
|
||||||
|
- `rg`
|
||||||
|
- `tree`
|
||||||
|
- `git diff`
|
||||||
|
- recursive `find`
|
||||||
|
|
||||||
|
Use raw shell only for:
|
||||||
|
- builds
|
||||||
|
- runtime/debugging
|
||||||
|
- Docker
|
||||||
|
- pnpm
|
||||||
|
- commands RTK cannot perform
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# FILE READING POLICY
|
||||||
|
|
||||||
|
Preferred order:
|
||||||
|
|
||||||
|
1. `rtk grep`
|
||||||
|
2. `rtk smart`
|
||||||
|
3. `rtk read`
|
||||||
|
|
||||||
|
Rules:
|
||||||
|
- Search before reading.
|
||||||
|
- Read only required files.
|
||||||
|
- Do not read TS/HTML/SCSS together unless required.
|
||||||
|
- Stop exploring once edit location is clear.
|
||||||
|
- Avoid rereading unchanged files.
|
||||||
|
|
||||||
|
Large files:
|
||||||
|
- `rtk read <file> -l aggressive`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# ANGULAR WORKFLOW
|
||||||
|
|
||||||
|
For components:
|
||||||
|
|
||||||
|
1. `rtk grep "<component-name>"`
|
||||||
|
2. `rtk smart component.ts`
|
||||||
|
3. Read template only if UI changes are required
|
||||||
|
4. Read styles only if styling changes are required
|
||||||
|
|
||||||
|
Avoid broad module inspection.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# TOKEN RULES
|
||||||
|
|
||||||
|
Do not:
|
||||||
|
- dump large files
|
||||||
|
- scan unrelated folders
|
||||||
|
- inspect generated directories
|
||||||
|
- perform repeated searches
|
||||||
|
- over-explain edits
|
||||||
|
|
||||||
|
Avoid:
|
||||||
|
- `dist/`
|
||||||
|
- `.angular/`
|
||||||
|
- `coverage/`
|
||||||
|
- `node_modules/`
|
||||||
|
- `.git/`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# CHANGE POLICY
|
||||||
|
|
||||||
|
- Keep changes minimal and scoped.
|
||||||
|
- Reuse existing patterns.
|
||||||
|
- Avoid unrelated refactors.
|
||||||
|
- Preserve tenant separation.
|
||||||
|
- Prefer root-cause fixes.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# PROJECT RULES
|
||||||
|
|
||||||
|
## Tenant Builds
|
||||||
|
|
||||||
|
- `default` → `dist/production`
|
||||||
|
- `tis` → `dist/tis`
|
||||||
|
|
||||||
|
Keep Docker `DIST_DIR` aligned with Angular output.
|
||||||
|
|
||||||
|
Do not use Angular `fileReplacements` for static assets.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Input Component
|
||||||
|
|
||||||
|
File:
|
||||||
|
- `src/app/shared/components/input/input.component.ts`
|
||||||
|
|
||||||
|
For:
|
||||||
|
- `type="number"`
|
||||||
|
- `type="price"`
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
- normalize Persian/Arabic digits
|
||||||
|
- allow only digits and `.`
|
||||||
|
- support fixed precision
|
||||||
|
- keep identifier fields string-safe
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Shared Field Rules
|
||||||
|
|
||||||
|
When creating fields:
|
||||||
|
- use shared field wrappers
|
||||||
|
- reuse `app-input`
|
||||||
|
- register exports in shared indexes
|
||||||
|
- keep control names consistent
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# VALIDATION
|
||||||
|
|
||||||
|
TypeScript:
|
||||||
|
- `pnpm -s exec tsc -p tsconfig.app.json --noEmit`
|
||||||
|
|
||||||
|
Docker:
|
||||||
|
- `docker compose build app_default`
|
||||||
|
- `docker compose build app_tis`
|
||||||
|
|
||||||
|
Validate only impacted areas when possible.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# FINAL RESPONSE RULES
|
||||||
|
|
||||||
|
Keep final responses under 10 lines unless:
|
||||||
|
- validation failed
|
||||||
|
- architecture changed
|
||||||
|
- user requested explanation
|
||||||
|
|
||||||
|
Prefer:
|
||||||
|
|
||||||
|
Updated:
|
||||||
|
- file1
|
||||||
|
- file2
|
||||||
|
|
||||||
|
Validation:
|
||||||
|
- tsc passed
|
||||||
|
|
||||||
|
|
||||||
|
# TARGETED READ RULES
|
||||||
|
|
||||||
|
Do not read files larger than 300 lines unless required.
|
||||||
|
|
||||||
|
For changes at a known location:
|
||||||
|
|
||||||
|
- read the surrounding symbol only
|
||||||
|
- avoid full-file reads
|
||||||
|
|
||||||
|
Prefer:
|
||||||
|
- rtk grep
|
||||||
|
- rtk smart
|
||||||
|
- targeted read
|
||||||
|
|
||||||
|
Avoid:
|
||||||
|
- opening 400+ line files for small edits
|
||||||
|
|
||||||
|
# REASONING OUTPUT RULES
|
||||||
|
|
||||||
|
Do not expose internal reasoning.
|
||||||
|
|
||||||
|
Never output:
|
||||||
|
- "I think..."
|
||||||
|
- "I'm considering..."
|
||||||
|
- "I wonder..."
|
||||||
|
- "Maybe..."
|
||||||
|
- implementation deliberation
|
||||||
|
- "It sounds..."
|
||||||
|
|
||||||
|
Never explain alternative approaches unless requested.
|
||||||
|
|
||||||
|
Use:
|
||||||
|
|
||||||
|
Inspecting confirmation dialog.
|
||||||
|
|
||||||
|
Updating async accept support.
|
||||||
|
|
||||||
|
Validation passed.
|
||||||
|
|
||||||
|
|
||||||
|
# INVESTIGATION LIMITS
|
||||||
|
|
||||||
|
For localized fixes:
|
||||||
|
|
||||||
|
- maximum 3 file reads before first edit
|
||||||
|
- maximum 1 related-file read unless required
|
||||||
|
|
||||||
|
Stop searching once the edit target is identified.
|
||||||
|
|
||||||
|
# REVIEW MODE
|
||||||
|
|
||||||
|
During reviews:
|
||||||
|
|
||||||
|
- inspect changed files only
|
||||||
|
- avoid loading unrelated dependencies
|
||||||
|
- avoid architecture exploration
|
||||||
|
- avoid repository-wide searches
|
||||||
|
|
||||||
|
Review only code directly affected by the diff.
|
||||||
|
|
||||||
|
|
||||||
|
# HARD TOKEN LIMITS
|
||||||
|
|
||||||
|
For localized fixes:
|
||||||
|
|
||||||
|
- Never read files larger than 300 lines unless the target symbol cannot be isolated.
|
||||||
|
- Never read an entire file when a symbol-level read is possible.
|
||||||
|
- Never read more than 5 total files before the first edit.
|
||||||
|
- Never open a file already summarized by `rtk smart` unless implementation details are required.
|
||||||
|
|
||||||
|
When a file exceeds 300 lines:
|
||||||
|
|
||||||
|
1. rtk grep
|
||||||
|
2. rtk smart
|
||||||
|
3. read only the relevant symbol/section
|
||||||
|
|
||||||
|
Avoid full-file reads.
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# AI Agent Assistant Guide
|
||||||
|
|
||||||
|
This file provides a quick operational guide for AI assistants working on this project.
|
||||||
|
|
||||||
|
## Project
|
||||||
|
- Framework: Angular
|
||||||
|
- Package manager: pnpm
|
||||||
|
- Root path: `/Users/ahasani/Projects/PSP/consumer/panel`
|
||||||
|
|
||||||
|
## Core Rules
|
||||||
|
- Follow `AGENTS.md` instructions in this repository.
|
||||||
|
- Avoid reverting unrelated local changes.
|
||||||
|
- Keep edits minimal and scoped to the requested feature.
|
||||||
|
- Prefer existing shared abstractions and services over duplicating logic.
|
||||||
|
|
||||||
|
## Common Commands
|
||||||
|
```bash
|
||||||
|
pnpm install
|
||||||
|
pnpm start
|
||||||
|
pnpm build
|
||||||
|
pnpm test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Useful Practices
|
||||||
|
- Search files quickly with `rg` when available.
|
||||||
|
- For form changes, keep model/interface, form controls, and templates aligned.
|
||||||
|
- For Android WebView integration, keep contract changes synchronized between panel and Android app.
|
||||||
|
- For shared components, preserve desktop behavior and add mobile behavior conditionally.
|
||||||
|
|
||||||
|
## Delivery Checklist
|
||||||
|
- Build passes (or document why not run).
|
||||||
|
- No unrelated files changed.
|
||||||
|
- New behavior documented in changed file comments only when necessary.
|
||||||
|
- Keep final output short with file paths and key behavior changes.
|
||||||
@@ -10,12 +10,13 @@
|
|||||||
"build": {
|
"build": {
|
||||||
"builder": "@angular/build:application",
|
"builder": "@angular/build:application",
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"development": {
|
"default": {
|
||||||
"extractLicenses": false,
|
"assets": [
|
||||||
"optimization": false,
|
{
|
||||||
"sourceMap": true
|
"glob": "**/*",
|
||||||
},
|
"input": "public-default"
|
||||||
"production": {
|
}
|
||||||
|
],
|
||||||
"budgets": [
|
"budgets": [
|
||||||
{
|
{
|
||||||
"maximumError": "3MB",
|
"maximumError": "3MB",
|
||||||
@@ -31,12 +32,150 @@
|
|||||||
"fileReplacements": [
|
"fileReplacements": [
|
||||||
{
|
{
|
||||||
"replace": "src/environments/environment.ts",
|
"replace": "src/environments/environment.ts",
|
||||||
"with": "src/environments/environment.prod.ts"
|
"with": "src/environments/environment.default.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/app.routes.ts",
|
||||||
|
"with": "src/tenants/default/app.routes.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/app/branding/branding.config.ts",
|
||||||
|
"with": "src/tenants/default/branding.config.ts"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputHashing": "all",
|
"outputHashing": "all",
|
||||||
"outputPath": "dist/pos.client",
|
"outputPath": "dist/default"
|
||||||
"serviceWorker": "ngsw-config.json"
|
},
|
||||||
|
"development": {
|
||||||
|
"extractLicenses": false,
|
||||||
|
"optimization": false,
|
||||||
|
"sourceMap": true
|
||||||
|
},
|
||||||
|
"novin": {
|
||||||
|
"assets": [
|
||||||
|
{
|
||||||
|
"glob": "**/*",
|
||||||
|
"input": "public-novin"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"budgets": [
|
||||||
|
{
|
||||||
|
"maximumError": "3MB",
|
||||||
|
"maximumWarning": "2MB",
|
||||||
|
"type": "initial"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"maximumError": "8kB",
|
||||||
|
"maximumWarning": "4kB",
|
||||||
|
"type": "anyComponentStyle"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/config.ts",
|
||||||
|
"with": "src/tenants/novin/config.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/assets/images/brandingAssets.ts",
|
||||||
|
"with": "src/tenants/novin/brandingAssets.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/environments/environment.ts",
|
||||||
|
"with": "src/environments/environment.novin.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/app.routes.ts",
|
||||||
|
"with": "src/tenants/novin/app.routes.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/app/branding/branding.config.ts",
|
||||||
|
"with": "src/tenants/novin/branding.config.ts"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputHashing": "all",
|
||||||
|
"outputPath": "dist/novin",
|
||||||
|
"styles": [
|
||||||
|
"src/assets/styles.scss",
|
||||||
|
"src/assets/psp.scss"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"production": {
|
||||||
|
"budgets": [
|
||||||
|
{
|
||||||
|
"maximumError": "2.5MB",
|
||||||
|
"maximumWarning": "1.5MB",
|
||||||
|
"type": "initial"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"maximumError": "6kB",
|
||||||
|
"maximumWarning": "3kB",
|
||||||
|
"type": "anyComponentStyle"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/environments/environment.ts",
|
||||||
|
"with": "src/environments/environment.prod.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/app.routes.ts",
|
||||||
|
"with": "src/tenants/default/app.routes.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/app/branding/branding.config.ts",
|
||||||
|
"with": "src/tenants/default/branding.config.ts"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputHashing": "all",
|
||||||
|
"outputPath": "dist/production"
|
||||||
|
},
|
||||||
|
"sepehr": {
|
||||||
|
"assets": [
|
||||||
|
{
|
||||||
|
"glob": "**/*",
|
||||||
|
"input": "public-sepehr"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"budgets": [
|
||||||
|
{
|
||||||
|
"maximumError": "3MB",
|
||||||
|
"maximumWarning": "2MB",
|
||||||
|
"type": "initial"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"maximumError": "8kB",
|
||||||
|
"maximumWarning": "4kB",
|
||||||
|
"type": "anyComponentStyle"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/config.ts",
|
||||||
|
"with": "src/tenants/sepehr/config.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/assets/images/brandingAssets.ts",
|
||||||
|
"with": "src/tenants/sepehr/brandingAssets.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/environments/environment.ts",
|
||||||
|
"with": "src/environments/environment.sepehr.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/app.routes.ts",
|
||||||
|
"with": "src/tenants/sepehr/app.routes.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/app/branding/branding.config.ts",
|
||||||
|
"with": "src/tenants/sepehr/branding.config.ts"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputHashing": "all",
|
||||||
|
"outputPath": "dist/sepehr",
|
||||||
|
"styles": [
|
||||||
|
"src/assets/styles.scss",
|
||||||
|
"src/assets/psp.scss"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"staging": {
|
"staging": {
|
||||||
"extractLicenses": true,
|
"extractLicenses": true,
|
||||||
@@ -48,7 +187,6 @@
|
|||||||
],
|
],
|
||||||
"optimization": true,
|
"optimization": true,
|
||||||
"outputHashing": "all",
|
"outputHashing": "all",
|
||||||
"serviceWorker": "ngsw-config.json",
|
|
||||||
"sourceMap": false
|
"sourceMap": false
|
||||||
},
|
},
|
||||||
"tis": {
|
"tis": {
|
||||||
@@ -71,6 +209,14 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"fileReplacements": [
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/config.ts",
|
||||||
|
"with": "src/tenants/tis/config.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/assets/images/brandingAssets.ts",
|
||||||
|
"with": "src/tenants/tis/brandingAssets.ts"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"replace": "src/environments/environment.ts",
|
"replace": "src/environments/environment.ts",
|
||||||
"with": "src/environments/environment.tis.ts"
|
"with": "src/environments/environment.tis.ts"
|
||||||
@@ -86,11 +232,70 @@
|
|||||||
],
|
],
|
||||||
"outputHashing": "all",
|
"outputHashing": "all",
|
||||||
"outputPath": "dist/tis",
|
"outputPath": "dist/tis",
|
||||||
"serviceWorker": "ngsw-config.json"
|
"styles": [
|
||||||
|
"src/assets/styles.scss",
|
||||||
|
"src/assets/psp.scss"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"tis-development": {
|
||||||
|
"assets": [
|
||||||
|
{
|
||||||
|
"glob": "**/*",
|
||||||
|
"input": "public-tis"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"budgets": [
|
||||||
|
{
|
||||||
|
"maximumError": "2.5MB",
|
||||||
|
"maximumWarning": "1.5MB",
|
||||||
|
"type": "initial"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"maximumError": "6kB",
|
||||||
|
"maximumWarning": "3kB",
|
||||||
|
"type": "anyComponentStyle"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"extractLicenses": false,
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/config.ts",
|
||||||
|
"with": "src/tenants/tis/config.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/assets/images/brandingAssets.ts",
|
||||||
|
"with": "src/tenants/tis/brandingAssets.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/environments/environment.ts",
|
||||||
|
"with": "src/environments/environment.tis.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/app.routes.ts",
|
||||||
|
"with": "src/tenants/tis/app.routes.ts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"replace": "src/app/branding/branding.config.ts",
|
||||||
|
"with": "src/tenants/tis/branding.config.ts"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"optimization": false,
|
||||||
|
"outputHashing": "all",
|
||||||
|
"outputPath": "dist/tis",
|
||||||
|
"sourceMap": true,
|
||||||
|
"styles": [
|
||||||
|
"src/assets/styles.scss",
|
||||||
|
"src/assets/psp.scss"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"defaultConfiguration": "production",
|
"defaultConfiguration": "production",
|
||||||
"options": {
|
"options": {
|
||||||
|
"allowedCommonJsDependencies": [
|
||||||
|
"dayjs",
|
||||||
|
"dayjs/locale/fa",
|
||||||
|
"dayjs/plugin/relativeTime"
|
||||||
|
],
|
||||||
"assets": [
|
"assets": [
|
||||||
{
|
{
|
||||||
"glob": "**/*",
|
"glob": "**/*",
|
||||||
@@ -121,14 +326,20 @@
|
|||||||
"development": {
|
"development": {
|
||||||
"buildTarget": "pos.client:build:development"
|
"buildTarget": "pos.client:build:development"
|
||||||
},
|
},
|
||||||
|
"novin": {
|
||||||
|
"buildTarget": "pos.client:build:novin"
|
||||||
|
},
|
||||||
"production": {
|
"production": {
|
||||||
"buildTarget": "pos.client:build:production"
|
"buildTarget": "pos.client:build:production"
|
||||||
},
|
},
|
||||||
|
"sepehr": {
|
||||||
|
"buildTarget": "pos.client:build:sepehr"
|
||||||
|
},
|
||||||
"staging": {
|
"staging": {
|
||||||
"buildTarget": "pos.client:build:staging"
|
"buildTarget": "pos.client:build:staging"
|
||||||
},
|
},
|
||||||
"tis": {
|
"tis": {
|
||||||
"buildTarget": "pos.client:build:tis"
|
"buildTarget": "pos.client:build:tis-development"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"defaultConfiguration": "development",
|
"defaultConfiguration": "development",
|
||||||
|
|||||||
@@ -1,72 +1,74 @@
|
|||||||
version: "3.8"
|
version: "3.8"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# Production service
|
app_tis:
|
||||||
app:
|
|
||||||
platform: ${DOCKER_PLATFORM:-linux/amd64}
|
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
args:
|
args:
|
||||||
TENANT: ${TENANT:-tis}
|
TENANT: tis
|
||||||
DIST_DIR: ${DIST_DIR:-tis}
|
DIST_DIR: tis
|
||||||
container_name: psp_panel_prod
|
|
||||||
ports:
|
|
||||||
- "5000:5000"
|
|
||||||
environment:
|
|
||||||
- NODE_ENV=production
|
|
||||||
restart: unless-stopped
|
|
||||||
healthcheck:
|
|
||||||
test: [ "CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:5000/" ]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 3s
|
|
||||||
retries: 3
|
|
||||||
start_period: 5s
|
|
||||||
networks:
|
|
||||||
- psp_panel_network
|
|
||||||
# Staging service
|
|
||||||
# staging:
|
|
||||||
# build:
|
|
||||||
# context: .
|
|
||||||
# dockerfile: Dockerfile.staging
|
|
||||||
# container_name: psp_panel_staging
|
|
||||||
# ports:
|
|
||||||
# - "5050:5000"
|
|
||||||
# environment:
|
|
||||||
# - NODE_ENV=staging
|
|
||||||
# restart: unless-stopped
|
|
||||||
# healthcheck:
|
|
||||||
# test:
|
|
||||||
# ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"]
|
|
||||||
# interval: 30s
|
|
||||||
# timeout: 3s
|
|
||||||
# retries: 3
|
|
||||||
# start_period: 5s
|
|
||||||
# profiles:
|
|
||||||
# - staging
|
|
||||||
# networks:
|
|
||||||
# - psp_panel_network
|
|
||||||
|
|
||||||
# # Development service with hot reload
|
ports:
|
||||||
# dev:
|
- "8091:8090"
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
app_novin:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
TENANT: novin
|
||||||
|
DIST_DIR: novin
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- "8093:8090"
|
||||||
|
restart: unless-stopped
|
||||||
|
# app_sepehr:
|
||||||
# build:
|
# build:
|
||||||
# context: .
|
# context: .
|
||||||
# dockerfile: Dockerfile.dev
|
# dockerfile: Dockerfile
|
||||||
# container_name: psp_panel-dev
|
# args:
|
||||||
# working_dir: /app
|
# TENANT: sepehr
|
||||||
# volumes:
|
# DIST_DIR: sepehr
|
||||||
# - .:/app
|
|
||||||
# - /app/node_modules
|
|
||||||
# ports:
|
# ports:
|
||||||
# - "4200:4200"
|
# - "8092:8090"
|
||||||
# environment:
|
|
||||||
# - NODE_ENV=development
|
|
||||||
# restart: unless-stopped
|
# restart: unless-stopped
|
||||||
# profiles:
|
|
||||||
# - dev
|
app_default:
|
||||||
# networks:
|
build:
|
||||||
# - psp_panel_network
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
TENANT: default
|
||||||
|
DIST_DIR: production
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- "8090:8090"
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
# labels:
|
||||||
|
# - "traefik.enable=true"
|
||||||
|
|
||||||
|
# # 🌐 Router
|
||||||
|
# - "traefik.http.routers.psp.rule=Host(`your-domain.com`)"
|
||||||
|
# - "traefik.http.routers.psp.entrypoints=websecure"
|
||||||
|
# - "traefik.http.routers.psp.tls=true"
|
||||||
|
|
||||||
|
# # 🔐 SSL (auto with Traefik)
|
||||||
|
# - "traefik.http.routers.psp.tls.certresolver=letsencrypt"
|
||||||
|
|
||||||
|
# # ⚡ Service port (IMPORTANT)
|
||||||
|
# - "traefik.http.services.psp.loadbalancer.server.port=80"
|
||||||
|
|
||||||
|
# # 🚀 Compression at edge (optional)
|
||||||
|
# - "traefik.http.middlewares.compress.compress=true"
|
||||||
|
# - "traefik.http.routers.psp.middlewares=compress@docker"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
- web
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
psp_panel_network:
|
web:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|||||||
@@ -1,80 +1,28 @@
|
|||||||
user nginx;
|
server {
|
||||||
worker_processes auto;
|
listen 8090;
|
||||||
error_log /var/log/nginx/error.log warn;
|
server_name _;
|
||||||
pid /var/run/nginx.pid;
|
|
||||||
|
|
||||||
events {
|
root /usr/share/nginx/html;
|
||||||
worker_connections 1024;
|
index index.html;
|
||||||
}
|
|
||||||
|
|
||||||
http {
|
|
||||||
include /etc/nginx/mime.types;
|
|
||||||
default_type application/octet-stream;
|
|
||||||
|
|
||||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
||||||
'$status $body_bytes_sent "$http_referer" '
|
|
||||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
||||||
|
|
||||||
access_log /var/log/nginx/access.log main;
|
|
||||||
|
|
||||||
sendfile on;
|
|
||||||
tcp_nopush on;
|
|
||||||
tcp_nodelay on;
|
|
||||||
keepalive_timeout 65;
|
|
||||||
types_hash_max_size 2048;
|
|
||||||
client_max_body_size 20M;
|
|
||||||
|
|
||||||
|
# 🔥 Gzip
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_vary on;
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||||
gzip_proxied any;
|
|
||||||
gzip_comp_level 6;
|
gzip_comp_level 6;
|
||||||
gzip_types text/plain text/css text/xml text/javascript
|
|
||||||
application/json application/javascript application/xml+rss
|
|
||||||
application/rss+xml font/truetype font/opentype
|
|
||||||
application/vnd.ms-fontobject image/svg+xml;
|
|
||||||
|
|
||||||
include /etc/nginx/conf.d/*.conf;
|
# 🔥 Brotli (better than gzip)
|
||||||
|
# brotli on;
|
||||||
|
# brotli_comp_level 6;
|
||||||
|
# brotli_types text/plain text/css application/javascript application/json image/svg+xml;
|
||||||
|
|
||||||
server {
|
# 🔥 Cache static assets
|
||||||
listen 5000;
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ {
|
||||||
server_name localhost;
|
expires 1y;
|
||||||
charset utf-8;
|
add_header Cache-Control "public, immutable";
|
||||||
|
}
|
||||||
|
|
||||||
root /usr/share/nginx/html;
|
# 🔥 Angular routing (SPA fallback)
|
||||||
index index.html index.htm;
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
# Security headers
|
|
||||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
||||||
add_header X-Content-Type-Options "nosniff" always;
|
|
||||||
add_header X-XSS-Protection "1; mode=block" always;
|
|
||||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
||||||
|
|
||||||
# Cache control for static assets
|
|
||||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
|
||||||
expires 1y;
|
|
||||||
add_header Cache-Control "public, immutable";
|
|
||||||
}
|
|
||||||
|
|
||||||
# Service worker files should be revalidated on each request
|
|
||||||
location = /ngsw.json {
|
|
||||||
expires -1;
|
|
||||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
||||||
}
|
|
||||||
|
|
||||||
location = /ngsw-worker.js {
|
|
||||||
expires -1;
|
|
||||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
||||||
}
|
|
||||||
|
|
||||||
# Angular routing - serve index.html for all routes
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ /index.html;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Don't cache index.html
|
|
||||||
location = /index.html {
|
|
||||||
expires -1;
|
|
||||||
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
|
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
|
||||||
"appData": {
|
"appData": {
|
||||||
"appVersion": "0.0.0",
|
"appVersion": "0.0.24",
|
||||||
"buildDate": "2026-04-27T06:02:22.249Z"
|
"buildDate": "2026-05-16T20:25:55.273Z",
|
||||||
|
"buildNumber": 24
|
||||||
},
|
},
|
||||||
"assetGroups": [
|
"assetGroups": [
|
||||||
{
|
{
|
||||||
@@ -10,10 +11,7 @@
|
|||||||
"name": "app",
|
"name": "app",
|
||||||
"resources": {
|
"resources": {
|
||||||
"files": [
|
"files": [
|
||||||
"/favicon.ico",
|
"/favicon.ico"
|
||||||
"/index.html",
|
|
||||||
"/*.css",
|
|
||||||
"/*.js"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"updateMode": "prefetch"
|
"updateMode": "prefetch"
|
||||||
@@ -40,27 +38,6 @@
|
|||||||
"updateMode": "prefetch"
|
"updateMode": "prefetch"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dataGroups": [
|
"dataGroups": [],
|
||||||
{
|
"index": "/index.html"
|
||||||
"cacheConfig": {
|
|
||||||
"maxAge": "1h",
|
|
||||||
"maxSize": 100,
|
|
||||||
"strategy": "freshness",
|
|
||||||
"timeout": "10s"
|
|
||||||
},
|
|
||||||
"name": "api-fresh",
|
|
||||||
"urls": [
|
|
||||||
"/api/**",
|
|
||||||
"https://*/api/**",
|
|
||||||
"http://*/api/**"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"index": "/index.html",
|
|
||||||
"navigationUrls": [
|
|
||||||
"/**",
|
|
||||||
"!/**/*.*",
|
|
||||||
"!/**/*__*",
|
|
||||||
"!/**/*__*/**"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,9 @@
|
|||||||
"@primeng/themes": "^20.4.0",
|
"@primeng/themes": "^20.4.0",
|
||||||
"@primeuix/themes": "^1.2.5",
|
"@primeuix/themes": "^1.2.5",
|
||||||
"@tailwindcss/postcss": "^4.2.3",
|
"@tailwindcss/postcss": "^4.2.3",
|
||||||
"@zoomit/dayjs-jalali-plugin": "^0.1.11",
|
"angularx-qrcode": "20.0.0",
|
||||||
"chart.js": "4.4.2",
|
"chart.js": "4.4.2",
|
||||||
"dayjs": "^1.11.20",
|
"dayjs": "^1.11.20",
|
||||||
"flatpickr": "^4.6.13",
|
|
||||||
"flatpickr-wrap": "^1.0.0",
|
|
||||||
"jalaliday": "^3.1.1",
|
"jalaliday": "^3.1.1",
|
||||||
"jest-editor-support": "32.0.0-beta.1",
|
"jest-editor-support": "32.0.0-beta.1",
|
||||||
"ngx-cookie-service": "^21.3.1",
|
"ngx-cookie-service": "^21.3.1",
|
||||||
@@ -55,26 +53,18 @@
|
|||||||
"typescript": "~5.8.3"
|
"typescript": "~5.8.3"
|
||||||
},
|
},
|
||||||
"name": "psp_panel",
|
"name": "psp_panel",
|
||||||
"prettier": {
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"files": "*.html",
|
|
||||||
"options": {
|
|
||||||
"parser": "angular"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
|
"build:novin": "ng build --configuration novin",
|
||||||
|
"build:sepehr": "ng build --configuration sepehr",
|
||||||
"build:tis": "ng build --configuration tis",
|
"build:tis": "ng build --configuration tis",
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"prebuild": "node scripts/update-ngsw-appdata.js",
|
|
||||||
"prebuild:tis": "node scripts/update-ngsw-appdata.js",
|
|
||||||
"prestart": "node aspnetcore-https",
|
"prestart": "node aspnetcore-https",
|
||||||
"start": "run-script-os",
|
"start": "run-script-os",
|
||||||
"start:tis": "ng serve --configuration tis",
|
"start:novin": " ng serve --configuration novin",
|
||||||
|
"start:sepehr": " ng serve --configuration sepehr",
|
||||||
|
"start:tis": " ng serve --configuration tis",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"watch": "ng build --watch --configuration development"
|
"watch": "ng build --watch --configuration development"
|
||||||
},
|
},
|
||||||
|
|||||||
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 6.7 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 94 KiB |
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"background_color": "#ffffff",
|
||||||
|
"display": "standalone",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"purpose": "any",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"src": "/favicon/web-app-manifest-192x192.png",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"purpose": "maskable",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"src": "/favicon/web-app-manifest-192x192.png",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"purpose": "any",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"src": "/favicon/web-app-manifest-512x512.png",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"purpose": "maskable",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"src": "/favicon/web-app-manifest-512x512.png",
|
||||||
|
"type": "image/png"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": "/",
|
||||||
|
"name": "پرداخت نوین - مدیریت صورتحسابهای مالیاتی",
|
||||||
|
"scope": "/",
|
||||||
|
"short_name": "پرداخت نوین",
|
||||||
|
"start_url": "/",
|
||||||
|
"theme_color": "#ffffff"
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 9.5 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 187 KiB |
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "پرداخت الکترونیک سپهر",
|
||||||
|
"short_name": "پرداخت الکترونیک سپهر",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "/web-app-manifest-192x192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/web-app-manifest-512x512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"theme_color": "#ffffff",
|
||||||
|
"background_color": "#ffffff",
|
||||||
|
"display": "standalone"
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"background_color": "#ffffff",
|
||||||
|
"display": "standalone",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"purpose": "any",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"src": "/favicon/web-app-manifest-192x192.png",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"purpose": "maskable",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"src": "/favicon/web-app-manifest-192x192.png",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"purpose": "any",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"src": "/favicon/web-app-manifest-512x512.png",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"purpose": "maskable",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"src": "/favicon/web-app-manifest-512x512.png",
|
||||||
|
"type": "image/png"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": "/",
|
||||||
|
"name": "پرداخت الکترونیک سپهر",
|
||||||
|
"scope": "/",
|
||||||
|
"short_name": "سپهر",
|
||||||
|
"start_url": "/",
|
||||||
|
"theme_color": "#ffffff"
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 524 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 37 KiB |
@@ -1,14 +1,25 @@
|
|||||||
{
|
{
|
||||||
"background_color": "#ffffff",
|
"background_color": "#ffffff",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"id": "/",
|
|
||||||
"icons": [
|
"icons": [
|
||||||
|
{
|
||||||
|
"purpose": "any",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"src": "/favicon/web-app-manifest-192x192.png",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"purpose": "maskable",
|
"purpose": "maskable",
|
||||||
"sizes": "192x192",
|
"sizes": "192x192",
|
||||||
"src": "/favicon/web-app-manifest-192x192.png",
|
"src": "/favicon/web-app-manifest-192x192.png",
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"purpose": "any",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"src": "/favicon/web-app-manifest-512x512.png",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"purpose": "maskable",
|
"purpose": "maskable",
|
||||||
"sizes": "512x512",
|
"sizes": "512x512",
|
||||||
@@ -16,9 +27,10 @@
|
|||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "PSP A - مدیریت صورتحسابهای مالیاتی",
|
"id": "/",
|
||||||
"short_name": "PSP A",
|
"name": "تیس - مدیریت صورتحسابهای مالیاتی",
|
||||||
"start_url": "/",
|
|
||||||
"scope": "/",
|
"scope": "/",
|
||||||
|
"short_name": "تیس",
|
||||||
|
"start_url": "/",
|
||||||
"theme_color": "#ffffff"
|
"theme_color": "#ffffff"
|
||||||
}
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 4.5 KiB |
@@ -2,12 +2,24 @@
|
|||||||
"background_color": "#ffffff",
|
"background_color": "#ffffff",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"icons": [
|
"icons": [
|
||||||
|
{
|
||||||
|
"purpose": "any",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"src": "/favicon/web-app-manifest-192x192.png",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"purpose": "maskable",
|
"purpose": "maskable",
|
||||||
"sizes": "192x192",
|
"sizes": "192x192",
|
||||||
"src": "/favicon/web-app-manifest-192x192.png",
|
"src": "/favicon/web-app-manifest-192x192.png",
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"purpose": "any",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"src": "/favicon/web-app-manifest-512x512.png",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"purpose": "maskable",
|
"purpose": "maskable",
|
||||||
"sizes": "512x512",
|
"sizes": "512x512",
|
||||||
@@ -16,9 +28,9 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"id": "/",
|
"id": "/",
|
||||||
"name": "مدیریت صورتحسابهای مالیاتی",
|
"name": "نرم افزار صورتحسابهای مالیاتی سپاس",
|
||||||
"scope": "/",
|
"scope": "/",
|
||||||
"short_name": "مدیریت صورتحسابهای مالیاتی",
|
"short_name": "سپاس",
|
||||||
"start_url": "/",
|
"start_url": "/",
|
||||||
"theme_color": "#ffffff"
|
"theme_color": "#ffffff"
|
||||||
}
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 19 KiB |
@@ -0,0 +1,22 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const root = path.resolve(__dirname, '../..');
|
||||||
|
const tenantLogo = path.join(root, 'public-tis', 'branding', 'logo.png/');
|
||||||
|
const defaultLogo = path.join(root, 'src', 'assets', 'images', 'logo.png');
|
||||||
|
const targetLogo = path.join(root, 'src', 'tenants', 'tis', 'assets', 'images', 'logo.png');
|
||||||
|
|
||||||
|
const source = fs.existsSync(tenantLogo) ? tenantLogo : defaultLogo;
|
||||||
|
|
||||||
|
if (!fs.existsSync(source)) {
|
||||||
|
console.warn(
|
||||||
|
`[prepare-tis-logo] No logo source found. Checked: ${tenantLogo} and ${defaultLogo}`,
|
||||||
|
);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.mkdirSync(path.dirname(targetLogo), { recursive: true });
|
||||||
|
fs.copyFileSync(source, targetLogo);
|
||||||
|
console.log(
|
||||||
|
`[prepare-tis-logo] Using logo: ${path.relative(root, source)} -> ${path.relative(root, targetLogo)}`,
|
||||||
|
);
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const root = process.cwd();
|
||||||
|
const packageJsonPath = path.join(root, 'package.json');
|
||||||
|
const ngswConfigPath = path.join(root, 'ngsw-config.json');
|
||||||
|
|
||||||
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||||
|
const ngswConfig = JSON.parse(fs.readFileSync(ngswConfigPath, 'utf8'));
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
const buildDate = process.env.TIS_BUILD_DATE || now.toISOString();
|
||||||
|
const previousAppVersion = ngswConfig.appData?.appVersion || packageJson.version || '0.0.0';
|
||||||
|
const appVersion =
|
||||||
|
process.env.TIS_APP_VERSION ||
|
||||||
|
previousAppVersion.replace(
|
||||||
|
/^(\d+)\.(\d+)\.(\d+)$/,
|
||||||
|
(_, major, minor, patch) => `${major}.${minor}.${Number(patch) + 1}`,
|
||||||
|
);
|
||||||
|
const previousBuildNumber = Number(ngswConfig.appData?.buildNumber || 0);
|
||||||
|
const buildNumber = Number(process.env.TIS_BUILD_NUMBER || previousBuildNumber + 1);
|
||||||
|
|
||||||
|
ngswConfig.appData = {
|
||||||
|
...(ngswConfig.appData || {}),
|
||||||
|
appVersion,
|
||||||
|
buildNumber,
|
||||||
|
buildDate,
|
||||||
|
};
|
||||||
|
|
||||||
|
fs.writeFileSync(ngswConfigPath, `${JSON.stringify(ngswConfig, null, 2)}\n`);
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const root = path.resolve(__dirname, '..');
|
const root = process.cwd();
|
||||||
const packageJsonPath = path.join(root, 'package.json');
|
const packageJsonPath = path.join(root, 'package.json');
|
||||||
const ngswConfigPath = path.join(root, 'ngsw-config.json');
|
const ngswConfigPath = path.join(root, 'ngsw-config.json');
|
||||||
|
|
||||||
@@ -10,11 +10,20 @@ const ngswConfig = JSON.parse(fs.readFileSync(ngswConfigPath, 'utf8'));
|
|||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const buildDate = process.env.BUILD_DATE || now.toISOString();
|
const buildDate = process.env.BUILD_DATE || now.toISOString();
|
||||||
const appVersion = process.env.APP_VERSION || packageJson.version || '0.0.0';
|
const previousAppVersion = ngswConfig.appData?.appVersion || packageJson.version || '0.0.0';
|
||||||
|
const appVersion =
|
||||||
|
process.env.APP_VERSION ||
|
||||||
|
previousAppVersion.replace(
|
||||||
|
/^(\d+)\.(\d+)\.(\d+)$/,
|
||||||
|
(_, major, minor, patch) => `${major}.${minor}.${Number(patch) + 1}`,
|
||||||
|
);
|
||||||
|
const previousBuildNumber = Number(ngswConfig.appData?.buildNumber || 0);
|
||||||
|
const buildNumber = Number(process.env.BUILD_NUMBER || previousBuildNumber + 1);
|
||||||
|
|
||||||
ngswConfig.appData = {
|
ngswConfig.appData = {
|
||||||
...(ngswConfig.appData || {}),
|
...(ngswConfig.appData || {}),
|
||||||
appVersion,
|
appVersion,
|
||||||
|
buildNumber,
|
||||||
buildDate,
|
buildDate,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,41 @@
|
|||||||
import { Component } from '@angular/core';
|
import { NavigationService } from '@/core/services/navigation.service';
|
||||||
|
import { PwaInstallService } from '@/core/services/pwa-install.service';
|
||||||
|
import { ConfirmationDialogComponent } from '@/shared/components/confirmationDialog/confirmation-dialog.component';
|
||||||
|
import { Component, HostListener } from '@angular/core';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { ConfirmDialog } from 'primeng/confirmdialog';
|
|
||||||
import { ToastModule } from 'primeng/toast';
|
import { ToastModule } from 'primeng/toast';
|
||||||
|
import { brandingConfig } from './app/branding/branding.config';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [RouterModule, ToastModule, ConfirmDialog],
|
imports: [RouterModule, ToastModule, ConfirmationDialogComponent],
|
||||||
template: `
|
template: `
|
||||||
<p-toast position="bottom-right" />
|
<p-toast [position]="toastPosition" [baseZIndex]="3000" />
|
||||||
<p-confirmDialog />
|
<app-shared-confirmation-dialog />
|
||||||
<router-outlet />
|
<router-outlet />
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
export class AppComponent {}
|
export class AppComponent {
|
||||||
|
toastPosition: 'top-center' | 'bottom-right' = 'bottom-right';
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly pwaInstallService: PwaInstallService,
|
||||||
|
private readonly navigationService: NavigationService
|
||||||
|
) {
|
||||||
|
this.updateToastPosition();
|
||||||
|
if (brandingConfig.enableInstallPrompt) {
|
||||||
|
this.pwaInstallService.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener('window:resize')
|
||||||
|
onResize() {
|
||||||
|
this.updateToastPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateToastPosition() {
|
||||||
|
this.toastPosition =
|
||||||
|
typeof window !== 'undefined' && window.innerWidth <= 768 ? 'top-center' : 'bottom-right';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ import {
|
|||||||
withInterceptors,
|
withInterceptors,
|
||||||
withInterceptorsFromDi,
|
withInterceptorsFromDi,
|
||||||
} from '@angular/common/http';
|
} from '@angular/common/http';
|
||||||
import { ApplicationConfig, isDevMode, provideZonelessChangeDetection } from '@angular/core';
|
import { ApplicationConfig, provideZonelessChangeDetection } from '@angular/core';
|
||||||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
||||||
import {
|
import {
|
||||||
provideRouter,
|
provideRouter,
|
||||||
withEnabledBlockingInitialNavigation,
|
withEnabledBlockingInitialNavigation,
|
||||||
withInMemoryScrolling,
|
withInMemoryScrolling,
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import { provideServiceWorker } from '@angular/service-worker';
|
// import { provideServiceWorker } from '@angular/service-worker';
|
||||||
// Use the consolidated preset that includes our custom variables
|
// Use the consolidated preset that includes our custom variables
|
||||||
import { ConfirmationService, MessageService } from 'primeng/api';
|
import { ConfirmationService, MessageService } from 'primeng/api';
|
||||||
import { providePrimeNG } from 'primeng/config';
|
import { providePrimeNG } from 'primeng/config';
|
||||||
@@ -34,7 +34,7 @@ export const appConfig: ApplicationConfig = {
|
|||||||
anchorScrolling: 'enabled',
|
anchorScrolling: 'enabled',
|
||||||
scrollPositionRestoration: 'enabled',
|
scrollPositionRestoration: 'enabled',
|
||||||
}),
|
}),
|
||||||
withEnabledBlockingInitialNavigation(),
|
withEnabledBlockingInitialNavigation()
|
||||||
),
|
),
|
||||||
provideZonelessChangeDetection(),
|
provideZonelessChangeDetection(),
|
||||||
// configure HttpClient once: enable fetch and register both functional
|
// configure HttpClient once: enable fetch and register both functional
|
||||||
@@ -42,6 +42,12 @@ export const appConfig: ApplicationConfig = {
|
|||||||
provideAnimationsAsync(),
|
provideAnimationsAsync(),
|
||||||
// ensure PrimeNG uses our preset (applies css variables at app initialization)
|
// ensure PrimeNG uses our preset (applies css variables at app initialization)
|
||||||
providePrimeNG({
|
providePrimeNG({
|
||||||
|
zIndex: {
|
||||||
|
tooltip: 2100,
|
||||||
|
menu: 2000,
|
||||||
|
overlay: 2000,
|
||||||
|
modal: 1100,
|
||||||
|
},
|
||||||
theme: {
|
theme: {
|
||||||
preset: MyPreset,
|
preset: MyPreset,
|
||||||
options: { darkModeSelector: '.app-dark' },
|
options: { darkModeSelector: '.app-dark' },
|
||||||
@@ -53,7 +59,7 @@ export const appConfig: ApplicationConfig = {
|
|||||||
emptySearchMessage: 'هیچ موردی برای نمایش وجود ندارد',
|
emptySearchMessage: 'هیچ موردی برای نمایش وجود ندارد',
|
||||||
accept: 'تایید',
|
accept: 'تایید',
|
||||||
reject: 'رد کردن',
|
reject: 'رد کردن',
|
||||||
cancel: 'لغو',
|
cancel: 'انصراف',
|
||||||
noFileChosenMessage: 'هیچ فایلی انتخاب نشده است',
|
noFileChosenMessage: 'هیچ فایلی انتخاب نشده است',
|
||||||
fileChosenMessage: 'انتخاب فایل',
|
fileChosenMessage: 'انتخاب فایل',
|
||||||
selectionMessage: '{0} مورد انتخاب شده است',
|
selectionMessage: '{0} مورد انتخاب شده است',
|
||||||
@@ -72,11 +78,11 @@ export const appConfig: ApplicationConfig = {
|
|||||||
provideHttpClient(
|
provideHttpClient(
|
||||||
withFetch(),
|
withFetch(),
|
||||||
withInterceptors([loggingInterceptor, authInterceptor, errorInterceptor, dedupInterceptor]),
|
withInterceptors([loggingInterceptor, authInterceptor, errorInterceptor, dedupInterceptor]),
|
||||||
withInterceptorsFromDi(),
|
withInterceptorsFromDi()
|
||||||
),
|
),
|
||||||
provideServiceWorker('ngsw-worker.js', {
|
// provideServiceWorker('ngsw-worker.js', {
|
||||||
enabled: !isDevMode(),
|
// enabled: !isDevMode(),
|
||||||
registrationStrategy: 'registerWhenStable:30000',
|
// registrationStrategy: 'registerWhenStable:30000',
|
||||||
}),
|
// }),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1 +1,29 @@
|
|||||||
export { appRoutes } from './tenants/default/app.routes';
|
import { CONSUMER_ROUTES } from '@/domains/consumer/routes';
|
||||||
|
import { PARTNER_ROUTES } from '@/domains/partner/routes';
|
||||||
|
import { POS_ROUTES } from '@/domains/pos/routes';
|
||||||
|
import { PROVIDER_ROUTES } from '@/domains/provider/routes';
|
||||||
|
import { SUPER_ADMIN_ROUTES } from '@/domains/superAdmin/routes';
|
||||||
|
import { PUBLIC_SALE_INVOICES_ROUTES } from '@/modules/saleInvoices/constants';
|
||||||
|
import { Notfound } from '@/pages/notfound/notfound.component';
|
||||||
|
import { Routes } from '@angular/router';
|
||||||
|
|
||||||
|
export const appRoutes: Routes = [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
loadComponent: () => import('@/layout/default/app.layout.component').then((m) => m.AppLayout),
|
||||||
|
children: [SUPER_ADMIN_ROUTES, CONSUMER_ROUTES, PROVIDER_ROUTES, PARTNER_ROUTES],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'pos',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('@/domains/pos/layouts/layout.component').then((m) => m.PosLayoutComponent),
|
||||||
|
children: [POS_ROUTES],
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
path: 'auth',
|
||||||
|
loadComponent: () => import('@/modules/auth/pages/auth.component').then((m) => m.AuthComponent),
|
||||||
|
},
|
||||||
|
...PUBLIC_SALE_INVOICES_ROUTES,
|
||||||
|
{ path: '**', component: Notfound },
|
||||||
|
];
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
export * from './pos-display';
|
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
# POS Display Component
|
|
||||||
|
|
||||||
A reusable component for displaying Point-of-Sale (POS) terminal information with configurable variants.
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
The `PosDisplayComponent` displays POS entity information in a card-based layout with support for different visibility variants ('consumer', 'partner', 'full').
|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
- **Variant Support**: Choose from 'consumer', 'partner', or 'full' display modes
|
|
||||||
- **Conditional Field Visibility**: Fields are dynamically shown/hidden based on variant
|
|
||||||
- **Edit Mode**: Toggle between view and edit modes
|
|
||||||
- **Responsive Grid**: Displays up to 3 columns with gap-4 spacing
|
|
||||||
- **More Actions**: Optional button for additional actions
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
### Basic Usage
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
import { PosDisplayComponent, IPosEntity } from '@/app/components';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-my-component',
|
|
||||||
template: `
|
|
||||||
<app-pos-display
|
|
||||||
variant="consumer"
|
|
||||||
[pos]="posData"
|
|
||||||
[editMode]="isEditing"
|
|
||||||
(onMoreAction)="handleMoreAction()"
|
|
||||||
(editModeChange)="editModeChange($event)"
|
|
||||||
/>
|
|
||||||
`,
|
|
||||||
standalone: true,
|
|
||||||
imports: [PosDisplayComponent],
|
|
||||||
})
|
|
||||||
export class MyComponent {
|
|
||||||
posData = signal<IPosEntity>({
|
|
||||||
id: '123',
|
|
||||||
name: 'Terminal 1',
|
|
||||||
pos_type: 'PSP',
|
|
||||||
serial_number: 'SN123',
|
|
||||||
model: 'Model X',
|
|
||||||
status: 'active',
|
|
||||||
complex: { id: 'c1', name: 'Complex 1' },
|
|
||||||
device: { id: 'd1', name: 'Device A' },
|
|
||||||
provider: { id: 'p1', name: 'Provider A' },
|
|
||||||
});
|
|
||||||
|
|
||||||
isEditing = signal(false);
|
|
||||||
|
|
||||||
handleMoreAction(): void {
|
|
||||||
console.log('More action clicked');
|
|
||||||
}
|
|
||||||
|
|
||||||
editModeChange(editing: boolean): void {
|
|
||||||
this.isEditing.set(editing);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Variants
|
|
||||||
|
|
||||||
### Consumer Variant
|
|
||||||
Displays: name, pos_type, serial_number, device, model, provider (6 fields)
|
|
||||||
|
|
||||||
### Partner Variant
|
|
||||||
Displays: name, pos_type, serial_number (3 fields)
|
|
||||||
|
|
||||||
### Full Variant
|
|
||||||
Displays: name, pos_type, serial_number, device, model, provider (6 fields - same as consumer)
|
|
||||||
|
|
||||||
## Inputs
|
|
||||||
|
|
||||||
| Input | Type | Default | Description |
|
|
||||||
|-------|------|---------|-------------|
|
|
||||||
| `variant` | 'consumer' \| 'partner' \| 'full' | 'full' | Display variant mode |
|
|
||||||
| `pos` | Signal<IPosEntity \| undefined> | undefined | POS entity data |
|
|
||||||
| `editMode` | Signal<boolean> | false | Edit mode state |
|
|
||||||
| `cardTitle` | string | 'اطلاعات پایانهی فروش' | Card header title |
|
|
||||||
| `showMoreActions` | boolean | true | Show more actions button |
|
|
||||||
|
|
||||||
## Outputs
|
|
||||||
|
|
||||||
| Output | Payload | Description |
|
|
||||||
|--------|---------|-------------|
|
|
||||||
| `editModeChange` | boolean | Emitted when edit mode toggled |
|
|
||||||
| `onMoreAction` | void | Emitted when more actions button clicked |
|
|
||||||
| `onSubmit` | void | Emitted on form submission |
|
|
||||||
|
|
||||||
## Model (IPosEntity)
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
interface IPosEntity {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
serial_number: string;
|
|
||||||
model?: string;
|
|
||||||
status: string;
|
|
||||||
pos_type: string;
|
|
||||||
complex: ISummary;
|
|
||||||
device?: ISummary;
|
|
||||||
provider?: ISummary;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Integration in Existing Component
|
|
||||||
|
|
||||||
To replace the inline display in your POS single view:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
// Before: Manual field rendering
|
|
||||||
<app-key-value label="عنوان" [value]="pos()?.name" />
|
|
||||||
<app-key-value label="نوع پایانه" [value]="pos()?.pos_type" />
|
|
||||||
// ... more fields
|
|
||||||
|
|
||||||
// After: Use the component
|
|
||||||
<app-pos-display
|
|
||||||
variant="full"
|
|
||||||
[pos]="pos"
|
|
||||||
[editMode]="editMode"
|
|
||||||
(onMoreAction)="toPosLanding()"
|
|
||||||
/>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Files
|
|
||||||
|
|
||||||
- `pos-display.component.ts` - Component logic
|
|
||||||
- `pos-display.component.html` - Template
|
|
||||||
- `pos-display.component.scss` - Styles
|
|
||||||
- `models/posEntity.model.ts` - TypeScript interfaces and types
|
|
||||||
- `index.ts` - Barrel export
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
export * from './models/posEntity.model';
|
|
||||||
export * from './pos-display.component';
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
import ISummary from '@/core/models/summary';
|
|
||||||
|
|
||||||
export type PosVariant = 'consumer' | 'partner' | 'full';
|
|
||||||
|
|
||||||
export interface IPosEntity {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
serial_number: string;
|
|
||||||
model?: string;
|
|
||||||
status: string;
|
|
||||||
pos_type: string;
|
|
||||||
complex: ISummary;
|
|
||||||
device?: ISummary;
|
|
||||||
provider?: ISummary;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IPosDisplayConfig {
|
|
||||||
variant: PosVariant;
|
|
||||||
editable?: boolean;
|
|
||||||
showMoreActions?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const POS_VARIANT_FIELDS: Record<PosVariant, Array<keyof IPosEntity>> = {
|
|
||||||
consumer: ['name', 'pos_type', 'serial_number', 'device', 'model', 'provider'],
|
|
||||||
partner: ['name', 'pos_type', 'serial_number'],
|
|
||||||
full: ['name', 'pos_type', 'serial_number', 'device', 'model', 'provider'],
|
|
||||||
};
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<app-card-data [cardTitle]="cardTitle" [editable]="true" [editMode]="isEditing()" (editModeChange)="toggleEditMode()">
|
|
||||||
<ng-template #moreActions>
|
|
||||||
@if (showMoreActions) {
|
|
||||||
<p-button type="button" variant="outlined" (onClick)="handleMoreAction()"> ورود به پایانه </p-button>
|
|
||||||
}
|
|
||||||
</ng-template>
|
|
||||||
|
|
||||||
<div class="flex flex-col gap-4">
|
|
||||||
<div class="grid grid-cols-3 gap-4 items-center">
|
|
||||||
@for (field of visibleFields(); track field) {
|
|
||||||
@if (isFieldVisible(field)) {
|
|
||||||
<app-key-value [label]="fieldLabels[field]" [value]="getFieldValue(field)" />
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</app-card-data>
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
|
||||||
import { CommonModule } from '@angular/common';
|
|
||||||
import { Component, effect, EventEmitter, Input, Output, signal } from '@angular/core';
|
|
||||||
import { Button } from 'primeng/button';
|
|
||||||
import { IPosEntity, POS_VARIANT_FIELDS, PosVariant } from './models/posEntity.model';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-pos-entity-display',
|
|
||||||
standalone: true,
|
|
||||||
imports: [CommonModule, AppCardComponent, Button, KeyValueComponent],
|
|
||||||
templateUrl: './pos-display.component.html',
|
|
||||||
})
|
|
||||||
export class PosDisplayComponent {
|
|
||||||
@Input() variant: PosVariant = 'full';
|
|
||||||
@Input() pos = signal<IPosEntity | undefined>(undefined);
|
|
||||||
@Input() editMode = signal<boolean>(false);
|
|
||||||
@Input() cardTitle = 'اطلاعات پایانهی فروش';
|
|
||||||
@Input() showMoreActions = true;
|
|
||||||
|
|
||||||
@Output() editModeChange = new EventEmitter<boolean>();
|
|
||||||
@Output() onMoreAction = new EventEmitter<void>();
|
|
||||||
@Output() onSubmit = new EventEmitter<void>();
|
|
||||||
|
|
||||||
visibleFields = signal<Array<keyof IPosEntity>>([]);
|
|
||||||
isEditing = signal<boolean>(false);
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
effect(() => {
|
|
||||||
this.visibleFields.set(POS_VARIANT_FIELDS[this.variant] || POS_VARIANT_FIELDS.full);
|
|
||||||
});
|
|
||||||
|
|
||||||
effect(() => {
|
|
||||||
this.isEditing.set(this.editMode());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
get fieldLabels(): Record<string, string> {
|
|
||||||
return {
|
|
||||||
name: 'عنوان',
|
|
||||||
pos_type: 'نوع پایانه',
|
|
||||||
serial_number: 'شماره سریال',
|
|
||||||
device: 'نوع دستگاه',
|
|
||||||
model: 'مدل دستگاه',
|
|
||||||
provider: 'ارایهدهنده',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
isFieldVisible(field: keyof IPosEntity): boolean {
|
|
||||||
return this.visibleFields().includes(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
getFieldValue(field: keyof IPosEntity): any {
|
|
||||||
const posData = this.pos();
|
|
||||||
if (!posData) return null;
|
|
||||||
|
|
||||||
if (field === 'device' && posData.device) {
|
|
||||||
return posData.device.name;
|
|
||||||
}
|
|
||||||
if (field === 'provider' && posData.provider) {
|
|
||||||
return posData.provider.name;
|
|
||||||
}
|
|
||||||
return posData[field];
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleEditMode(): void {
|
|
||||||
const newMode = !this.isEditing();
|
|
||||||
this.isEditing.set(newMode);
|
|
||||||
this.editModeChange.emit(newMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleMoreAction(): void {
|
|
||||||
this.onMoreAction.emit();
|
|
||||||
}
|
|
||||||
|
|
||||||
handleSubmit(): void {
|
|
||||||
this.onSubmit.emit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,8 +6,9 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { computed, inject, Injectable, signal } from '@angular/core';
|
import { computed, inject, Injectable, signal } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { CookieService } from 'ngx-cookie-service';
|
import { CookieService } from 'ngx-cookie-service';
|
||||||
import { BehaviorSubject, Observable, throwError } from 'rxjs';
|
import { BehaviorSubject, from, Observable, throwError } from 'rxjs';
|
||||||
import { catchError, finalize, tap } from 'rxjs/operators';
|
import { catchError, finalize, switchMap, tap } from 'rxjs/operators';
|
||||||
|
import config from 'src/config';
|
||||||
import { COOKIE_KEYS, LOCAL_STORAGE_KEYS } from '../../../assets/constants';
|
import { COOKIE_KEYS, LOCAL_STORAGE_KEYS } from '../../../assets/constants';
|
||||||
import {
|
import {
|
||||||
IAuthAccountResponse,
|
IAuthAccountResponse,
|
||||||
@@ -75,17 +76,20 @@ export class AuthService {
|
|||||||
return this.http
|
return this.http
|
||||||
.post<IAuthResponse>(
|
.post<IAuthResponse>(
|
||||||
'/api/v1/auth/login',
|
'/api/v1/auth/login',
|
||||||
{ username, password },
|
{ username, password, isPos: config.isPosApplication },
|
||||||
{
|
{
|
||||||
headers: baseHeaders,
|
headers: baseHeaders,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.pipe(
|
.pipe(
|
||||||
tap((response) => {
|
switchMap((response) =>
|
||||||
this.handleAuthSuccess(response);
|
from(
|
||||||
this.refreshCookies();
|
this.handleAuthSuccess(response).then(() => {
|
||||||
return response;
|
this.refreshCookies();
|
||||||
}),
|
return response;
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
catchError((error) => {
|
catchError((error) => {
|
||||||
console.error('Login error:', error);
|
console.error('Login error:', error);
|
||||||
this.isLoadingSubject.next(false);
|
this.isLoadingSubject.next(false);
|
||||||
@@ -97,19 +101,19 @@ export class AuthService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
logout(): void {
|
async logout(): Promise<void> {
|
||||||
localStorage.removeItem(LOCAL_STORAGE_KEYS.AUTH_TOKEN);
|
localStorage.removeItem(LOCAL_STORAGE_KEYS.AUTH_TOKEN);
|
||||||
localStorage.removeItem(LOCAL_STORAGE_KEYS.USER_DATA);
|
localStorage.removeItem(LOCAL_STORAGE_KEYS.USER_DATA);
|
||||||
localStorage.removeItem(LOCAL_STORAGE_KEYS.REFRESH_TOKEN);
|
localStorage.removeItem(LOCAL_STORAGE_KEYS.REFRESH_TOKEN);
|
||||||
this.refreshCookies();
|
await this.refreshCookies();
|
||||||
|
|
||||||
this.setCurrentUser(null);
|
await this.setCurrentUser(null);
|
||||||
this.router.navigate(['/auth']);
|
this.router.navigate(['/auth']);
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshCookies() {
|
async refreshCookies() {
|
||||||
this.cookieService.set(COOKIE_KEYS.POS_ID, '', new Date());
|
await this.cookieService.set(COOKIE_KEYS.POS_ID, '', new Date());
|
||||||
this.cookieService.set(COOKIE_KEYS.ACCESS_TOKEN, '', new Date());
|
await this.cookieService.set(COOKIE_KEYS.ACCESS_TOKEN, '', new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
doRefreshToken(): Observable<IAuthResponse> {
|
doRefreshToken(): Observable<IAuthResponse> {
|
||||||
@@ -170,6 +174,22 @@ export class AuthService {
|
|||||||
return localStorage.getItem(LOCAL_STORAGE_KEYS.AUTH_TOKEN);
|
return localStorage.getItem(LOCAL_STORAGE_KEYS.AUTH_TOKEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
waitForAuthReady(maxRetries = 20): Promise<boolean> {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
let retries = 0;
|
||||||
|
const check = () => {
|
||||||
|
const isReady = Boolean(this.getToken()) && Boolean(this.currentAccount());
|
||||||
|
if (isReady || retries >= maxRetries) {
|
||||||
|
resolve(isReady);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
retries += 1;
|
||||||
|
setTimeout(check, 0);
|
||||||
|
};
|
||||||
|
check();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current refresh token
|
* Get current refresh token
|
||||||
*/
|
*/
|
||||||
@@ -246,7 +266,7 @@ export class AuthService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleAuthSuccess(response: IAuthResponse): void {
|
private async handleAuthSuccess(response: IAuthResponse): Promise<void> {
|
||||||
localStorage.setItem(LOCAL_STORAGE_KEYS.AUTH_TOKEN, response.accessToken);
|
localStorage.setItem(LOCAL_STORAGE_KEYS.AUTH_TOKEN, response.accessToken);
|
||||||
this.token.set(response.accessToken);
|
this.token.set(response.accessToken);
|
||||||
this.refreshToken.set(response.refreshToken);
|
this.refreshToken.set(response.refreshToken);
|
||||||
@@ -259,7 +279,7 @@ export class AuthService {
|
|||||||
// this.navigateByRole(response.user.role);
|
// this.navigateByRole(response.user.role);
|
||||||
}
|
}
|
||||||
|
|
||||||
private setCurrentUser(account: Maybe<IAuthAccountResponse>): void {
|
private async setCurrentUser(account: Maybe<IAuthAccountResponse>): Promise<void> {
|
||||||
this.currentAccount.set(account);
|
this.currentAccount.set(account);
|
||||||
this.currentAccountSubject.next(account);
|
this.currentAccountSubject.next(account);
|
||||||
localStorage.setItem(LOCAL_STORAGE_KEYS.USER_DATA, JSON.stringify(account));
|
localStorage.setItem(LOCAL_STORAGE_KEYS.USER_DATA, JSON.stringify(account));
|
||||||
|
|||||||
@@ -64,6 +64,22 @@ export class FormErrorsService {
|
|||||||
if (errors['invalidMobile']) {
|
if (errors['invalidMobile']) {
|
||||||
out.push({ key: 'invalidMobile', message: `${label} معتبر نیست.` });
|
out.push({ key: 'invalidMobile', message: `${label} معتبر نیست.` });
|
||||||
}
|
}
|
||||||
|
if (errors['invalidUsername']) {
|
||||||
|
const info = errors['invalidUsername'];
|
||||||
|
out.push({ key: 'invalidUsername', message: info.message ?? `${label} معتبر نیست.` });
|
||||||
|
}
|
||||||
|
if (errors['equalLength']) {
|
||||||
|
const info = errors['equalLength'];
|
||||||
|
out.push({
|
||||||
|
key: 'equalLength',
|
||||||
|
message: `تعداد کاراکترهای ${label} باید برابر با ${info.length} باشد.`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors['invalidFiscalId']) {
|
||||||
|
const info = errors['invalidFiscalId'];
|
||||||
|
out.push({ key: 'invalidFiscalId', message: info.message ?? `${label} معتبر نیست.` });
|
||||||
|
}
|
||||||
// fallback: include any other error keys
|
// fallback: include any other error keys
|
||||||
Object.keys(errors).forEach((k) => {
|
Object.keys(errors).forEach((k) => {
|
||||||
if (
|
if (
|
||||||
@@ -76,6 +92,7 @@ export class FormErrorsService {
|
|||||||
'max',
|
'max',
|
||||||
'email',
|
'email',
|
||||||
'pattern',
|
'pattern',
|
||||||
|
'invalidFiscalId',
|
||||||
].indexOf(k) === -1
|
].indexOf(k) === -1
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -4,3 +4,4 @@ export { ErrorHandlerService } from './error-handler.service';
|
|||||||
export { ConfigService } from './config.service';
|
export { ConfigService } from './config.service';
|
||||||
export * from './breadcrumb.service';
|
export * from './breadcrumb.service';
|
||||||
export * from './native-bridge.service';
|
export * from './native-bridge.service';
|
||||||
|
export * from './pwa-install.service';
|
||||||
|
|||||||
@@ -1,20 +1,25 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { inject, Injectable } from '@angular/core';
|
||||||
import { environment } from 'src/environments/environment';
|
import { Maybe } from '../models';
|
||||||
|
import { ToastService } from './toast.service';
|
||||||
|
|
||||||
interface INativeBridgeHost {
|
interface INativeBridgeHost {
|
||||||
pay?: (payload: string) => unknown;
|
pay?: (amount: number, id: Maybe<string>) => unknown;
|
||||||
print?: (payload: string) => unknown;
|
print?: (payload: INativePrintRequest) => unknown;
|
||||||
|
isEnabled?: () => boolean;
|
||||||
|
getUUID?: () => Maybe<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface INativePayRequest {
|
export interface INativePayRequest {
|
||||||
amount: number;
|
amount: number;
|
||||||
totalAmount: number;
|
id: Maybe<string>;
|
||||||
invoiceDate: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface INativePrintRequest {
|
export interface INativePrintRequest {
|
||||||
invoiceId?: string;
|
title: string;
|
||||||
code?: string;
|
items: {
|
||||||
|
label: string;
|
||||||
|
value: string;
|
||||||
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface INativeBridgeResult<T = unknown> {
|
export interface INativeBridgeResult<T = unknown> {
|
||||||
@@ -23,19 +28,40 @@ export interface INativeBridgeResult<T = unknown> {
|
|||||||
error?: string;
|
error?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface INativeBridgeDeviceInfo {
|
||||||
|
deviceName: string;
|
||||||
|
androidId: string;
|
||||||
|
}
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class NativeBridgeService {
|
export class NativeBridgeService {
|
||||||
|
private readonly toastService = inject(ToastService);
|
||||||
|
|
||||||
private get host(): INativeBridgeHost | undefined {
|
private get host(): INativeBridgeHost | undefined {
|
||||||
const globalWindow = window as unknown as {
|
const globalWindow = window as unknown as {
|
||||||
AndroidBridge?: INativeBridgeHost;
|
NativeBridge?: INativeBridgeHost;
|
||||||
Android?: INativeBridgeHost;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return globalWindow.AndroidBridge || globalWindow.Android;
|
return globalWindow.NativeBridge;
|
||||||
}
|
}
|
||||||
|
|
||||||
isEnabled(): boolean {
|
isEnabled(): boolean {
|
||||||
return !!environment.enableNativeBridge;
|
// @ts-ignore
|
||||||
|
return !!window.NativeBridge;
|
||||||
|
// if (window.NativeBridge) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
// if (!this.host) return false;
|
||||||
|
// const hostEnabled = this.host?.isEnabled;
|
||||||
|
// if (typeof hostEnabled === 'function') {
|
||||||
|
// try {
|
||||||
|
// return !!hostEnabled();
|
||||||
|
// } catch {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return !!environment.enableNativeBridge && !!this.host;
|
||||||
}
|
}
|
||||||
|
|
||||||
canPay(): boolean {
|
canPay(): boolean {
|
||||||
@@ -46,37 +72,81 @@ export class NativeBridgeService {
|
|||||||
return this.isEnabled() && typeof this.host?.print === 'function';
|
return this.isEnabled() && typeof this.host?.print === 'function';
|
||||||
}
|
}
|
||||||
|
|
||||||
pay(request: INativePayRequest): INativeBridgeResult {
|
pay(request: INativePayRequest): any {
|
||||||
return this.invoke('pay', request);
|
// if (request.amount <= 1_000) {
|
||||||
}
|
// const errorMessage = 'برای مقادیر زیر ۱۰ هزار ریال، پرداخت ممکن نیست.';
|
||||||
|
// this.toastService.warn({ text: errorMessage, life: 3000 });
|
||||||
print(request: INativePrintRequest): INativeBridgeResult {
|
// return {
|
||||||
return this.invoke('print', request);
|
// success: false,
|
||||||
}
|
// error: errorMessage,
|
||||||
|
// };
|
||||||
private invoke(method: 'pay' | 'print', payload: object): INativeBridgeResult {
|
// }
|
||||||
if (!this.isEnabled()) {
|
this.toastService.info({ text: 'در حال پردازش پرداخت...' });
|
||||||
return { success: false, error: 'Native bridge is disabled for this tenant.' };
|
|
||||||
}
|
|
||||||
|
|
||||||
const fn = this.host?.[method];
|
|
||||||
if (typeof fn !== 'function') {
|
|
||||||
return { success: false, error: `Native method "${method}" is not available.` };
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const raw = fn(JSON.stringify(payload));
|
// @ts-ignore
|
||||||
const parsed = this.tryParse(raw);
|
window.NativeBridge.pay(request.amount, request.id || '');
|
||||||
if (parsed && typeof parsed === 'object' && 'success' in parsed) {
|
return { success: true };
|
||||||
return parsed as INativeBridgeResult;
|
} catch (error) {
|
||||||
}
|
// this.toastService.info({ text: (error as Error).message });
|
||||||
|
return { success: false, error: (error as Error).message };
|
||||||
|
}
|
||||||
|
// const fn = window.NativeBridge.pay(123, 'test');
|
||||||
|
// if (typeof fn !== 'function') {
|
||||||
|
// this.toastService.error({ text: 'متاسفانه پرداخت امکانپذیر نیست.', life: 3000 });
|
||||||
|
// return { success: false, error: 'متاسفانه پرداخت امکانپذیر نیست.' };
|
||||||
|
// }
|
||||||
|
|
||||||
return { success: true, data: parsed ?? raw };
|
// try {
|
||||||
|
// fn(123, 'test');
|
||||||
|
// // fn(request.amount, request.id || '');
|
||||||
|
|
||||||
|
// return { success: true };
|
||||||
|
|
||||||
|
// // return { success: true, data: parsed ?? raw };
|
||||||
|
// } catch (error) {
|
||||||
|
// this.toastService.info({ text: (error as Error).message, });
|
||||||
|
// return { success: false, error: (error as Error).message };
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
print(request: INativePrintRequest[]): INativeBridgeResult {
|
||||||
|
return this.invokePrint(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getDeviceInfo(): Promise<INativeBridgeResult<INativeBridgeDeviceInfo>> {
|
||||||
|
if (!this.isEnabled()) {
|
||||||
|
return { success: false, error: 'متاسفانه ارتباط با دستگاه برقرار نیست.' };
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// @ts-ignore
|
||||||
|
const deviceInfo = await window.NativeBridge.deviceInfo();
|
||||||
|
return { success: true, data: JSON.parse(deviceInfo) };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return { success: false, error: (error as Error).message };
|
return { success: false, error: (error as Error).message };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private invokePrint(payload: INativePrintRequest[]): INativeBridgeResult {
|
||||||
|
if (!this.isEnabled() || !this.canPrint()) {
|
||||||
|
this.toastService.warn({ text: 'متاسفانه ارتباط با چاپگر برقرار نیست.' });
|
||||||
|
return { success: false, error: 'متاسفانه ارتباط با چاپگر برقرار نیست.' };
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
this.toastService.info({ text: 'در حال چاپ ...' });
|
||||||
|
// @ts-ignore
|
||||||
|
window.NativeBridge.print(JSON.stringify(payload));
|
||||||
|
|
||||||
|
return { success: true };
|
||||||
|
} catch (error) {
|
||||||
|
this.toastService.warn({ text: 'متاسفانه ارتباط با چاپگر برقرار نیست.' });
|
||||||
|
return { success: false, error: (error as Error).message };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getNativeDeviceId(): Maybe<string> {
|
||||||
|
return typeof this.host?.getUUID === 'function' ? this.host.getUUID!() : null;
|
||||||
|
}
|
||||||
|
|
||||||
private tryParse(value: unknown): unknown {
|
private tryParse(value: unknown): unknown {
|
||||||
if (typeof value !== 'string') return value;
|
if (typeof value !== 'string') return value;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { NavigationEnd, Router } from '@angular/router';
|
||||||
|
import { filter } from 'rxjs/operators';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class NavigationService {
|
||||||
|
private readonly CURRENT_URL_KEY = 'currentUrl';
|
||||||
|
private readonly PREVIOUS_URL_KEY = 'previousUrl';
|
||||||
|
|
||||||
|
currentUrl: string | null;
|
||||||
|
previousUrl: string | null;
|
||||||
|
|
||||||
|
constructor(private router: Router) {
|
||||||
|
this.currentUrl = sessionStorage.getItem(this.CURRENT_URL_KEY);
|
||||||
|
this.previousUrl = sessionStorage.getItem(this.PREVIOUS_URL_KEY);
|
||||||
|
|
||||||
|
this.router.events
|
||||||
|
.pipe(filter((event): event is NavigationEnd => event instanceof NavigationEnd))
|
||||||
|
.subscribe((event) => {
|
||||||
|
const newUrl = event.urlAfterRedirects;
|
||||||
|
|
||||||
|
// Ignore duplicate events
|
||||||
|
if (newUrl === this.currentUrl) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.previousUrl = this.currentUrl;
|
||||||
|
this.currentUrl = newUrl;
|
||||||
|
|
||||||
|
if (this.previousUrl) {
|
||||||
|
sessionStorage.setItem(this.PREVIOUS_URL_KEY, this.previousUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
sessionStorage.setItem(this.CURRENT_URL_KEY, this.currentUrl);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
canGoBack(): boolean {
|
||||||
|
return !!this.previousUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
back(fallbackUrl = '/'): void {
|
||||||
|
if (this.canGoBack()) {
|
||||||
|
window.history.back();
|
||||||
|
} else {
|
||||||
|
this.router.navigateByUrl(fallbackUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import { Injectable, signal } from '@angular/core';
|
||||||
|
import { ConfirmationService } from 'primeng/api';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class PwaInstallService {
|
||||||
|
private deferredInstallPrompt: any = null;
|
||||||
|
readonly isInstalled = signal(false);
|
||||||
|
readonly canInstall = signal(false);
|
||||||
|
|
||||||
|
constructor(private readonly confirmationService: ConfirmationService) {
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
if (typeof window === 'undefined') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const standalone =
|
||||||
|
window.matchMedia('(display-mode: standalone)').matches ||
|
||||||
|
(window.navigator as any).standalone === true;
|
||||||
|
|
||||||
|
this.isInstalled.set(standalone);
|
||||||
|
|
||||||
|
window.addEventListener('beforeinstallprompt', (event: any) => {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
this.deferredInstallPrompt = event;
|
||||||
|
this.canInstall.set(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener('appinstalled', () => {
|
||||||
|
this.deferredInstallPrompt = null;
|
||||||
|
this.canInstall.set(false);
|
||||||
|
this.isInstalled.set(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
openInstallConfirm() {
|
||||||
|
if (this.isInstalled() || !this.canInstall() || !this.deferredInstallPrompt) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.confirmationService.confirm({
|
||||||
|
header: 'نصب اپلیکیشن',
|
||||||
|
message: 'برای ادامه میبایست نیازمندیهای نرمافزار را نصب کنید',
|
||||||
|
acceptLabel: 'نصب',
|
||||||
|
rejectButtonProps: {
|
||||||
|
outlined: true,
|
||||||
|
},
|
||||||
|
accept: () => {
|
||||||
|
this.deferredInstallPrompt.prompt();
|
||||||
|
this.deferredInstallPrompt.userChoice.finally(() => {
|
||||||
|
this.deferredInstallPrompt = null;
|
||||||
|
this.canInstall.set(false);
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,10 +10,18 @@ interface IToast extends Pick<ToastMessageOptions, 'sticky' | 'life'> {
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class ToastService {
|
export class ToastService {
|
||||||
|
private readonly dedupeWindowMs = 2000;
|
||||||
|
private readonly recentMessages = new Map<string, number>();
|
||||||
|
|
||||||
constructor(private messageService: MessageService) {}
|
constructor(private messageService: MessageService) {}
|
||||||
|
|
||||||
add(message: ToastMessageOptions) {
|
add(message: ToastMessageOptions) {
|
||||||
if (!message.detail) return;
|
if (!message.detail) return;
|
||||||
|
const dedupeKey = `${message.severity ?? ''}|${message.summary ?? ''}|${message.detail}`;
|
||||||
|
const now = Date.now();
|
||||||
|
const lastShownAt = this.recentMessages.get(dedupeKey);
|
||||||
|
if (lastShownAt && now - lastShownAt < this.dedupeWindowMs) return;
|
||||||
|
this.recentMessages.set(dedupeKey, now);
|
||||||
this.messageService.add(message);
|
this.messageService.add(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -197,11 +197,7 @@ export abstract class EntityStore<
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
// @TODO: check to familiar with ts
|
// @TODO: check to familiar with ts
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: false,
|
...defaultBaseStateData,
|
||||||
error: null,
|
|
||||||
entity: null,
|
|
||||||
initialized: false,
|
|
||||||
isRefreshing: false,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { inject, Injectable } from '@angular/core';
|
import { inject, Injectable } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import config from 'src/config';
|
||||||
import { AuthService } from '../../services/auth.service';
|
import { AuthService } from '../../services/auth.service';
|
||||||
import { BaseState, BaseStore } from '../base-store';
|
import { BaseState, BaseStore } from '../base-store';
|
||||||
|
|
||||||
@@ -123,7 +124,7 @@ export class GlobalStore extends BaseStore<GlobalState> {
|
|||||||
readonly isOnline = this.computed((state) => state.isOnline);
|
readonly isOnline = this.computed((state) => state.isOnline);
|
||||||
readonly notifications = this.computed((state) => state.notifications);
|
readonly notifications = this.computed((state) => state.notifications);
|
||||||
readonly unreadNotifications = this.computed((state) =>
|
readonly unreadNotifications = this.computed((state) =>
|
||||||
state.notifications.filter((n) => !n.read),
|
state.notifications.filter((n) => !n.read)
|
||||||
);
|
);
|
||||||
readonly breadcrumbs = this.computed((state) => state.breadcrumbs);
|
readonly breadcrumbs = this.computed((state) => state.breadcrumbs);
|
||||||
readonly preferences = this.computed((state) => state.preferences);
|
readonly preferences = this.computed((state) => state.preferences);
|
||||||
@@ -144,7 +145,11 @@ export class GlobalStore extends BaseStore<GlobalState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load theme from localStorage
|
// Load theme from localStorage
|
||||||
const savedTheme = localStorage.getItem('app_theme') as 'light' | 'dark';
|
const savedTheme = config.isPosApplication
|
||||||
|
? 'light'
|
||||||
|
: (localStorage.getItem('app_theme') as 'light' | 'dark');
|
||||||
|
console.log('savedTheme', savedTheme);
|
||||||
|
|
||||||
if (savedTheme) {
|
if (savedTheme) {
|
||||||
this.patchState({ theme: savedTheme });
|
this.patchState({ theme: savedTheme });
|
||||||
}
|
}
|
||||||
@@ -250,7 +255,7 @@ export class GlobalStore extends BaseStore<GlobalState> {
|
|||||||
*/
|
*/
|
||||||
markNotificationRead(id: string): void {
|
markNotificationRead(id: string): void {
|
||||||
const notifications = this._state().notifications.map((n) =>
|
const notifications = this._state().notifications.map((n) =>
|
||||||
n.id === id ? { ...n, read: true } : n,
|
n.id === id ? { ...n, read: true } : n
|
||||||
);
|
);
|
||||||
this.patchState({ notifications });
|
this.patchState({ notifications });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms';
|
||||||
|
|
||||||
|
export function equalLengthValidator(length: number): ValidatorFn {
|
||||||
|
return (control: AbstractControl): ValidationErrors | null => {
|
||||||
|
const v = control.value;
|
||||||
|
if (v === null || v === undefined || v === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const normalized = String(v);
|
||||||
|
|
||||||
|
return normalized.length !== length
|
||||||
|
? {
|
||||||
|
equalLength: {
|
||||||
|
length,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import { ValidatorFn } from '@angular/forms';
|
|
||||||
|
|
||||||
export function fiscalCodeValidator(): ValidatorFn {
|
|
||||||
return (control) => {
|
|
||||||
if (control.value === null || control.value === undefined || control.value === '') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return control.value.length === 11 && /^[0-9]{11}$/.test(control.value)
|
|
||||||
? null
|
|
||||||
: { fiscalCode: 'معتبر نیست' };
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { ValidatorFn } from '@angular/forms';
|
||||||
|
|
||||||
|
export function fiscalIdValidator(): ValidatorFn {
|
||||||
|
return (control) => {
|
||||||
|
if (control.value === null || control.value === undefined || control.value === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (control.value.length < 6) {
|
||||||
|
return {
|
||||||
|
minlength: {
|
||||||
|
requiredLength: 6,
|
||||||
|
actualLength: control.value.length,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const pattern = /^[a-zA-Z0-9]*$/;
|
||||||
|
|
||||||
|
if (!pattern.test(control.value)) {
|
||||||
|
return {
|
||||||
|
invalidFiscalId: {
|
||||||
|
value: control.value,
|
||||||
|
message: 'شناسه مالی فقط میتواند شامل حروف انگلیسی و اعداد باشد',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strictly checks numeric value is greater than `minValue` (not equal).
|
||||||
|
* Empty values are treated as valid; combine with `Validators.required` when needed.
|
||||||
|
*/
|
||||||
|
export function greaterThanValidator(minValue: number): ValidatorFn {
|
||||||
|
return (control: AbstractControl): ValidationErrors | null => {
|
||||||
|
const v = control.value;
|
||||||
|
if (v === null || v === undefined || v === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const numericValue = typeof v === 'number' ? v : Number(v);
|
||||||
|
if (Number.isNaN(numericValue)) {
|
||||||
|
return { greaterThan: 'مقدار باید عددی باشد' };
|
||||||
|
}
|
||||||
|
|
||||||
|
return numericValue > minValue
|
||||||
|
? null
|
||||||
|
: {
|
||||||
|
greaterThan: `مقدار باید بیشتر از ${minValue} باشد`,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
export * from './fiscal-code.validator';
|
export * from './equalLength.validator';
|
||||||
|
export * from './fiscal-id.validator';
|
||||||
|
export * from './greater.validator';
|
||||||
export * from './iban.validator';
|
export * from './iban.validator';
|
||||||
export * from './mobile.validator';
|
export * from './mobile.validator';
|
||||||
export * from './must-match.validator';
|
export * from './must-match.validator';
|
||||||
export * from './password.validator';
|
export * from './password.validator';
|
||||||
export * from './postal-code.validator';
|
export * from './postal-code.validator';
|
||||||
|
export * from './username.validator';
|
||||||
|
|||||||
@@ -1,16 +1,21 @@
|
|||||||
import { ValidatorFn } from '@angular/forms';
|
import { ValidatorFn } from '@angular/forms';
|
||||||
|
|
||||||
// Password must be minimum 8 characters, include at least one uppercase,
|
// const PASSWORD_PATTERN = /^[a-zA-Z0-9_-]*$/;
|
||||||
// one lowercase, one number and one special character
|
|
||||||
// export const PASSWORD_PATTERN = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,}$/;
|
|
||||||
export const PASSWORD_PATTERN = /^[0-9]{6,}$/;
|
|
||||||
|
|
||||||
// Validator factory named `password` as requested. Returns `null` for empty
|
|
||||||
// values so `Validators.required` can be used alongside it when needed.
|
|
||||||
export function password(): ValidatorFn {
|
export function password(): ValidatorFn {
|
||||||
return (control) => {
|
return (control) => {
|
||||||
const value = control?.value;
|
const value = control?.value;
|
||||||
if (value === null || value === undefined || String(value).length === 0) return null;
|
if (value === null || value === undefined || String(value).length === 0) return null;
|
||||||
return PASSWORD_PATTERN.test(String(value)) ? null : { password: 'معتبر نیست' };
|
|
||||||
|
if (value.length < 6) {
|
||||||
|
return {
|
||||||
|
minlength: {
|
||||||
|
requiredLength: 6,
|
||||||
|
actualLength: value.length,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
// return PASSWORD_PATTERN.test(String(value)) ? null : { password: 'معتبر نیست' };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { ValidatorFn } from '@angular/forms';
|
||||||
|
|
||||||
|
export function usernameValidator(): ValidatorFn {
|
||||||
|
return (control) => {
|
||||||
|
if (control.value === null || control.value === undefined || control.value === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (control.value.length < 6) {
|
||||||
|
return {
|
||||||
|
minlength: {
|
||||||
|
requiredLength: 6,
|
||||||
|
actualLength: control.value.length,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const pattern = /^[a-zA-Z0-9_-]*$/;
|
||||||
|
|
||||||
|
if (!pattern.test(control.value)) {
|
||||||
|
return {
|
||||||
|
invalidUsername: {
|
||||||
|
value: control.value,
|
||||||
|
message:
|
||||||
|
'نام کاربری فقط میتواند شامل حروف انگلیسی، اعداد، خط تیره (-) و زیرخط (_) باشد',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
@if (loading) {
|
|
||||||
<shared-page-loading />
|
|
||||||
} @else if (!invoice) {
|
|
||||||
<uikit-empty-state> </uikit-empty-state>
|
|
||||||
} @else {
|
|
||||||
<div class="flex flex-col gap-6">
|
|
||||||
<app-card-data cardTitle="اطلاعات فاکتور" [editable]="false">
|
|
||||||
<ng-template #moreActions>
|
|
||||||
<button pButton type="button" label="چاپ" icon="pi pi-print" outlined (click)="printInvoice()"></button>
|
|
||||||
</ng-template>
|
|
||||||
<div class="flex flex-col gap-4">
|
|
||||||
<div class="grid grid-cols-3 gap-4 items-center">
|
|
||||||
<app-key-value label="کد رهگیری" [value]="invoice.code" />
|
|
||||||
<app-key-value label="تاریخ فاکتور" [value]="invoice.invoice_date" type="dateTime" />
|
|
||||||
<app-key-value label="تاریخ ایجاد فاکتور" [value]="invoice.created_at" type="dateTime" />
|
|
||||||
<app-key-value label="وضعیت صدور به سامانهی مودیان">
|
|
||||||
<p-badge value="ارسال نشده" severity="danger" />
|
|
||||||
</app-key-value>
|
|
||||||
<div class="col-span-3">
|
|
||||||
<app-key-value label="توضیحات" [value]="invoice.notes" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p-divider align="center"> اطلاعات پرداخت </p-divider>
|
|
||||||
<div class="grid grid-cols-3 gap-4 items-center">
|
|
||||||
<app-key-value label="مجموع قابل پرداخت" [value]="invoice.total_amount" type="price" />
|
|
||||||
@for (payment of invoice.payments; track $index) {
|
|
||||||
<app-key-value
|
|
||||||
[label]="`${payment.payment_method === 'SET_OF' ? 'تهاتر' : payment.payment_method === 'TERMINAL' ? 'پایانه' : 'نقدی'}`"
|
|
||||||
[value]="payment.amount"
|
|
||||||
type="price"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p-divider align="center"> اطلاعات صادر کننده </p-divider>
|
|
||||||
<div class="grid grid-cols-3 gap-4 items-center">
|
|
||||||
<app-key-value label="کسب و کار" [value]="invoice.pos!.complex.business_activity.name" />
|
|
||||||
<app-key-value label="مجموعه" [value]="invoice.pos!.complex.name" />
|
|
||||||
<app-key-value label="پایانهی فروش" [value]="invoice.pos!.name" />
|
|
||||||
<app-key-value label="ایجاد کننده" [value]="invoice.consumer_account.account.username" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@if (variant !== "customer") {
|
|
||||||
<p-divider align="center"> اطلاعات مشتری </p-divider>
|
|
||||||
@if (invoice.customer) {
|
|
||||||
<div class="grid grid-cols-3 gap-4 items-center">
|
|
||||||
@if (invoice.customer.type === "INDIVIDUAL") {
|
|
||||||
<app-key-value label="نوع مشتری" value="حقیقی" />
|
|
||||||
<app-key-value label="نام" [value]="invoice.customer.individual?.first_name" />
|
|
||||||
<app-key-value label="نام خانوادگی" [value]="invoice.customer.individual?.last_name" />
|
|
||||||
<app-key-value label="کد اقتصادی" [value]="invoice.customer.individual?.economic_code" />
|
|
||||||
<app-key-value label="کد ملی" [value]="invoice.customer.individual?.national_id" />
|
|
||||||
<app-key-value label="کد پستی" [value]="invoice.customer.individual?.postal_code" />
|
|
||||||
} @else {
|
|
||||||
<app-key-value label="نوع مشتری" value="حقوقی" />
|
|
||||||
<app-key-value label="نام شرکت" [value]="invoice.customer.legal?.company_name" />
|
|
||||||
<app-key-value label="کد اقتصادی" [value]="invoice.customer.legal?.economic_code" />
|
|
||||||
<app-key-value label="کد ثبتی" [value]="invoice.customer.legal?.registration_number" />
|
|
||||||
<app-key-value label="کد پستی" [value]="invoice.customer.legal?.postal_code" />
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
} @else if (invoice.unknown_customer) {
|
|
||||||
<div class="grid grid-cols-3 gap-4 items-center">
|
|
||||||
<app-key-value label="نوع مشتری" value="نوع دوم" />
|
|
||||||
<app-key-value label="عنوان" [value]="invoice.unknown_customer.name" />
|
|
||||||
<app-key-value label="کد ثبتی" [value]="invoice.unknown_customer.national_code" />
|
|
||||||
</div>
|
|
||||||
} @else {
|
|
||||||
<p class="text-center text-text-color pt-3 pb-5">اطلاعات مشتری ثبت نشده است.</p>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</app-card-data>
|
|
||||||
<app-card-data cardTitle="کالاهای خریداری شده" [editable]="false">
|
|
||||||
<app-page-data-list
|
|
||||||
[columns]="columns"
|
|
||||||
[expandColumns]="expandableColumns"
|
|
||||||
[expandable]="true"
|
|
||||||
expandableItemKey="payload"
|
|
||||||
[items]="invoice.items"
|
|
||||||
[loading]="loading"
|
|
||||||
pageTitle=""
|
|
||||||
[showRefresh]="false"
|
|
||||||
>
|
|
||||||
<ng-template #totalAmount let-item>
|
|
||||||
aaa
|
|
||||||
@if (!item.discount_amount) {
|
|
||||||
<span [appPriceMask]="item.total_amount"></span>
|
|
||||||
} @else {
|
|
||||||
<!-- <div class="flex flex-col items-end">
|
|
||||||
<span class="line-through text-muted-color text-xs" [appPriceMask]="item.total_amount"></span>
|
|
||||||
<span [appPriceMask]="item.total_amount - item.discount_amount"></span>
|
|
||||||
</div> -->
|
|
||||||
}
|
|
||||||
</ng-template>
|
|
||||||
</app-page-data-list>
|
|
||||||
</app-card-data>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
import { Maybe } from '@/core';
|
|
||||||
import { NativeBridgeService } from '@/core/services';
|
|
||||||
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
|
||||||
import { PageLoadingComponent } from '@/shared/components/page-loading.component';
|
|
||||||
import {
|
|
||||||
IColumn,
|
|
||||||
PageDataListComponent,
|
|
||||||
} from '@/shared/components/pageDataList/page-data-list.component';
|
|
||||||
import { PriceMaskDirective } from '@/shared/directives';
|
|
||||||
import { UikitEmptyStateComponent } from '@/uikit';
|
|
||||||
import { getGoodUnitTypeProperties } from '@/utils';
|
|
||||||
import { Component, EventEmitter, inject, Input, Output, TemplateRef, ViewChild } from '@angular/core';
|
|
||||||
import { Badge } from 'primeng/badge';
|
|
||||||
import { ButtonDirective } from 'primeng/button';
|
|
||||||
import { Divider } from 'primeng/divider';
|
|
||||||
import { TableModule } from 'primeng/table';
|
|
||||||
import { ISaleInvoiceFullResponse } from '../../models';
|
|
||||||
|
|
||||||
export type TConsumerSaleInvoice = 'full' | 'customer' | 'pos';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'consumer-saleInvoice-shared',
|
|
||||||
templateUrl: './shared-saleInvoice.component.html',
|
|
||||||
imports: [
|
|
||||||
AppCardComponent,
|
|
||||||
KeyValueComponent,
|
|
||||||
Badge,
|
|
||||||
Divider,
|
|
||||||
ButtonDirective,
|
|
||||||
PageDataListComponent,
|
|
||||||
TableModule,
|
|
||||||
PageLoadingComponent,
|
|
||||||
UikitEmptyStateComponent,
|
|
||||||
PriceMaskDirective,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
export class ConsumerSaleInvoiceSharedComponent {
|
|
||||||
private readonly nativeBridge = inject(NativeBridgeService);
|
|
||||||
|
|
||||||
@Input({ required: true }) loading!: boolean;
|
|
||||||
@Input() invoice?: Maybe<ISaleInvoiceFullResponse>;
|
|
||||||
@Input() variant: TConsumerSaleInvoice = 'full';
|
|
||||||
|
|
||||||
@Output() onRefresh = new EventEmitter<void>();
|
|
||||||
|
|
||||||
@ViewChild('totalAmount', { static: false }) totalAmount!: TemplateRef<any>;
|
|
||||||
|
|
||||||
printInvoice = () => {
|
|
||||||
if (this.nativeBridge.isEnabled()) {
|
|
||||||
const result = this.nativeBridge.print({
|
|
||||||
invoiceId: this.invoice?.id,
|
|
||||||
code: this.invoice?.code,
|
|
||||||
});
|
|
||||||
if (result.success) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.print();
|
|
||||||
};
|
|
||||||
|
|
||||||
columns: IColumn[] = [
|
|
||||||
{
|
|
||||||
field: '',
|
|
||||||
header: '',
|
|
||||||
type: 'index',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'name',
|
|
||||||
header: 'عنوان',
|
|
||||||
type: 'nested',
|
|
||||||
nestedOption: {
|
|
||||||
path: 'good.name',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'unit_price',
|
|
||||||
header: 'قیمت واحد',
|
|
||||||
type: 'price',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'quantity',
|
|
||||||
header: 'مقدار',
|
|
||||||
customDataModel(item) {
|
|
||||||
return `${item.quantity} ${getGoodUnitTypeProperties(item.good.unit_type).quantitySymbolText}`;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'total_amount',
|
|
||||||
header: 'قیمت نهایی',
|
|
||||||
type: 'price',
|
|
||||||
// customDataModel: this.totalAmount,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
expandableColumns: IColumn[] = [
|
|
||||||
{
|
|
||||||
field: 'commission',
|
|
||||||
header: 'کارمزد',
|
|
||||||
type: 'price',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'wages',
|
|
||||||
header: 'اجرت',
|
|
||||||
type: 'price',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'profit',
|
|
||||||
header: 'سود',
|
|
||||||
type: 'price',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
expandedRows: { [key: string]: boolean } = {};
|
|
||||||
|
|
||||||
refresh() {
|
|
||||||
this.onRefresh.emit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,14 +3,14 @@ import { FormBuilder, Validators } from '@angular/forms';
|
|||||||
import { IPosInitialValues } from './pos.model';
|
import { IPosInitialValues } from './pos.model';
|
||||||
|
|
||||||
export const columns: IColumn[] = [
|
export const columns: IColumn[] = [
|
||||||
// { field: 'id', header: 'شناسه', type: 'id' },
|
// // { field: 'id', header: 'شناسه', type: 'id' },
|
||||||
{ field: 'name', header: 'عنوان' },
|
{ field: 'name', header: 'عنوان' },
|
||||||
{ field: 'serial_number', header: 'شماره سریال' },
|
{ field: 'serial_number', header: 'شماره سریال' },
|
||||||
{ field: 'pos_type', header: 'نوع دستگاه' },
|
{ field: 'pos_type', header: 'نوع دستگاه' },
|
||||||
{ field: 'device', header: 'دستگاه', type: 'nested', nestedOption: { path: 'device.name' } },
|
{ field: 'device', header: 'دستگاه', type: 'nested', nestedOption: { path: 'device.name' } },
|
||||||
{
|
{
|
||||||
field: 'provider',
|
field: 'provider',
|
||||||
header: 'ارایهدهنده',
|
header: 'PSP',
|
||||||
type: 'nested',
|
type: 'nested',
|
||||||
nestedOption: { path: 'provider.name' },
|
nestedOption: { path: 'provider.name' },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,29 +8,29 @@ export const CONSUMER_MENU_ITEMS = [
|
|||||||
routerLink: ['/consumer'],
|
routerLink: ['/consumer'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'فعالیتهای اقتصادی',
|
label: 'فعالیت اقتصادی',
|
||||||
icon: 'pi pi-fw pi-home',
|
icon: 'pi pi-fw pi-shop',
|
||||||
routerLink: ['/consumer/business_activities'],
|
routerLink: ['/consumer/business_activities'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'پایانههای فروش',
|
label: 'پایانهی فروش',
|
||||||
icon: 'pi pi-fw pi-home',
|
icon: 'pi pi-fw pi-tablet',
|
||||||
routerLink: ['/consumer/poses'],
|
routerLink: ['/consumer/poses'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'لیست فاکتورها',
|
label: 'صورتحساب',
|
||||||
icon: 'pi pi-fw pi-home',
|
icon: 'pi pi-fw pi-receipt',
|
||||||
routerLink: ['/consumer/sale_invoices'],
|
routerLink: ['/consumer/sale_invoices'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'مشتریان',
|
label: 'مشتری',
|
||||||
icon: 'pi pi-fw pi-home',
|
icon: 'pi pi-fw pi-users',
|
||||||
routerLink: ['/consumer/customers'],
|
routerLink: ['/consumer/customers'],
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
label: 'حسابهای کاربری',
|
label: 'حسابهای کاربری',
|
||||||
icon: 'pi pi-fw pi-home',
|
icon: 'pi pi-fw pi-user',
|
||||||
routerLink: ['/consumer/accounts'],
|
routerLink: ['/consumer/accounts'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,9 +1,31 @@
|
|||||||
|
import { IEnumTranslate } from '@/shared/models/enum_translate.type';
|
||||||
|
|
||||||
export interface IConsumerInfoRawResponse {
|
export interface IConsumerInfoRawResponse {
|
||||||
id: string;
|
id: string;
|
||||||
|
partner: Partner;
|
||||||
|
type: IEnumTranslate<'INDIVIDUAL' | 'LEGAL'>;
|
||||||
|
status: IEnumTranslate<'ACTIVE' | 'INACTIVE'>;
|
||||||
|
legal?: Legal;
|
||||||
|
individual?: Individual;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
export interface IConsumerInfoResponse extends IConsumerInfoRawResponse {}
|
||||||
|
|
||||||
|
interface Individual {
|
||||||
first_name: string;
|
first_name: string;
|
||||||
last_name: string;
|
last_name: string;
|
||||||
mobile_number: string;
|
mobile_number: string;
|
||||||
status: string;
|
national_code: string;
|
||||||
fullname: string;
|
fullname: string;
|
||||||
}
|
}
|
||||||
export interface IConsumerInfoResponse extends IConsumerInfoRawResponse {}
|
|
||||||
|
interface Legal {
|
||||||
|
company_name: string;
|
||||||
|
registration_number: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Partner {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
code: string;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,19 +1,5 @@
|
|||||||
import ISummary from '@/core/models/summary';
|
import ISummary from '@/core/models/summary';
|
||||||
|
import { ISaleInvoiceFullRawResponse } from '@/shared/components/invoices/sale-invoice-full-response.model';
|
||||||
export interface ISaleInvoiceFullRawResponse {
|
|
||||||
id: string;
|
|
||||||
code: string;
|
|
||||||
total_amount: string;
|
|
||||||
invoice_date: string;
|
|
||||||
consumer_account: ConsumerAccount;
|
|
||||||
pos: Pos;
|
|
||||||
payments: Payment[];
|
|
||||||
items: Item[];
|
|
||||||
created_at: string;
|
|
||||||
notes?: string;
|
|
||||||
customer?: Customer;
|
|
||||||
unknown_customer?: UnknownCustomer;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ISaleInvoiceFullResponse extends ISaleInvoiceFullRawResponse {}
|
export interface ISaleInvoiceFullResponse extends ISaleInvoiceFullRawResponse {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
<shared-dialog
|
<shared-dialog
|
||||||
header="ویرایش گذرواژه"
|
header="تغییر رمز عبور"
|
||||||
[(visible)]="visible"
|
[(visible)]="visible"
|
||||||
[modal]="true"
|
[modal]="true"
|
||||||
[style]="{ width: '500px' }"
|
[style]="{ width: '500px' }"
|
||||||
[closable]="true"
|
[closable]="true"
|
||||||
(onHide)="close()"
|
(onHide)="close()">
|
||||||
>
|
|
||||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||||
<shared-password-input
|
<shared-password-input
|
||||||
[passwordControl]="form.controls.password"
|
[passwordControl]="form.controls.password"
|
||||||
[confirmPasswordControl]="form.controls.confirmPassword"
|
[confirmPasswordControl]="form.controls.confirmPassword" />
|
||||||
/>
|
|
||||||
|
|
||||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<div class="flex flex-col gap-6">
|
<div class="flex flex-col gap-4">
|
||||||
<app-card-data cardTitle="مدیریت سطح دسترسی">
|
<app-card-data cardTitle="مدیریت سطح دسترسی">
|
||||||
@if (isOwner()) {
|
@if (isOwner()) {
|
||||||
<div class="py-20 flex items-center justify-center">
|
<div class="flex items-center justify-center py-20">
|
||||||
کاربر با سطح Owner به تمامی سطوح دسترسی داشته و قابل ویرایش نمیباشد
|
کاربر با سطح Owner به تمامی سطوح دسترسی داشته و قابل ویرایش نمیباشد
|
||||||
</div>
|
</div>
|
||||||
} @else if (loading()) {
|
} @else if (loading()) {
|
||||||
<div class="py-20 flex items-center justify-center">
|
<div class="flex items-center justify-center py-20">
|
||||||
<p-progressSpinner />
|
<p-progressSpinner />
|
||||||
</div>
|
</div>
|
||||||
} @else if (permissions()) {
|
} @else if (permissions()) {
|
||||||
<div class="flex flex-col gap-6">
|
<div class="flex flex-col gap-4">
|
||||||
<p-message severity="secondary"> پیام مفهومی برای مشخص کردن نوع دسترسی دادن</p-message>
|
<p-message severity="secondary"> پیام مفهومی برای مشخص کردن نوع دسترسی دادن</p-message>
|
||||||
@for (pos of permissions()?.poses; track $index) {
|
@for (pos of permissions()?.poses; track $index) {
|
||||||
<div class="flex items-center gap-4">
|
<div class="flex items-center gap-4">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { EntityState, EntityStore } from '@/core/state';
|
import { defaultBaseStateData, EntityState, EntityStore } from '@/core/state';
|
||||||
import { computed, inject, Injectable } from '@angular/core';
|
import { computed, inject, Injectable } from '@angular/core';
|
||||||
import { MenuItem } from 'primeng/api';
|
import { MenuItem } from 'primeng/api';
|
||||||
import { catchError, finalize } from 'rxjs';
|
import { catchError, finalize } from 'rxjs';
|
||||||
@@ -17,11 +17,7 @@ export class AccountStore extends EntityStore<IAccountResponse, AccountState> {
|
|||||||
private readonly service = inject(AccountsService);
|
private readonly service = inject(AccountsService);
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
loading: false,
|
...defaultBaseStateData,
|
||||||
error: null,
|
|
||||||
entity: null,
|
|
||||||
initialized: false,
|
|
||||||
isRefreshing: false,
|
|
||||||
breadcrumbItems: [],
|
breadcrumbItems: [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -64,11 +60,7 @@ export class AccountStore extends EntityStore<IAccountResponse, AccountState> {
|
|||||||
|
|
||||||
override reset(): void {
|
override reset(): void {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: false,
|
...defaultBaseStateData,
|
||||||
error: null,
|
|
||||||
entity: null,
|
|
||||||
initialized: false,
|
|
||||||
isRefreshing: false,
|
|
||||||
breadcrumbItems: [],
|
breadcrumbItems: [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
IChangePasswordSubmitPayload,
|
IChangePasswordSubmitPayload,
|
||||||
} from '@/shared/components';
|
} from '@/shared/components';
|
||||||
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
|
import { PageDataListComponent } from '@/shared/components/pageDataList/page-data-list.component';
|
||||||
|
import { accountListConfig } from '@/shared/constants/list-configs';
|
||||||
import { Component, inject, signal } from '@angular/core';
|
import { Component, inject, signal } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { finalize } from 'rxjs';
|
import { finalize } from 'rxjs';
|
||||||
@@ -23,27 +24,7 @@ export class ConsumerAccountsComponent extends AbstractList<IAccountResponse> {
|
|||||||
passwordSubmitLoading = signal(false);
|
passwordSubmitLoading = signal(false);
|
||||||
|
|
||||||
override setColumns(): void {
|
override setColumns(): void {
|
||||||
this.columns = [
|
this.columns = accountListConfig.columns;
|
||||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
|
||||||
{
|
|
||||||
field: 'username',
|
|
||||||
header: 'نام کاربری',
|
|
||||||
type: 'nested',
|
|
||||||
nestedOption: { path: 'account.username' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'pos',
|
|
||||||
header: 'پایانه',
|
|
||||||
customDataModel(item) {
|
|
||||||
return `${item.pos.name} - ${item.pos.complex.name} - ${item.pos.complex.business_activity.name}`;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'created_at',
|
|
||||||
header: 'تاریخ ایجاد',
|
|
||||||
type: 'date',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override getDataRequest() {
|
override getDataRequest() {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="flex flex-col gap-6">
|
<div class="flex flex-col gap-4">
|
||||||
<app-card-data cardTitle="اطلاعات کاربری" [editable]="false" [(editMode)]="editMode">
|
<app-card-data cardTitle="اطلاعات کاربری" [editable]="false" [(editMode)]="editMode">
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<div class="grid grid-cols-3 gap-4 items-center">
|
<div class="listKeyValue">
|
||||||
<app-key-value label="نام کاربری" [value]="account()?.account?.username" />
|
<app-key-value label="نام کاربری" [value]="account()?.account?.username" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
// import { CatalogRolesComponent } from '@/shared/catalog/roles';
|
// import { CatalogRolesComponent } from '@/shared/catalog/roles';
|
||||||
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||||
import {
|
import { AddressComponent, BranchCodeComponent, NameComponent } from '@/shared/components';
|
||||||
NameComponent,
|
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
||||||
AddressComponent,
|
|
||||||
BranchCodeComponent,
|
|
||||||
} from '@/shared/components';
|
|
||||||
import { fieldControl } from '@/shared/constants/fields';
|
|
||||||
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||||
|
import { fieldControl } from '@/shared/constants/fields';
|
||||||
import { Component, inject, Input } from '@angular/core';
|
import { Component, inject, Input } from '@angular/core';
|
||||||
import { ReactiveFormsModule } from '@angular/forms';
|
import { ReactiveFormsModule } from '@angular/forms';
|
||||||
import { IComplexRequest, IComplexResponse } from '../../models';
|
import { IComplexRequest, IComplexResponse } from '../../models';
|
||||||
import { ConsumerComplexesService } from '../../services/complexes.service';
|
import { ConsumerComplexesService } from '../../services/complexes.service';
|
||||||
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'consumer-complex-form',
|
selector: 'consumer-complex-form',
|
||||||
@@ -45,7 +41,7 @@ export class ConsumerComplexFormComponent extends AbstractFormDialog<
|
|||||||
form = this.initForm();
|
form = this.initForm();
|
||||||
|
|
||||||
get preparedTitle() {
|
get preparedTitle() {
|
||||||
return `${this.editMode ? 'ویرایش' : 'ایجاد'} شعبه`;
|
return `${this.editMode ? 'ویرایش' : 'افزودن'} شعبه`;
|
||||||
}
|
}
|
||||||
|
|
||||||
override ngOnChanges(): void {
|
override ngOnChanges(): void {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<app-page-data-list
|
<app-page-data-list
|
||||||
pageTitle="مدیریت شعب"
|
pageTitle="مدیریت شعب"
|
||||||
[addNewCtaLabel]="'افزودن شعبه جدید'"
|
[addNewCtaLabel]="'افزودن شعبه'"
|
||||||
[showAdd]="true"
|
[showAdd]="true"
|
||||||
[columns]="columns"
|
[columns]="columns"
|
||||||
[showAdd]="true"
|
[showAdd]="true"
|
||||||
emptyPlaceholderTitle="شعبهای یافت نشد."
|
emptyPlaceholderTitle="شعبهای یافت نشد."
|
||||||
emptyPlaceholderDescription="برای افزودن شعبه جدید، روی دکمهٔ بالا کلیک کنید."
|
emptyPlaceholderDescription="برای افزودن شعبه، روی دکمهٔ بالا کلیک کنید."
|
||||||
[items]="items()"
|
[items]="items()"
|
||||||
[loading]="loading()"
|
[loading]="loading()"
|
||||||
[showDetails]="true"
|
[showDetails]="true"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
IColumn,
|
IColumn,
|
||||||
PageDataListComponent,
|
PageDataListComponent,
|
||||||
} from '@/shared/components/pageDataList/page-data-list.component';
|
} from '@/shared/components/pageDataList/page-data-list.component';
|
||||||
|
import { complexListConfig } from '@/shared/constants/list-configs';
|
||||||
import { Component, inject, Input } from '@angular/core';
|
import { Component, inject, Input } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { consumerComplexesNamedRoutes } from '../../constants/routes/complexes';
|
import { consumerComplexesNamedRoutes } from '../../constants/routes/complexes';
|
||||||
@@ -19,16 +20,7 @@ import { ConsumerComplexFormComponent } from './form.component';
|
|||||||
export class ConsumerComplexListComponent extends AbstractList<IComplexResponse> {
|
export class ConsumerComplexListComponent extends AbstractList<IComplexResponse> {
|
||||||
@Input({ required: true }) businessId!: string;
|
@Input({ required: true }) businessId!: string;
|
||||||
@Input() fullHeight?: boolean;
|
@Input() fullHeight?: boolean;
|
||||||
@Input() header: IColumn[] = [
|
@Input() header: IColumn[] = complexListConfig.columns;
|
||||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
|
||||||
{ field: 'name', header: 'عنوان' },
|
|
||||||
{ field: 'branch_code', header: 'کد شعبه' },
|
|
||||||
{
|
|
||||||
field: 'created_at',
|
|
||||||
header: 'تاریخ ایجاد',
|
|
||||||
type: 'date',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
private readonly service = inject(ConsumerComplexesService);
|
private readonly service = inject(ConsumerComplexesService);
|
||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
|
|||||||
@@ -4,13 +4,13 @@
|
|||||||
[modal]="true"
|
[modal]="true"
|
||||||
[style]="{ width: '500px' }"
|
[style]="{ width: '500px' }"
|
||||||
[closable]="true"
|
[closable]="true"
|
||||||
(onHide)="close()"
|
(onHide)="close()">
|
||||||
>
|
|
||||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||||
<field-name [control]="form.controls.name" />
|
<field-name [control]="form.controls.name" />
|
||||||
<field-economic-code [control]="form.controls.economic_code" />
|
<field-individual-economic-code [control]="form.controls.economic_code" />
|
||||||
<field-fiscal-code [control]="form.controls.fiscal_code" />
|
<field-fiscal-id [control]="form.controls.fiscal_id" />
|
||||||
<field-partner-token [control]="form.controls.partner_token" />
|
<field-partner-token [control]="form.controls.partner_token" />
|
||||||
|
<field-invoice-number-sequence [control]="form.controls.invoice_number_sequence" [min]="1" />
|
||||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||||
</form>
|
</form>
|
||||||
</shared-dialog>
|
</shared-dialog>
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
import { AbstractFormDialog } from '@/shared/abstractClasses';
|
||||||
import {
|
import {
|
||||||
EconomicCodeComponent,
|
FiscalIdComponent,
|
||||||
FiscalCodeComponent,
|
IndividualEconomicCodeComponent,
|
||||||
NameComponent,
|
NameComponent,
|
||||||
PartnerTokenComponent,
|
PartnerTokenComponent,
|
||||||
} from '@/shared/components';
|
} from '@/shared/components';
|
||||||
|
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
||||||
|
import { InvoiceNumberSequenceComponent } from '@/shared/components/fields/invoice_number_sequence.component';
|
||||||
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||||
import { fieldControl } from '@/shared/constants/fields';
|
import { fieldControl } from '@/shared/constants/fields';
|
||||||
import { Component, inject, Input } from '@angular/core';
|
import { Component, inject, Input } from '@angular/core';
|
||||||
import { ReactiveFormsModule } from '@angular/forms';
|
import { ReactiveFormsModule } from '@angular/forms';
|
||||||
import { IBusinessActivityRequest, IBusinessActivityResponse } from '../models';
|
import { IBusinessActivityRequest, IBusinessActivityResponse } from '../models';
|
||||||
import { BusinessActivitiesService } from '../services/main.service';
|
import { BusinessActivitiesService } from '../services/main.service';
|
||||||
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'consumer-businessActivity-form',
|
selector: 'consumer-businessActivity-form',
|
||||||
@@ -21,9 +22,10 @@ import { SharedDialogComponent } from '@/shared/components/dialog/dialog.compone
|
|||||||
SharedDialogComponent,
|
SharedDialogComponent,
|
||||||
FormFooterActionsComponent,
|
FormFooterActionsComponent,
|
||||||
NameComponent,
|
NameComponent,
|
||||||
EconomicCodeComponent,
|
IndividualEconomicCodeComponent,
|
||||||
FiscalCodeComponent,
|
|
||||||
PartnerTokenComponent,
|
PartnerTokenComponent,
|
||||||
|
InvoiceNumberSequenceComponent,
|
||||||
|
FiscalIdComponent,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class ConsumerBusinessActivityFormComponent extends AbstractFormDialog<
|
export class ConsumerBusinessActivityFormComponent extends AbstractFormDialog<
|
||||||
@@ -35,12 +37,18 @@ export class ConsumerBusinessActivityFormComponent extends AbstractFormDialog<
|
|||||||
|
|
||||||
form = this.fb.group({
|
form = this.fb.group({
|
||||||
name: fieldControl.name(this.initialValues?.name || ''),
|
name: fieldControl.name(this.initialValues?.name || ''),
|
||||||
economic_code: fieldControl.economic_code(this.initialValues?.economic_code || ''),
|
economic_code: fieldControl.individual_economic_code(this.initialValues?.economic_code || ''),
|
||||||
fiscal_code: fieldControl.fiscal_code(this.initialValues?.fiscal_code || ''),
|
fiscal_id: fieldControl.fiscal_id(this.initialValues?.fiscal_id || ''),
|
||||||
partner_token: fieldControl.partner_token(this.initialValues?.partner_token || ''),
|
partner_token: fieldControl.partner_token(this.initialValues?.partner_token || ''),
|
||||||
|
invoice_number_sequence: fieldControl.invoice_number_sequence(
|
||||||
|
this.initialValues?.invoice_number_sequence || 1
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
override submitForm(payload: IBusinessActivityRequest) {
|
override submitForm(payload: IBusinessActivityRequest) {
|
||||||
return this.service.update(this.businessId, payload);
|
return this.service.update(this.businessId, {
|
||||||
|
...payload,
|
||||||
|
economic_code: payload.economic_code.toString(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,10 @@
|
|||||||
<shared-dialog [header]="preparedTitle" [(visible)]="visible" [modal]="true" [style]="{ width: '500px' }" [closable]="true">
|
<shared-good-form-dialog
|
||||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
[guildId]="guildId"
|
||||||
<app-input label="عنوان" [control]="form.controls.name" name="name" />
|
[visible]="visible"
|
||||||
<app-input label="شناسه عمومی" [control]="form.controls.sku" name="sku" />
|
(visibleChange)="visibleChange.emit($event)"
|
||||||
<catalog-guild-goodCategories-select
|
[initialValues]="initialValues"
|
||||||
[guildId]="guildId"
|
[editMode]="editMode"
|
||||||
label="دستهبندی"
|
[createFn]="create"
|
||||||
[control]="form.controls.category_id"
|
[updateFn]="update"
|
||||||
name="category_id"
|
(onSubmit)="onSubmit.emit($event)"
|
||||||
/>
|
(onClose)="onClose.emit()" />
|
||||||
<app-enum-select type="unitType" [control]="form.controls.unit_type" />
|
|
||||||
<app-enum-select type="goodPricingModel" [control]="form.controls.pricing_model" />
|
|
||||||
<app-input label="توضیحات" [control]="form.controls.description" name="description" />
|
|
||||||
|
|
||||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
|
||||||
</form>
|
|
||||||
</shared-dialog>
|
|
||||||
|
|||||||