@burdenoff/microfe-support 2026.625.1 → 2026.626.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/support/components/PageLayout.js +64 -51
  2. package/dist/support/components/PageLayout.js.map +1 -1
  3. package/dist/support/components/ui.js +2 -2
  4. package/dist/support/pages/AnalyticsPage.js +145 -114
  5. package/dist/support/pages/AnalyticsPage.js.map +1 -1
  6. package/dist/support/pages/ArticleDetailAdminPage.js +180 -143
  7. package/dist/support/pages/ArticleDetailAdminPage.js.map +1 -1
  8. package/dist/support/pages/ArticleDetailUserPage.js +56 -49
  9. package/dist/support/pages/ArticleDetailUserPage.js.map +1 -1
  10. package/dist/support/pages/ContactInquiriesPage.js +51 -61
  11. package/dist/support/pages/ContactInquiriesPage.js.map +1 -1
  12. package/dist/support/pages/ContactInquiryDetailPage.js +225 -205
  13. package/dist/support/pages/ContactInquiryDetailPage.js.map +1 -1
  14. package/dist/support/pages/CreateArticlePage.js +50 -46
  15. package/dist/support/pages/CreateArticlePage.js.map +1 -1
  16. package/dist/support/pages/CreateTicketPage.js +122 -116
  17. package/dist/support/pages/CreateTicketPage.js.map +1 -1
  18. package/dist/support/pages/EditArticlePage.js +76 -80
  19. package/dist/support/pages/EditArticlePage.js.map +1 -1
  20. package/dist/support/pages/JobApplicationDetailPage.js +292 -269
  21. package/dist/support/pages/JobApplicationDetailPage.js.map +1 -1
  22. package/dist/support/pages/JobApplicationsPage.js +53 -63
  23. package/dist/support/pages/JobApplicationsPage.js.map +1 -1
  24. package/dist/support/pages/KnowledgeBaseAdminPage.js +84 -81
  25. package/dist/support/pages/KnowledgeBaseAdminPage.js.map +1 -1
  26. package/dist/support/pages/KnowledgeBaseUserPage.js +79 -76
  27. package/dist/support/pages/KnowledgeBaseUserPage.js.map +1 -1
  28. package/dist/support/pages/SettingsPage.js +215 -182
  29. package/dist/support/pages/SettingsPage.js.map +1 -1
  30. package/dist/support/pages/TicketDetailAdminPage.js +159 -129
  31. package/dist/support/pages/TicketDetailAdminPage.js.map +1 -1
  32. package/dist/support/pages/TicketDetailUserPage.js +175 -142
  33. package/dist/support/pages/TicketDetailUserPage.js.map +1 -1
  34. package/dist/support/pages/TicketListPage.js +173 -169
  35. package/dist/support/pages/TicketListPage.js.map +1 -1
  36. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsPage.js","names":[],"sources":["../../../src/support/pages/AnalyticsPage.tsx"],"sourcesContent":["import {\n BarChart3,\n TrendingUp,\n Clock,\n CheckCircle,\n Calendar,\n Download,\n ThumbsUp,\n ShieldAlert,\n} from 'lucide-react';\nimport { Button, EmphasisPanel } from '../components/ui';\nimport { useAnalyticsOperations, type TimePeriod } from '../hooks/useAnalyticsOperations';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { tWithFallback } from '../utils/i18n';\nimport { MetricCard } from '../components/analytics/MetricCard';\nimport { TrendChart } from '../components/analytics/TrendChart';\nimport { PriorityBreakdown } from '../components/analytics/PriorityBreakdown';\nimport { CategoryBreakdown } from '../components/analytics/CategoryBreakdown';\nimport { SLAReport } from '../components/analytics/SLAReport';\nimport { TopAgents } from '../components/analytics/TopAgents';\nimport { SatisfactionDistribution } from '../components/analytics/SatisfactionDistribution';\nimport { PageLayout, LoadingState, EmptyState } from '../components/PageLayout';\n\n// Helper to check if error is a permission/authorization error\nfunction isPermissionError(error: unknown): boolean {\n if (!error) return false;\n const errorMessage = String(error).toLowerCase();\n return (\n errorMessage.includes('forbidden') ||\n errorMessage.includes('not authorized') ||\n errorMessage.includes('permission denied') ||\n errorMessage.includes('admin')\n );\n}\n\nconst periodOptions: { value: TimePeriod; label: string }[] = [\n { value: 'LAST_7_DAYS' as TimePeriod, label: 'Last 7 Days' },\n { value: 'LAST_30_DAYS' as TimePeriod, label: 'Last 30 Days' },\n { value: 'LAST_90_DAYS' as TimePeriod, label: 'Last 90 Days' },\n { value: 'LAST_YEAR' as TimePeriod, label: 'Last Year' },\n];\n\nexport function AnalyticsPage() {\n const { t } = useI18n();\n const tr = (key: string, fallback: string) => tWithFallback(t, key, fallback);\n const {\n analytics,\n trends,\n slaReport,\n satisfaction,\n agentLeaderboard,\n period,\n analyticsLoading,\n trendsLoading,\n updatePeriod,\n exportReport,\n analyticsError,\n slaReportError,\n satisfactionError,\n } = useAnalyticsOperations();\n\n // Check for permission errors across all analytics queries\n const hasPermissionError =\n isPermissionError(analyticsError) ||\n isPermissionError(slaReportError) ||\n isPermissionError(satisfactionError);\n\n if (hasPermissionError) {\n return (\n <PageLayout\n title={tr('support.analytics.title', 'Support Analytics')}\n subtitle={tr('support.analytics.subtitle', 'View support performance metrics')}\n icon={<BarChart3 size={24} />}\n >\n <EmptyState\n icon={<ShieldAlert size={48} />}\n title={tr('support.analytics.adminRequired.title', 'Admin Access Required')}\n description={tr(\n 'support.analytics.adminRequired.description',\n 'You need administrator privileges to view support analytics. Please contact your workspace admin for access.'\n )}\n />\n </PageLayout>\n );\n }\n\n if (analyticsLoading || trendsLoading) {\n return (\n <PageLayout\n title={tr('support.analytics.title', 'Support Analytics')}\n subtitle={tr('support.analytics.loadingSubtitle', 'Loading analytics data...')}\n icon={<BarChart3 size={24} />}\n >\n <LoadingState message={tr('support.analytics.loading', 'Loading analytics...')} />\n </PageLayout>\n );\n }\n\n if (!analytics || analytics.stats.totalTickets === 0) {\n return (\n <PageLayout\n title={tr('support.analytics.title', 'Support Analytics')}\n subtitle={tr('support.analytics.subtitle', 'View support performance metrics')}\n icon={<BarChart3 size={24} />}\n >\n <EmptyState\n icon={<BarChart3 size={48} />}\n title={tr('support.analytics.noData.title', 'No analytics data available')}\n description={tr(\n 'support.analytics.noData.description',\n \"Analytics data will appear once there's ticket activity to report.\"\n )}\n />\n </PageLayout>\n );\n }\n\n const periodLabel = periodOptions.find((option) => option.value === period)?.label || 'Custom';\n const periodRange = {\n startDate: slaReport?.startDate ?? satisfaction?.startDate ?? new Date().toISOString(),\n endDate: slaReport?.endDate ?? satisfaction?.endDate ?? new Date().toISOString(),\n label: periodLabel,\n };\n const ticketStats = {\n total: analytics.stats.totalTickets,\n open: analytics.stats.openTickets,\n resolved: analytics.stats.resolvedTickets,\n avgResponseTimeHours: analytics.stats.averageFirstResponseTimeHours || 0,\n avgResolutionTimeHours: analytics.stats.averageResolutionTimeHours || 0,\n byPriority: analytics.priorityBreakdown,\n };\n const transformedSlaReport = {\n period: periodRange,\n totalTickets: slaReport?.totalTickets ?? analytics.stats.totalTickets,\n firstResponseCompliance:\n slaReport?.firstResponseCompliance ?? analytics.stats.slaComplianceRate ?? 0,\n resolutionCompliance: slaReport?.resolutionCompliance ?? analytics.stats.slaComplianceRate ?? 0,\n avgFirstResponseTime: slaReport?.averageFirstResponseMinutes || 0,\n avgResolutionTime: slaReport?.averageResolutionMinutes || 0,\n breachedTickets: slaReport?.totalBreaches ?? 0,\n byPriority: (slaReport?.byPriority ?? []).map(\n (item: { priority: string; totalTickets: number; resolutionCompliance: number }) => ({\n priority: item.priority,\n tickets: item.totalTickets,\n compliance: item.resolutionCompliance,\n })\n ),\n };\n const ratingDistribution = satisfaction?.ratingDistribution ?? [];\n const satisfactionMetrics = {\n period: periodRange,\n totalResponses: satisfaction?.totalResponses ?? 0,\n averageRating: satisfaction?.averageRating || 0,\n csat: satisfaction?.csatScore || 0,\n nps: satisfaction?.npsScore || 0,\n ratings: {\n rating1:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 1)\n ?.count || 0,\n rating2:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 2)\n ?.count || 0,\n rating3:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 3)\n ?.count || 0,\n rating4:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 4)\n ?.count || 0,\n rating5:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 5)\n ?.count || 0,\n },\n };\n const topAgents = (agentLeaderboard?.agents ?? []).map(\n (item: {\n rank: number;\n ticketsResolved: number;\n averageRating?: number | null;\n agent: { id: string; userId: string };\n }) => ({\n rank: item.rank,\n ticketsResolved: item.ticketsResolved,\n avgRating: item.averageRating || 0,\n agent: {\n id: item.agent.id,\n user: {\n id: item.agent.userId,\n name: item.agent.userId,\n email: item.agent.userId,\n },\n },\n })\n );\n const trendSource = trends.length > 0 ? trends : analytics.ticketTrends;\n const trendChartData = trendSource.map(\n (trend: { date: string; count: number; groupBy: string }) => ({\n timestamp: trend.date,\n value: trend.count,\n label: trend.groupBy,\n })\n );\n\n return (\n <PageLayout\n title=\"Support Analytics\"\n subtitle={periodLabel}\n icon={<BarChart3 size={24} />}\n headerActions={\n <div className=\"flex items-center gap-3\">\n {/* Period Selector */}\n <div className=\"flex items-center gap-2\">\n <Calendar size={20} className=\"text-text-secondary\" />\n <select\n value={period}\n onChange={(e) => updatePeriod(e.target.value as TimePeriod)}\n className=\"px-3 py-2 rounded-lg border border-border-subtle bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n >\n {periodOptions.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </div>\n\n {/* Export Button */}\n <Button onClick={() => exportReport('PDF')}>\n <Download size={18} />\n {tr('support.analytics.export', 'Export')}\n </Button>\n </div>\n }\n >\n <div className=\"space-y-6\">\n {/* Key Metrics — the single emphasis zone of the analytics page */}\n <EmphasisPanel className=\"p-4 sm:p-5\">\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4\">\n <MetricCard\n title=\"Total Tickets\"\n value={ticketStats.total.toString()}\n icon={TrendingUp}\n iconColor=\"text-primary\"\n subtitle={`${ticketStats.open} open, ${ticketStats.resolved} resolved`}\n />\n <MetricCard\n title=\"Avg Response Time\"\n value={`${ticketStats.avgResponseTimeHours.toFixed(1)}h`}\n icon={Clock}\n iconColor=\"text-accent\"\n subtitle={`Resolution: ${ticketStats.avgResolutionTimeHours.toFixed(1)}h`}\n />\n <MetricCard\n title=\"SLA Compliance\"\n value={`${transformedSlaReport.firstResponseCompliance.toFixed(1)}%`}\n icon={CheckCircle}\n iconColor={\n transformedSlaReport.firstResponseCompliance >= 90 ? 'text-success' : 'text-warning'\n }\n subtitle={`${transformedSlaReport.breachedTickets} breached`}\n />\n <MetricCard\n title=\"Satisfaction\"\n value={satisfactionMetrics.averageRating.toFixed(1)}\n icon={ThumbsUp}\n iconColor=\"text-success\"\n subtitle={`CSAT: ${satisfactionMetrics.csat.toFixed(0)}%, NPS: ${satisfactionMetrics.nps.toFixed(0)}`}\n />\n </div>\n </EmphasisPanel>\n\n {/* Ticket Trends Chart */}\n <TrendChart trends={trendChartData} period={satisfactionMetrics.period} />\n\n {/* Breakdowns Row */}\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-6\">\n <PriorityBreakdown data={ticketStats.byPriority} />\n <CategoryBreakdown data={analytics.categoryBreakdown} />\n </div>\n\n {/* SLA Report */}\n <SLAReport report={transformedSlaReport} />\n\n {/* Bottom Row */}\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-6\">\n <SatisfactionDistribution metrics={satisfactionMetrics} />\n <TopAgents agents={topAgents} />\n </div>\n </div>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,SAAS,EAAkB,GAAyB;AAClD,KAAI,CAAC,EAAO,QAAO;CACnB,IAAM,IAAe,OAAO,EAAM,CAAC,aAAa;AAChD,QACE,EAAa,SAAS,YAAY,IAClC,EAAa,SAAS,iBAAiB,IACvC,EAAa,SAAS,oBAAoB,IAC1C,EAAa,SAAS,QAAQ;;AAIlC,IAAM,IAAwD;CAC5D;EAAE,OAAO;EAA6B,OAAO;EAAe;CAC5D;EAAE,OAAO;EAA8B,OAAO;EAAgB;CAC9D;EAAE,OAAO;EAA8B,OAAO;EAAgB;CAC9D;EAAE,OAAO;EAA2B,OAAO;EAAa;CACzD;AAED,SAAgB,IAAgB;CAC9B,IAAM,EAAE,SAAM,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CAAA;OACF,kBAAC,GAAD;QACE,OAAM;QACN,OAAO,GAAG,EAAqB,wBAAwB,QAAQ,EAAE,CAAC;QAClE,MAAM;QACN,WACE,EAAqB,2BAA2B,KAAK,iBAAiB;QAExE,UAAU,GAAG,EAAqB,gBAAgB;QAClD,CAAA;OACF,kBAAC,GAAD;QACE,OAAM;QACN,OAAO,EAAoB,cAAc,QAAQ,EAAE;QACnD,MAAM;QACN,WAAU;QACV,UAAU,SAAS,EAAoB,KAAK,QAAQ,EAAE,CAAC,UAAU,EAAoB,IAAI,QAAQ,EAAE;QACnG,CAAA;OACI;;KACQ,CAAA;IAGhB,kBAAC,GAAD;KAAY,QAAQ;KAAgB,QAAQ,EAAoB;KAAU,CAAA;IAG1E,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,GAAD,EAAmB,MAAM,EAAY,YAAc,CAAA,EACnD,kBAAC,GAAD,EAAmB,MAAM,EAAU,mBAAqB,CAAA,CACpD;;IAGN,kBAAC,GAAD,EAAW,QAAQ,GAAwB,CAAA;IAG3C,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,GAAD,EAA0B,SAAS,GAAuB,CAAA,EAC1D,kBAAC,GAAD,EAAW,QAAQ,GAAa,CAAA,CAC5B;;IACF;;EACK,CAAA"}
1
+ {"version":3,"file":"AnalyticsPage.js","names":[],"sources":["../../../src/support/pages/AnalyticsPage.tsx"],"sourcesContent":["import {\n BarChart3,\n TrendingUp,\n Clock,\n CheckCircle,\n Calendar,\n Download,\n ThumbsUp,\n ShieldAlert,\n} from 'lucide-react';\nimport { Button, EmphasisPanel, PagePurpose, NextSteps } from '../components/ui';\nimport { useAnalyticsOperations, type TimePeriod } from '../hooks/useAnalyticsOperations';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { tWithFallback } from '../utils/i18n';\nimport { MetricCard } from '../components/analytics/MetricCard';\nimport { TrendChart } from '../components/analytics/TrendChart';\nimport { PriorityBreakdown } from '../components/analytics/PriorityBreakdown';\nimport { CategoryBreakdown } from '../components/analytics/CategoryBreakdown';\nimport { SLAReport } from '../components/analytics/SLAReport';\nimport { TopAgents } from '../components/analytics/TopAgents';\nimport { SatisfactionDistribution } from '../components/analytics/SatisfactionDistribution';\nimport { PageLayout, LoadingState, EmptyState } from '../components/PageLayout';\n\n// Helper to check if error is a permission/authorization error\nfunction isPermissionError(error: unknown): boolean {\n if (!error) return false;\n const errorMessage = String(error).toLowerCase();\n return (\n errorMessage.includes('forbidden') ||\n errorMessage.includes('not authorized') ||\n errorMessage.includes('permission denied') ||\n errorMessage.includes('admin')\n );\n}\n\nconst periodOptions: { value: TimePeriod; label: string }[] = [\n { value: 'LAST_7_DAYS' as TimePeriod, label: 'Last 7 Days' },\n { value: 'LAST_30_DAYS' as TimePeriod, label: 'Last 30 Days' },\n { value: 'LAST_90_DAYS' as TimePeriod, label: 'Last 90 Days' },\n { value: 'LAST_YEAR' as TimePeriod, label: 'Last Year' },\n];\n\nexport function AnalyticsPage() {\n const { t } = useI18n();\n const tr = (key: string, fallback: string) => tWithFallback(t, key, fallback);\n const {\n analytics,\n trends,\n slaReport,\n satisfaction,\n agentLeaderboard,\n period,\n analyticsLoading,\n trendsLoading,\n updatePeriod,\n exportReport,\n analyticsError,\n slaReportError,\n satisfactionError,\n } = useAnalyticsOperations();\n\n // Check for permission errors across all analytics queries\n const hasPermissionError =\n isPermissionError(analyticsError) ||\n isPermissionError(slaReportError) ||\n isPermissionError(satisfactionError);\n\n if (hasPermissionError) {\n return (\n <PageLayout\n title={tr('support.analytics.title', 'Support Analytics')}\n subtitle={tr('support.analytics.subtitle', 'View support performance metrics')}\n icon={<BarChart3 size={24} />}\n >\n <EmptyState\n icon={<ShieldAlert size={48} />}\n title={tr('support.analytics.adminRequired.title', 'Admin Access Required')}\n description={tr(\n 'support.analytics.adminRequired.description',\n 'You need administrator privileges to view support analytics. Please contact your workspace admin for access.'\n )}\n />\n </PageLayout>\n );\n }\n\n if (analyticsLoading || trendsLoading) {\n return (\n <PageLayout\n title={tr('support.analytics.title', 'Support Analytics')}\n subtitle={tr('support.analytics.loadingSubtitle', 'Loading analytics data...')}\n icon={<BarChart3 size={24} />}\n >\n <LoadingState message={tr('support.analytics.loading', 'Loading analytics...')} />\n </PageLayout>\n );\n }\n\n if (!analytics || analytics.stats.totalTickets === 0) {\n return (\n <PageLayout\n title={tr('support.analytics.title', 'Support Analytics')}\n subtitle={tr('support.analytics.subtitle', 'View support performance metrics')}\n icon={<BarChart3 size={24} />}\n >\n <EmptyState\n illustration=\"empty-data\"\n title={tr('support.analytics.noData.title', 'No analytics data available')}\n description={tr(\n 'support.analytics.noData.description',\n \"Analytics data will appear once there's ticket activity to report.\"\n )}\n />\n </PageLayout>\n );\n }\n\n const periodLabel = periodOptions.find((option) => option.value === period)?.label || 'Custom';\n const periodRange = {\n startDate: slaReport?.startDate ?? satisfaction?.startDate ?? new Date().toISOString(),\n endDate: slaReport?.endDate ?? satisfaction?.endDate ?? new Date().toISOString(),\n label: periodLabel,\n };\n const ticketStats = {\n total: analytics.stats.totalTickets,\n open: analytics.stats.openTickets,\n resolved: analytics.stats.resolvedTickets,\n avgResponseTimeHours: analytics.stats.averageFirstResponseTimeHours || 0,\n avgResolutionTimeHours: analytics.stats.averageResolutionTimeHours || 0,\n byPriority: analytics.priorityBreakdown,\n };\n const transformedSlaReport = {\n period: periodRange,\n totalTickets: slaReport?.totalTickets ?? analytics.stats.totalTickets,\n firstResponseCompliance:\n slaReport?.firstResponseCompliance ?? analytics.stats.slaComplianceRate ?? 0,\n resolutionCompliance: slaReport?.resolutionCompliance ?? analytics.stats.slaComplianceRate ?? 0,\n avgFirstResponseTime: slaReport?.averageFirstResponseMinutes || 0,\n avgResolutionTime: slaReport?.averageResolutionMinutes || 0,\n breachedTickets: slaReport?.totalBreaches ?? 0,\n byPriority: (slaReport?.byPriority ?? []).map(\n (item: { priority: string; totalTickets: number; resolutionCompliance: number }) => ({\n priority: item.priority,\n tickets: item.totalTickets,\n compliance: item.resolutionCompliance,\n })\n ),\n };\n const ratingDistribution = satisfaction?.ratingDistribution ?? [];\n const satisfactionMetrics = {\n period: periodRange,\n totalResponses: satisfaction?.totalResponses ?? 0,\n averageRating: satisfaction?.averageRating || 0,\n csat: satisfaction?.csatScore || 0,\n nps: satisfaction?.npsScore || 0,\n ratings: {\n rating1:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 1)\n ?.count || 0,\n rating2:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 2)\n ?.count || 0,\n rating3:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 3)\n ?.count || 0,\n rating4:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 4)\n ?.count || 0,\n rating5:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 5)\n ?.count || 0,\n },\n };\n const topAgents = (agentLeaderboard?.agents ?? []).map(\n (item: {\n rank: number;\n ticketsResolved: number;\n averageRating?: number | null;\n agent: { id: string; userId: string };\n }) => ({\n rank: item.rank,\n ticketsResolved: item.ticketsResolved,\n avgRating: item.averageRating || 0,\n agent: {\n id: item.agent.id,\n user: {\n id: item.agent.userId,\n name: item.agent.userId,\n email: item.agent.userId,\n },\n },\n })\n );\n const trendSource = trends.length > 0 ? trends : analytics.ticketTrends;\n const trendChartData = trendSource.map(\n (trend: { date: string; count: number; groupBy: string }) => ({\n timestamp: trend.date,\n value: trend.count,\n label: trend.groupBy,\n })\n );\n\n return (\n <PageLayout\n title=\"Support Analytics\"\n subtitle={periodLabel}\n icon={<BarChart3 size={24} />}\n headerActions={\n <div className=\"flex items-center gap-3\">\n {/* Period Selector */}\n <div className=\"flex items-center gap-2\">\n <Calendar size={20} className=\"text-text-secondary\" />\n <select\n value={period}\n onChange={(e) => updatePeriod(e.target.value as TimePeriod)}\n className=\"px-3 py-2 rounded-lg border border-border-subtle bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n >\n {periodOptions.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </div>\n\n {/* Export Button */}\n <Button onClick={() => exportReport('PDF')}>\n <Download size={18} />\n {tr('support.analytics.export', 'Export')}\n </Button>\n </div>\n }\n >\n <div className=\"space-y-6\">\n <PagePurpose>\n Measure how your support operation is performing. Track ticket volume, first-response and\n resolution times, SLA compliance and customer satisfaction so you can spot bottlenecks,\n balance agent workload, and prove the impact of your team. Adjust the period to compare\n trends over time.\n </PagePurpose>\n\n <NextSteps\n storageKey=\"support-analytics\"\n title=\"Make the most of your data\"\n steps={[\n {\n id: 'period',\n label: 'Switch the reporting period',\n description: 'Compare the last 7, 30, 90 days or a full year to spot trends.',\n onClick: () => updatePeriod('LAST_90_DAYS' as TimePeriod),\n },\n {\n id: 'export',\n label: 'Export a PDF report',\n description: 'Share performance with stakeholders in one click.',\n onClick: () => exportReport('PDF'),\n },\n {\n id: 'sla',\n label: 'Review SLA compliance',\n description: 'Scroll to the SLA report to see where commitments slipped.',\n onClick: () =>\n document\n .querySelector('[data-tour=\"support-analytics-sla\"]')\n ?.scrollIntoView({ behavior: 'smooth', block: 'start' }),\n },\n ]}\n />\n\n {/* Key Metrics — the single emphasis zone of the analytics page */}\n <EmphasisPanel className=\"p-4 sm:p-5\">\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4\">\n <MetricCard\n title=\"Total Tickets\"\n value={ticketStats.total.toString()}\n icon={TrendingUp}\n iconColor=\"text-primary\"\n subtitle={`${ticketStats.open} open, ${ticketStats.resolved} resolved`}\n />\n <MetricCard\n title=\"Avg Response Time\"\n value={`${ticketStats.avgResponseTimeHours.toFixed(1)}h`}\n icon={Clock}\n iconColor=\"text-accent\"\n subtitle={`Resolution: ${ticketStats.avgResolutionTimeHours.toFixed(1)}h`}\n />\n <MetricCard\n title=\"SLA Compliance\"\n value={`${transformedSlaReport.firstResponseCompliance.toFixed(1)}%`}\n icon={CheckCircle}\n iconColor={\n transformedSlaReport.firstResponseCompliance >= 90 ? 'text-success' : 'text-warning'\n }\n subtitle={`${transformedSlaReport.breachedTickets} breached`}\n />\n <MetricCard\n title=\"Satisfaction\"\n value={satisfactionMetrics.averageRating.toFixed(1)}\n icon={ThumbsUp}\n iconColor=\"text-success\"\n subtitle={`CSAT: ${satisfactionMetrics.csat.toFixed(0)}%, NPS: ${satisfactionMetrics.nps.toFixed(0)}`}\n />\n </div>\n </EmphasisPanel>\n\n {/* Ticket Trends Chart */}\n <TrendChart trends={trendChartData} period={satisfactionMetrics.period} />\n\n {/* Breakdowns Row */}\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-6\">\n <PriorityBreakdown data={ticketStats.byPriority} />\n <CategoryBreakdown data={analytics.categoryBreakdown} />\n </div>\n\n {/* SLA Report */}\n <div data-tour=\"support-analytics-sla\">\n <SLAReport report={transformedSlaReport} />\n </div>\n\n {/* Bottom Row */}\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-6\">\n <SatisfactionDistribution metrics={satisfactionMetrics} />\n <TopAgents agents={topAgents} />\n </div>\n </div>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,SAAS,EAAkB,GAAyB;AAClD,KAAI,CAAC,EAAO,QAAO;CACnB,IAAM,IAAe,OAAO,EAAM,CAAC,aAAa;AAChD,QACE,EAAa,SAAS,YAAY,IAClC,EAAa,SAAS,iBAAiB,IACvC,EAAa,SAAS,oBAAoB,IAC1C,EAAa,SAAS,QAAQ;;AAIlC,IAAM,IAAwD;CAC5D;EAAE,OAAO;EAA6B,OAAO;EAAe;CAC5D;EAAE,OAAO;EAA8B,OAAO;EAAgB;CAC9D;EAAE,OAAO;EAA8B,OAAO;EAAgB;CAC9D;EAAE,OAAO;EAA2B,OAAO;EAAa;CACzD;AAED,SAAgB,IAAgB;CAC9B,IAAM,EAAE,SAAM,GAAS,EACjB,KAAM,GAAa,MAAqB,EAAc,GAAG,GAAK,EAAS,EACvE,EACJ,cACA,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AAY,MAAM,UAAU;QACnC,MAAM;QACN,WAAU;QACV,UAAU,GAAG,EAAY,KAAK,SAAS,EAAY,SAAS;QAC5D,CAAA;OACF,kBAAC,GAAD;QACE,OAAM;QACN,OAAO,GAAG,EAAY,qBAAqB,QAAQ,EAAE,CAAC;QACtD,MAAM;QACN,WAAU;QACV,UAAU,eAAe,EAAY,uBAAuB,QAAQ,EAAE,CAAC;QACvE,CAAA;OACF,kBAAC,GAAD;QACE,OAAM;QACN,OAAO,GAAG,EAAqB,wBAAwB,QAAQ,EAAE,CAAC;QAClE,MAAM;QACN,WACE,EAAqB,2BAA2B,KAAK,iBAAiB;QAExE,UAAU,GAAG,EAAqB,gBAAgB;QAClD,CAAA;OACF,kBAAC,GAAD;QACE,OAAM;QACN,OAAO,EAAoB,cAAc,QAAQ,EAAE;QACnD,MAAM;QACN,WAAU;QACV,UAAU,SAAS,EAAoB,KAAK,QAAQ,EAAE,CAAC,UAAU,EAAoB,IAAI,QAAQ,EAAE;QACnG,CAAA;OACE;;KACQ,CAAA;IAGhB,kBAAC,GAAD;KAAY,QAAQ;KAAgB,QAAQ,EAAoB;KAAU,CAAA;IAG1E,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,GAAD,EAAmB,MAAM,EAAY,YAAc,CAAA,EACnD,kBAAC,GAAD,EAAmB,MAAM,EAAU,mBAAqB,CAAA,CACpD;;IAGN,kBAAC,OAAD;KAAK,aAAU;eACb,kBAAC,GAAD,EAAW,QAAQ,GAAwB,CAAA;KACvC,CAAA;IAGN,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,GAAD,EAA0B,SAAS,GAAuB,CAAA,EAC1D,kBAAC,GAAD,EAAW,QAAQ,GAAa,CAAA,CAC5B;;IACF;;EACK,CAAA"}
@@ -1,188 +1,188 @@
1
1
  import { useSupport as e } from "../providers/SupportProvider.js";
2
- import { Badge as t, Button as n, CTAOverflowMenu as ee } from "../components/ui.js";
3
- import { EmptyState as te, LoadingState as ne, PageLayout as r } from "../components/PageLayout.js";
4
- import { getCategoryBadgeClass as re } from "../utils/categoryColors.js";
5
- import { useKnowledgeBaseOperations as i } from "../hooks/useKnowledgeBaseOperations.js";
6
- import { purify as a } from "../../node_modules/dompurify/dist/purify.es.js";
7
- import { nativeConfirm as ie, nativeImpact as ae, nativeNotify as o } from "../../utils/nativeBridge.js";
8
- import { useEffect as s, useRef as c, useState as l } from "react";
9
- import { AlertCircle as oe, Archive as u, ArrowLeft as d, BookOpen as f, Calendar as p, CheckCircle as m, Edit as h, Eye as g, Globe as _, GlobeLock as v, Loader2 as y, Tag as se, ThumbsDown as ce, ThumbsUp as le, Trash2 as b, User as ue } from "lucide-react";
10
- import { useNavigate as de, useParams as fe } from "react-router-dom";
2
+ import { Badge as t, Button as n, CTAOverflowMenu as r, EmphasisPanel as ee, NextSteps as te } from "../components/ui.js";
3
+ import { EmptyState as ne, LoadingState as i, PageLayout as a } from "../components/PageLayout.js";
4
+ import { getCategoryBadgeClass as o } from "../utils/categoryColors.js";
5
+ import { useKnowledgeBaseOperations as re } from "../hooks/useKnowledgeBaseOperations.js";
6
+ import { purify as ie } from "../../node_modules/dompurify/dist/purify.es.js";
7
+ import { nativeConfirm as ae, nativeImpact as oe, nativeNotify as s } from "../../utils/nativeBridge.js";
8
+ import { useEffect as c, useRef as l, useState as u } from "react";
9
+ import { AlertCircle as d, Archive as f, ArrowLeft as p, Calendar as m, CheckCircle as h, Edit as g, Eye as se, Globe as _, GlobeLock as v, Loader2 as y, Tag as ce, ThumbsDown as le, ThumbsUp as ue, Trash2 as b, User as de } from "lucide-react";
10
+ import { useNavigate as fe, useParams as pe } from "react-router-dom";
11
11
  import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
12
- import { AlertDialog as pe, AlertDialogAction as w, AlertDialogCancel as T, AlertDialogContent as E, AlertDialogDescription as D, AlertDialogFooter as O, AlertDialogHeader as k, AlertDialogTitle as A } from "@burdenoff/fe-libs/ui";
12
+ import { AlertDialog as me, AlertDialogAction as he, AlertDialogCancel as w, AlertDialogContent as T, AlertDialogDescription as E, AlertDialogFooter as D, AlertDialogHeader as O, AlertDialogTitle as k } from "@burdenoff/fe-libs/ui";
13
13
  //#region src/support/pages/ArticleDetailAdminPage.tsx
14
- function j() {
15
- let { slug: j } = fe(), M = de(), { basePath: N = "" } = e(), { articleDetail: P, articleLoading: F, articleError: I, voteArticle: L, recordView: R, ratingArticle: z, deleteArticle: B, publishArticle: me, unpublishArticle: he, archiveArticle: ge, deletingArticle: V, publishingArticle: H, unpublishingArticle: U, archivingArticle: W } = i(j), [_e, G] = l(!1), [K, q] = l(null), J = c(null), Y = c(null);
16
- s(() => {
17
- P?.id && R(P.id);
18
- }, [P?.id, R]), s(() => () => {
19
- J.current && clearTimeout(J.current), Y.current && clearTimeout(Y.current);
14
+ function A() {
15
+ let { slug: A } = pe(), j = fe(), { basePath: M = "" } = e(), { articleDetail: N, articleLoading: P, articleError: F, voteArticle: I, recordView: L, ratingArticle: R, deleteArticle: ge, publishArticle: _e, unpublishArticle: ve, archiveArticle: ye, deletingArticle: z, publishingArticle: B, unpublishingArticle: V, archivingArticle: H } = re(A), [be, U] = u(!1), [W, G] = u(null), K = l(null), q = l(null);
16
+ c(() => {
17
+ N?.id && L(N.id);
18
+ }, [N?.id, L]), c(() => () => {
19
+ K.current && clearTimeout(K.current), q.current && clearTimeout(q.current);
20
20
  }, []);
21
- let X = () => {
22
- Y.current && clearTimeout(Y.current), Y.current = setTimeout(() => q(null), 3e3);
23
- }, ve = (e) => {
24
- J.current && clearTimeout(J.current), J.current = setTimeout(() => M(e), 1e3);
25
- }, Z = async (e) => {
26
- if (P) try {
27
- await L(P.id, e);
21
+ let J = () => {
22
+ q.current && clearTimeout(q.current), q.current = setTimeout(() => G(null), 3e3);
23
+ }, xe = (e) => {
24
+ K.current && clearTimeout(K.current), K.current = setTimeout(() => j(e), 1e3);
25
+ }, Y = async (e) => {
26
+ if (N) try {
27
+ await I(N.id, e);
28
28
  } catch (e) {
29
29
  console.error("Failed to vote:", e);
30
30
  }
31
- }, Q = async () => {
32
- if (P) {
31
+ }, X = async () => {
32
+ if (N) {
33
33
  try {
34
- await B(P.id), q({
34
+ await ge(N.id), G({
35
35
  type: "success",
36
36
  message: "Article deleted successfully!"
37
- }), o("success"), ve(`${N}/kb`);
37
+ }), s("success"), xe(`${M}/kb`);
38
38
  } catch {
39
- q({
39
+ G({
40
40
  type: "error",
41
41
  message: "Failed to delete article."
42
- }), o("error"), X();
42
+ }), s("error"), J();
43
43
  }
44
- G(!1);
44
+ U(!1);
45
45
  }
46
- }, ye = async () => {
47
- ae("medium");
48
- let e = await ie({
46
+ }, Se = async () => {
47
+ oe("medium");
48
+ let e = await ae({
49
49
  title: "Delete Article",
50
50
  message: "Delete this article? This cannot be undone.",
51
51
  okButtonTitle: "Delete",
52
52
  cancelButtonTitle: "Cancel"
53
53
  });
54
54
  if (e === null) {
55
- G(!0);
55
+ U(!0);
56
56
  return;
57
57
  }
58
- e && await Q();
59
- }, be = async () => {
60
- if (P) try {
61
- await me(P.id), q({
58
+ e && await X();
59
+ }, Z = async () => {
60
+ if (N) try {
61
+ await _e(N.id), G({
62
62
  type: "success",
63
63
  message: "Article published successfully!"
64
- }), X();
64
+ }), J();
65
65
  } catch {
66
- q({
66
+ G({
67
67
  type: "error",
68
68
  message: "Failed to publish article."
69
- }), X();
69
+ }), J();
70
70
  }
71
- }, xe = async () => {
72
- if (P) try {
73
- await he(P.id), q({
71
+ }, Q = async () => {
72
+ if (N) try {
73
+ await ve(N.id), G({
74
74
  type: "success",
75
75
  message: "Article unpublished."
76
- }), X();
76
+ }), J();
77
77
  } catch {
78
- q({
78
+ G({
79
79
  type: "error",
80
80
  message: "Failed to unpublish article."
81
- }), X();
81
+ }), J();
82
82
  }
83
- }, Se = async () => {
84
- if (P) try {
85
- await ge(P.id), q({
83
+ }, Ce = async () => {
84
+ if (N) try {
85
+ await ye(N.id), G({
86
86
  type: "success",
87
87
  message: "Article archived."
88
- }), X();
88
+ }), J();
89
89
  } catch {
90
- q({
90
+ G({
91
91
  type: "error",
92
92
  message: "Failed to archive article."
93
- }), X();
93
+ }), J();
94
94
  }
95
- }, $ = V || H || U || W, Ce = [
96
- ...P?.status === "DRAFT" ? [{
95
+ }, $ = z || B || V || H, we = [
96
+ ...N?.status === "DRAFT" ? [{
97
97
  label: "Publish",
98
- icon: H ? /* @__PURE__ */ S(y, {
98
+ icon: B ? /* @__PURE__ */ S(y, {
99
99
  size: 16,
100
100
  className: "animate-spin"
101
101
  }) : /* @__PURE__ */ S(_, { size: 16 }),
102
- onSelect: () => void be(),
102
+ onSelect: () => void Z(),
103
103
  disabled: $
104
104
  }] : [],
105
- ...P?.status === "PUBLISHED" ? [{
105
+ ...N?.status === "PUBLISHED" ? [{
106
106
  label: "Unpublish",
107
- icon: U ? /* @__PURE__ */ S(y, {
107
+ icon: V ? /* @__PURE__ */ S(y, {
108
108
  size: 16,
109
109
  className: "animate-spin"
110
110
  }) : /* @__PURE__ */ S(v, { size: 16 }),
111
- onSelect: () => void xe(),
111
+ onSelect: () => void Q(),
112
112
  disabled: $
113
113
  }, {
114
114
  label: "Archive",
115
- icon: W ? /* @__PURE__ */ S(y, {
115
+ icon: H ? /* @__PURE__ */ S(y, {
116
116
  size: 16,
117
117
  className: "animate-spin"
118
- }) : /* @__PURE__ */ S(u, { size: 16 }),
119
- onSelect: () => void Se(),
118
+ }) : /* @__PURE__ */ S(f, { size: 16 }),
119
+ onSelect: () => void Ce(),
120
120
  disabled: $
121
121
  }] : [],
122
122
  {
123
123
  label: "Delete",
124
124
  icon: /* @__PURE__ */ S(b, { size: 16 }),
125
125
  intent: "destructive",
126
- onSelect: () => void ye(),
126
+ onSelect: () => void Se(),
127
127
  disabled: $
128
128
  }
129
129
  ];
130
- return F ? /* @__PURE__ */ S(r, {
130
+ return P ? /* @__PURE__ */ S(a, {
131
131
  showHeader: !1,
132
- children: /* @__PURE__ */ S(ne, { message: "Loading article…" })
133
- }) : I || !P ? /* @__PURE__ */ S(r, {
132
+ children: /* @__PURE__ */ S(i, { message: "Loading article…" })
133
+ }) : F || !N ? /* @__PURE__ */ S(a, {
134
134
  showHeader: !1,
135
- children: /* @__PURE__ */ S(te, {
136
- icon: /* @__PURE__ */ S(f, { size: 48 }),
135
+ children: /* @__PURE__ */ S(ne, {
136
+ illustration: "empty-search",
137
137
  title: "Article not found",
138
138
  description: "The article you're looking for doesn't exist or has been removed.",
139
139
  action: /* @__PURE__ */ C(n, {
140
- onClick: () => M(`${N}/kb`),
141
- children: [/* @__PURE__ */ S(d, { size: 18 }), "Back to Knowledge Base"]
140
+ onClick: () => j(`${M}/kb`),
141
+ children: [/* @__PURE__ */ S(p, { size: 18 }), "Back to Knowledge Base"]
142
142
  })
143
143
  })
144
144
  }) : /* @__PURE__ */ C("div", {
145
145
  className: "flex flex-col h-full",
146
146
  children: [
147
- K && /* @__PURE__ */ C("div", {
148
- className: `fixed right-4 top-[calc(var(--header-height,4rem)+1rem)] z-[200] flex items-center gap-3 px-5 py-3 rounded-xl shadow-2xl border-2 animate-in slide-in-from-top-4 duration-200 ${K.type === "success" ? "bg-success/10 text-success border-success/30" : "bg-error/10 text-error border-error/30"}`,
149
- children: [K.type === "success" ? /* @__PURE__ */ S(m, {
147
+ W && /* @__PURE__ */ C("div", {
148
+ className: `fixed right-4 top-[calc(var(--header-height,4rem)+1rem)] z-[200] flex items-center gap-3 px-5 py-3 rounded-xl shadow-2xl border-2 animate-in slide-in-from-top-4 duration-200 ${W.type === "success" ? "bg-success/10 text-success border-success/30" : "bg-error/10 text-error border-error/30"}`,
149
+ children: [W.type === "success" ? /* @__PURE__ */ S(h, {
150
150
  size: 20,
151
151
  className: "text-success"
152
- }) : /* @__PURE__ */ S(oe, {
152
+ }) : /* @__PURE__ */ S(d, {
153
153
  size: 20,
154
154
  className: "text-error"
155
155
  }), /* @__PURE__ */ S("span", {
156
156
  className: "font-medium",
157
- children: K.message
157
+ children: W.message
158
158
  })]
159
159
  }),
160
- /* @__PURE__ */ S(pe, {
161
- open: _e,
160
+ /* @__PURE__ */ S(me, {
161
+ open: be,
162
162
  onOpenChange: (e) => {
163
- e || G(!1);
163
+ e || U(!1);
164
164
  },
165
- children: /* @__PURE__ */ C(E, {
165
+ children: /* @__PURE__ */ C(T, {
166
166
  className: "max-w-md",
167
- children: [/* @__PURE__ */ C(k, { children: [/* @__PURE__ */ S(A, { children: "Delete Article?" }), /* @__PURE__ */ C(D, { children: [
167
+ children: [/* @__PURE__ */ C(O, { children: [/* @__PURE__ */ S(k, { children: "Delete Article?" }), /* @__PURE__ */ C(E, { children: [
168
168
  "Are you sure you want to delete \"",
169
- P.title,
169
+ N.title,
170
170
  "\"? This action cannot be undone."
171
- ] })] }), /* @__PURE__ */ C(O, { children: [/* @__PURE__ */ S(w, {
171
+ ] })] }), /* @__PURE__ */ C(D, { children: [/* @__PURE__ */ S(he, {
172
172
  asChild: !0,
173
173
  children: /* @__PURE__ */ S(n, {
174
174
  variant: "destructive",
175
175
  onClick: (e) => {
176
- e.preventDefault(), Q();
176
+ e.preventDefault(), X();
177
177
  },
178
- disabled: V,
178
+ disabled: z,
179
179
  className: "flex-1",
180
- children: V ? /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(y, {
180
+ children: z ? /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(y, {
181
181
  size: 16,
182
182
  className: "animate-spin"
183
183
  }), "Deleting…"] }) : /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(b, { size: 16 }), "Delete"] })
184
184
  })
185
- }), /* @__PURE__ */ S(T, {
185
+ }), /* @__PURE__ */ S(w, {
186
186
  asChild: !0,
187
187
  children: /* @__PURE__ */ S(n, {
188
188
  variant: "outline",
@@ -200,26 +200,26 @@ function j() {
200
200
  children: [/* @__PURE__ */ C(n, {
201
201
  variant: "ghost",
202
202
  size: "sm",
203
- onClick: () => M(`${N}/kb`),
204
- children: [/* @__PURE__ */ S(d, { size: 20 }), "Back to Knowledge Base"]
205
- }), /* @__PURE__ */ S(ee, {
203
+ onClick: () => j(`${M}/kb`),
204
+ children: [/* @__PURE__ */ S(p, { size: 20 }), "Back to Knowledge Base"]
205
+ }), /* @__PURE__ */ S(r, {
206
206
  primary: {
207
207
  label: "Edit",
208
- icon: /* @__PURE__ */ S(h, { size: 16 }),
209
- onSelect: () => M("edit"),
208
+ icon: /* @__PURE__ */ S(g, { size: 16 }),
209
+ onSelect: () => j("edit"),
210
210
  disabled: $
211
211
  },
212
- actions: Ce
212
+ actions: we
213
213
  })]
214
214
  }),
215
215
  /* @__PURE__ */ C("div", {
216
216
  className: "flex items-center gap-3 mb-3",
217
- children: [P.category && /* @__PURE__ */ S(t, {
217
+ children: [N.category && /* @__PURE__ */ S(t, {
218
218
  variant: "outline",
219
- className: re(P.category.color),
220
- children: P.category.name
219
+ className: o(N.category.color),
220
+ children: N.category.name
221
221
  }), (() => {
222
- switch (P.status) {
222
+ switch (N.status) {
223
223
  case "PUBLISHED": return /* @__PURE__ */ C(t, {
224
224
  className: "bg-success/10 text-success",
225
225
  children: [/* @__PURE__ */ S(_, {
@@ -236,7 +236,7 @@ function j() {
236
236
  });
237
237
  case "ARCHIVED": return /* @__PURE__ */ C(t, {
238
238
  className: "bg-bg-sunken text-tertiary",
239
- children: [/* @__PURE__ */ S(u, {
239
+ children: [/* @__PURE__ */ S(f, {
240
240
  size: 12,
241
241
  className: "mr-1"
242
242
  }), "Archived"]
@@ -247,31 +247,31 @@ function j() {
247
247
  }),
248
248
  /* @__PURE__ */ S("h1", {
249
249
  className: "mb-4 text-2xl font-bold text-text-primary sm:text-3xl lg:text-4xl",
250
- children: P.title
250
+ children: N.title
251
251
  }),
252
252
  /* @__PURE__ */ C("div", {
253
253
  className: "flex flex-wrap items-center gap-4 text-sm text-text-secondary",
254
254
  children: [
255
- P.author && /* @__PURE__ */ C("div", {
255
+ N.author && /* @__PURE__ */ C("div", {
256
256
  className: "flex items-center gap-2",
257
- children: [/* @__PURE__ */ S(ue, { size: 16 }), /* @__PURE__ */ S("span", { children: P.author.name })]
257
+ children: [/* @__PURE__ */ S(de, { size: 16 }), /* @__PURE__ */ S("span", { children: N.author.name })]
258
258
  }),
259
- P.publishedAt && /* @__PURE__ */ C("div", {
259
+ N.publishedAt && /* @__PURE__ */ C("div", {
260
260
  className: "flex items-center gap-2",
261
- children: [/* @__PURE__ */ S(p, { size: 16 }), /* @__PURE__ */ S("span", { children: new Date(P.publishedAt).toLocaleDateString() })]
261
+ children: [/* @__PURE__ */ S(m, { size: 16 }), /* @__PURE__ */ S("span", { children: new Date(N.publishedAt).toLocaleDateString() })]
262
262
  }),
263
263
  /* @__PURE__ */ C("div", {
264
264
  className: "flex items-center gap-2",
265
- children: [/* @__PURE__ */ S(g, { size: 16 }), /* @__PURE__ */ C("span", { children: [P.viewCount, " views"] })]
265
+ children: [/* @__PURE__ */ S(se, { size: 16 }), /* @__PURE__ */ C("span", { children: [N.viewCount, " views"] })]
266
266
  })
267
267
  ]
268
268
  }),
269
- P.tags && P.tags.length > 0 && /* @__PURE__ */ C("div", {
269
+ N.tags && N.tags.length > 0 && /* @__PURE__ */ C("div", {
270
270
  className: "flex flex-wrap items-center gap-2 mt-4",
271
- children: [/* @__PURE__ */ S(se, {
271
+ children: [/* @__PURE__ */ S(ce, {
272
272
  size: 16,
273
273
  className: "text-text-secondary"
274
- }), P.tags.map((e) => /* @__PURE__ */ S(t, {
274
+ }), N.tags.map((e) => /* @__PURE__ */ S(t, {
275
275
  variant: "outline",
276
276
  className: "text-xs",
277
277
  children: e
@@ -281,53 +281,90 @@ function j() {
281
281
  }),
282
282
  /* @__PURE__ */ S("div", {
283
283
  className: "flex-1 overflow-y-auto p-4 sm:p-6",
284
- children: /* @__PURE__ */ S("div", {
284
+ children: /* @__PURE__ */ C("div", {
285
285
  className: "max-w-4xl mx-auto",
286
- children: /* @__PURE__ */ S("div", {
286
+ children: [/* @__PURE__ */ S(te, {
287
+ storageKey: "support-article-detail-admin",
288
+ title: "Manage this article",
289
+ className: "mb-6",
290
+ steps: [
291
+ {
292
+ id: "edit",
293
+ label: "Edit the article",
294
+ description: "Update the content, category or tags.",
295
+ onClick: () => j("edit")
296
+ },
297
+ ...N.status === "DRAFT" ? [{
298
+ id: "publish",
299
+ label: "Publish it",
300
+ description: "Make this article visible to customers.",
301
+ onClick: () => void Z()
302
+ }] : [{
303
+ id: "unpublish",
304
+ label: "Unpublish or archive",
305
+ description: "Hide it from customers while you revise.",
306
+ onClick: () => void Q(),
307
+ done: N.status === "ARCHIVED"
308
+ }],
309
+ {
310
+ id: "back-kb",
311
+ label: "Back to the knowledge base",
312
+ description: "Return to the full list of articles.",
313
+ onClick: () => j(`${M}/kb`)
314
+ }
315
+ ]
316
+ }), /* @__PURE__ */ S("div", {
287
317
  className: "prose prose-lg max-w-none dark:prose-invert text-text-primary",
288
- dangerouslySetInnerHTML: { __html: a.sanitize(P.content) }
289
- })
318
+ dangerouslySetInnerHTML: { __html: ie.sanitize(N.content) }
319
+ })]
290
320
  })
291
321
  }),
292
322
  /* @__PURE__ */ S("div", {
293
323
  className: "border-t border-border-subtle bg-bg-surface p-4 sm:p-6",
294
- children: /* @__PURE__ */ C("div", {
295
- className: "max-w-4xl mx-auto",
296
- children: [/* @__PURE__ */ S("h3", {
297
- className: "text-lg font-semibold mb-4 text-text-primary",
298
- children: "Was this article helpful?"
299
- }), /* @__PURE__ */ C("div", {
300
- className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",
301
- children: [/* @__PURE__ */ C(n, {
302
- variant: "outline",
303
- onClick: () => Z(!0),
304
- disabled: z,
305
- className: "px-6",
306
- children: [
307
- /* @__PURE__ */ S(le, { size: 20 }),
308
- "Yes (",
309
- P.helpfulCount,
310
- ")"
311
- ]
312
- }), /* @__PURE__ */ C(n, {
313
- variant: "outline",
314
- onClick: () => Z(!1),
315
- disabled: z,
316
- className: "px-6",
317
- children: [
318
- /* @__PURE__ */ S(ce, { size: 20 }),
319
- "No (",
320
- P.notHelpfulCount,
321
- ")"
322
- ]
323
- })]
324
- })]
324
+ children: /* @__PURE__ */ C(ee, {
325
+ className: "max-w-4xl mx-auto p-5",
326
+ children: [
327
+ /* @__PURE__ */ S("h3", {
328
+ className: "text-lg font-semibold mb-1 text-text-primary",
329
+ children: "Was this article helpful?"
330
+ }),
331
+ /* @__PURE__ */ S("p", {
332
+ className: "mb-4 text-sm text-text-secondary",
333
+ children: "See how readers rate this guide — low scores are a cue to revise it."
334
+ }),
335
+ /* @__PURE__ */ C("div", {
336
+ className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",
337
+ children: [/* @__PURE__ */ C(n, {
338
+ variant: "outline",
339
+ onClick: () => Y(!0),
340
+ disabled: R,
341
+ className: "px-6",
342
+ children: [
343
+ /* @__PURE__ */ S(ue, { size: 20 }),
344
+ "Yes (",
345
+ N.helpfulCount,
346
+ ")"
347
+ ]
348
+ }), /* @__PURE__ */ C(n, {
349
+ variant: "outline",
350
+ onClick: () => Y(!1),
351
+ disabled: R,
352
+ className: "px-6",
353
+ children: [
354
+ /* @__PURE__ */ S(le, { size: 20 }),
355
+ "No (",
356
+ N.notHelpfulCount,
357
+ ")"
358
+ ]
359
+ })]
360
+ })
361
+ ]
325
362
  })
326
363
  })
327
364
  ]
328
365
  });
329
366
  }
330
367
  //#endregion
331
- export { j as ArticleDetailAdminPage };
368
+ export { A as ArticleDetailAdminPage };
332
369
 
333
370
  //# sourceMappingURL=ArticleDetailAdminPage.js.map