PageSourceSearch

https://fridayreport.ai/assets/DailyLogsTab-Dpl10ssu.js

js fridayreport.ai collected 2026-10-05 13:59:07 UTC 18,623 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-query-CS-Sb1c4.js";import{a as x}from"./vendor-router-CZSztoNj.js";import{b as me,c as u,B as W,C as Q,p as $}from"./index-D-3pbJbQ.js";import{u as xe,a as he,b as ue,c as je,d as pe,e as ae}from"./use-daily-logs-C59bPN7Z.js";import{B as ne}from"./badge-Dc91IPO4.js";import{D as z,a as H,d as B,b as _,c as G,e as ge}from"./dialog-BO586DMh.js";import{L as m}from"./label-Umko-O4j.js";import{I as h}from"./input-BvtS77xI.js";import{T as X}from"./textarea-CZuGeFTv.js";import{S as Y,a as J,b as Z,c as ee,d as M}from"./select--txDPtWB.js";import{f as y,s as se,w as R}from"./vendor-dates-WZsEYwlI.js";import{u as P,h as Ne,n as U,bE as V,K as ve,aY as ye,b4 as fe,a$ as we,e4 as ie,X as te}from"./vendor-icons-B_ClLdji.js";import"./vendor-ui-Cz1dd9Yr.js";import"./vendor-motion-D0xMKZ2p.js";const be=["Sunny","Partly Cloudy","Cloudy","Overcast","Light Rain","Rain","Heavy Rain","Snow","Fog","Wind","Storm"];function Ue({projectId:a}){const[l,c]=x.useState({}),{data:j=[],isLoading:t}=xe(a,l.from,l.to),{data:p}=he(a,l.from,l.to),[r,o]=x.useState(!1),[f,b]=x.useState(null),[L,O]=x.useState(!1),[E,q]=x.useState(!1),[D,S]=x.useState(null),k=ue(a),I=je(a),N=pe(a),{toast:v}=me(),w=[{label:"Last 7 days",from:y(se(new Date,7),"yyyy-MM-dd"),to:y(new Date,"yyyy-MM-dd")},{label:"Last 30 days",from:y(se(new Date,30),"yyyy-MM-dd"),to:y(new Date,"yyyy-MM-dd")},{label:"All",from:void 0,to:void 0}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Daily Logs"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track daily site activity, weather, labor, and equipment"})]}),e.jsxs(u,{onClick:()=>o(!0),size:"sm",children:[e.jsx(P,{className:"h-4 w-4 mr-1"}),"New Daily Log"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[w.map(n=>e.jsx(u,{variant:l.from===n.from&&l.to===n.to?"default":"outline",size:"sm",onClick:()=>c({from:n.from,to:n.to}),children:n.label},n.label)),e.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.jsx(h,{type:"date",value:l.from||"",onChange:n=>c(g=>({...g,from:n.target.value||void 0})),className:"w-36 h-8 text-xs"}),e.jsx("span",{className:"text-muted-foreground text-xs",children:"to"}),e.jsx(h,{type:"date",value:l.to||"",onChange:n=>c(g=>({...g,to:n.target.value||void 0})),className:"w-36 h-8 text-xs"})]})]}),p&&e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-4",children:[e.jsx(T,{icon:e.jsx(Ne,{className:"h-4 w-4"}),label:"Total Days",value:p.totalDays}),e.jsx(T,{icon:e.jsx(U,{className:"h-4 w-4"}),label:"Labor Headcount",value:p.totalLaborHeadcount}),e.jsx(T,{icon:e.jsx(U,{className:"h-4 w-4"}),label:"Labor Hours",value:p.totalLaborHours.toFixed(1)}),e.jsx(T,{icon:e.jsx(V,{className:"h-4 w-4"}),label:"Equipment Units",value:p.totalEquipmentCount}),e.jsx(T,{icon:e.jsx(V,{className:"h-4 w-4"}),label:"Equipment Hours",value:p.totalEquipmentHours.toFixed(1)})]}),t?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(W,{size:"sm",className:"h-8 w-8"})}):j.length===0?e.jsx(Q,{children:e.jsxs($,{className:"py-12 text-center",children:[e.jsx(ve,{className:"h-12 w-12 mx-auto text-muted-foreground/50 mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No daily logs found"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Create your first daily log to start tracking site activity"}),e.jsxs(u,{onClick:()=>o(!0),className:"mt-4",size:"sm",children:[e.jsx(P,{className:"h-4 w-4 mr-1"}),"Create Daily Log"]})]})}):e.jsx("div",{className:"space-y-2",children:j.map(n=>e.jsx(Ce,{log:n,onView:()=>{b(n.id),O(!0)},onEdit:()=>{b(n.id),q(!0)},onDelete:()=>S(n.id)},n.id))}),e.jsx(De,{open:r,onClose:()=>o(!1),onSubmit:async n=>{try{await k.mutateAsync(n),v({title:"Daily log created"}),o(!1)}catch(g){v({title:"Error",description:g instanceof Error?g.message:"Failed to create daily log",variant:"destructive"})}},isLoading:k.isPending}),f&&L&&e.jsx(Le,{open:L,onClose:()=>{O(!1),b(null)},projectId:a,logId:f}),f&&E&&e.jsx(Se,{open:E,onClose:()=>{q(!1),b(null)},projectId:a,logId:f,onSubmit:async n=>{try{await I.mutateAsync({logId:f,data:n}),v({title:"Daily log updated"}),q(!1),b(null)}catch(g){v({title:"Error",description:g instanceof Error?g.message:"Failed to update",variant:"destructive"})}},isLoading:I.isPending}),e.jsx(z,{open:D!==null,onOpenChange:()=>
1S(null),children:e.jsxs(H,{children:[e.jsxs(B,{children:[e.jsx(_,{children:"Delete Daily Log"}),e.jsx(G,{children:"Are you sure you want to delete this daily log? This action cannot be undone."})]}),e.jsxs(ge,{children:[e.jsx(u,{variant:"outline",onClick:()=>S(null),children:"Cancel"}),e.jsxs(u,{variant:"destructive",disabled:N.isPending,onClick:async()=>{if(D)try{await N.mutateAsync(D),v({title:"Daily log deleted"}),S(null)}catch(n){v({title:"Error",description:n instanceof Error?n.message:"Failed to delete",variant:"destructive"})}},children:[N.isPending&&e.jsx(W,{size:"sm",className:"mr-1"}),"Delete"]})]})]})})]})}function T({icon:a,label:l,value:c}){return e.jsx(Q,{children:e.jsxs($,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[a,e.jsx("span",{className:"text-xs",children:l})]}),e.jsx("p",{className:"text-2xl font-bold",children:c})]})})}function Ce({log:a,onView:l,onEdit:c,onDelete:j}){const t=a.weatherCondition?K(a.weatherCondition):null;return e.jsx(Q,{className:"hover:bg-muted/50 transition-colors",children:e.jsx($,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-col items-center w-16 shrink-0",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:y(R(a.logDate),"EEE")}),e.jsx("span",{className:"text-xl font-bold",children:y(R(a.logDate),"dd")}),e.jsx("span",{className:"text-xs text-muted-foreground",children:y(R(a.logDate),"MMM yyyy")})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.weatherCondition&&e.jsxs(ne,{variant:"outline",className:"text-xs",children:[t," ",a.weatherCondition,a.temperature&&` · ${a.temperature}`]})}),a.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-1",children:a.notes})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:l,children:e.jsx(ye,{className:"h-4 w-4"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:c,children:e.jsx(fe,{className:"h-4 w-4"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:j,children:e.jsx(we,{className:"h-4 w-4"})})]})]})})})}function K(a){return{Sunny:"☀️","Partly Cloudy":"⛅",Cloudy:"☁️",Overcast:"🌥️","Light Rain":"🌦️",Rain:"🌧️","Heavy Rain":"⛈️",Snow:"❄️",Fog:"🌫️",Wind:"💨",Storm:"⛈️"}[a]||"🌤️"}function le({initialData:a,onSubmit:l,isLoading:c,submitLabel:j}){const[t,p]=x.useState(a?.logDate||y(new Date,"yyyy-MM-dd")),[r,o]=x.useState(a?.weatherCondition||""),[f,b]=x.useState(a?.temperature||""),[L,O]=x.useState(a?.windSpeed||""),[E,q]=x.useState(a?.precipitation||""),[D,S]=x.useState(a?.visitors||""),[k,I]=x.useState(a?.notes||""),[N,v]=x.useState(a?.labor?.map(s=>({company:s.company||"",trade:s.trade||"",headcount:s.headcount||0,hoursWorked:Number(s.hoursWorked)||0,notes:s.notes||""}))||[]),[w,n]=x.useState(a?.equipment?.map(s=>({equipmentName:s.equipmentName,quantity:s.quantity||1,hoursUsed:Number(s.hoursUsed)||0,status:s.status||"Active",notes:s.notes||""}))||[]),g=()=>v([...N,{company:"",trade:"",headcount:0,hoursWorked:0,notes:""}]),re=s=>v(N.filter((d,i)=>i!==s)),A=(s,d,i)=>{const C=[...N];C[s]={...C[s],[d]:i},v(C)},de=()=>n([...w,{equipmentName:"",quantity:1,hoursUsed:0,status:"Active",notes:""}]),ce=s=>n(w.filter((d,i)=>i!==s)),F=(s,d,i)=>{const C=[...w];C[s]={...C[s],[d]:i},n(C)},oe=()=>{l({logDate:t,weatherCondition:r||null,temperature:f||null,windSpeed:L||null,precipitation:E||null,visitors:D||null,notes:k||null,labor:N.filter(s=>s.company||s.trade||s.headcount>0),equipment:w.filter(s=>s.equipmentName)})};return e.jsxs("div",{className:"space-y-6 max-h-[70vh] overflow-y-auto pr-2",children:[e.jsxs("div",{children:[e.jsx(m,{children:"Date"}),e.jsx(h,{type:"date",value:t,onChange:s=>p(s.target.value)})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[e.jsx(ie,{className:"h-4 w-4"})," Weather"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(m,{className:"text-xs",children:"Condition"}),e.jsxs(Y,{value:r,onValueChange:o,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:"Select..."})}),e.jsx(ee,{children:be.map(s=>e.jsxs(M,{value:s,children:[K(s)," ",s]},s))})]})]}),e.jsxs("div",{children:[e.jsx(m,{className:"text-xs",children:"Temperature"}),e.jsx(h,{placeholder:"e.g. 72°F",value:f,onChange:s=>b(s.target.value)})]}),e.jsxs("div",{children:[e.jsx(m,{className:"text-xs",children:"Wind Speed"}),e.jsx(h,{placeholder:"e.g. 10 mph",value:L,onChange:s=>O(s.target.value)})]}),e.jsxs("div",{children:[e.jsx(m,{className:"text-xs",children:"Precipitation"}),e.jsx(h,{placeholder:"e.g. None",value:E,onChange:s=>q(s.target.value)})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[e.jsx(U,{className:"h-4 w-4"})," Labor"]}),e.jsxs(u,{variant:"outline",size:"sm",onClick:g,children:[e.jsx(P,{className:"h-3 w-3 mr-1"})," Add"]})]}),N.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"No labor entries yet"}),N.map((s,d)=>e.jsxs("div",{className:"border rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-medium text-muted-foreground",children:["Entry ",d+1]}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>re(d),children:e.jsx(te,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(m,{className:"text-xs",children:"Company"}),e.jsx(h,{value:s.company,onChange:i=>A(d,"company",i.target.value),placeholder:"Company name"})]}),e.jsxs("div",{children:[e.jsx(m,{className:"text-xs",children:"Trade"}
1),e.jsx(h,{value:s.trade,onChange:i=>A(d,"trade",i.target.value),placeholder:"e.g. Electrician"})]}),e.jsxs("div",{children:[e.jsx(m,{className:"text-xs",children:"Headcount"}),e.jsx(h,{type:"number",value:s.headcount,onChange:i=>A(d,"headcount",Number(i.target.value))})]}),e.jsxs("div",{children:[e.jsx(m,{className:"text-xs",children:"Hours Worked"}),e.jsx(h,{type:"number",step:"0.5",value:s.hoursWorked,onChange:i=>A(d,"hoursWorked",Number(i.target.value))})]})]})]},d))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[e.jsx(V,{className:"h-4 w-4"})," Equipment"]}),e.jsxs(u,{variant:"outline",size:"sm",onClick:de,children:[e.jsx(P,{className:"h-3 w-3 mr-1"})," Add"]})]}),w.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"No equipment entries yet"}),w.map((s,d)=>e.jsxs("div",{className:"border rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-medium text-muted-foreground",children:["Entry ",d+1]}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ce(d),children:e.jsx(te,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(m,{className:"text-xs",children:"Equipment Name"}),e.jsx(h,{value:s.equipmentName,onChange:i=>F(d,"equipmentName",i.target.value),placeholder:"e.g. Crane"})]}),e.jsxs("div",{children:[e.jsx(m,{className:"text-xs",children:"Quantity"}),e.jsx(h,{type:"number",value:s.quantity,onChange:i=>F(d,"quantity",Number(i.target.value))})]}),e.jsxs("div",{children:[e.jsx(m,{className:"text-xs",children:"Hours Used"}),e.jsx(h,{type:"number",step:"0.5",value:s.hoursUsed,onChange:i=>F(d,"hoursUsed",Number(i.target.value))})]}),e.jsxs("div",{children:[e.jsx(m,{className:"text-xs",children:"Status"}),e.jsxs(Y,{value:s.status,onValueChange:i=>F(d,"status",i),children:[e.jsx(J,{children:e.jsx(Z,{})}),e.jsxs(ee,{children:[e.jsx(M,{value:"Active",children:"Active"}),e.jsx(M,{value:"Idle",children:"Idle"}),e.jsx(M,{value:"Maintenance",children:"Maintenance"}),e.jsx(M,{value:"Breakdown",children:"Breakdown"})]})]})]})]})]},d))]}),e.jsxs("div",{children:[e.jsx(m,{children:"Visitors"}),e.jsx(X,{placeholder:"List any site visitors (names, organizations, purpose)",value:D,onChange:s=>S(s.target.value),rows:2})]}),e.jsxs("div",{children:[e.jsx(m,{children:"Notes"}),e.jsx(X,{placeholder:"General notes about the day's activities",value:k,onChange:s=>I(s.target.value),rows:3})]}),e.jsxs(u,{onClick:oe,disabled:c,className:"w-full",children:[c&&e.jsx(W,{size:"sm",className:"mr-1"}),j]})]})}function De({open:a,onClose:l,onSubmit:c,isLoading:j}){return e.jsx(z,{open:a,onOpenChange:l,children:e.jsxs(H,{className:"max-w-2xl",children:[e.jsxs(B,{children:[e.jsx(_,{children:"New Daily Log"}),e.jsx(G,{children:"Record daily site activity including weather, labor, and equipment"})]}),e.jsx(le,{onSubmit:c,isLoading:j,submitLabel:"Create Daily Log"})]})})}function Se({open:a,onClose:l,projectId:c,logId:j,onSubmit:t,isLoading:p}){const{data:r,isLoading:o}=ae(c,j);return o?e.jsx(z,{open:a,onOpenChange:l,children:e.jsx(H,{children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(W,{size:"sm",className:"h-8 w-8"})})})}):e.jsx(z,{open:a,onOpenChange:l,children:e.jsxs(H,{className:"max-w-2xl",children:[e.jsxs(B,{children:[e.jsx(_,{children:"Edit Daily Log"}),e.jsx(G,{children:"Update the daily log entry"})]}),r&&e.jsx(le,{initialData:r,onSubmit:t,isLoading:p,submitLabel:"Save Changes"})]})})}function Le({open:a,onClose:l,projectId:c,logId:j}){const{data:t,isLoading:p}=ae(c,j);return e.jsx(z,{open:a,onOpenChange:l,children:e.jsxs(H,{className:"max-w-2xl",children:[e.jsx(B,{children:e.jsxs(_,{children:["Daily Log — ",t?y(R(t.logDate),"EEEE, MMMM d, yyyy"):"Loading..."]})}),p?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(W,{size:"sm",className:"h-8 w-8"})}):t?e.jsxs("div",{className:"space-y-6 max-h-[70vh] overflow-y-auto pr-2",children:[(t.weatherCondition||t.temperature||t.windSpeed||t.precipitation)&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium flex items-center gap-2 mb-2",children:[e.jsx(ie,{className:"h-4 w-4"})," Weather"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[t.weatherCondition&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Condition:"})," ",K(t.weatherCondition)," ",t.weatherCondition]}),t.temperature&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Temperature:"})," ",t.temperature]}),t.windSpeed&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Wind:"})," ",t.windSpeed]}),t.precipitation&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Precipitation:"})," ",t.precipitation]})]})]}),t.labor&&t.labor.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium flex items-center gap-2 mb-2",children:[e.jsx(U,{className:"h-4 w-4"})," Labor (",t.labor.length," ",t.labor.length===1?"entry":"entries",")"]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-2 font-medium",children:"Company"}),e.jsx("th",{className:"text-left p-2 font-medium",children:"Trade"}),e.jsx("th",{className:"text-right p-2 font-medium",children:"Headcount"}),e.jsx("th",{className:"text-right p-2 font-medium",children:"Hours"})]})}),e.jsxs("tbody",{children:[t.labor.map((r,o)=>e.jsxs("tr",{className:"border-t",children:[e.jsx("td",{className:"p-2",children:r.company||"—"}),e.jsx("td",{className:"p-2",children:r.trade||"—"}),e.jsx("td",{className:"p-2 text-right",children:r.headcount||0}),e.jsx("td",{className:"p-2 text-right",children:Number(r.hoursWorked)||0})]},o)),e.jsxs("tr",{className:"border-t bg-muted font-medium",children:[e.jsx("td",{className:"p-2",colSpan:2,children:"Total"}),e.jsx("td",{className:"p-2 text-right",children:t.labor.reduce((r,o)=>r+(o.headcount||0),0)}),e.jsx("td",{className:"p-2 text-right",children:t.labor.reduce((r,o)=>r+(Number(o.hoursWorked)||0),0)})]})]})]})})]}),t.equipment&&t.equipment.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium flex items-center gap-2 mb-2",children:[e.jsx(V,{className:"h-4 w-4"})," Equipment (",t.equipment.length," ",t.equipment.length===1?"item":"items",")"]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-2 font-medium",children:"Equipment"}),e.jsx("th",{className:"text-right p-2 font-medium",children:"Qty"}),e.jsx("th",{className:"text-right p-2 font-medium",children:"Hours"}),e.jsx("th",{className:"text-left p-2 font-medium",children:"Status"})]})}),e.jsx("tbody",{children:t.equipment.map((r,o)=>e.jsxs("tr",{className:"border-t",children:[e.jsx("td",{className:"p-2",children:r.equipmentName}),e.jsx("td",{className:"p-2 text-right",children:r.quantity||1}),e.jsx("td",{className:"p-2 text-right",children:Number(r.hoursUsed)||0}),e.jsx("td",{className:"p-2",children:e.jsx(ne,{variant:"outline",className:"text-xs",children:r.status})})]},o))})]})})]}),t.visitors&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-1",children:"Visitors"}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t.visitors})]}),t.notes&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-1",children:"Notes"}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t.notes})]})]}):null]})})}export{Ue as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.