diff --git a/src/components/cards/DailyLogCard.tsx b/src/components/cards/DailyLogCard.tsx index d09f63d..7723851 100644 --- a/src/components/cards/DailyLogCard.tsx +++ b/src/components/cards/DailyLogCard.tsx @@ -1,14 +1,25 @@ import { formatValue } from '../../lib/format'; -import { User as UserIcon, Clock, LogOut } from 'lucide-react'; +import { User as UserIcon, Clock, LogOut, FileText } from 'lucide-react'; import { Button } from '../buttons/Button'; import './card.css'; -export function DailyLogCard({ row, onPunchOut }: { row: Record; onPunchOut?: (row: any) => void }) { +export function DailyLogCard({ row, onPunchOut, isDetailView = false }: { row: Record; onPunchOut?: (row: any) => void; isDetailView?: boolean }) { const stateName = String(row.status || row.current_state_name || 'Logged'); // User details const userObj = (row.sales_officer_name || row.user_id || row.user) as Record | null; const userName = formatValue(userObj?.name || row.user_name || 'Unknown User'); + const userEmail = formatValue(userObj?.email || row.performed_by_email || row.user_email || '—'); + const initials = userName !== '—' ? String(userName).substring(0, 2).toUpperCase() : 'SO'; + + // Route Details + const routeCode = formatValue(row.route_code || row.route || '—'); + const subRoute = formatValue(row.sub_route || row.area || '—'); + + // End of Day Stats + const prodCalls = formatValue(row.total_productive_calls || 0); + const nonProdCalls = formatValue(row.total_non_productive_calls || 0); + const eodNotes = formatValue(row.eod_notes_remarks || row.notes || '—'); // Date let dateStr = '—'; @@ -59,7 +70,7 @@ export function DailyLogCard({ row, onPunchOut }: { row: Record; on } let checkOutTime = checkOutTimeRaw ? formatTimeStr(checkOutTimeRaw) : null; - const isPunchedIn = stateName.toLowerCase().includes('in') || stateName.toLowerCase().includes('active'); + const isPunchedIn = stateName.toLowerCase().includes('punched in') || stateName.toLowerCase().includes('active') || (stateName.toLowerCase().includes('in') && !stateName.toLowerCase().includes('out')); let statusClass = 'z-card-status--neutral'; if (isPunchedIn) statusClass = 'z-card-status--success'; @@ -69,41 +80,113 @@ export function DailyLogCard({ row, onPunchOut }: { row: Record; on
- - {userName} + {isDetailView ? ( +
+
+ {initials} +
+
+

{userName}

+ {userEmail !== '—' && ( +

{userEmail}

+ )} +
+
+ ) : ( + <> + + {userName} + + )}
{stateName}
-
- -
-
-
PUNCH-IN TIME
-
- - {dateStr} - {checkInTime} - + {!isDetailView && ( + <> +
+
+
+
PUNCH-IN TIME
+
+ + {dateStr} + {checkInTime} + +
+
+ {checkOutTime && ( +
+
PUNCH-OUT TIME
+
+ + {dateStr} + {checkOutTime} + +
+
+ )}
-
- {checkOutTime && ( -
-
PUNCH-OUT TIME
-
- - {dateStr} - {checkOutTime} - + + )} + + {isDetailView && ( + <> +
+
+

Route Code

+

{routeCode}

+
+
+

Sub Route

+

{subRoute}

- )} -
+ +
+
+

PUNCH-IN

+

{dateStr} {checkInTime}

+
+ {checkOutTime && ( +
+

PUNCH-OUT

+

{dateStr} {checkOutTime}

+
+ )} +
+ + {!isPunchedIn && ( + <> +
+
+ Productive + {prodCalls} Calls +
+
+ Non Productive + {nonProdCalls} Calls +
+
+ + {eodNotes !== '—' && ( +
+
+ + EOD Notes +
+

{eodNotes}

+
+ )} + + )} + + )} {isPunchedIn && onPunchOut && ( -
+
); }