PageSourceSearch

https://rovno.ai/assets/ShareEstimate-DGAjYL57.js

js rovno.ai collected 2026-10-05 15:25:00 UTC 7,223 bytes, 1 lines download raw bytes

1import{b as H,T as Q,h as U,u as V,i as K,r as p,j as t}from"./index-bOzovnTh.js";import{B as N}from"./button-B4WosgHx.js";import{S as O}from"./skeleton-CSjDPazD.js";import{T as W,a as $,b as C,c as u,d as J,e as x}from"./table-DBbwiqma.js";import{E as z}from"./EmptyState-BeQJetZH.js";import{J as G,K as X}from"./use-mock-data-CeMu1QC3.js";import{u as Y}from"./use-runtime-auth-BYnOTJhl.js";import{i as Z}from"./auth-state-BDcY2nEB.js";import{L as _,M as ee,aD as te,aE as re,a2 as se}from"./finance-read-model-BUiI6pYJ.js";import{A as ae,a as oe}from"./ApprovalStampFormModal-B4fIQiLp.js";import{T as ie}from"./triangle-alert-C5UWgj1C.js";import"./index-BYVpM6yO.js";import"./store-7xxjmIbm.js";import"./workspace-profile-cache-qZhdgqC8.js";import"./seed-StDvnsY3.js";import"./useQuery-B9bgS4KO.js";import"./use-workspace-source-B5yD-YQ4.js";import"./useMutation-D_--Pyfg.js";import"./client-C2RhHgD-.js";import"./badge-B2eAVb6I.js";import"./input-B1bozISh.js";import"./dialog-Be-UyxOi.js";import"./index-D1ozFdVv.js";import"./index-CyjSksVH.js";function g(n,m){return new Intl.NumberFormat("ru-RU",{style:"currency",currency:m,minimumFractionDigits:2,maximumFractionDigits:2}).format(n/100)}function ne(n){return(n/1e3).toString()}function le(n){return typeof n=="object"&&n!==null&&n.code==="P0002"}function Fe(){const{shareId:n=""}=H(),{toast:m}=Q(),A=U(),{t:r}=V(),f=K(),{shared:c,status:M}=G(n),{status:j}=Y(),[I,h]=p.useState(!1),e=c==null?void 0:c.version.snapshot;c==null||c.projectId;const l=(c==null?void 0:c.version)??null,k=p.useMemo(()=>[...(e==null?void 0:e.stages)??[]].sort((o,a)=>o.order-a.order),[e==null?void 0:e.stages]),E=p.useMemo(()=>{const o=(e==null?void 0:e.works)??[],a=new Map;return o.forEach(s=>{const i=a.get(s.stageId)??[];i.push(s),a.set(s.stageId,i)}),a.forEach(s=>s.sort((i,d)=>i.order-d.order)),a},[e==null?void 0:e.works]),F=p.useMemo(()=>{const o=(e==null?void 0:e.lines)??[],a=new Map;return o.forEach(s=>{const i=a.get(s.workId)??[];i.push(s),a.set(s.workId,i)}),a},[e==null?void 0:e.lines]),T=p.useMemo(()=>new Map(((e==null?void 0:e.stages)??[]).map(o=>[o.id,o])),[e==null?void 0:e.stages]),P=p.useMemo(()=>{const o=(e==null?void 0:e.lines)??[],a=e==null?void 0:e.project,s=new Map;return a&&o.forEach(i=>{const d=T.get(i.stageId);d&&s.set(i.id,_(i,d,a,a.projectMode))}),s},[e==null?void 0:e.lines,e==null?void 0:e.project,T]),S=p.useMemo(()=>e?ee(e.project,e.stages,e.works,e.lines,e.project.projectMode):{subtotalCents:0,taxableBaseCents:0,subtotalBeforeDiscountCents:0,taxAmountCents:0,totalCents:0,costTotalCents:0,markupTotalCents:0,discountTotalCents:0,breakdownByType:{material:0,tool:0,labor:0,subcontractor:0,other:0}},[e]),q=null,v=(l==null?void 0:l.status)==="proposed"&&l.submitted&&!l.archived&&!l.approvalStamp,b=(l==null?void 0:l.shareApprovalPolicy)==="disabled",w=!!(v&&j==="authenticated"&&!b),B=!!(v&&j==="guest"&&!b),D=!!(v&&j==="loading"&&!b);if(M==="loading")return t.jsx("div",{className:"flex min-h-[40vh] items-center justify-center p-sp-3 text-sm text-muted-foreground",children:r("app.loading")});if(!c||!e||!l)return t.jsx("div",{className:"p-sp-3",children:t.jsx(z,{icon:ie,title:r("share.estimate.notFoundTitle"),description:r("share.estimate.notFoundBody")})});const R=async o=>{if(!w){m({title:r("share.estimate.toast.noLonger"),variant:"destructive"});return}const a=Z()?te(n):null,s=a&&re(a.projectId)?a:null;if(s){if(!se(s.projectId,s.version.id,o,{actorId:"client"})){m({title:r("share.estimate.toast.unableToApprove"),variant:"destructive"});return}}else try{const i=await X(n,o);f.setQueryData(["estimate-share",n],i)}catch(i){if(le(i)){m({title:r("share.estimate.toast.noLonger"),variant:"destructive"}),f.invalidateQueries({queryKey:["estimate-share",n]}),h(!1);return}m({title:r("share.estimate.toast.unableToApprove"),variant:"destructive"});return}f.invalidateQueries({queryKey:["estimate-share",n]}),h(!1),m({title:r("share.estimate.toast.approved")})},L=()=>{A(`/auth/signup?next=${encodeURIComponent(`/share/estimate/${n}`)}`)};return t.jsxs("div",{className:"mx-auto max-w-6xl p-sp-3 space-y-sp-2",children:[t.jsxs("div",{className:"rounded-card border border-border bg-card p-sp-2 space-y-2",children:[t.jsx("h1",{className:"text-lg font-semibold text-foreground",children:r("share.estimate.title")}),null,q,B&&t.jsx("div",{className:"rounded-md border border-info/50 bg-info/10 p-2 text-caption text-foreground",children:r("share.estimate.registerToApproveHint")}),b&&t.jsx("div",{className:"rounded-md border border-warning/40 bg-warning/10 p-2 text-caption text-foreground",children:r("share.estimate.disabledHint")})]}),t.jsxs("div",{className:"rounded-card border border-border bg-card p-sp-2 flex flex-wrap gap-2",children:[l.approvalStamp&&t.jsx(ae,{stamp:l.approvalStamp,versionNumber:l.number,className:"w-full"}),t.jsx("span",{className:"inline-flex items-center rounded-md border border-border px-2 py-1 text-caption",children:r("share.estimate.tax",{percent:(e.project.taxBps/100).toFixed(2),amount:g(S.taxAmountCents,e.project.currency)})}),t.jsx("span",{className:"inline-flex items-center rounded-md border border-border px-2 py-1 text-caption font-medium",children:r("share.estimate.total",{amount:g(S.totalCents,e.project.currency)})})]}),k.map(o=>{const a=E.get(o.id)??[];return t.jsxs("div",{className:"rounded-card border border-border bg-card p-sp-2 space-y-2",children:[t.jsx("h2",{className:"text-body-sm font-semibold text-foreground",children:o.title}),a.map(s=>{const i=F.get(s.id)??[];return t.jsxs("div",{className:"rounded-md border border-border/80 p-2 space-y-2",children:[t.jsx("h3",{className:"text-caption font-medium text-foreground",children:s.title}),t.jsxs(W,{children:[t.jsx($,{children:t.jsxs(C,{children:[t.jsx(u,{children:r("share.estimate.columns.line")}),t.jsx(u,{className:"text-right",children:r("share.estimate.columns.qty")}),t.jsx(u,{children:r("share.estimate.columns.unit")}),t.jsx(u,{className:"text-right",children:r("share.estimate.columns.clientUnit")}),t.jsx(u,{className:"text-right",children:r("share.estimate.columns.clientTotal")})]})}),t.jsx(J,{children:i.map(d=>{const y=P.get(d.id);return y?t.jsxs(C,{children:[t.jsx(x,{children:d.title}
1),t.jsx(x,{className:"text-right",children:ne(d.qtyMilli)}),t.jsx(x,{children:d.unit}),t.jsx(x,{className:"text-right",children:g(y.clientUnitCents,e.project.currency)}),t.jsx(x,{className:"text-right",children:g(y.clientTotalCents,e.project.currency)})]},d.id):null})})]})]},s.id)})]},o.id)}),t.jsxs("div",{className:"rounded-card border border-border bg-card p-sp-2 space-y-2",children:[t.jsx("h2",{className:"text-body-sm font-semibold text-foreground",children:r("share.estimate.approvalHeading")}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[w&&t.jsx(N,{onClick:()=>h(!0),children:r("share.estimate.approveButton")}),B&&t.jsx(N,{onClick:L,children:r("share.estimate.registerButton")}),D&&t.jsx(O,{"data-testid":"approval-action-pending",className:"h-10 w-40",role:"status","aria-label":r("app.loading")}),t.jsx(N,{variant:"outline",disabled:!0,children:r("share.estimate.askQuestionsSoon")})]})]}),t.jsx(oe,{open:I,onOpenChange:h,title:r("share.estimate.approveModalTitle"),onSubmit:R})]})}export{Fe 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.