Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit Β·
d02993d
1
Parent(s): 94b1a89
backend stabilization
Browse files- api/v1/dashboard.py +6 -4
- api/v1/messages.py +2 -0
- api/v1/reports.py +5 -5
- frontend/apps/customer/src/components/Analytics.tsx +20 -13
- frontend/apps/customer/src/components/Dashboard.tsx +14 -6
- frontend/apps/customer/src/components/KnowledgeBase.tsx +88 -87
- frontend/apps/customer/src/components/Skeleton.tsx +45 -0
- frontend/apps/customer/src/components/TicketList.tsx +20 -8
api/v1/dashboard.py
CHANGED
|
@@ -60,18 +60,20 @@ async def get_dashboard_stats(
|
|
| 60 |
if s not in counts: counts[s] = 0
|
| 61 |
total = sum(counts.values())
|
| 62 |
|
|
|
|
|
|
|
| 63 |
# 2. Advanced Metrics (High-Performance SQL Aggregations)
|
| 64 |
# Resolution Time: AVG(resolved - created)
|
| 65 |
-
# CSAT:
|
| 66 |
metrics_stmt = select(
|
| 67 |
func.avg(func.extract('epoch', Ticket.resolved_at - Ticket.created_at) / 3600).label("avg_res"),
|
| 68 |
-
func.avg(func.cast(
|
| 69 |
-
func.count(
|
| 70 |
func.count(Ticket.id).filter(
|
| 71 |
(Ticket.status.notin_([TicketStatus.RESOLVED, TicketStatus.CLOSED])) &
|
| 72 |
(Ticket.sla_deadline < now)
|
| 73 |
).label("breached_count")
|
| 74 |
-
).where(Ticket.deleted_at.is_(None))
|
| 75 |
|
| 76 |
if not is_global:
|
| 77 |
metrics_stmt = metrics_stmt.where(Ticket.workspace_id == target_ws)
|
|
|
|
| 60 |
if s not in counts: counts[s] = 0
|
| 61 |
total = sum(counts.values())
|
| 62 |
|
| 63 |
+
from models.feedback import Feedback
|
| 64 |
+
|
| 65 |
# 2. Advanced Metrics (High-Performance SQL Aggregations)
|
| 66 |
# Resolution Time: AVG(resolved - created)
|
| 67 |
+
# CSAT: Join with Feedback table for user ratings
|
| 68 |
metrics_stmt = select(
|
| 69 |
func.avg(func.extract('epoch', Ticket.resolved_at - Ticket.created_at) / 3600).label("avg_res"),
|
| 70 |
+
func.avg(func.cast(Feedback.rating, Float)).label("avg_csat"),
|
| 71 |
+
func.count(Feedback.id).label("rated_count"),
|
| 72 |
func.count(Ticket.id).filter(
|
| 73 |
(Ticket.status.notin_([TicketStatus.RESOLVED, TicketStatus.CLOSED])) &
|
| 74 |
(Ticket.sla_deadline < now)
|
| 75 |
).label("breached_count")
|
| 76 |
+
).outerjoin(Feedback, Ticket.id == Feedback.ticket_id).where(Ticket.deleted_at.is_(None))
|
| 77 |
|
| 78 |
if not is_global:
|
| 79 |
metrics_stmt = metrics_stmt.where(Ticket.workspace_id == target_ws)
|
api/v1/messages.py
CHANGED
|
@@ -42,7 +42,9 @@ async def parse_mentions(content: str, workspace_id: UUID, db: AsyncSession) ->
|
|
| 42 |
users = result.scalars().all()
|
| 43 |
|
| 44 |
return [{"user_id": str(u.id), "name": u.full_name} for u in users]
|
|
|
|
| 45 |
|
|
|
|
| 46 |
from models.user_workspace import UserWorkspace
|
| 47 |
# Fetch the role for the user *in this specific workspace*
|
| 48 |
stmt = (
|
|
|
|
| 42 |
users = result.scalars().all()
|
| 43 |
|
| 44 |
return [{"user_id": str(u.id), "name": u.full_name} for u in users]
|
| 45 |
+
|
| 46 |
|
| 47 |
+
async def sanitize_message_response(message: Message, db: AsyncSession) -> Message:
|
| 48 |
from models.user_workspace import UserWorkspace
|
| 49 |
# Fetch the role for the user *in this specific workspace*
|
| 50 |
stmt = (
|
api/v1/reports.py
CHANGED
|
@@ -16,7 +16,7 @@ from models.feedback import Feedback
|
|
| 16 |
|
| 17 |
router = APIRouter()
|
| 18 |
|
| 19 |
-
@router.get("/volume", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])
|
| 20 |
async def get_volume_trends(
|
| 21 |
workspace_id: str = None,
|
| 22 |
days: int = 30,
|
|
@@ -44,7 +44,7 @@ async def get_volume_trends(
|
|
| 44 |
result = await db.execute(stmt)
|
| 45 |
return {str(row[0]): row[1] for row in result.all()}
|
| 46 |
|
| 47 |
-
@router.get("/csat", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])
|
| 48 |
async def get_csat_report(
|
| 49 |
workspace_id: str = None,
|
| 50 |
current_user: User = Depends(get_current_user),
|
|
@@ -66,7 +66,7 @@ async def get_csat_report(
|
|
| 66 |
"total_responses": count
|
| 67 |
}
|
| 68 |
|
| 69 |
-
@router.get("/sla", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])
|
| 70 |
async def get_sla_compliance(
|
| 71 |
workspace_id: str = None,
|
| 72 |
current_user: User = Depends(get_current_user),
|
|
@@ -117,7 +117,7 @@ async def get_sla_compliance(
|
|
| 117 |
"on_time_tickets": on_time
|
| 118 |
}
|
| 119 |
|
| 120 |
-
@router.get("/insights", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])
|
| 121 |
async def get_ai_service_insights(
|
| 122 |
workspace_id: str = None,
|
| 123 |
current_user: User = Depends(get_current_user),
|
|
@@ -165,7 +165,7 @@ async def get_ai_service_insights(
|
|
| 165 |
insight_text = await generate_service_insights(metrics, ticket_data)
|
| 166 |
return {"insights": insight_text, "generated_at": now.isoformat()}
|
| 167 |
|
| 168 |
-
@router.get("/daily-stats", dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 169 |
async def get_daily_stats(
|
| 170 |
workspace_id: str = None,
|
| 171 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 16 |
|
| 17 |
router = APIRouter()
|
| 18 |
|
| 19 |
+
@router.get("/volume/", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])
|
| 20 |
async def get_volume_trends(
|
| 21 |
workspace_id: str = None,
|
| 22 |
days: int = 30,
|
|
|
|
| 44 |
result = await db.execute(stmt)
|
| 45 |
return {str(row[0]): row[1] for row in result.all()}
|
| 46 |
|
| 47 |
+
@router.get("/csat/", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])
|
| 48 |
async def get_csat_report(
|
| 49 |
workspace_id: str = None,
|
| 50 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 66 |
"total_responses": count
|
| 67 |
}
|
| 68 |
|
| 69 |
+
@router.get("/sla/", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])
|
| 70 |
async def get_sla_compliance(
|
| 71 |
workspace_id: str = None,
|
| 72 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 117 |
"on_time_tickets": on_time
|
| 118 |
}
|
| 119 |
|
| 120 |
+
@router.get("/insights/", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])
|
| 121 |
async def get_ai_service_insights(
|
| 122 |
workspace_id: str = None,
|
| 123 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 165 |
insight_text = await generate_service_insights(metrics, ticket_data)
|
| 166 |
return {"insights": insight_text, "generated_at": now.isoformat()}
|
| 167 |
|
| 168 |
+
@router.get("/daily-stats/", dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 169 |
async def get_daily_stats(
|
| 170 |
workspace_id: str = None,
|
| 171 |
current_user: User = Depends(get_current_user),
|
frontend/apps/customer/src/components/Analytics.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import React, { useState, useEffect } from 'react';
|
| 2 |
import { StatusBadge, PriorityBadge } from './Badges';
|
| 3 |
import { api } from '@nexus/shared';
|
|
|
|
| 4 |
import ReactMarkdown from 'react-markdown';
|
| 5 |
|
| 6 |
const COLORS = {
|
|
@@ -122,37 +123,37 @@ export const Analytics: React.FC<AnalyticsProps> = ({ tickets }) => {
|
|
| 122 |
{[
|
| 123 |
{
|
| 124 |
label: "Active Tickets",
|
| 125 |
-
value: total - resolvedCount,
|
| 126 |
-
footer: `${total} Total Tickets`,
|
| 127 |
color: "hsl(217, 91%, 60%)",
|
| 128 |
icon: "π",
|
| 129 |
-
viz: <Sparkline data={volumeValues.length > 0 ? volumeValues : [0,0,0]} color="hsl(217, 91%, 60%)" />
|
| 130 |
},
|
| 131 |
{
|
| 132 |
label: "SLA Compliance",
|
| 133 |
-
value: slaData ? `${Math.round(slaData.sla_compliance_rate * 100)}%` : "100%",
|
| 134 |
-
footer: `${slaData?.breached_tickets || 0} Rule Breaches`,
|
| 135 |
color: "hsl(142, 71%, 45%)",
|
| 136 |
icon: "β‘",
|
| 137 |
-
viz: <div style={{ height: 4, width: '100%', background: COLORS.gray100, borderRadius: 2 }}>
|
| 138 |
<div style={{ height: '100%', width: slaData ? `${slaData.sla_compliance_rate * 100}%` : '100%', background: "hsl(142, 71%, 45%)", borderRadius: 2 }} />
|
| 139 |
</div>
|
| 140 |
},
|
| 141 |
{
|
| 142 |
label: "Avg. Resolution",
|
| 143 |
-
value: avgResHours > 0 ? `${avgResHours.toFixed(1)}h` : "β",
|
| 144 |
-
footer: `${resolvedCount} Resolved Tickets`,
|
| 145 |
color: "hsl(262, 83%, 58%)",
|
| 146 |
icon: "β
",
|
| 147 |
-
viz: <div style={{ fontSize: 11, fontWeight: 600, color: COLORS.gray400 }}>Operational Threshold: 24h</div>
|
| 148 |
},
|
| 149 |
{
|
| 150 |
label: "CSAT Score",
|
| 151 |
-
value: csatData ? `${csatData.average_rating.toFixed(1)} / 5` : "4.8",
|
| 152 |
-
footer: `${csatData?.total_responses || 0} Valid Ratings`,
|
| 153 |
color: "hsl(38, 92%, 50%)",
|
| 154 |
icon: "β",
|
| 155 |
-
viz: <div style={{ fontSize: 11, color: "#EAB308" }}>{"β
".repeat(Math.round(csatData?.average_rating || 5)) + "β".repeat(5 - Math.round(csatData?.average_rating || 5))}</div>
|
| 156 |
},
|
| 157 |
].map(s => (
|
| 158 |
<div key={s.label} style={{
|
|
@@ -293,7 +294,13 @@ export const Analytics: React.FC<AnalyticsProps> = ({ tickets }) => {
|
|
| 293 |
transition: "opacity 0.3s ease"
|
| 294 |
}}
|
| 295 |
>
|
| 296 |
-
{loading ?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
<div className="prose prose-sm max-w-none">
|
| 298 |
<ReactMarkdown>{insights || "Workspace metrics are within normal operational parameters. All systems reporting healthy compliance levels."}</ReactMarkdown>
|
| 299 |
</div>
|
|
|
|
| 1 |
import React, { useState, useEffect } from 'react';
|
| 2 |
import { StatusBadge, PriorityBadge } from './Badges';
|
| 3 |
import { api } from '@nexus/shared';
|
| 4 |
+
import { Skeleton } from './Skeleton';
|
| 5 |
import ReactMarkdown from 'react-markdown';
|
| 6 |
|
| 7 |
const COLORS = {
|
|
|
|
| 123 |
{[
|
| 124 |
{
|
| 125 |
label: "Active Tickets",
|
| 126 |
+
value: loading ? <Skeleton width={60} height={32} /> : total - resolvedCount,
|
| 127 |
+
footer: loading ? <Skeleton width={100} height={12} /> : `${total} Total Tickets`,
|
| 128 |
color: "hsl(217, 91%, 60%)",
|
| 129 |
icon: "π",
|
| 130 |
+
viz: loading ? <Skeleton width={100} height={30} /> : <Sparkline data={volumeValues.length > 0 ? volumeValues : [0,0,0]} color="hsl(217, 91%, 60%)" />
|
| 131 |
},
|
| 132 |
{
|
| 133 |
label: "SLA Compliance",
|
| 134 |
+
value: loading ? <Skeleton width={80} height={32} /> : (slaData ? `${Math.round(slaData.sla_compliance_rate * 100)}%` : "100%"),
|
| 135 |
+
footer: loading ? <Skeleton width={100} height={12} /> : `${slaData?.breached_tickets || 0} Rule Breaches`,
|
| 136 |
color: "hsl(142, 71%, 45%)",
|
| 137 |
icon: "β‘",
|
| 138 |
+
viz: loading ? <Skeleton height={4} /> : <div style={{ height: 4, width: '100%', background: COLORS.gray100, borderRadius: 2 }}>
|
| 139 |
<div style={{ height: '100%', width: slaData ? `${slaData.sla_compliance_rate * 100}%` : '100%', background: "hsl(142, 71%, 45%)", borderRadius: 2 }} />
|
| 140 |
</div>
|
| 141 |
},
|
| 142 |
{
|
| 143 |
label: "Avg. Resolution",
|
| 144 |
+
value: loading ? <Skeleton width={70} height={32} /> : (avgResHours > 0 ? `${avgResHours.toFixed(1)}h` : "β"),
|
| 145 |
+
footer: loading ? <Skeleton width={100} height={12} /> : `${resolvedCount} Resolved Tickets`,
|
| 146 |
color: "hsl(262, 83%, 58%)",
|
| 147 |
icon: "β
",
|
| 148 |
+
viz: loading ? <Skeleton width={120} height={11} /> : <div style={{ fontSize: 11, fontWeight: 600, color: COLORS.gray400 }}>Operational Threshold: 24h</div>
|
| 149 |
},
|
| 150 |
{
|
| 151 |
label: "CSAT Score",
|
| 152 |
+
value: loading ? <Skeleton width={60} height={32} /> : (csatData ? `${csatData.average_rating.toFixed(1)} / 5` : "4.8"),
|
| 153 |
+
footer: loading ? <Skeleton width={100} height={12} /> : `${csatData?.total_responses || 0} Valid Ratings`,
|
| 154 |
color: "hsl(38, 92%, 50%)",
|
| 155 |
icon: "β",
|
| 156 |
+
viz: loading ? <Skeleton width={80} height={11} /> : <div style={{ fontSize: 11, color: "#EAB308" }}>{"β
".repeat(Math.round(csatData?.average_rating || 5)) + "β".repeat(5 - Math.round(csatData?.average_rating || 5))}</div>
|
| 157 |
},
|
| 158 |
].map(s => (
|
| 159 |
<div key={s.label} style={{
|
|
|
|
| 294 |
transition: "opacity 0.3s ease"
|
| 295 |
}}
|
| 296 |
>
|
| 297 |
+
{loading ? (
|
| 298 |
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
| 299 |
+
<Skeleton width="100%" height={16} />
|
| 300 |
+
<Skeleton width="95%" height={16} />
|
| 301 |
+
<Skeleton width="90%" height={16} />
|
| 302 |
+
</div>
|
| 303 |
+
) : (
|
| 304 |
<div className="prose prose-sm max-w-none">
|
| 305 |
<ReactMarkdown>{insights || "Workspace metrics are within normal operational parameters. All systems reporting healthy compliance levels."}</ReactMarkdown>
|
| 306 |
</div>
|
frontend/apps/customer/src/components/Dashboard.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import React, { useState, useEffect } from 'react';
|
| 2 |
import { StatusBadge } from './Badges';
|
| 3 |
import { api } from '@nexus/shared';
|
|
|
|
| 4 |
|
| 5 |
const COLORS = {
|
| 6 |
brand: "#1E40AF",
|
|
@@ -126,9 +127,9 @@ export const Dashboard: React.FC<DashboardProps> = ({ setActive, setSelectedTick
|
|
| 126 |
{/* Right Section: Workspace Intelligence Hub */}
|
| 127 |
<div style={{ display: "flex", gap: 16, flexWrap: "wrap", justifyContent: "flex-end" }}>
|
| 128 |
{[
|
| 129 |
-
{ label: "WORKSPACE VOLUME", value: stats?.total_tickets
|
| 130 |
-
{ label: "ACTIVE LOAD", value:
|
| 131 |
-
{ label: "RESOLVED SUCCESS", value:
|
| 132 |
].map(s => (
|
| 133 |
<div key={s.label} style={{
|
| 134 |
background: "rgba(255, 255, 255, 0.12)",
|
|
@@ -156,8 +157,8 @@ export const Dashboard: React.FC<DashboardProps> = ({ setActive, setSelectedTick
|
|
| 156 |
|
| 157 |
<div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 14, marginBottom: 24 }}>
|
| 158 |
{[
|
| 159 |
-
{ label: "Open tickets", value: activeTickets.length.toString(), sub: "Active cases", color: COLORS.brand },
|
| 160 |
-
{ label: "Resolved (Total)", value: resolvedCount.toString(), sub: "Lifetime count", color: COLORS.success },
|
| 161 |
{
|
| 162 |
label: "Avg. resolution",
|
| 163 |
value: avgResStr,
|
|
@@ -183,7 +184,14 @@ export const Dashboard: React.FC<DashboardProps> = ({ setActive, setSelectedTick
|
|
| 183 |
<div style={{ background: "#fff", border: `1px solid ${COLORS.gray200}`, borderRadius: 10, padding: "20px" }}>
|
| 184 |
<div style={{ fontSize: 14, fontWeight: 600, color: COLORS.gray800, marginBottom: 16 }}>Latest updates</div>
|
| 185 |
{loading ? (
|
| 186 |
-
<div style={{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
) : activeTickets.length === 0 ? (
|
| 188 |
<div style={{ fontSize: 13, color: COLORS.gray400, textAlign: 'center', padding: '20px 0' }}>No active tickets</div>
|
| 189 |
) : activeTickets.slice(0, 5).map(t => (
|
|
|
|
| 1 |
import React, { useState, useEffect } from 'react';
|
| 2 |
import { StatusBadge } from './Badges';
|
| 3 |
import { api } from '@nexus/shared';
|
| 4 |
+
import { Skeleton } from './Skeleton';
|
| 5 |
|
| 6 |
const COLORS = {
|
| 7 |
brand: "#1E40AF",
|
|
|
|
| 127 |
{/* Right Section: Workspace Intelligence Hub */}
|
| 128 |
<div style={{ display: "flex", gap: 16, flexWrap: "wrap", justifyContent: "flex-end" }}>
|
| 129 |
{[
|
| 130 |
+
{ label: "WORKSPACE VOLUME", value: stats?.total_tickets ?? (loading ? <Skeleton width={40} height={28} /> : "0"), sub: "Lifetime Tickets", icon: "π" },
|
| 131 |
+
{ label: "ACTIVE LOAD", value: stats ? (stats.by_status?.OPEN || 0) + (stats.by_status?.IN_PROGRESS || 0) + (stats.by_status?.ACKNOWLEDGED || 0) : (loading ? <Skeleton width={40} height={28} /> : 0), sub: "Open Cases", icon: "β‘" },
|
| 132 |
+
{ label: "RESOLVED SUCCESS", value: stats ? (stats.by_status?.RESOLVED || 0) + (stats.by_status?.CLOSED || 0) : (loading ? <Skeleton width={40} height={28} /> : 0), sub: "Completed Tasks", icon: "β
" }
|
| 133 |
].map(s => (
|
| 134 |
<div key={s.label} style={{
|
| 135 |
background: "rgba(255, 255, 255, 0.12)",
|
|
|
|
| 157 |
|
| 158 |
<div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 14, marginBottom: 24 }}>
|
| 159 |
{[
|
| 160 |
+
{ label: "Open tickets", value: loading ? <Skeleton width={30} height={24} /> : activeTickets.length.toString(), sub: "Active cases", color: COLORS.brand },
|
| 161 |
+
{ label: "Resolved (Total)", value: loading ? <Skeleton width={30} height={24} /> : resolvedCount.toString(), sub: "Lifetime count", color: COLORS.success },
|
| 162 |
{
|
| 163 |
label: "Avg. resolution",
|
| 164 |
value: avgResStr,
|
|
|
|
| 184 |
<div style={{ background: "#fff", border: `1px solid ${COLORS.gray200}`, borderRadius: 10, padding: "20px" }}>
|
| 185 |
<div style={{ fontSize: 14, fontWeight: 600, color: COLORS.gray800, marginBottom: 16 }}>Latest updates</div>
|
| 186 |
{loading ? (
|
| 187 |
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
| 188 |
+
{[1, 2, 3, 4].map(i => (
|
| 189 |
+
<div key={i} style={{ padding: "12px 0", borderTop: i > 1 ? `1px solid ${COLORS.gray100}` : 'none' }}>
|
| 190 |
+
<Skeleton width="60%" height={16} marginBottom={8} />
|
| 191 |
+
<Skeleton width="40%" height={12} />
|
| 192 |
+
</div>
|
| 193 |
+
))}
|
| 194 |
+
</div>
|
| 195 |
) : activeTickets.length === 0 ? (
|
| 196 |
<div style={{ fontSize: 13, color: COLORS.gray400, textAlign: 'center', padding: '20px 0' }}>No active tickets</div>
|
| 197 |
) : activeTickets.slice(0, 5).map(t => (
|
frontend/apps/customer/src/components/KnowledgeBase.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
import React, { useState, useEffect } from 'react';
|
| 2 |
import { api } from '@nexus/shared';
|
|
|
|
|
|
|
| 3 |
|
| 4 |
const COLORS = {
|
| 5 |
brand: "#1E40AF",
|
|
@@ -67,7 +69,6 @@ export const KnowledgeBase: React.FC<KnowledgeBaseProps> = ({ onNewTicket }) =>
|
|
| 67 |
} else {
|
| 68 |
res = await api.get('kb/', { params: { category: activeCategory } });
|
| 69 |
let data = res.data || [];
|
| 70 |
-
// Local Sorting
|
| 71 |
data.sort((a: any, b: any) => {
|
| 72 |
const dateA = new Date(a.created_at).getTime();
|
| 73 |
const dateB = new Date(b.created_at).getTime();
|
|
@@ -86,15 +87,11 @@ export const KnowledgeBase: React.FC<KnowledgeBaseProps> = ({ onNewTicket }) =>
|
|
| 86 |
|
| 87 |
const renderRichContent = (content: string) => {
|
| 88 |
if (!content) return null;
|
| 89 |
-
|
| 90 |
-
// Pattern for Markdown images: 
|
| 91 |
const imgRegex = /!\[(.*?)\]\((.*?)\)/g;
|
| 92 |
const parts = content.split(imgRegex);
|
| 93 |
-
|
| 94 |
const result = [];
|
| 95 |
for (let i = 0; i < parts.length; i++) {
|
| 96 |
if (i % 3 === 0) {
|
| 97 |
-
// Regular text
|
| 98 |
if (parts[i]) {
|
| 99 |
result.push(
|
| 100 |
<div key={`text-${i}`} style={{ whiteSpace: "pre-wrap", marginBottom: (i < parts.length - 1) ? 0 : 0 }}>
|
|
@@ -103,10 +100,8 @@ export const KnowledgeBase: React.FC<KnowledgeBaseProps> = ({ onNewTicket }) =>
|
|
| 103 |
);
|
| 104 |
}
|
| 105 |
} else if (i % 3 === 1) {
|
| 106 |
-
// Alt text (skip, handled by next index)
|
| 107 |
continue;
|
| 108 |
} else {
|
| 109 |
-
// URL
|
| 110 |
const alt = parts[i-1];
|
| 111 |
const url = parts[i];
|
| 112 |
result.push(
|
|
@@ -127,7 +122,6 @@ export const KnowledgeBase: React.FC<KnowledgeBaseProps> = ({ onNewTicket }) =>
|
|
| 127 |
);
|
| 128 |
}
|
| 129 |
}
|
| 130 |
-
|
| 131 |
return result;
|
| 132 |
};
|
| 133 |
|
|
@@ -186,7 +180,7 @@ export const KnowledgeBase: React.FC<KnowledgeBaseProps> = ({ onNewTicket }) =>
|
|
| 186 |
|
| 187 |
return (
|
| 188 |
<div style={{ padding: "32px 48px" }}>
|
| 189 |
-
{/*
|
| 190 |
<div style={{ marginBottom: 48 }}>
|
| 191 |
<h1 style={{ fontSize: 32, fontWeight: 800, color: COLORS.gray900, marginBottom: 8, letterSpacing: "-0.02em" }}>Knowledge Base</h1>
|
| 192 |
<p style={{ color: COLORS.gray500, fontSize: 15, marginBottom: 32 }}>Expert guides and troubleshooting for everything Nexus.</p>
|
|
@@ -197,14 +191,12 @@ export const KnowledgeBase: React.FC<KnowledgeBaseProps> = ({ onNewTicket }) =>
|
|
| 197 |
value={searchInput}
|
| 198 |
onChange={e => setSearchInput(e.target.value)}
|
| 199 |
onKeyDown={e => {
|
| 200 |
-
if (e.key === 'Enter')
|
| 201 |
-
setSearch(searchInput);
|
| 202 |
-
}
|
| 203 |
}}
|
| 204 |
placeholder="How can we help you today?"
|
| 205 |
style={{
|
| 206 |
width: "100%", padding: "16px 20px 16px 52px", borderRadius: 16, border: `1px solid ${COLORS.gray200}`,
|
| 207 |
-
fontSize: 16, boxSizing: "border-box", outline: "none", boxShadow: "0 2px 10px rgba(0,0,0,0.03)"
|
| 208 |
}}
|
| 209 |
/>
|
| 210 |
<button
|
|
@@ -218,7 +210,6 @@ export const KnowledgeBase: React.FC<KnowledgeBaseProps> = ({ onNewTicket }) =>
|
|
| 218 |
Search
|
| 219 |
</button>
|
| 220 |
<span style={{ position: "absolute", left: 20, top: "50%", transform: "translateY(-50%)", fontSize: 20, opacity: 0.4 }}>π</span>
|
| 221 |
-
{loading && searchInput.length > 0 && <span style={{ position: "absolute", right: 100, top: "50%", transform: "translateY(-50%)", fontSize: 12, color: COLORS.brand, fontWeight: 600 }}>Searching AI...</span>}
|
| 222 |
</div>
|
| 223 |
|
| 224 |
<div style={{ display: "flex", gap: 12, alignItems: "center" }}>
|
|
@@ -234,17 +225,14 @@ export const KnowledgeBase: React.FC<KnowledgeBaseProps> = ({ onNewTicket }) =>
|
|
| 234 |
</div>
|
| 235 |
</div>
|
| 236 |
|
| 237 |
-
{/* AI Suggestions */}
|
| 238 |
{suggestions.length > 0 && (
|
| 239 |
<div style={{ marginTop: 20, display: "flex", gap: 10, alignItems: "center", flexWrap: "wrap" }}>
|
| 240 |
-
<span style={{ fontSize: 11, fontWeight: 800, color: COLORS.brand, textTransform: "uppercase", letterSpacing: "0.05em"
|
| 241 |
{suggestions.map(s => (
|
| 242 |
<button
|
| 243 |
key={s}
|
| 244 |
onClick={() => { setSearchInput(s); setSearch(s); }}
|
| 245 |
-
style={{ padding: "6px 14px", borderRadius: 20, border: `1px solid ${COLORS.brand}22`, background: COLORS.brandLight, color: COLORS.brand, fontSize: 12, fontWeight: 600, cursor: "pointer"
|
| 246 |
-
onMouseEnter={e => e.currentTarget.style.background = COLORS.brand}
|
| 247 |
-
onMouseLeave={e => e.currentTarget.style.background = COLORS.brandLight}
|
| 248 |
>
|
| 249 |
{s}
|
| 250 |
</button>
|
|
@@ -273,80 +261,93 @@ export const KnowledgeBase: React.FC<KnowledgeBaseProps> = ({ onNewTicket }) =>
|
|
| 273 |
</div>
|
| 274 |
|
| 275 |
{/* Article Feed */}
|
| 276 |
-
{
|
| 277 |
-
|
| 278 |
-
<div style={{ color: COLORS.gray300, fontSize: 14 }}>Connecting to help library...</div>
|
| 279 |
-
</div>
|
| 280 |
-
) : articles.length === 0 ? (
|
| 281 |
-
<div style={{ padding: "100px 0", textAlign: "center" }}>
|
| 282 |
-
<div style={{ fontSize: 48, marginBottom: 20 }}>π</div>
|
| 283 |
-
<h3 style={{ fontSize: 20, fontWeight: 700, color: COLORS.gray900, marginBottom: 8 }}>We couldn't find that</h3>
|
| 284 |
-
<p style={{ color: COLORS.gray500, fontSize: 14 }}>Try searching for broader terms or check a different category.</p>
|
| 285 |
-
</div>
|
| 286 |
-
) : (
|
| 287 |
-
<div style={{ maxWidth: 1100, margin: "0 auto" }}>
|
| 288 |
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(440px, 1fr))", gap: 32 }}>
|
| 289 |
-
{
|
| 290 |
-
<div
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
<
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
onMouseEnter={e => {
|
| 300 |
-
e.currentTarget.style.transform = "translateY(-4px)";
|
| 301 |
-
e.currentTarget.style.boxShadow = "0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.04)";
|
| 302 |
-
e.currentTarget.style.borderColor = COLORS.brand;
|
| 303 |
-
}}
|
| 304 |
-
onMouseLeave={e => {
|
| 305 |
-
e.currentTarget.style.transform = "none";
|
| 306 |
-
e.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.02)";
|
| 307 |
-
e.currentTarget.style.borderColor = COLORS.gray100;
|
| 308 |
-
}}
|
| 309 |
-
>
|
| 310 |
-
<span style={{ fontSize: 10, fontWeight: 800, color: COLORS.brand, textTransform: "uppercase", letterSpacing: "0.1em", marginBottom: 16, display: "block" }}>{article.category || "N/A"}</span>
|
| 311 |
-
<h3 style={{ fontSize: 22, fontWeight: 800, color: COLORS.gray900, marginBottom: 12, lineHeight: 1.2, wordBreak: "break-word", overflowWrap: "anywhere" }}>{article.title}</h3>
|
| 312 |
-
<p style={{
|
| 313 |
-
fontSize: 15, color: COLORS.gray600, lineHeight: 1.6, marginBottom: 24,
|
| 314 |
-
display: "-webkit-box", WebkitLineClamp: 3, WebkitBoxOrient: "vertical", overflow: "hidden",
|
| 315 |
-
wordBreak: "break-word", overflowWrap: "anywhere"
|
| 316 |
-
}}>
|
| 317 |
-
{article.content.slice(0, 180)}...
|
| 318 |
-
</p>
|
| 319 |
-
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", borderTop: `1px solid ${COLORS.gray50}`, paddingTop: 24, marginTop: "auto" }}>
|
| 320 |
-
<span style={{ fontSize: 12, color: COLORS.gray400, fontWeight: 500 }}>Published {new Date(article.created_at).toLocaleDateString()}</span>
|
| 321 |
-
<span style={{ fontSize: 13, fontWeight: 700, color: COLORS.brand }}>Read Guide β</span>
|
| 322 |
-
</div>
|
| 323 |
</div>
|
| 324 |
</div>
|
| 325 |
))}
|
| 326 |
</div>
|
| 327 |
-
|
| 328 |
-
{
|
| 329 |
-
|
| 330 |
-
<
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 346 |
</div>
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 350 |
</div>
|
| 351 |
);
|
| 352 |
};
|
|
|
|
| 1 |
import React, { useState, useEffect } from 'react';
|
| 2 |
import { api } from '@nexus/shared';
|
| 3 |
+
import { Skeleton } from './Skeleton';
|
| 4 |
+
import { StatusBadge } from './Badges'; // Assuming StatusBadge might be needed, or keep same imports as before
|
| 5 |
|
| 6 |
const COLORS = {
|
| 7 |
brand: "#1E40AF",
|
|
|
|
| 69 |
} else {
|
| 70 |
res = await api.get('kb/', { params: { category: activeCategory } });
|
| 71 |
let data = res.data || [];
|
|
|
|
| 72 |
data.sort((a: any, b: any) => {
|
| 73 |
const dateA = new Date(a.created_at).getTime();
|
| 74 |
const dateB = new Date(b.created_at).getTime();
|
|
|
|
| 87 |
|
| 88 |
const renderRichContent = (content: string) => {
|
| 89 |
if (!content) return null;
|
|
|
|
|
|
|
| 90 |
const imgRegex = /!\[(.*?)\]\((.*?)\)/g;
|
| 91 |
const parts = content.split(imgRegex);
|
|
|
|
| 92 |
const result = [];
|
| 93 |
for (let i = 0; i < parts.length; i++) {
|
| 94 |
if (i % 3 === 0) {
|
|
|
|
| 95 |
if (parts[i]) {
|
| 96 |
result.push(
|
| 97 |
<div key={`text-${i}`} style={{ whiteSpace: "pre-wrap", marginBottom: (i < parts.length - 1) ? 0 : 0 }}>
|
|
|
|
| 100 |
);
|
| 101 |
}
|
| 102 |
} else if (i % 3 === 1) {
|
|
|
|
| 103 |
continue;
|
| 104 |
} else {
|
|
|
|
| 105 |
const alt = parts[i-1];
|
| 106 |
const url = parts[i];
|
| 107 |
result.push(
|
|
|
|
| 122 |
);
|
| 123 |
}
|
| 124 |
}
|
|
|
|
| 125 |
return result;
|
| 126 |
};
|
| 127 |
|
|
|
|
| 180 |
|
| 181 |
return (
|
| 182 |
<div style={{ padding: "32px 48px" }}>
|
| 183 |
+
{/* Search Hero */}
|
| 184 |
<div style={{ marginBottom: 48 }}>
|
| 185 |
<h1 style={{ fontSize: 32, fontWeight: 800, color: COLORS.gray900, marginBottom: 8, letterSpacing: "-0.02em" }}>Knowledge Base</h1>
|
| 186 |
<p style={{ color: COLORS.gray500, fontSize: 15, marginBottom: 32 }}>Expert guides and troubleshooting for everything Nexus.</p>
|
|
|
|
| 191 |
value={searchInput}
|
| 192 |
onChange={e => setSearchInput(e.target.value)}
|
| 193 |
onKeyDown={e => {
|
| 194 |
+
if (e.key === 'Enter') setSearch(searchInput);
|
|
|
|
|
|
|
| 195 |
}}
|
| 196 |
placeholder="How can we help you today?"
|
| 197 |
style={{
|
| 198 |
width: "100%", padding: "16px 20px 16px 52px", borderRadius: 16, border: `1px solid ${COLORS.gray200}`,
|
| 199 |
+
fontSize: 16, boxSizing: "border-box", outline: "none", boxShadow: "0 2px 10px rgba(0,0,0,0.03)"
|
| 200 |
}}
|
| 201 |
/>
|
| 202 |
<button
|
|
|
|
| 210 |
Search
|
| 211 |
</button>
|
| 212 |
<span style={{ position: "absolute", left: 20, top: "50%", transform: "translateY(-50%)", fontSize: 20, opacity: 0.4 }}>π</span>
|
|
|
|
| 213 |
</div>
|
| 214 |
|
| 215 |
<div style={{ display: "flex", gap: 12, alignItems: "center" }}>
|
|
|
|
| 225 |
</div>
|
| 226 |
</div>
|
| 227 |
|
|
|
|
| 228 |
{suggestions.length > 0 && (
|
| 229 |
<div style={{ marginTop: 20, display: "flex", gap: 10, alignItems: "center", flexWrap: "wrap" }}>
|
| 230 |
+
<span style={{ fontSize: 11, fontWeight: 800, color: COLORS.brand, textTransform: "uppercase", letterSpacing: "0.05em" }}>Suggestions:</span>
|
| 231 |
{suggestions.map(s => (
|
| 232 |
<button
|
| 233 |
key={s}
|
| 234 |
onClick={() => { setSearchInput(s); setSearch(s); }}
|
| 235 |
+
style={{ padding: "6px 14px", borderRadius: 20, border: `1px solid ${COLORS.brand}22`, background: COLORS.brandLight, color: COLORS.brand, fontSize: 12, fontWeight: 600, cursor: "pointer" }}
|
|
|
|
|
|
|
| 236 |
>
|
| 237 |
{s}
|
| 238 |
</button>
|
|
|
|
| 261 |
</div>
|
| 262 |
|
| 263 |
{/* Article Feed */}
|
| 264 |
+
<div style={{ maxWidth: 1100, margin: "0 auto" }}>
|
| 265 |
+
{loading ? (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(440px, 1fr))", gap: 32 }}>
|
| 267 |
+
{[1, 2, 3, 4].map(i => (
|
| 268 |
+
<div key={i} style={{ background: "#fff", border: `1px solid ${COLORS.gray100}`, borderRadius: 20, padding: 32 }}>
|
| 269 |
+
<Skeleton width="30%" height={12} marginBottom={16} />
|
| 270 |
+
<Skeleton width="80%" height={24} marginBottom={12} />
|
| 271 |
+
<Skeleton width="100%" height={16} marginBottom={8} />
|
| 272 |
+
<Skeleton width="100%" height={16} marginBottom={8} />
|
| 273 |
+
<Skeleton width="60%" height={16} marginBottom={24} />
|
| 274 |
+
<div style={{ display: "flex", justifyContent: "space-between", borderTop: `1px solid ${COLORS.gray50}`, paddingTop: 24 }}>
|
| 275 |
+
<Skeleton width="40%" height={12} />
|
| 276 |
+
<Skeleton width="20%" height={12} />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
</div>
|
| 278 |
</div>
|
| 279 |
))}
|
| 280 |
</div>
|
| 281 |
+
) : articles.length === 0 ? (
|
| 282 |
+
<div style={{ padding: "100px 0", textAlign: "center" }}>
|
| 283 |
+
<div style={{ fontSize: 48, marginBottom: 20 }}>π</div>
|
| 284 |
+
<h3 style={{ fontSize: 20, fontWeight: 700, color: COLORS.gray900, marginBottom: 8 }}>We couldn't find that</h3>
|
| 285 |
+
<p style={{ color: COLORS.gray500, fontSize: 14 }}>Try searching for broader terms or check a different category.</p>
|
| 286 |
+
</div>
|
| 287 |
+
) : (
|
| 288 |
+
<>
|
| 289 |
+
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(440px, 1fr))", gap: 32 }}>
|
| 290 |
+
{paginated.map(article => (
|
| 291 |
+
<div
|
| 292 |
+
key={article.id}
|
| 293 |
+
onClick={() => setSelectedArticle(article)}
|
| 294 |
+
style={{ cursor: "pointer", display: "flex" }}
|
| 295 |
+
>
|
| 296 |
+
<div style={{
|
| 297 |
+
background: "#fff", border: `1px solid ${COLORS.gray100}`, borderRadius: 20, padding: 32, transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
| 298 |
+
boxShadow: "0 2px 4px rgba(0,0,0,0.02)", display: "flex", flexDirection: "column", flex: 1, height: "100%"
|
| 299 |
+
}}
|
| 300 |
+
onMouseEnter={e => {
|
| 301 |
+
e.currentTarget.style.transform = "translateY(-4px)";
|
| 302 |
+
e.currentTarget.style.boxShadow = "0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.04)";
|
| 303 |
+
e.currentTarget.style.borderColor = COLORS.brand;
|
| 304 |
+
}}
|
| 305 |
+
onMouseLeave={e => {
|
| 306 |
+
e.currentTarget.style.transform = "none";
|
| 307 |
+
e.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.02)";
|
| 308 |
+
e.currentTarget.style.borderColor = COLORS.gray100;
|
| 309 |
+
}}
|
| 310 |
+
>
|
| 311 |
+
<span style={{ fontSize: 10, fontWeight: 800, color: COLORS.brand, textTransform: "uppercase", letterSpacing: "0.1em", marginBottom: 16, display: "block" }}>{article.category || "N/A"}</span>
|
| 312 |
+
<h3 style={{ fontSize: 22, fontWeight: 800, color: COLORS.gray900, marginBottom: 12, lineHeight: 1.2, wordBreak: "break-word", overflowWrap: "anywhere" }}>{article.title}</h3>
|
| 313 |
+
<p style={{
|
| 314 |
+
fontSize: 15, color: COLORS.gray600, lineHeight: 1.6, marginBottom: 24,
|
| 315 |
+
display: "-webkit-box", WebkitLineClamp: 3, WebkitBoxOrient: "vertical", overflow: "hidden",
|
| 316 |
+
wordBreak: "break-word", overflowWrap: "anywhere"
|
| 317 |
+
}}>
|
| 318 |
+
{article.summary || article.content.slice(0, 180)}...
|
| 319 |
+
</p>
|
| 320 |
+
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", borderTop: `1px solid ${COLORS.gray50}`, paddingTop: 24, marginTop: "auto" }}>
|
| 321 |
+
<span style={{ fontSize: 12, color: COLORS.gray400, fontWeight: 500 }}>Published {new Date(article.created_at).toLocaleDateString()}</span>
|
| 322 |
+
<span style={{ fontSize: 13, fontWeight: 700, color: COLORS.brand }}>Read Guide β</span>
|
| 323 |
+
</div>
|
| 324 |
+
</div>
|
| 325 |
+
</div>
|
| 326 |
+
))}
|
| 327 |
</div>
|
| 328 |
+
|
| 329 |
+
{totalPages > 1 && (
|
| 330 |
+
<div style={{ display: "flex", justifyContent: "center", alignItems: "center", gap: 24, marginTop: 60 }}>
|
| 331 |
+
<button
|
| 332 |
+
disabled={page === 1}
|
| 333 |
+
onClick={() => setPage(p => p - 1)}
|
| 334 |
+
style={{ padding: "10px 24px", borderRadius: 12, border: `1px solid ${COLORS.gray200}`, background: "#fff", fontWeight: 700, fontSize: 14, color: page === 1 ? COLORS.gray300 : COLORS.gray900, cursor: page === 1 ? "default" : "pointer" }}
|
| 335 |
+
>
|
| 336 |
+
Previous
|
| 337 |
+
</button>
|
| 338 |
+
<div style={{ fontSize: 14, fontWeight: 600, color: COLORS.gray600 }}>Page {page} of {totalPages}</div>
|
| 339 |
+
<button
|
| 340 |
+
disabled={page === totalPages}
|
| 341 |
+
onClick={() => setPage(p => p + 1)}
|
| 342 |
+
style={{ padding: "10px 24px", borderRadius: 12, border: `1px solid ${COLORS.gray200}`, background: "#fff", fontWeight: 700, fontSize: 14, color: page === totalPages ? COLORS.gray300 : COLORS.gray900, cursor: page === totalPages ? "default" : "pointer" }}
|
| 343 |
+
>
|
| 344 |
+
Next
|
| 345 |
+
</button>
|
| 346 |
+
</div>
|
| 347 |
+
)}
|
| 348 |
+
</>
|
| 349 |
+
)}
|
| 350 |
+
</div>
|
| 351 |
</div>
|
| 352 |
);
|
| 353 |
};
|
frontend/apps/customer/src/components/Skeleton.tsx
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
|
| 3 |
+
interface SkeletonProps {
|
| 4 |
+
width?: string | number;
|
| 5 |
+
height?: string | number;
|
| 6 |
+
borderRadius?: string | number;
|
| 7 |
+
marginBottom?: string | number;
|
| 8 |
+
style?: React.CSSProperties;
|
| 9 |
+
className?: string;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
export const Skeleton: React.FC<SkeletonProps> = ({
|
| 13 |
+
width = '100%',
|
| 14 |
+
height = '1em',
|
| 15 |
+
borderRadius = 4,
|
| 16 |
+
marginBottom = 0,
|
| 17 |
+
style,
|
| 18 |
+
className
|
| 19 |
+
}) => {
|
| 20 |
+
const skeletonStyle: React.CSSProperties = {
|
| 21 |
+
width,
|
| 22 |
+
height,
|
| 23 |
+
borderRadius,
|
| 24 |
+
marginBottom,
|
| 25 |
+
background: '#E5E7EB',
|
| 26 |
+
backgroundImage: 'linear-gradient(90deg, #E5E7EB 0px, #F3F4F6 50%, #E5E7EB 100%)',
|
| 27 |
+
backgroundSize: '200% 100%',
|
| 28 |
+
animation: 'skeleton-pulse 1.5s infinite linear',
|
| 29 |
+
...style
|
| 30 |
+
};
|
| 31 |
+
|
| 32 |
+
return (
|
| 33 |
+
<>
|
| 34 |
+
<style>
|
| 35 |
+
{`
|
| 36 |
+
@keyframes skeleton-pulse {
|
| 37 |
+
0% { background-position: 200% 0; }
|
| 38 |
+
100% { background-position: -200% 0; }
|
| 39 |
+
}
|
| 40 |
+
`}
|
| 41 |
+
</style>
|
| 42 |
+
<div style={skeletonStyle} className={className} />
|
| 43 |
+
</>
|
| 44 |
+
);
|
| 45 |
+
};
|
frontend/apps/customer/src/components/TicketList.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import React, { useState, useEffect } from 'react';
|
| 2 |
import { StatusBadge, PriorityBadge } from './Badges';
|
| 3 |
import { api } from '@nexus/shared';
|
|
|
|
| 4 |
|
| 5 |
const COLORS = {
|
| 6 |
brand: "#1E40AF",
|
|
@@ -126,16 +127,27 @@ export const TicketList: React.FC<TicketListProps> = ({ setActive, setSelectedTi
|
|
| 126 |
{/* Main List Section (75%) */}
|
| 127 |
<div style={{ flex: 1, minWidth: 0 }}>
|
| 128 |
<div style={{ background: "#fff", border: `1px solid ${COLORS.gray200}`, borderRadius: 12, overflow: "hidden", boxShadow: "0 1px 3px rgba(0,0,0,0.05)" }}>
|
| 129 |
-
{loading
|
| 130 |
-
<div style={{
|
| 131 |
-
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
</div>
|
| 134 |
) : filtered.length === 0 ? (
|
| 135 |
-
<div style={{
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
| 139 |
</div>
|
| 140 |
) : (
|
| 141 |
<table style={{ width: "100%", borderCollapse: "collapse" }}>
|
|
|
|
| 1 |
import React, { useState, useEffect } from 'react';
|
| 2 |
import { StatusBadge, PriorityBadge } from './Badges';
|
| 3 |
import { api } from '@nexus/shared';
|
| 4 |
+
import { Skeleton } from './Skeleton';
|
| 5 |
|
| 6 |
const COLORS = {
|
| 7 |
brand: "#1E40AF",
|
|
|
|
| 127 |
{/* Main List Section (75%) */}
|
| 128 |
<div style={{ flex: 1, minWidth: 0 }}>
|
| 129 |
<div style={{ background: "#fff", border: `1px solid ${COLORS.gray200}`, borderRadius: 12, overflow: "hidden", boxShadow: "0 1px 3px rgba(0,0,0,0.05)" }}>
|
| 130 |
+
{loading ? (
|
| 131 |
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
|
| 132 |
+
{[1, 2, 3, 4, 5].map(i => (
|
| 133 |
+
<div key={i} style={{ padding: "16px", borderBottom: `1px solid ${COLORS.gray100}`, display: "flex", alignItems: "center", gap: 16 }}>
|
| 134 |
+
<div style={{ flex: 1 }}>
|
| 135 |
+
<Skeleton width="40%" height={20} marginBottom={8} />
|
| 136 |
+
<Skeleton width="20%" height={12} />
|
| 137 |
+
</div>
|
| 138 |
+
<Skeleton width={80} height={20} />
|
| 139 |
+
<Skeleton width={60} height={20} />
|
| 140 |
+
</div>
|
| 141 |
+
))}
|
| 142 |
</div>
|
| 143 |
) : filtered.length === 0 ? (
|
| 144 |
+
<div style={{
|
| 145 |
+
padding: "64px 32px", textAlign: "center",
|
| 146 |
+
background: "#fff", border: `1px solid ${COLORS.gray100}`, borderRadius: 12
|
| 147 |
+
}}>
|
| 148 |
+
<div style={{ fontSize: 48, marginBottom: 16 }}>π</div>
|
| 149 |
+
<div style={{ fontSize: 18, fontWeight: 700, color: COLORS.gray800, marginBottom: 8 }}>No tickets found</div>
|
| 150 |
+
<div style={{ fontSize: 14, color: COLORS.gray400 }}>Try adjusting your filters or search query.</div>
|
| 151 |
</div>
|
| 152 |
) : (
|
| 153 |
<table style={{ width: "100%", borderCollapse: "collapse" }}>
|