Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a036d7b
Merge pull request #1 from ryocoding13/feature/customer-ui-figma
ryocoding13 Sep 22, 2026
5177812
Merge pull request #2 from ryocoding13/feature/customer-ui-figma
ryocoding13 Sep 23, 2026
6b583da
docs: thêm bộ harness cho AI coding agent
VectorNguyen Sep 26, 2026
845abdf
docs: cập nhật harness sau phiên 2 (D12–D15, F11–F21 chờ /api/ops/*, …
VectorNguyen Oct 1, 2026
34ddb73
Merge pull request #3 from ryocoding13/docs/ai-harness
VectorNguyen Oct 1, 2026
9fd076c
Merge branch 'main' into feature/customer-ui-figma
VectorNguyen Oct 1, 2026
ec716f4
Merge pull request #4 from ryocoding13/feature/customer-ui-figma
VectorNguyen Oct 1, 2026
1b41650
Code adjustment
TienPhanSE Oct 12, 2026
57bfe0a
Merge pull request from ryocoding13/Tien
TienPhanSE Oct 12, 2026
9a51d99
feat(F24,F22,F23): backend khu Quản lý vận hành KD (/api/operations)
VectorNguyen Oct 14, 2026
8d4e073
Merge pull request #7 from ryocoding13/feature/operations-backend
ryocoding13 Oct 14, 2026
4500d80
feat(F30): đồng bộ giao diện với Figma mới nhất sửa những lỗi thầy co…
VectorNguyen Oct 14, 2026
86af076
feat(F03,F11-F21): backend khu Nhân viên / Quản lý cơ sở, confirm-tra…
VectorNguyen Oct 14, 2026
4ae32ad
feat(business-ops): hoan thien giao dien frontend Quan ly van hanh KD
TienPhanSE Oct 15, 2026
57d3fd4
Merge pull request #11 from ryocoding13/branch01
TienPhanSE Oct 15, 2026
c9b72cf
feat(B05a,C02m): toạ độ cơ sở trong database, sửa ở B05a
VectorNguyen Oct 15, 2026
a6c3eef
chore: migration AddFacilityCoordinates
VectorNguyen Oct 15, 2026
a771f5e
chore: xoá tài liệu trùng (bản copy operations-api, báo cáo frontend KD)
VectorNguyen Oct 15, 2026
94f3c63
Merge pull request #8 from ryocoding13/feature/figma-1410-sync
ryocoding13 Oct 16, 2026
532cb74
Merge pull request #9 from ryocoding13/feature/ops-backend
ryocoding13 Oct 16, 2026
fef7249
Merge branch 'main' into feature/facility-coordinates
ryocoding13 Oct 16, 2026
fc5c505
Merge pull request #13 from ryocoding13/chore/cleanup-docs
ryocoding13 Oct 16, 2026
afd70c7
Merge pull request #12 from ryocoding13/feature/facility-coordinates
ryocoding13 Oct 16, 2026
aafb2c1
feat(C07): xem va mo phong quet QR mo cua kho (frontend)
TienPhanSE Oct 16, 2026
b4b6ec9
Merge pull request #14 from ryocoding13/feature/c07-qr-frontend
TienPhanSE Oct 16, 2026
b8d37e0
feat: local work (PayOS integration, Staff/Manager endpoints, DbSeede…
ryocoding13 Oct 16, 2026
836967b
Merge branch 'feature/local-backup' into main
ryocoding13 Oct 16, 2026
2e6c7aa
feat(F33): đồng bộ giao diện Figma 16/10, nối PayOS create-payos-qr v…
VectorNguyen Oct 16, 2026
cfae3f1
feat(F33): triển khai backend QR mở cửa (C07q, C07r) và kết nối frontend
ryocoding13 Oct 16, 2026
f9d6d18
Merge pull request #15 from ryocoding13/feature/figma-1610-sync
ryocoding13 Oct 16, 2026
6dfe1d8
Merge branch 'origin/main': kết hợp đồng bộ Figma 16/10 và backend QR…
ryocoding13 Oct 16, 2026
baaf3a0
fix(payment): sửa lỗi thiếu tiền cọc khi tạo mã thanh toán PayOS đơn …
ryocoding13 Oct 16, 2026
c128cf8
Raise timer to 15p
ryocoding13 Oct 17, 2026
242f701
Chỉnh sửa lại tí DB
ryocoding13 Oct 17, 2026
b482840
fix: reconcile payments, enforce unit transitions and fix policy seeding
VectorNguyen Oct 20, 2026
addb06e
refactor: organize frontend by role
VectorNguyen Oct 20, 2026
327ab5e
refactor: organize frontend by role
VectorNguyen Oct 20, 2026
6b1b751
Merge pull request #16 from ryocoding13/feature/payment-integrity-and…
ryocoding13 Oct 21, 2026
b572008
Merge pull request #17 from ryocoding13/feature/frontend-structure-an…
ryocoding13 Oct 21, 2026
6869de7
Sửa một số lỗi frontend và backend chưa đồng bộ
ryocoding13 Oct 21, 2026
7006823
Update admin
TienPhanSE Oct 21, 2026
fc83c3a
Merge pull request #18 from ryocoding13/Tien
TienPhanSE Oct 21, 2026
4ed4451
feat: hoan thien backend ho so va phan hoi ho tro
maingocse Oct 21, 2026
e615dad
feat: hoan thien frontend C12 C13 theo Figma
maingocse Oct 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
43 changes: 43 additions & 0 deletions .agents/skills/resetdb/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: resetdb
description: >-
Reset toàn bộ cơ sở dữ liệu SSFRMS (SQL Server) về trạng thái hệ thống mới mở (zero customer activity).
Sử dụng khi người dùng yêu cầu reset database, làm sạch giao dịch, hoặc gõ /resetdb, /reset-db.
---

# Reset SSFRMS Database to Fresh Launch State

This skill automates the complete reset of the SafeSpace (SSFRMS) SQL Server database (`SSFRMS`) to a Day 1 fresh operational state:
- Zero customer transactions (reservations, contracts, payments, tickets, handovers, return inspections, overdue cases, assignments).
- All 144 physical storage units (K01–K12 across 12 facilities) reset to `AVAILABLE` (decommissioned legacy units and non-K units removed).
- All temporary test accounts and activity/login logs deleted.
- Preserves all essential system master data: facilities, unit types, rental rates, policies, roles, permissions.
- Preserves default system accounts: `admin`, `manager01`, `staff01`, `ops01` (`OPERATIONS`), `customer01`, `customer02`.

---

## Instructions for Agent

When the user invokes `/resetdb` or asks to reset the database:

### Step 1: Execute the Automated Reset Script
Run the PowerShell reset script located in `scripts/reset-db.ps1`:

```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File .agents/skills/resetdb/scripts/reset-db.ps1
```

### Step 2: Validate Verification Output
Check the output from the script:
- All transaction tables must display `[PASS] <table_name> : 0 rows`.
- Storage units status must show `AVAILABLE 144`.
- Active seed accounts must list `admin`, `staff01`, `customer01`, `customer02`, `manager01`, `ops01`.

### Step 3: Respond to User
Inform the user that the database has been cleanly reset, and provide the credential table from [references/credentials.md](./references/credentials.md):
- `admin` / `Admin@123`
- `ops01` / `Ops@123` (`OPERATIONS`)
- `manager01` / `Manager@123`
- `staff01` / `Staff@123`
- `customer01` / `Customer@123`
- `customer02` / `Customer@123`
18 changes: 18 additions & 0 deletions .agents/skills/resetdb/references/credentials.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# SafeSpace (SSFRMS) — Default Seed Accounts

After resetting the database with `/resetdb`, the following accounts are ready to use:

| Role | Username | Password | Full Name | Facility Scope | Notes |
|---|---|---|---|---|---|
| **ADMIN** | `admin` | `Admin@123` | Hệ Thống Admin | Toàn hệ thống | Quản trị viên tối cao, toàn quyền cấu hình & phân quyền |
| **OPERATIONS** | `ops01` | `Ops@123` | Lê Vận Hành | Cơ sở Nguyễn Lương Bằng | Quản lý vận hành kinh doanh, báo cáo & audit log |
| **MANAGER** | `manager01` | `Manager@123` | Phạm Thu Hà | Cơ sở Nguyễn Lương Bằng | Quản lý cơ sở kho, duyệt gia hạn, phân bổ kho, đối soát |
| **STAFF** | `staff01` | `Staff@123` | Trần Nhân Viên | Cơ sở Nguyễn Lương Bằng | Nhân viên vận hành, bàn giao, kiểm tra trả kho, đối soát |
| **CUSTOMER** | `customer01` | `Customer@123` | Nguyễn Văn An | Khách hàng | Khách hàng mới, 0 đơn đặt chỗ, 0 hợp đồng |
| **CUSTOMER** | `customer02` | `Customer@123` | Trần Thị Mai | Khách hàng | Khách hàng mới, 0 đơn đặt chỗ, 0 hợp đồng |

## Storage Units Status
- Total Units: 72
- Available: 72 (100%)
- Occupied: 0
- Reserved: 0
95 changes: 95 additions & 0 deletions .agents/skills/resetdb/scripts/reset-db.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# =========================================================================
# reset-db.ps1: Automated reset script for SSFRMS
# Can be run standalone or invoked by Antigravity /resetdb skill
# =========================================================================

param(
[string]$ServerInstance = ".\SQLEXPRESS",
[string]$Database = "SSFRMS"
)

$ErrorActionPreference = "Stop"
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$SqlFile = Join-Path $ScriptDir "reset_db.sql"

Write-Host "======================================================" -ForegroundColor Cyan
Write-Host " SafeSpace (SSFRMS) - Database Reset to Fresh State " -ForegroundColor Cyan
Write-Host "======================================================" -ForegroundColor Cyan
Write-Host "Target Server : $ServerInstance"
Write-Host "Target Database : $Database"
Write-Host "SQL Script : $SqlFile"
Write-Host ""

if (-not (Test-Path $SqlFile)) {
Write-Host "[ERROR] Cannot find SQL file: $SqlFile" -ForegroundColor Red
exit 1
}

# 1. Execute SQL reset script
Write-Host "[1/3] Executing database cleanup..." -ForegroundColor Yellow
$result = sqlcmd -I -S $ServerInstance -d $Database -i $SqlFile -b
if ($LASTEXITCODE -ne 0) {
Write-Host "[ERROR] sqlcmd failed with exit code $LASTEXITCODE" -ForegroundColor Red
Write-Host $result
exit 1
}
Write-Host "Cleanup completed successfully." -ForegroundColor Green

# 2. Verify transaction table counts
Write-Host ""
Write-Host "[2/3] Verifying clean transaction state..." -ForegroundColor Yellow
$verifySql = @"
SELECT 'reservations' as tbl, COUNT(*) as cnt FROM reservations
UNION ALL SELECT 'rental_contracts', COUNT(*) FROM rental_contracts
UNION ALL SELECT 'payments', COUNT(*) FROM payments
UNION ALL SELECT 'support_tickets', COUNT(*) FROM support_tickets
UNION ALL SELECT 'handover_records', COUNT(*) FROM handover_records
UNION ALL SELECT 'return_inspections', COUNT(*) FROM return_inspections
UNION ALL SELECT 'unit_assignments', COUNT(*) FROM unit_assignments
UNION ALL SELECT 'maintenance_requests', COUNT(*) FROM maintenance_requests
UNION ALL SELECT 'contract_renewals', COUNT(*) FROM contract_renewals
UNION ALL SELECT 'overdue_cases', COUNT(*) FROM overdue_cases
UNION ALL SELECT 'access_credentials', COUNT(*) FROM access_credentials
UNION ALL SELECT 'activity_logs', COUNT(*) FROM activity_logs;
"@

$counts = sqlcmd -S $ServerInstance -d $Database -Q $verifySql -h -1 -W
$allZero = $true
$lines = $counts -split "`r?`n" | Where-Object { $_ -match '^\w+\s+\d+' }
foreach ($line in $lines) {
$parts = $line.Trim() -split '\s+'
if ($parts.Length -ge 2) {
$table = $parts[0]
$cnt = [int]$parts[1]
if ($cnt -ne 0) {
Write-Host " [FAIL] $table : $cnt rows" -ForegroundColor Red
$allZero = $false
} else {
Write-Host " [PASS] $table : 0 rows" -ForegroundColor Gray
}
}
}

if (-not $allZero) {
Write-Host "[ERROR] Some tables still have remaining rows!" -ForegroundColor Red
exit 1
}

# 3. Verify storage unit availability & accounts
Write-Host ""
Write-Host "[3/3] Checking storage units & seed accounts..." -ForegroundColor Yellow

$unitSql = "SELECT Status, COUNT(*) as cnt FROM storage_units GROUP BY Status;"
$unitResult = sqlcmd -S $ServerInstance -d $Database -Q $unitSql -h -1 -W
Write-Host "Storage Units status:" -ForegroundColor Cyan
Write-Host $unitResult

$userSql = "SELECT u.Username, r.RoleName FROM users u JOIN user_roles ur ON u.UserId = ur.UserId JOIN roles r ON ur.RoleId = r.RoleId ORDER BY u.UserId;"
$userResult = sqlcmd -S $ServerInstance -d $Database -Q $userSql -h -1 -W
Write-Host "Active Seed Accounts:" -ForegroundColor Cyan
Write-Host $userResult

Write-Host ""
Write-Host "======================================================" -ForegroundColor Green
Write-Host " DATABASE RESET COMPLETED - 100% CLEAN & READY! " -ForegroundColor Green
Write-Host "======================================================" -ForegroundColor Green
88 changes: 88 additions & 0 deletions .agents/skills/resetdb/scripts/reset_db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
-- =========================================================================
-- reset_db.sql: Reset SSFRMS database to pristine "Day 1" launch state
-- - Zero customer transactions / activity
-- - All 72 storage units set to 'AVAILABLE'
-- - Default seed roles, facilities, unit types, rates, policies preserved
-- - Default accounts (admin, staff01, manager01, ops01, customer01, customer02) preserved
-- - All temporary non-seeded accounts and logs deleted
-- =========================================================================

SET NOCOUNT ON;
SET QUOTED_IDENTIFIER ON;
SET ANSI_NULLS ON;

-- 1. Disable all foreign key constraints
EXEC sp_msforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all';

-- 2. Clear all customer transaction & activity tables
DELETE FROM [activity_logs];
DELETE FROM [login_history];
DELETE FROM [access_credentials];
DELETE FROM [overdue_cases];
DELETE FROM [contract_renewals];
DELETE FROM [maintenance_requests];
DELETE FROM [unit_assignments];
DELETE FROM [unit_status_history];
DELETE FROM [return_inspections];
DELETE FROM [handover_records];
DELETE FROM [support_tickets];
DELETE FROM [payments];
DELETE FROM [rental_contracts];
DELETE FROM [reservations];

-- 3. Reset identities on transaction tables so IDs start clean from 1
IF OBJECT_ID('reservations') IS NOT NULL DBCC CHECKIDENT ('reservations', RESEED, 0);
IF OBJECT_ID('rental_contracts') IS NOT NULL DBCC CHECKIDENT ('rental_contracts', RESEED, 0);
IF OBJECT_ID('payments') IS NOT NULL DBCC CHECKIDENT ('payments', RESEED, 0);
IF OBJECT_ID('support_tickets') IS NOT NULL DBCC CHECKIDENT ('support_tickets', RESEED, 0);
IF OBJECT_ID('handover_records') IS NOT NULL DBCC CHECKIDENT ('handover_records', RESEED, 0);
IF OBJECT_ID('return_inspections') IS NOT NULL DBCC CHECKIDENT ('return_inspections', RESEED, 0);
IF OBJECT_ID('unit_assignments') IS NOT NULL DBCC CHECKIDENT ('unit_assignments', RESEED, 0);
IF OBJECT_ID('maintenance_requests') IS NOT NULL DBCC CHECKIDENT ('maintenance_requests', RESEED, 0);
IF OBJECT_ID('contract_renewals') IS NOT NULL DBCC CHECKIDENT ('contract_renewals', RESEED, 0);
IF OBJECT_ID('overdue_cases') IS NOT NULL DBCC CHECKIDENT ('overdue_cases', RESEED, 0);
IF OBJECT_ID('access_credentials') IS NOT NULL DBCC CHECKIDENT ('access_credentials', RESEED, 0);
IF OBJECT_ID('activity_logs') IS NOT NULL DBCC CHECKIDENT ('activity_logs', RESEED, 0);
IF OBJECT_ID('login_history') IS NOT NULL DBCC CHECKIDENT ('login_history', RESEED, 0);
IF OBJECT_ID('unit_status_history') IS NOT NULL DBCC CHECKIDENT ('unit_status_history', RESEED, 0);

-- 4. Delete non-seeded test users (keep only system seed accounts)
DELETE FROM [user_roles]
WHERE UserId IN (
SELECT UserId FROM [users]
WHERE Username NOT IN ('admin', 'staff01', 'manager01', 'ops01', 'customer01', 'customer02')
);

DELETE FROM [user_facilities]
WHERE UserId IN (
SELECT UserId FROM [users]
WHERE Username NOT IN ('admin', 'staff01', 'manager01', 'ops01', 'customer01', 'customer02')
);

DELETE FROM [users]
WHERE Username NOT IN ('admin', 'staff01', 'manager01', 'ops01', 'customer01', 'customer02');

-- 5. Delete decommissioned legacy units (OUT_OF_SERVICE or non-K units)
DELETE FROM [storage_units] WHERE [Status] IN ('OUT_OF_SERVICE', 'OUT OF SERVICE') OR [UnitNumber] NOT LIKE 'K%';

-- 6. Inactivate legacy unit types and their rates (including Locker)
UPDATE [unit_types] SET [Status] = 'INACTIVE'
WHERE [TypeName] IN (
'Kho Mini S (1m x 1m)',
'Kho Tiêu Chuẩn M (2m x 2m)',
'Kho Lớn L (3m x 3m)',
'Kho Doanh Nghiệp XL (4m x 4m)',
'Tủ Locker Cá Nhân (0.5m x 0.5m)'
);
UPDATE [rental_rates] SET [Status] = 'INACTIVE'
WHERE [UnitTypeId] IN (SELECT [UnitTypeId] FROM [unit_types] WHERE [Status] = 'INACTIVE');

-- 7. Reset all active storage units (K01-K12) to AVAILABLE
UPDATE [storage_units] SET [Status] = 'AVAILABLE';

-- 8. Re-enable and validate all foreign key constraints
EXEC sp_msforeachtable 'ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all';

PRINT 'SSFRMS Database reset completed successfully!';


3 changes: 3 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Repository instructions

Read `AGENTS.md` first. For frontend changes, follow `docs/frontend-naming.md` and `SafeSpace-Customer-UI/SafeSpace-Customer-UI/AGENTS.md`. Consult the frontend `FRONTEND-MAP.md` before creating files. Run `npm run check:structure` in the frontend directory.
Loading