Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit Β·
d02993d
1
Parent(s): 94b1a89
backend stabilization
Browse filesFiles changed (8)
- api/v1/dashboard.py+6-4
- api/v1/messages.py+2
- 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.tsxAdded+45
- frontend/apps/customer/src/components/TicketList.tsx+20-8
59 unmodified lines60616263646566676869707172737475767759 unmodified linesif s not in counts: counts[s] = 0total = sum(counts.values())# 2. Advanced Metrics (High-Performance SQL Aggregations)# Resolution Time: AVG(resolved - created)# CSAT: AVG(ai_metadata -> 'rating')metrics_stmt = select(func.avg(func.extract('epoch', Ticket.resolved_at - Ticket.created_at) / 3600).label("avg_res"),func.avg(func.cast(Ticket.ai_metadata['rating'].astext, Float)).label("avg_csat"),func.count(Ticket.id).filter(Ticket.ai_metadata['rating'].isnot(None)).label("rated_count"),func.count(Ticket.id).filter((Ticket.status.notin_([TicketStatus.RESOLVED, TicketStatus.CLOSED])) &(Ticket.sla_deadline < now)).label("breached_count")).where(Ticket.deleted_at.is_(None))if not is_global:metrics_stmt = metrics_stmt.where(Ticket.workspace_id == target_ws)59 unmodified lines606162636465666768697071727374757677787959 unmodified linesif s not in counts: counts[s] = 0total = sum(counts.values())from models.feedback import Feedback# 2. Advanced Metrics (High-Performance SQL Aggregations)# Resolution Time: AVG(resolved - created)# CSAT: Join with Feedback table for user ratingsmetrics_stmt = select(func.avg(func.extract('epoch', Ticket.resolved_at - Ticket.created_at) / 3600).label("avg_res"),func.avg(func.cast(Feedback.rating, Float)).label("avg_csat"),func.count(Feedback.id).label("rated_count"),func.count(Ticket.id).filter((Ticket.status.notin_([TicketStatus.RESOLVED, TicketStatus.CLOSED])) &(Ticket.sla_deadline < now)).label("breached_count")).outerjoin(Feedback, Ticket.id == Feedback.ticket_id).where(Ticket.deleted_at.is_(None))if not is_global:metrics_stmt = metrics_stmt.where(Ticket.workspace_id == target_ws)
41 unmodified lines4243444546474841 unmodified linesusers = result.scalars().all()return [{"user_id": str(u.id), "name": u.full_name} for u in users]from models.user_workspace import UserWorkspace# Fetch the role for the user *in this specific workspace*stmt = (41 unmodified lines42434445464748495041 unmodified linesusers = result.scalars().all()return [{"user_id": str(u.id), "name": u.full_name} for u in users]async def sanitize_message_response(message: Message, db: AsyncSession) -> Message:from models.user_workspace import UserWorkspace# Fetch the role for the user *in this specific workspace*stmt = (
15 unmodified lines1617181920212221 unmodified lines4445464748495015 unmodified lines6667686970717244 unmodified lines11711811912012112212341 unmodified lines16516616716816917017115 unmodified linesrouter = APIRouter()@router.get("/volume", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])async def get_volume_trends(workspace_id: str = None,days: int = 30,21 unmodified linesresult = await db.execute(stmt)return {str(row[0]): row[1] for row in result.all()}@router.get("/csat", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])async def get_csat_report(workspace_id: str = None,current_user: User = Depends(get_current_user),15 unmodified lines"total_responses": count}@router.get("/sla", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])async def get_sla_compliance(workspace_id: str = None,current_user: User = Depends(get_current_user),44 unmodified lines"on_time_tickets": on_time}@router.get("/insights", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])async def get_ai_service_insights(workspace_id: str = None,current_user: User = Depends(get_current_user),41 unmodified linesinsight_text = await generate_service_insights(metrics, ticket_data)return {"insights": insight_text, "generated_at": now.isoformat()}@router.get("/daily-stats", dependencies=[Depends(require_roles(ALL_SC_ROLES))])async def get_daily_stats(workspace_id: str = None,current_user: User = Depends(get_current_user),15 unmodified lines1617181920212221 unmodified lines4445464748495015 unmodified lines6667686970717244 unmodified lines11711811912012112212341 unmodified lines16516616716816917017115 unmodified linesrouter = APIRouter()@router.get("/volume/", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])async def get_volume_trends(workspace_id: str = None,days: int = 30,21 unmodified linesresult = await db.execute(stmt)return {str(row[0]): row[1] for row in result.all()}@router.get("/csat/", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])async def get_csat_report(workspace_id: str = None,current_user: User = Depends(get_current_user),15 unmodified lines"total_responses": count}@router.get("/sla/", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])async def get_sla_compliance(workspace_id: str = None,current_user: User = Depends(get_current_user),44 unmodified lines"on_time_tickets": on_time}@router.get("/insights/", dependencies=[Depends(require_roles(EVERYBODY_ROLES))])async def get_ai_service_insights(workspace_id: str = None,current_user: User = Depends(get_current_user),41 unmodified linesinsight_text = await generate_service_insights(metrics, ticket_data)return {"insights": insight_text, "generated_at": now.isoformat()}@router.get("/daily-stats/", dependencies=[Depends(require_roles(ALL_SC_ROLES))])async def get_daily_stats(workspace_id: str = None,current_user: User = Depends(get_current_user),
123456115 unmodified lines122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158134 unmodified lines293294295296297298299import React, { useState, useEffect } from 'react';import { StatusBadge, PriorityBadge } from './Badges';import { api } from '@nexus/shared';import ReactMarkdown from 'react-markdown';const COLORS = {115 unmodified lines{[{label: "Active Tickets",value: total - resolvedCount,footer: `${total} Total Tickets`,color: "hsl(217, 91%, 60%)",icon: "π",viz: <Sparkline data={volumeValues.length > 0 ? volumeValues : [0,0,0]} color="hsl(217, 91%, 60%)" />},{label: "SLA Compliance",value: slaData ? `${Math.round(slaData.sla_compliance_rate * 100)}%` : "100%",footer: `${slaData?.breached_tickets || 0} Rule Breaches`,color: "hsl(142, 71%, 45%)",icon: "β‘",viz: <div style={{ height: 4, width: '100%', background: COLORS.gray100, borderRadius: 2 }}><div style={{ height: '100%', width: slaData ? `${slaData.sla_compliance_rate * 100}%` : '100%', background: "hsl(142, 71%, 45%)", borderRadius: 2 }} /></div>},{label: "Avg. Resolution",value: avgResHours > 0 ? `${avgResHours.toFixed(1)}h` : "β",footer: `${resolvedCount} Resolved Tickets`,color: "hsl(262, 83%, 58%)",icon: "β ",viz: <div style={{ fontSize: 11, fontWeight: 600, color: COLORS.gray400 }}>Operational Threshold: 24h</div>},{label: "CSAT Score",value: csatData ? `${csatData.average_rating.toFixed(1)} / 5` : "4.8",footer: `${csatData?.total_responses || 0} Valid Ratings`,color: "hsl(38, 92%, 50%)",icon: "β",viz: <div style={{ fontSize: 11, color: "#EAB308" }}>{"β ".repeat(Math.round(csatData?.average_rating || 5)) + "β".repeat(5 - Math.round(csatData?.average_rating || 5))}</div>},].map(s => (<div key={s.label} style={{134 unmodified linestransition: "opacity 0.3s ease"}}>{loading ? "Synthesizing workspace health narrative..." : (<div className="prose prose-sm max-w-none"><ReactMarkdown>{insights || "Workspace metrics are within normal operational parameters. All systems reporting healthy compliance levels."}</ReactMarkdown></div>1234567115 unmodified lines123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159134 unmodified lines294295296297298299300301302303304305306import React, { useState, useEffect } from 'react';import { StatusBadge, PriorityBadge } from './Badges';import { api } from '@nexus/shared';import { Skeleton } from './Skeleton';import ReactMarkdown from 'react-markdown';const COLORS = {115 unmodified lines{[{label: "Active Tickets",value: loading ? <Skeleton width={60} height={32} /> : total - resolvedCount,footer: loading ? <Skeleton width={100} height={12} /> : `${total} Total Tickets`,color: "hsl(217, 91%, 60%)",icon: "π",viz: loading ? <Skeleton width={100} height={30} /> : <Sparkline data={volumeValues.length > 0 ? volumeValues : [0,0,0]} color="hsl(217, 91%, 60%)" />},{label: "SLA Compliance",value: loading ? <Skeleton width={80} height={32} /> : (slaData ? `${Math.round(slaData.sla_compliance_rate * 100)}%` : "100%"),footer: loading ? <Skeleton width={100} height={12} /> : `${slaData?.breached_tickets || 0} Rule Breaches`,color: "hsl(142, 71%, 45%)",icon: "β‘",viz: loading ? <Skeleton height={4} /> : <div style={{ height: 4, width: '100%', background: COLORS.gray100, borderRadius: 2 }}><div style={{ height: '100%', width: slaData ? `${slaData.sla_compliance_rate * 100}%` : '100%', background: "hsl(142, 71%, 45%)", borderRadius: 2 }} /></div>},{label: "Avg. Resolution",value: loading ? <Skeleton width={70} height={32} /> : (avgResHours > 0 ? `${avgResHours.toFixed(1)}h` : "β"),footer: loading ? <Skeleton width={100} height={12} /> : `${resolvedCount} Resolved Tickets`,color: "hsl(262, 83%, 58%)",icon: "β ",viz: loading ? <Skeleton width={120} height={11} /> : <div style={{ fontSize: 11, fontWeight: 600, color: COLORS.gray400 }}>Operational Threshold: 24h</div>},{label: "CSAT Score",value: loading ? <Skeleton width={60} height={32} /> : (csatData ? `${csatData.average_rating.toFixed(1)} / 5` : "4.8"),footer: loading ? <Skeleton width={100} height={12} /> : `${csatData?.total_responses || 0} Valid Ratings`,color: "hsl(38, 92%, 50%)",icon: "β",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>},].map(s => (<div key={s.label} style={{134 unmodified linestransition: "opacity 0.3s ease"}}>{loading ? (<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}><Skeleton width="100%" height={16} /><Skeleton width="95%" height={16} /><Skeleton width="90%" height={16} /></div>) : (<div className="prose prose-sm max-w-none"><ReactMarkdown>{insights || "Workspace metrics are within normal operational parameters. All systems reporting healthy compliance levels."}</ReactMarkdown></div>
123456119 unmodified lines12612712812913013113213313421 unmodified lines15615715815916016116216319 unmodified lines183184185186187188189import React, { useState, useEffect } from 'react';import { StatusBadge } from './Badges';import { api } from '@nexus/shared';const COLORS = {brand: "#1E40AF",119 unmodified lines{/* Right Section: Workspace Intelligence Hub */}<div style={{ display: "flex", gap: 16, flexWrap: "wrap", justifyContent: "flex-end" }}>{[{ label: "WORKSPACE VOLUME", value: stats?.total_tickets || "0", sub: "Lifetime Tickets", icon: "π" },{ label: "ACTIVE LOAD", value: (stats?.by_status?.OPEN || 0) + (stats?.by_status?.IN_PROGRESS || 0) + (stats?.by_status?.ACKNOWLEDGED || 0), sub: "Open Cases", icon: "β‘" },{ label: "RESOLVED SUCCESS", value: (stats?.by_status?.RESOLVED || 0) + (stats?.by_status?.CLOSED || 0), sub: "Completed Tasks", icon: "β " }].map(s => (<div key={s.label} style={{background: "rgba(255, 255, 255, 0.12)",21 unmodified lines<div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 14, marginBottom: 24 }}>{[{ label: "Open tickets", value: activeTickets.length.toString(), sub: "Active cases", color: COLORS.brand },{ label: "Resolved (Total)", value: resolvedCount.toString(), sub: "Lifetime count", color: COLORS.success },{label: "Avg. resolution",value: avgResStr,19 unmodified lines<div style={{ background: "#fff", border: `1px solid ${COLORS.gray200}`, borderRadius: 10, padding: "20px" }}><div style={{ fontSize: 14, fontWeight: 600, color: COLORS.gray800, marginBottom: 16 }}>Latest updates</div>{loading ? (<div style={{ fontSize: 13, color: COLORS.gray400, textAlign: 'center', padding: '20px 0' }}>Syncing with backend...</div>) : activeTickets.length === 0 ? (<div style={{ fontSize: 13, color: COLORS.gray400, textAlign: 'center', padding: '20px 0' }}>No active tickets</div>) : activeTickets.slice(0, 5).map(t => (1234567119 unmodified lines12712812913013113213313413521 unmodified lines15715815916016116216316419 unmodified lines184185186187188189190191192193194195196197import React, { useState, useEffect } from 'react';import { StatusBadge } from './Badges';import { api } from '@nexus/shared';import { Skeleton } from './Skeleton';const COLORS = {brand: "#1E40AF",119 unmodified lines{/* Right Section: Workspace Intelligence Hub */}<div style={{ display: "flex", gap: 16, flexWrap: "wrap", justifyContent: "flex-end" }}>{[{ label: "WORKSPACE VOLUME", value: stats?.total_tickets ?? (loading ? <Skeleton width={40} height={28} /> : "0"), sub: "Lifetime Tickets", icon: "π" },{ 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: "β‘" },{ 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: "β " }].map(s => (<div key={s.label} style={{background: "rgba(255, 255, 255, 0.12)",21 unmodified lines<div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 14, marginBottom: 24 }}>{[{ label: "Open tickets", value: loading ? <Skeleton width={30} height={24} /> : activeTickets.length.toString(), sub: "Active cases", color: COLORS.brand },{ label: "Resolved (Total)", value: loading ? <Skeleton width={30} height={24} /> : resolvedCount.toString(), sub: "Lifetime count", color: COLORS.success },{label: "Avg. resolution",value: avgResStr,19 unmodified lines<div style={{ background: "#fff", border: `1px solid ${COLORS.gray200}`, borderRadius: 10, padding: "20px" }}><div style={{ fontSize: 14, fontWeight: 600, color: COLORS.gray800, marginBottom: 16 }}>Latest updates</div>{loading ? (<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>{[1, 2, 3, 4].map(i => (<div key={i} style={{ padding: "12px 0", borderTop: i > 1 ? `1px solid ${COLORS.gray100}` : 'none' }}><Skeleton width="60%" height={16} marginBottom={8} /><Skeleton width="40%" height={12} /></div>))}</div>) : activeTickets.length === 0 ? (<div style={{ fontSize: 13, color: COLORS.gray400, textAlign: 'center', padding: '20px 0' }}>No active tickets</div>) : activeTickets.slice(0, 5).map(t => (
1234561 unmodified lines6768697071727312 unmodified lines86878889909192939495969798991002 unmodified lines10310410510610710810911011111214 unmodified lines12712812913013113213352 unmodified lines1861871881891901911924 unmodified lines1971981992002012022032042052062072082092107 unmodified lines2182192202212222232249 unmodified lines23423523623723823924024124224324424524624724824925022 unmodified lines273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352import React, { useState, useEffect } from 'react';import { api } from '@nexus/shared';const COLORS = {brand: "#1E40AF",61 unmodified lines} else {res = await api.get('kb/', { params: { category: activeCategory } });let data = res.data || [];// Local Sortingdata.sort((a: any, b: any) => {const dateA = new Date(a.created_at).getTime();const dateB = new Date(b.created_at).getTime();12 unmodified linesconst renderRichContent = (content: string) => {if (!content) return null;// Pattern for Markdown images: const imgRegex = /!\[(.*?)\]\((.*?)\)/g;const parts = content.split(imgRegex);const result = [];for (let i = 0; i < parts.length; i++) {if (i % 3 === 0) {// Regular textif (parts[i]) {result.push(<div key={`text-${i}`} style={{ whiteSpace: "pre-wrap", marginBottom: (i < parts.length - 1) ? 0 : 0 }}>2 unmodified lines);}} else if (i % 3 === 1) {// Alt text (skip, handled by next index)continue;} else {// URLconst alt = parts[i-1];const url = parts[i];result.push(14 unmodified lines);}}return result;};52 unmodified linesreturn (<div style={{ padding: "32px 48px" }}>{/* Premium Search Hero */}<div style={{ marginBottom: 48 }}><h1 style={{ fontSize: 32, fontWeight: 800, color: COLORS.gray900, marginBottom: 8, letterSpacing: "-0.02em" }}>Knowledge Base</h1><p style={{ color: COLORS.gray500, fontSize: 15, marginBottom: 32 }}>Expert guides and troubleshooting for everything Nexus.</p>4 unmodified linesvalue={searchInput}onChange={e => setSearchInput(e.target.value)}onKeyDown={e => {if (e.key === 'Enter') {setSearch(searchInput);}}}placeholder="How can we help you today?"style={{width: "100%", padding: "16px 20px 16px 52px", borderRadius: 16, border: `1px solid ${COLORS.gray200}`,fontSize: 16, boxSizing: "border-box", outline: "none", boxShadow: "0 2px 10px rgba(0,0,0,0.03)", transition: "all 0.2s"}}/><button7 unmodified linesSearch</button><span style={{ position: "absolute", left: 20, top: "50%", transform: "translateY(-50%)", fontSize: 20, opacity: 0.4 }}>π</span>{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>}</div><div style={{ display: "flex", gap: 12, alignItems: "center" }}>9 unmodified lines</div></div>{/* AI Suggestions */}{suggestions.length > 0 && (<div style={{ marginTop: 20, display: "flex", gap: 10, alignItems: "center", flexWrap: "wrap" }}><span style={{ fontSize: 11, fontWeight: 800, color: COLORS.brand, textTransform: "uppercase", letterSpacing: "0.05em", marginRight: 4 }}>Suggestions:</span>{suggestions.map(s => (<buttonkey={s}onClick={() => { setSearchInput(s); setSearch(s); }}style={{ padding: "6px 14px", borderRadius: 20, border: `1px solid ${COLORS.brand}22`, background: COLORS.brandLight, color: COLORS.brand, fontSize: 12, fontWeight: 600, cursor: "pointer", transition: "all 0.2s" }}onMouseEnter={e => e.currentTarget.style.background = COLORS.brand}onMouseLeave={e => e.currentTarget.style.background = COLORS.brandLight}>{s}</button>22 unmodified lines</div>{/* Article Feed */}{loading && articles.length === 0 ? (<div style={{ padding: "100px 0", textAlign: "center" }}><div style={{ color: COLORS.gray300, fontSize: 14 }}>Connecting to help library...</div></div>) : articles.length === 0 ? (<div style={{ padding: "100px 0", textAlign: "center" }}><div style={{ fontSize: 48, marginBottom: 20 }}>π</div><h3 style={{ fontSize: 20, fontWeight: 700, color: COLORS.gray900, marginBottom: 8 }}>We couldn't find that</h3><p style={{ color: COLORS.gray500, fontSize: 14 }}>Try searching for broader terms or check a different category.</p></div>) : (<div style={{ maxWidth: 1100, margin: "0 auto" }}><div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(440px, 1fr))", gap: 32 }}>{paginated.map(article => (<divkey={article.id}onClick={() => setSelectedArticle(article)}style={{ cursor: "pointer", display: "flex" }}><div style={{background: "#fff", border: `1px solid ${COLORS.gray100}`, borderRadius: 20, padding: 32, transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow: "0 2px 4px rgba(0,0,0,0.02)", display: "flex", flexDirection: "column", flex: 1, height: "100%"} as any}onMouseEnter={e => {e.currentTarget.style.transform = "translateY(-4px)";e.currentTarget.style.boxShadow = "0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.04)";e.currentTarget.style.borderColor = COLORS.brand;}}onMouseLeave={e => {e.currentTarget.style.transform = "none";e.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.02)";e.currentTarget.style.borderColor = COLORS.gray100;}}><span style={{ fontSize: 10, fontWeight: 800, color: COLORS.brand, textTransform: "uppercase", letterSpacing: "0.1em", marginBottom: 16, display: "block" }}>{article.category || "N/A"}</span><h3 style={{ fontSize: 22, fontWeight: 800, color: COLORS.gray900, marginBottom: 12, lineHeight: 1.2, wordBreak: "break-word", overflowWrap: "anywhere" }}>{article.title}</h3><p style={{fontSize: 15, color: COLORS.gray600, lineHeight: 1.6, marginBottom: 24,display: "-webkit-box", WebkitLineClamp: 3, WebkitBoxOrient: "vertical", overflow: "hidden",wordBreak: "break-word", overflowWrap: "anywhere"}}>{article.content.slice(0, 180)}...</p><div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", borderTop: `1px solid ${COLORS.gray50}`, paddingTop: 24, marginTop: "auto" }}><span style={{ fontSize: 12, color: COLORS.gray400, fontWeight: 500 }}>Published {new Date(article.created_at).toLocaleDateString()}</span><span style={{ fontSize: 13, fontWeight: 700, color: COLORS.brand }}>Read Guide β</span></div></div></div>))}</div>{/* Pagination */}{totalPages > 1 && (<div style={{ display: "flex", justifyContent: "center", alignItems: "center", gap: 24, marginTop: 60 }}><buttondisabled={page === 1}onClick={() => setPage(p => p - 1)}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" }}>Previous</button><div style={{ fontSize: 14, fontWeight: 600, color: COLORS.gray600 }}>Page {page} of {totalPages}</div><buttondisabled={page === totalPages}onClick={() => setPage(p => p + 1)}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" }}>Next</button></div>)}</div>)}</div>);};123456761 unmodified lines69707172737412 unmodified lines87888990919293949596972 unmodified lines10010110210310410510610714 unmodified lines12212312412512612752 unmodified lines1801811821831841851864 unmodified lines1911921931941951961971981992002012027 unmodified lines2102112122132142159 unmodified lines22522622722822923023123223323423523623723822 unmodified lines261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353import React, { useState, useEffect } from 'react';import { api } from '@nexus/shared';import { Skeleton } from './Skeleton';import { StatusBadge } from './Badges'; // Assuming StatusBadge might be needed, or keep same imports as beforeconst COLORS = {brand: "#1E40AF",61 unmodified lines} else {res = await api.get('kb/', { params: { category: activeCategory } });let data = res.data || [];data.sort((a: any, b: any) => {const dateA = new Date(a.created_at).getTime();const dateB = new Date(b.created_at).getTime();12 unmodified linesconst renderRichContent = (content: string) => {if (!content) return null;const imgRegex = /!\[(.*?)\]\((.*?)\)/g;const parts = content.split(imgRegex);const result = [];for (let i = 0; i < parts.length; i++) {if (i % 3 === 0) {if (parts[i]) {result.push(<div key={`text-${i}`} style={{ whiteSpace: "pre-wrap", marginBottom: (i < parts.length - 1) ? 0 : 0 }}>2 unmodified lines);}} else if (i % 3 === 1) {continue;} else {const alt = parts[i-1];const url = parts[i];result.push(14 unmodified lines);}}return result;};52 unmodified linesreturn (<div style={{ padding: "32px 48px" }}>{/* Search Hero */}<div style={{ marginBottom: 48 }}><h1 style={{ fontSize: 32, fontWeight: 800, color: COLORS.gray900, marginBottom: 8, letterSpacing: "-0.02em" }}>Knowledge Base</h1><p style={{ color: COLORS.gray500, fontSize: 15, marginBottom: 32 }}>Expert guides and troubleshooting for everything Nexus.</p>4 unmodified linesvalue={searchInput}onChange={e => setSearchInput(e.target.value)}onKeyDown={e => {if (e.key === 'Enter') setSearch(searchInput);}}placeholder="How can we help you today?"style={{width: "100%", padding: "16px 20px 16px 52px", borderRadius: 16, border: `1px solid ${COLORS.gray200}`,fontSize: 16, boxSizing: "border-box", outline: "none", boxShadow: "0 2px 10px rgba(0,0,0,0.03)"}}/><button7 unmodified linesSearch</button><span style={{ position: "absolute", left: 20, top: "50%", transform: "translateY(-50%)", fontSize: 20, opacity: 0.4 }}>π</span></div><div style={{ display: "flex", gap: 12, alignItems: "center" }}>9 unmodified lines</div></div>{suggestions.length > 0 && (<div style={{ marginTop: 20, display: "flex", gap: 10, alignItems: "center", flexWrap: "wrap" }}><span style={{ fontSize: 11, fontWeight: 800, color: COLORS.brand, textTransform: "uppercase", letterSpacing: "0.05em" }}>Suggestions:</span>{suggestions.map(s => (<buttonkey={s}onClick={() => { setSearchInput(s); setSearch(s); }}style={{ padding: "6px 14px", borderRadius: 20, border: `1px solid ${COLORS.brand}22`, background: COLORS.brandLight, color: COLORS.brand, fontSize: 12, fontWeight: 600, cursor: "pointer" }}>{s}</button>22 unmodified lines</div>{/* Article Feed */}<div style={{ maxWidth: 1100, margin: "0 auto" }}>{loading ? (<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(440px, 1fr))", gap: 32 }}>{[1, 2, 3, 4].map(i => (<div key={i} style={{ background: "#fff", border: `1px solid ${COLORS.gray100}`, borderRadius: 20, padding: 32 }}><Skeleton width="30%" height={12} marginBottom={16} /><Skeleton width="80%" height={24} marginBottom={12} /><Skeleton width="100%" height={16} marginBottom={8} /><Skeleton width="100%" height={16} marginBottom={8} /><Skeleton width="60%" height={16} marginBottom={24} /><div style={{ display: "flex", justifyContent: "space-between", borderTop: `1px solid ${COLORS.gray50}`, paddingTop: 24 }}><Skeleton width="40%" height={12} /><Skeleton width="20%" height={12} /></div></div>))}</div>) : articles.length === 0 ? (<div style={{ padding: "100px 0", textAlign: "center" }}><div style={{ fontSize: 48, marginBottom: 20 }}>π</div><h3 style={{ fontSize: 20, fontWeight: 700, color: COLORS.gray900, marginBottom: 8 }}>We couldn't find that</h3><p style={{ color: COLORS.gray500, fontSize: 14 }}>Try searching for broader terms or check a different category.</p></div>) : (<><div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(440px, 1fr))", gap: 32 }}>{paginated.map(article => (<divkey={article.id}onClick={() => setSelectedArticle(article)}style={{ cursor: "pointer", display: "flex" }}><div style={{background: "#fff", border: `1px solid ${COLORS.gray100}`, borderRadius: 20, padding: 32, transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow: "0 2px 4px rgba(0,0,0,0.02)", display: "flex", flexDirection: "column", flex: 1, height: "100%"}}onMouseEnter={e => {e.currentTarget.style.transform = "translateY(-4px)";e.currentTarget.style.boxShadow = "0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.04)";e.currentTarget.style.borderColor = COLORS.brand;}}onMouseLeave={e => {e.currentTarget.style.transform = "none";e.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.02)";e.currentTarget.style.borderColor = COLORS.gray100;}}><span style={{ fontSize: 10, fontWeight: 800, color: COLORS.brand, textTransform: "uppercase", letterSpacing: "0.1em", marginBottom: 16, display: "block" }}>{article.category || "N/A"}</span><h3 style={{ fontSize: 22, fontWeight: 800, color: COLORS.gray900, marginBottom: 12, lineHeight: 1.2, wordBreak: "break-word", overflowWrap: "anywhere" }}>{article.title}</h3><p style={{fontSize: 15, color: COLORS.gray600, lineHeight: 1.6, marginBottom: 24,display: "-webkit-box", WebkitLineClamp: 3, WebkitBoxOrient: "vertical", overflow: "hidden",wordBreak: "break-word", overflowWrap: "anywhere"}}>{article.summary || article.content.slice(0, 180)}...</p><div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", borderTop: `1px solid ${COLORS.gray50}`, paddingTop: 24, marginTop: "auto" }}><span style={{ fontSize: 12, color: COLORS.gray400, fontWeight: 500 }}>Published {new Date(article.created_at).toLocaleDateString()}</span><span style={{ fontSize: 13, fontWeight: 700, color: COLORS.brand }}>Read Guide β</span></div></div></div>))}</div>{totalPages > 1 && (<div style={{ display: "flex", justifyContent: "center", alignItems: "center", gap: 24, marginTop: 60 }}><buttondisabled={page === 1}onClick={() => setPage(p => p - 1)}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" }}>Previous</button><div style={{ fontSize: 14, fontWeight: 600, color: COLORS.gray600 }}>Page {page} of {totalPages}</div><buttondisabled={page === totalPages}onClick={() => setPage(p => p + 1)}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" }}>Next</button></div>)}</>)}</div></div>);};
123456789101112131415161718192021222324252627282930313233343536373839404142434445import React from 'react';
interface SkeletonProps { width?: string | number; height?: string | number; borderRadius?: string | number; marginBottom?: string | number; style?: React.CSSProperties; className?: string;}
export const Skeleton: React.FC<SkeletonProps> = ({ width = '100%', height = '1em', borderRadius = 4, marginBottom = 0, style, className}) => { const skeletonStyle: React.CSSProperties = { width, height, borderRadius, marginBottom, background: '#E5E7EB', backgroundImage: 'linear-gradient(90deg, #E5E7EB 0px, #F3F4F6 50%, #E5E7EB 100%)', backgroundSize: '200% 100%', animation: 'skeleton-pulse 1.5s infinite linear', ...style };
return ( <> <style> {` @keyframes skeleton-pulse { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } } `} </style> <div style={skeletonStyle} className={className} /> </> );};123456119 unmodified lines126127128129130131132133134135136137138139140141import React, { useState, useEffect } from 'react';import { StatusBadge, PriorityBadge } from './Badges';import { api } from '@nexus/shared';const COLORS = {brand: "#1E40AF",119 unmodified lines{/* Main List Section (75%) */}<div style={{ flex: 1, minWidth: 0 }}><div style={{ background: "#fff", border: `1px solid ${COLORS.gray200}`, borderRadius: 12, overflow: "hidden", boxShadow: "0 1px 3px rgba(0,0,0,0.05)" }}>{loading && tickets.length === 0 ? (<div style={{ padding: 60, textAlign: 'center' }}><div style={{ color: COLORS.brand, marginBottom: 12, fontSize: 24 }}>β</div><div style={{ color: COLORS.gray500, fontSize: 14 }}>Retrieving system tickets...</div></div>) : filtered.length === 0 ? (<div style={{ padding: 60, textAlign: 'center' }}><div style={{ color: COLORS.gray300, marginBottom: 12, fontSize: 32 }}>π</div><div style={{ color: COLORS.gray800, fontWeight: 600, marginBottom: 4 }}>No matching tickets</div><div style={{ color: COLORS.gray400, fontSize: 13 }}>Try adjusting your filters or search terms</div></div>) : (<table style={{ width: "100%", borderCollapse: "collapse" }}>1234567119 unmodified lines127128129130131132133134135136137138139140141142143144145146147148149150151152153import React, { useState, useEffect } from 'react';import { StatusBadge, PriorityBadge } from './Badges';import { api } from '@nexus/shared';import { Skeleton } from './Skeleton';const COLORS = {brand: "#1E40AF",119 unmodified lines{/* Main List Section (75%) */}<div style={{ flex: 1, minWidth: 0 }}><div style={{ background: "#fff", border: `1px solid ${COLORS.gray200}`, borderRadius: 12, overflow: "hidden", boxShadow: "0 1px 3px rgba(0,0,0,0.05)" }}>{loading ? (<div style={{ display: 'flex', flexDirection: 'column', gap: 1 }}>{[1, 2, 3, 4, 5].map(i => (<div key={i} style={{ padding: "16px", borderBottom: `1px solid ${COLORS.gray100}`, display: "flex", alignItems: "center", gap: 16 }}><div style={{ flex: 1 }}><Skeleton width="40%" height={20} marginBottom={8} /><Skeleton width="20%" height={12} /></div><Skeleton width={80} height={20} /><Skeleton width={60} height={20} /></div>))}</div>) : filtered.length === 0 ? (<div style={{padding: "64px 32px", textAlign: "center",background: "#fff", border: `1px solid ${COLORS.gray100}`, borderRadius: 12}}><div style={{ fontSize: 48, marginBottom: 16 }}>π</div><div style={{ fontSize: 18, fontWeight: 700, color: COLORS.gray800, marginBottom: 8 }}>No tickets found</div><div style={{ fontSize: 14, color: COLORS.gray400 }}>Try adjusting your filters or search query.</div></div>) : (<table style={{ width: "100%", borderCollapse: "collapse" }}>
api/v1/dashboard.py+6-4
api/v1/messages.py+2
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.tsxAdded+45
frontend/apps/customer/src/components/TicketList.tsx+20-8