Skip to content

Dashboard - Technical Map

Auto-generated bởi codebase-doc-generator ngày 2026-03-23 (verified từ code thực). Không chỉnh sửa thủ công.

Routes

RoutePathMục đích
ROUTE_SALES_DASHBOARD/dashboard/salesDashboard doanh thu
ROUTE_CUSTOMER_DEBT_DASHBOARD/dashboard/customer-debtDashboard công nợ khách hàng
ROUTE_CAMPAIGN_DASHBOARD/dashboard/campaignDashboard chiến dịch
ROUTE_CUSTOMER_DASHBOARD/dashboard/customerDashboard khách hàng
ROUTE_INVENTORY_DASHBOARD/dashboard/inventoryDashboard kho
ROUTE_LEAGUE_TABLES_DASHBOARD/dashboard/league-tablesDashboard bảng xếp hạng
ItemGiá trị
MODULE_DASHBOARDdashboard
Menu titleThống kê
Parent menu moduleIdstatistic
Shared permission builderadminRoles()
adminRoles() scopeToàn bộ groups trừ PosCallCenter
Submenu module IDsrevenue, customer_debt, statistic_campaign, customer, warehouse, rank_chart

FE Pages (6)

PageFileVai trò
SalesDashboardpages/SalesDashboard.tsxSales cards + payment/revenue charts
CustomerDebtDashboardpages/CustomerDebtDashboard.tsxDebt cards + debt trend/by branch
CampaignDashboardpages/CampaignDashboard.tsxCampaign KPI cards + conversion/revenue
CustomerDashboardpages/CustomerDashboard.tsxCustomer segmentation dashboard
InventoryDashboardpages/InventoryDashboard.tsxInventory cards + 4 tabbed charts
LeagueTablesDashboardpages/LeagueTablesDashboard.tsxRanking/revenue/task/violation dashboards

FE Components / Areas

AreaComponents tiêu biểu
Shared chart primitivesLineChart, PieChart, BarChart, DashboardCardItem
SalesSalesCards, OrderByTime, RevenueByBranch, RevenueByPaymentMethod, RevenuePercentageByPaymentMethod
Customer debtDebtByTime, RestDebtByTime, DebtByBranch
CampaignCampaignDashboardCard, OrderByCampaign, ConversionRateByCampaign, CampaignRevenueByBranch
CustomerCustomerCards, OrderByGender, OrderByAge, CustomerBySource, CustomerByOccupation, CustomerByGroup, CustomerByProvince, NewAndActiveCustomer, TotalCustomer
InventorySoldCosmetics, InventoryProducts, TransferOrders, CosmeticSales
League tablesBranchRevenue, BranchSalesRevenue, TechnicianRevenue, TelesalesRevenue, CustomerServiceRevenue, DepartmentRevenue, PointAndTourFee, ViolationRanking

GraphQL Operations

sales_dashboard.graphql

OperationMục đích
getSalesDashboardCardLấy sales cards tổng quan
getRevenueByPaymentMethodDoanh thu theo phương thức thanh toán
getRevenuePercentageByPaymentMethodTỉ trọng doanh thu theo phương thức thanh toán
getOrderByTimeSố đơn theo thời gian
getRevenueByBranchDoanh thu theo chi nhánh

customer_dept_dashboard.graphql

OperationMục đích
getCustomerDebtDashboardCardCards công nợ tổng quan
getCustomerDebtDashboardDebtByTimeDebt theo thời gian
getCustomerDebtDashboardRestDebtByTimeDư nợ còn lại theo thời gian
getCustomerDebtDashboardDebtByBranchDebt theo chi nhánh

campaign_dashboard.graphql

OperationMục đích
getDashboardCampaignCards chiến dịch tổng quan
getDashboardCampaignOrderĐơn theo campaign
getDashboardCampaignRevenueDoanh thu campaign
getDashboardCampaignConversionRateTỉ lệ chuyển đổi campaign

customer_dashboard.graphql

OperationMục đích
getDashBoardCustomerCardCards khách hàng tổng quan
getDashBoardCustomerGenderCơ cấu giới tính
getDashBoardCustomerContactBookContact book theo thời gian
getDashBoardCustomerProvincePhân bố tỉnh/thành
getDashBoardCustomerAgePhân bố độ tuổi
getDashBoardCustomerSourceKhách hàng theo nguồn
getDashBoardCustomerActiveActive customer theo thời gian
getDashBoardCustomerOccupationKhách hàng theo nghề nghiệp
getDashBoardCustomerGroupKhách hàng theo nhóm

inventory_dashboard.graphql

OperationMục đích
getInventoryDashboardCardCards tồn kho/công nợ kho
getInventoryDashboardSoldCosmeticMỹ phẩm bán ra
getInventoryDashboardProductTồn sản phẩm / cận date
getInventoryDashboardTransferOrderPhiếu chuyển kho
getInventoryDashboardCosmeticSalesDoanh số mỹ phẩm theo user

league_table_dashboard.graphql

OperationMục đích
GetAccountRoleUsersLấy user theo role
GetDashBoardRevenueRevenue stats theo user
GetDashBoardTaskTask stats theo user
getDashBoardBranchRevenueRevenue stats theo branch
getDashBoardDepartmentTaskPoint/tour fee theo phòng ban
getDashBoardViolationStaffVi phạm theo nhân viên
getDashBoardViolationBranchVi phạm theo chi nhánh

FE Runtime logic

Shared useDashboard.ts

LogicGhi chú
Default filterthismonth với from/to dạng DD/MM/YYYY
Compare periodTự tính kỳ trước bằng getComparedTime()
Range labelsgetDisplayedRangeTime() build trục X theo day/month/year
LabelsCó helper ageLabels()provinceLabels()
External dependencyDùng getTimeRange() từ module projects

SalesDashboard.tsx

LogicGhi chú
Compare cardsQuery cards cho current + compared period
Branch scopeNếu không chọn branch thì dùng globalStore.currentBranches
Payment methods preloadQuery payment methods, loại cod
Args builderConvert from/to sang ISO day start/end

CustomerDebtDashboard.tsx

LogicGhi chú
Compare cardsQuery current + compared debt cards
Time textDựng timeFilterText cho UI hiển thị kỳ filter vs kỳ so sánh
Shared branch gatingFallback về branch scope hiện có của user

CampaignDashboard.tsx

LogicGhi chú
Filtersbranches, campaigns, time, compare
Compare cardsCampaign dashboard card nhận cả current và compared filter
Branch init inconsistencybranches khởi tạo từ default scope, không restore từ userBehavior.branches

CustomerDashboard.tsx

LogicGhi chú
Master data preloadLoad customer group, source, occupation khi mount
Compare cardsCustomerCards nhận current + compared filter
Dimension slicesGender, age, source, occupation, group, province, active/new

InventoryDashboard.tsx

LogicGhi chú
Warehouse scopeFallback về warehouse của các branch user đang thuộc
Compare cardsQuery cards cho current + compared period
Tabbed chartsshownCharts điều khiển 4 tab chart inventory
Args builderTruyền _warehouse_ids theo dạng string array literal {id1,id2}

LeagueTablesDashboard.tsx

LogicGhi chú
Multi-filtersbranches, departments, paymentMethods, time
Chart tabs8 chart/ranking types cố định từ LeagueTableDashboardCharts
Payment method filterQuery trực tiếp payment_method để build options
Label key anomalyDùng i18n key dashboard.label.chartTypes.inventory.${e} cho league charts

Constants / filter vocab

ConstantÝ nghĩa
DashboardOrderTypesproduct_order_number, service_order_number, prepaid_order_number, all_order_number
OrderLabelsrevenue_product, revenue_service, revenue_prepaid, total
CustomerTypesnew, active
InventoryDashboardChartssold_cosmeics, inventory_products, transfer_orders, cosmetic_sales
LeagueTableDashboardChartsrevenue_of_branch_sales, revenue_of_technician, point_and_tour_fee_of_technician, revenue_of_telesales, revenue_of_customer_service, revenue_of_branch, point_of_department, violation_ranking

Backend read models / Hasura functions

Ecommerce database

NhómVí dụ function/table
Salessearch_dashboard_sales_card, search_dashboard_sales_revenue, search_dashboard_sales_chart_order_by_time, search_dashboard_sales_chart_revenue_by_branch, search_dashboard_sales_chart_revenue_by_payment_method
Customer debtsearch_dashboard_customer_debt_card, search_dashboard_customer_debt_chart_debt_by_time, search_dashboard_customer_debt_chart_rest_debt_by_time, search_dashboard_customer_debt_chart_debt_by_branch
Campaignsearch_dashboard_campaign, search_dashboard_campaign_order, search_dashboard_campaign_revenue, search_dashboard_campaign_conversion_rate
Customersearch_dashboard_customer_card, search_dashboard_customer_contact_book, search_dashboard_customer_gender, search_dashboard_customer_age, search_dashboard_customer_source, search_dashboard_customer_group, search_dashboard_customer_occupation, search_dashboard_customer_province, search_dashboard_customer_active
Inventorysearch_dashboard_inventory_card, search_dashboard_inventory_chart_sold_cosmetic, search_dashboard_inventory_chart_inventory_product, search_dashboard_inventory_chart_transfer_order, search_dashboard_inventory_chart_cosmetic_sales
League / violationget_full_violation_dashboard_stats, dashboard_complaint_report, search_dashboard_report_employee

Project database

NhómFunction/table
Tour / task dashboardsearch_dashboard_report_tour_income, search_dashboard_project_task_user_chart_by_day, search_dashboard_project_task_user_rating_chart_by_day

Default database

NhómFunction/table
Customer age read modelsearch_dashboard_customer_age, dashboard_customer_age

Domain coupling

Module/DomainKiểu liên kết
reportCùng dùng read models tổng hợp; dashboard nghiêng về cards/charts nhanh
ecommerceNguồn chính cho sales, debt, campaign, customer, inventory
userBranch, department, role, warehouse access scope
projectsTime-range helper bị import chéo; league tables dùng task/point/tour fee stats
crmMột phần customer/contact/ticket dimensions đi qua read models tổng hợp

Rủi ro / Findings kỹ thuật

#Note
1Module gần như read-only hoàn toàn; không có backend service riêng cho dashboard logic, mà chủ yếu dựa trên Hasura functions/views đã materialize.
2diva-admin/src/modules/dashboard/stores/useDashboardStore.ts hiện trống.
3useDashboard.ageLabels() có dấu hiệu bug logic khi so tuổi bằng chênh lệch năm theo chiều ngược.
4CampaignDashboard.tsx không restore branches từ userBehavior giống các page khác.
5LeagueTablesDashboard.tsx dùng i18n namespace inventory cho labels chart league tables.
6InventoryDashboardCharts chứa key typo sold_cosmeics, có thể kéo theo mismatch text/icon lookup.