@accounter/client 0.0.8-alpha-20251022034712-a30a030f5a83f0dff0ee9fa8ccd0ebdaf7986647 → 0.0.8-alpha-20251022131500-0d2446e83760934b05cf2c65a8b065989f7724c8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -1
- package/dist/assets/Checkbox-D7nOeER7.js +6 -0
- package/dist/assets/Progress-_KQ8BRrQ.js +1 -0
- package/dist/assets/Typography-BYHNiKxL.js +1 -0
- package/dist/assets/accordion-aunUrlum.js +1 -0
- package/dist/assets/accountant-approvals-1lH0z-Rv.js +1 -0
- package/dist/assets/all-charges-Cngljy2T.js +1 -0
- package/dist/assets/arrow-up-down-De1dsSxL.js +6 -0
- package/dist/assets/business-7l6LGFQt.js +37 -0
- package/dist/assets/business-transactions-single-BmOnrzw-.js +1 -0
- package/dist/assets/business-trip-BH8ZEeSB.js +1 -0
- package/dist/assets/charges-filters-DkzCOY0r.js +1 -0
- package/dist/assets/charges-ledger-validation-tNA_f_7H.js +1 -0
- package/dist/assets/chart-BJ85ZFS0.js +74 -0
- package/dist/assets/data-table-pagination-_iPJtRUP.js +11 -0
- package/dist/assets/editable-business-trip-DCtXJ6w4.js +16 -0
- package/dist/assets/graphql-document-dedupe-fragments-ByT8-wlV.js +1 -0
- package/dist/assets/index-6W3Ndi5M.js +1 -0
- package/dist/assets/index-A086__I6.js +1 -0
- package/dist/assets/index-AoVRWBXr.js +6 -0
- package/dist/assets/index-BGZNb2wc.js +17 -0
- package/dist/assets/index-BHUgtFG6.js +1 -0
- package/dist/assets/index-BQw927FW.js +11 -0
- package/dist/assets/index-C27oA70V.js +1 -0
- package/dist/assets/index-CIqGQ8uI.js +1 -0
- package/dist/assets/index-CMXNoVEJ.js +24 -0
- package/dist/assets/index-CQEXsBvi.js +1 -0
- package/dist/assets/index-CRWwjUSx.js +1 -0
- package/dist/assets/index-CUPkGo8z.js +1 -0
- package/dist/assets/index-Ch3veRcP.js +1 -0
- package/dist/assets/index-Cll1w4iD.js +6 -0
- package/dist/assets/index-Cnf3x_0g.js +2 -0
- package/dist/assets/index-DCiQggcN.js +9 -0
- package/dist/assets/index-DFO0fSvK.js +876 -0
- package/dist/assets/index-DLrRdx1l.js +1 -0
- package/dist/assets/index-DgOX69C5.js +1 -0
- package/dist/assets/index-DqPz6G2w.js +2 -0
- package/dist/assets/index-DxgUoyCT.js +1 -0
- package/dist/assets/index-Dxkz1HG4.js +137 -0
- package/dist/assets/index-LwYKcUCw.js +1 -0
- package/dist/assets/index-gdTXrWXt.css +1 -0
- package/dist/assets/{index.es-CWwhWGxX.js → index.es-g2vV-Mpx.js} +5 -5
- package/dist/assets/issue-document-DlwQP2Xx.js +1 -0
- package/dist/assets/login-page-C2voZ_Kj.js +1 -0
- package/dist/assets/missing-info-charges-eJYTfSDz.js +1 -0
- package/dist/assets/page-not-found-t6EEvRUF.js +1 -0
- package/dist/assets/pencil-nACAiGf5.js +6 -0
- package/dist/assets/report-commentary-row-BeCkGfXh.js +1 -0
- package/dist/assets/save-DIy7YBvX.js +11 -0
- package/dist/assets/sequential-CAnleQny.js +1 -0
- package/dist/assets/similar-charges-by-business-modal-BTts1hyT.js +1 -0
- package/dist/assets/sub-CNmFodmJ.js +1 -0
- package/dist/assets/subMonths-BkHf0iFx.js +1 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/components/business-transactions/business-extended-info.tsx +13 -15
- package/src/components/business-transactions/business-transactions-single.tsx +3 -3
- package/src/components/business-transactions/index.tsx +12 -1
- package/src/components/business-trips/business-trip.tsx +3 -3
- package/src/components/charges/cells/business-trip.tsx +6 -8
- package/src/components/charges/cells/counterparty.tsx +7 -5
- package/src/components/common/accounter-table.tsx +6 -5
- package/src/components/common/business-trip-report/parts/core-expense-row.tsx +11 -9
- package/src/components/common/business-trip-report/parts/uncategorized-transactions.tsx +11 -13
- package/src/components/common/buttons/index.ts +0 -2
- package/src/components/common/buttons/logout-button.tsx +7 -6
- package/src/components/common/documents-to-charge-matcher/selection-handler/index.tsx +4 -2
- package/src/components/common/documents-to-charge-matcher/selection-handler/wide-filtered-selection.tsx +5 -7
- package/src/components/common/forms/edit-document.tsx +23 -10
- package/src/components/common/new-documents-list.tsx +10 -8
- package/src/components/documents-table/cells/creditor.tsx +11 -4
- package/src/components/documents-table/cells/debtor.tsx +11 -4
- package/src/components/error-boundary.tsx +189 -0
- package/src/components/layout/breadcrumbs.tsx +77 -0
- package/src/components/layout/dashboard-layout.tsx +4 -0
- package/src/components/layout/document-title.tsx +31 -0
- package/src/components/layout/navigation-progress.tsx +52 -0
- package/src/components/layout/page-skeleton.tsx +49 -0
- package/src/components/layout/sidelinks.tsx +28 -27
- package/src/components/ledger-table/counterparty-cell.tsx +19 -13
- package/src/components/login-page.tsx +2 -1
- package/src/components/reports/corporate-tax-ruling-compliance-report/index.tsx +3 -3
- package/src/components/reports/profit-and-loss-report/index.tsx +3 -3
- package/src/components/reports/tax-report/index.tsx +3 -3
- package/src/components/screens/businesses/business.tsx +21 -9
- package/src/components/screens/charges/charge.tsx +22 -9
- package/src/components/transactions-table/cells/counterparty.tsx +9 -2
- package/src/components/transactions-table/cells-legacy/counterparty.tsx +9 -2
- package/src/index.tsx +4 -22
- package/src/providers/auth-guard.tsx +14 -23
- package/src/providers/index.tsx +7 -2
- package/src/providers/urql-client.ts +86 -0
- package/src/providers/urql.tsx +7 -12
- package/src/providers/user-provider.tsx +3 -2
- package/src/router/config.tsx +534 -0
- package/src/router/layouts/dashboard-layout.tsx +20 -0
- package/src/router/layouts/root-layout.tsx +69 -0
- package/src/router/loaders/auth-loader.ts +32 -0
- package/src/router/loaders/business-loader.ts +25 -0
- package/src/router/loaders/charge-loader.ts +25 -0
- package/src/router/loaders/index.ts +17 -0
- package/src/router/routes.ts +88 -0
- package/src/router/types.ts +62 -0
- package/dist/assets/index-B2UYAO1O.css +0 -1
- package/dist/assets/index-BexxGuN6.js +0 -1224
- package/src/components/common/buttons/button-with-label.tsx +0 -41
- package/src/components/common/buttons/button.tsx +0 -44
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,dq as D,du as t,Z as y,cT as n,D as N,eO as w,c_ as T,r as d,u as v,d1 as A,ad as I,ae as O,B as S,d0 as P,ag as L,k as q,di as M,l as U,ak as f,al as C,am as F,aq as B,aN as V,ao as R,aL as k,aw as _,F as $,U as z,a as H,c as Q,w as G,dn as J,dp as Z,dr as o,dt as K,eP as W}from"./index-DFO0fSvK.js";const X=({record:a})=>{const s=N(w,a);return e.jsxs(D,{children:[e.jsx(t,{children:a.description}),e.jsx(t,{children:y(new Date(a.purchaseDate),"dd/MM/yyyy")}),e.jsx(t,{children:a.activationDate?y(new Date(a.activationDate),"dd/MM/yyyy"):void 0}),e.jsx(t,{children:s.originalCost?n(s.originalCost,0):void 0}),e.jsx(t,{children:s.reportYearDelta?n(s.reportYearDelta,0):void 0}),e.jsx(t,{children:n(s.totalDepreciableCosts,0)}),e.jsxs(t,{children:[n(a.statutoryDepreciationRate,0),"%"]}),e.jsx(t,{children:a.claimedDepreciationRate?`${n(a.claimedDepreciationRate,1)}%`:"-"}),e.jsx(t,{children:s.reportYearClaimedDepreciation?n(s.reportYearClaimedDepreciation,0):"-"}),e.jsx(t,{children:s.pastYearsAccumulatedDepreciation?n(s.pastYearsAccumulatedDepreciation,0):"-"}),e.jsx(t,{children:s.totalDepreciation?n(s.totalDepreciation,0):"-"}),e.jsx(t,{children:s.netValue?n(s.netValue,0):"-"})]})};function Y(a){return!a||T(a)?null:encodeURIComponent(JSON.stringify(a))}const b="depreciationReportFilters";function ee({filter:a,setFilter:s,close:r}){const p=q({defaultValues:{...a}}),{control:c,handleSubmit:x}=p,{selectableFinancialEntities:u,fetching:l}=M(),j=i=>{s({...i,year:Number(i.year)}),r()};return e.jsx(U,{...p,children:e.jsxs("form",{onSubmit:x(j),className:"space-y-4",children:[e.jsx(f,{name:"year",control:c,rules:{required:"Year is required",validate:i=>{const m=Number(i);return Number.isNaN(m)||m<2e3||m>2100?"Invalid year":!0}},render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Year"}),e.jsx(B,{children:e.jsx(V,{...i,hideControls:!0,decimalScale:0})}),e.jsx(R,{})]})}),e.jsx(f,{name:"financialEntityId",defaultValue:a?.financialEntityId,control:c,render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Owner"}),e.jsx(k,{...i,data:u,value:i.value??void 0,disabled:l,placeholder:"Select a financial entity",formPart:!0}),e.jsx(R,{})]})}),e.jsx(_,{children:e.jsx(S,{type:"submit",disabled:l,children:"Filter"})})]})})}function ae({filter:a,setFilter:s}){const[r,p]=d.useState(!1),{get:c,set:x}=v();d.useEffect(()=>{const l=Y(a),j=c(b);l!==j&&x(b,l)},[a,c,x]);const u=d.useCallback(l=>{A(l,a)||s(l)},[a,s]);return e.jsxs(I,{open:r,onOpenChange:p,children:[e.jsx(O,{asChild:!0,children:e.jsx(S,{variant:"outline",size:"icon",children:e.jsx(P,{size:20})})}),e.jsx(L,{className:"sm:max-w-[425px]",children:e.jsx(ee,{filter:a,setFilter:u,close:()=>p(!1)})})]})}const g=({data:a,groupName:s})=>{const r=N(w,a);return e.jsxs(D,{className:"font-bold border-b border-black",children:[e.jsx(t,{children:s?"Group Total":"Overall Total"}),e.jsx(t,{colSpan:2,children:s}),e.jsx(t,{children:r.originalCost?n(r.originalCost,0):void 0}),e.jsx(t,{children:r.reportYearDelta?n(r.reportYearDelta,0):void 0}),e.jsx(t,{children:r.totalDepreciableCosts?n(r.totalDepreciableCosts,0):void 0}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:r.reportYearClaimedDepreciation?n(r.reportYearClaimedDepreciation,0):void 0}),e.jsx(t,{children:r.pastYearsAccumulatedDepreciation?n(r.pastYearsAccumulatedDepreciation,0):void 0}),e.jsx(t,{children:r.totalDepreciation?n(r.totalDepreciation,0):void 0}),e.jsx(t,{children:r.netValue?n(r.netValue,0):void 0})]})};function te(a){const s=new URLSearchParams,r=Y(a);return r&&s.append(b,r),`/reports/depreciation${s.size>0?`?${s}`:""}`}const re=()=>{const{setFiltersContext:a}=d.useContext($),{userContext:s}=d.useContext(z),{get:r}=v(),p=d.useMemo(()=>{const i={financialEntityId:s?.context.adminBusinessId,year:new Date().getFullYear()},m=r(b);if(m)try{return JSON.parse(decodeURIComponent(m))}catch(h){console.error("Failed to parse depreciation report filters from URL",h)}return i},[s?.context.adminBusinessId]),[c,x]=d.useState(p),[{data:u,fetching:l}]=H({query:W,variables:{filters:c}});d.useEffect(()=>{a(e.jsx("div",{className:"flex flex-row gap-x-5",children:e.jsx(ae,{filter:c,setFilter:x})}))},[c,a,x]);const j=d.useMemo(()=>`Depreciation Report for ${c.year}`,[c.year]);return e.jsx(Q,{title:"Depreciation Report",description:j,children:l?e.jsx(G,{}):e.jsxs(J,{children:[e.jsxs(Z,{children:[e.jsxs(D,{className:"font-bold text-xl",children:[e.jsx(o,{colSpan:6,className:"text-center border-x",children:"List of Assets and Costs"}),e.jsx(o,{colSpan:5,className:"text-center border-x",children:"Depreciation"}),e.jsx(o,{className:"text-center border-x",children:"Remaining"})]}),e.jsxs(D,{className:"border-b border-black",children:[e.jsx(o,{className:"whitespace-normal",children:"Assets List and Descriptions"}),e.jsx(o,{className:"whitespace-normal",children:"Date of Purchase"}),e.jsx(o,{className:"whitespace-normal",children:"Activation Date"}),e.jsx(o,{className:"whitespace-normal",children:"Original Cost"}),e.jsx(o,{className:"whitespace-normal",children:"Changes During the Year"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciable Assets"}),e.jsx(o,{className:"whitespace-normal",children:"Statutory Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Claimed Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Depreciation Claimed This Year"}),e.jsx(o,{className:"whitespace-normal",children:"Previous Tax Years Accumulated Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Net Book Value"})]})]}),e.jsx(K,{children:u?.depreciationReport&&e.jsxs(e.Fragment,{children:[u.depreciationReport.categories.map((i,m)=>e.jsxs(d.Fragment,{children:[e.jsxs(D,{className:"font-bold",children:[e.jsx(t,{children:`Category ${m+1}`}),e.jsx(t,{colSpan:2,children:i.category.name}),e.jsx(t,{colSpan:3}),e.jsxs(t,{children:[n(i.category.percentage,0),"%"]}),e.jsx(t,{colSpan:5})]}),i.records.sort((h,E)=>h.purchaseDate.localeCompare(E.purchaseDate)).map(h=>e.jsx(X,{record:h},h.id)),e.jsx(g,{data:i.summary,groupName:i.category.name})]},i.id)),e.jsx(g,{data:u.depreciationReport.summary})]})})]})})};export{re as DepreciationReport,te as getDepreciationReportHref};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,T as se,B as q,af as ae,cd as ne,a as D,fv as te,r as x,U as H,fw as le,fx as z,k as G,t as f,l as oe,fy as ie,dc as V,bP as u,bQ as k,ak as de,fz as ce,al as me,am as ue,aq as xe,Q as ye,ao as pe,bW as g,bR as S,Z as E,o as ge,p as W,fA as he,s as Q,fB as je,fC as _,e as fe,fD as ve,fE as be,u as J,c_ as Ne,d1 as Se,c$ as Ee,d0 as we,ch as Fe,D as w,fF as Ce,fG as De,fH as Ie,fI as Ae,fJ as Pe,fK as Re,fL as Te,fM as ke,fN as Me,F as Be,c as Le,L as Ze,fO as Oe}from"./index-DFO0fSvK.js";function Y(t){return e.jsx(se,{disabled:!t.tooltip,label:t.tooltip,children:e.jsx(q,{variant:"ghost",size:"icon",className:"size-7.5",...t,children:e.jsx(ae,{className:"size-5"})})})}const K=({isNewInsert:t=!0,defaultValues:s,month:o,onDone:d,isModifying:l})=>{const{selectableBusinesses:i,fetching:n}=ne(),[{data:c,fetching:y,error:j}]=D({query:te}),{userContext:v}=x.useContext(H),[{data:b,fetching:F,error:R}]=D({query:le}),[{data:I,fetching:M,error:C}]=D({query:z,variables:{employerId:v?.context.adminBusinessId??""}}),[p,N]=x.useState([]),[A,T]=x.useState([]),[X,ee]=x.useState([]),P=s?.month??o,Z=G({defaultValues:{...s,month:P}}),{control:m,handleSubmit:O,formState:{dirtyFields:U},setValue:B}=Z;x.useEffect(()=>{j&&f.error("Error",{description:"Oh no!, we have an error fetching pension funds! 🤥"})},[j]),x.useEffect(()=>{R&&f.error("Error",{description:"Oh no!, we have an error fetching training funds! 🤥"})},[R]),x.useEffect(()=>{C&&f.error("Error",{description:"Oh no!, we have an error employees! 🤥"})},[C]),x.useEffect(()=>{c?.allPensionFunds?.length&&N(c.allPensionFunds.map(r=>({value:r.id,label:r.name})).sort((r,a)=>r.label>a.label?1:-1))},[c,T]),x.useEffect(()=>{b?.allTrainingFunds?.length&&T(b.allTrainingFunds.map(r=>({value:r.id,label:r.name})).sort((r,a)=>r.label>a.label?1:-1))},[b,T]),x.useEffect(()=>{I?.employeesByEmployerId.length&&ee(I.employeesByEmployerId.filter(r=>!r.name.toLocaleLowerCase().includes("batched")).map(r=>({value:r.id,label:r.name})).sort((r,a)=>r.label>a.label?1:-1))},[I,T]),x.useEffect(()=>{!s?.employer&&v?.context.adminBusinessId&&B("employer",v.context.adminBusinessId,{shouldDirty:!0,shouldTouch:!0})},[B,s?.employer,v?.context.adminBusinessId]);const $=r=>{const a=ge(r,U);if(!(t&&(!a?.directPaymentAmount||!a?.employeeId||!a?.employer||!a?.month)))if(a&&Object.keys(a).length>0){if(!t){if(!s)return;a.employeeId??=s.employeeId,a.month??=s.month}d(a)}else d()};function re(r){B("month",E(r,"yyyy-MM-dd"),{shouldDirty:!0,shouldTouch:!0})}return e.jsx(oe,{...Z,children:e.jsxs("form",{onSubmit:O($),children:[e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsxs(ie,{cols:4,children:[e.jsxs("div",{className:"flex-column h-max justify-start block",children:[e.jsx(V,{defaultDate:P?new Date(P):void 0,defaultValue:P?new Date(P):void 0,onChange:re,popoverProps:{withinPortal:!0}}),e.jsx(u,{name:"employer",control:m,defaultValue:s?.employer,rules:{required:"Required"},render:({field:r,fieldState:a})=>e.jsx(k,{...r,data:i,value:r.value,disabled:n,label:"Employer",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})}),e.jsx(de,{name:"chargeId",control:m,defaultValue:s?.chargeId,rules:{pattern:{value:ce,message:"Invalid UUID"}},render:({field:r})=>e.jsxs(me,{children:[e.jsx(ue,{children:"Charge ID"}),e.jsx(xe,{children:e.jsx(ye,{...r,value:r.value??void 0})}),e.jsx(pe,{})]})}),e.jsx(u,{name:"employeeId",control:m,defaultValue:s?.employeeId,rules:{required:"Required"},render:({field:r,fieldState:a})=>e.jsx(k,{...r,data:X,value:r.value,disabled:M,label:"Employee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"baseSalary",control:m,defaultValue:s?.baseSalary,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Base Salary",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"globalAdditionalHours",control:m,defaultValue:s?.globalAdditionalHours,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Global Additional Hours",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"bonus",control:m,defaultValue:s?.bonus,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Bonus",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"gift",control:m,defaultValue:s?.gift,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Gift",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"travelAndSubsistence",control:m,defaultValue:s?.travelAndSubsistence,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Travel and Subsistence",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"recovery",control:m,defaultValue:s?.recovery,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Recovery",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency"}})}),e.jsx(u,{name:"vacationTakeout",control:m,defaultValue:s?.vacationTakeout,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Vacation Takeout",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"directPaymentAmount",control:m,defaultValue:s?.directPaymentAmount,rules:{required:"Required"},render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Direct Payment",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"pensionFundId",control:m,defaultValue:s?.pensionFundId,render:({field:r,fieldState:a})=>e.jsx(k,{...r,data:p,value:r.value,disabled:y,label:"Pension Fund",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})}),e.jsx(u,{name:"pensionEmployeeAmount",control:m,defaultValue:s?.pensionEmployeeAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Pension Employee Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"pensionEmployeePercentage",control:m,defaultValue:s?.pensionEmployeePercentage,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Pension Employee Percentage"})}),e.jsx(u,{name:"pensionEmployerAmount",control:m,defaultValue:s?.pensionEmployerAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Pension Employer Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"pensionEmployerPercentage",control:m,defaultValue:s?.pensionEmployerPercentage,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Pension Employer Percentage"})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"compensationsEmployerAmount",control:m,defaultValue:s?.compensationsEmployerAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Compensations Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"compensationsEmployerPercentage",control:m,defaultValue:s?.compensationsEmployerPercentage,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Compensations Percentage"})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"trainingFundId",control:m,defaultValue:s?.trainingFundId,render:({field:r,fieldState:a})=>e.jsx(k,{...r,data:A,value:r.value,disabled:F,label:"Training Fund",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})}),e.jsx(u,{name:"trainingFundEmployeeAmount",control:m,defaultValue:s?.trainingFundEmployeeAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Training Employee Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"trainingFundEmployeePercentage",control:m,defaultValue:s?.trainingFundEmployeePercentage,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Training Employee Percentage"})}),e.jsx(u,{name:"trainingFundEmployerAmount",control:m,defaultValue:s?.trainingFundEmployerAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Training Employer Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"trainingFundEmployerPercentage",control:m,defaultValue:s?.trainingFundEmployerPercentage,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Training Employer Percentage"})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"socialSecurityAmountEmployee",control:m,defaultValue:s?.socialSecurityAmountEmployee,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Social Security - Employee",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"socialSecurityAmountEmployer",control:m,defaultValue:s?.socialSecurityAmountEmployer,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Social Security - Employer",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"healthPaymentAmount",control:m,defaultValue:s?.healthPaymentAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Health Insurance",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"taxAmount",control:m,defaultValue:s?.taxAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Income Tax",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"zkufot",control:m,defaultValue:s?.zkufot,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,precision:0,label:"Notional Expense",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"workDays",control:m,defaultValue:s?.workDays,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Work Days"})}),e.jsx(u,{name:"addedVacationDays",control:m,defaultValue:s?.addedVacationDays,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Added Vacation Days"})}),e.jsx(u,{name:"vacationDaysBalance",control:m,defaultValue:s?.vacationDaysBalance,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Vacation Days Balance"})}),e.jsx(u,{name:"sicknessDaysBalance",control:m,defaultValue:s?.sicknessDaysBalance,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Sickness Days Balance"})})]})]})}),e.jsxs("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:[e.jsx("button",{type:"submit",onClick:()=>O($),className:"mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:l||Object.keys(U).length===0,children:"Accept"}),e.jsx("button",{type:"button",className:"mt-8 text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:()=>d(),children:"Cancel"})]})]})})},Ue="updateSalaryRecord",$e=()=>{const[{fetching:t},s]=W(he),o=x.useCallback(async d=>{const l=`Error updating salary record [${d.salaryRecord.month}] employee [${d.salaryRecord.employeeId}]`,i=Ue;f.loading("Updating Salary Record",{id:i});try{const n=await s(d),c=Q(n,l,i,"updateSalaryRecord");if(c)return f.success("Success",{id:i,description:"Salary record was updated"}),c.updateSalaryRecord.salaryRecord}catch(n){console.error(`${l}: ${n}`),f.error("Error",{id:i,description:l,duration:1e5,closeButton:!0})}},[s]);return{fetching:t,updateSalaryRecord:o}},qe=({recordVariables:t,onDone:s})=>t?e.jsx(He,{recordVariables:t,onDone:s}):null,He=({recordVariables:t,onDone:s})=>{const{updateSalaryRecord:o,fetching:d}=$e(),[{data:l,fetching:i}]=D({query:je,variables:{employeeIDs:[t.employeeId],month:E(new Date(t.month),"yyyy-MM-dd")}}),n=l?.salaryRecordsByDates?.[0],c=x.useCallback(j=>{s(),j&&o({salaryRecord:j})},[s,o]);if(!n?.employer?.id||!n?.employee?.id)return e.jsx(e.Fragment,{});const y={addedVacationDays:n?.vacationDays?.added,baseSalary:n?.baseAmount?.raw,bonus:n?.bonus?.raw,chargeId:n?.charge?.id,compensationsEmployerAmount:n?.compensationsAmount?.raw,compensationsEmployerPercentage:n?.compensationsPercentage,directPaymentAmount:n?.directAmount?.raw,employer:n.employer.id,employeeId:n.employee.id,gift:n?.gift?.raw,globalAdditionalHours:n?.globalAdditionalHoursAmount?.raw,healthPaymentAmount:n?.healthInsuranceAmount?.raw,month:n?.month,pensionEmployeeAmount:n?.pensionEmployeeAmount?.raw,pensionEmployeePercentage:n?.pensionEmployeePercentage,pensionEmployerAmount:n?.pensionEmployerAmount?.raw,pensionEmployerPercentage:n?.pensionEmployerPercentage,pensionFundId:n?.pensionFund?.id,recovery:n?.recovery?.raw,sicknessDaysBalance:n?.sicknessDays?.balance,socialSecurityAmountEmployee:n?.socialSecurityEmployeeAmount?.raw,socialSecurityAmountEmployer:n?.socialSecurityEmployerAmount?.raw,taxAmount:n?.incomeTaxAmount?.raw,trainingFundEmployeeAmount:n?.trainingFundEmployeeAmount?.raw,trainingFundEmployeePercentage:n?.trainingFundEmployeePercentage,trainingFundEmployerAmount:n?.trainingFundEmployerAmount?.raw,trainingFundEmployerPercentage:n?.trainingFundEmployerPercentage,trainingFundId:n?.trainingFund?.id,travelAndSubsistence:n?.travelAndSubsistence?.raw,vacationDaysBalance:n?.vacationDays?.balance,vacationTakeout:n?.vacationTakeout?.raw,workDays:n?.workDays,zkufot:n?.notionalExpense?.raw};return e.jsx(_,{modalSize:"fit-content",position:"bottom",title:e.jsxs("div",{className:"flex flex-row mx-3 pt-3 sm:text-1xl gap-10",children:[e.jsx("h1",{className:"sm:text-2xl font-small text-gray-900",children:"Edit Salary Record:"}),e.jsxs("div",{className:"flex flex-row gap-2",children:["month: ",t.month," employeeId: ",t.employeeId]})]}),opened:!!t,onClose:s,children:i||!n?e.jsx(fe,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}):e.jsx(K,{isNewInsert:!1,defaultValues:y,onDone:c,isModifying:d})})},ze="insertSalaryRecords",Ge=()=>{const[{fetching:t},s]=W(ve),o=x.useCallback(async d=>{const l=ze;if(f.loading("Adding salary record",{id:l}),!d.salaryRecords||Array.isArray(d.salaryRecords)&&d.salaryRecords.length===0){f.error("Error",{id:l,description:"No salary records to insert",duration:1e5,closeButton:!0});return}const i=Array.isArray(d.salaryRecords)?d.salaryRecords[0]:d.salaryRecords;if(!i?.directPaymentAmount||!i?.employeeId||!i?.employer||!i?.month){f.error("Error",{id:l,description:"Missing required salary record fields",duration:1e5,closeButton:!0});return}const n=`Error adding salary record [${i.month}] employee [${i.employeeId}]`;try{const c=await s(d),y=Q(c,n,l,"insertSalaryRecords");if(y)return f.success("Success",{id:l,description:"Salary record was added"}),y.insertSalaryRecords.salaryRecords[0]}catch(c){console.error(`${n}: ${c}`),f.error("Error",{id:l,description:n,duration:1e5,closeButton:!0})}},[s]);return{fetching:t,insertSalaryRecord:o}},Ve=({insertSalaryRecordParams:t,setInsertSalaryRecord:s})=>{const{insertSalaryRecord:o,fetching:d}=Ge(),l=x.useCallback(i=>{i&&o({salaryRecords:[i]}),s(void 0)},[s,o]);return e.jsx(_,{modalSize:"40%",position:"bottom",title:e.jsx("div",{className:"flex flex-row mx-3 pt-3 sm:text-1xl gap-10",children:e.jsx("h1",{className:"sm:text-2xl font-small text-gray-900",children:"Insert Salary Record:"})}),opened:!!t,onClose:()=>s(void 0),children:e.jsx(K,{isNewInsert:!0,onDone:l,isModifying:d,month:t.month})})};function L(){const t=new Date,s=E(t,"yyyy-MM-dd"),o=E(be(t),"yyyy-MM-dd");return{fromDate:s,toDate:o}}function We({filter:t,setFilter:s,closeModal:o}){const{control:d,handleSubmit:l,setValue:i}=G({defaultValues:{...t}}),[n,c]=x.useState([]),{userContext:y}=x.useContext(H),[{data:j,fetching:v,error:b},F]=D({query:z,variables:{employerId:y?.context.adminBusinessId??""},pause:!0});x.useEffect(()=>{F()},[y?.context.adminBusinessId,F]),x.useEffect(()=>{b&&f.error("Error",{description:"Oh no!, we have an error fetching employees! 🤥"})},[b]);const R=p=>{p.employeeIDs?.length===0&&delete p.employeeIDs,s(p),o()};function I(){s({...L()}),o()}x.useEffect(()=>{j?.employeesByEmployerId.length&&c(j.employeesByEmployerId.filter(p=>!p.name.toLocaleLowerCase().includes("batched")).map(p=>({value:p.id,label:p.name})).sort((p,N)=>p.label>N.label?1:-1))},[j,c]);function M([p,N]){if(N){const A=new Date(N.getFullYear(),N.getMonth()+1,0);i("toDate",E(A,"yyyy-MM-dd"))}if(p){const A=new Date(p.getFullYear(),p.getMonth(),1);i("fromDate",E(A,"yyyy-MM-dd"))}}const C=L();return e.jsxs(e.Fragment,{children:[v?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:l(R),children:[e.jsx(V,{type:"range",numberOfColumns:2,defaultValue:[new Date(t?.fromDate??C.fromDate),new Date(t?.toDate??C.toDate)],defaultDate:new Date(t?.fromDate??C.fromDate),onChange:M,popoverProps:{withinPortal:!0}}),e.jsx(u,{name:"employeeIDs",control:d,defaultValue:t.employeeIDs,render:({field:p,fieldState:N})=>e.jsx(Fe,{...p,data:n,value:p.value??[],disabled:v,label:"Employees",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:N.error?.message})}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:v,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:I,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:o,children:"Cancel"})]})]})]})}function Qe({filter:t,setFilter:s}){const[o,d]=x.useState(!1),{get:l,set:i}=J();x.useEffect(()=>{const c=Ne(t)?null:encodeURIComponent(JSON.stringify(t)),y=l("salariesFilters");c!==y&&i("salariesFilters",c)},[t,l,i]);const n=x.useCallback(c=>{Se(c,t)||s(c)},[t,s]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(Ee,{opened:o,onClose:()=>d(!1),content:e.jsx(We,{filter:t,setFilter:n,closeModal:()=>d(!1)}),modalSize:"xl"}),e.jsx(q,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>d(!0),children:e.jsx(we,{className:"size-5"})})]})}const _e=({month:t,setInsertSalaryRecord:s})=>{const o=E(new Date(t),"MMMM yyyy");return e.jsx("tr",{tabIndex:0,className:"h-16 rounded-sm",children:e.jsx("td",{colSpan:100,children:e.jsxs("div",{className:"flex justify-between pl-5",children:[e.jsx("p",{className:"text-lg font-bold text-gray-800",children:o}),e.jsx("div",{className:"flex items-center",children:e.jsx("div",{className:"flex flex-col",children:e.jsx(Y,{onClick:s})})})]})})})},Je=({data:t})=>{const{employee:s,month:o}=w(Ce,t),d=E(new Date(o),"MMMM yyyy");return e.jsx("td",{className:"",children:e.jsx("div",{className:"flex items-center pl-5",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-base font-bold text-gray-800",children:s?.name}),e.jsx("p",{className:"text-base font-medium text-gray-800",children:d})]})})})},Ye=({data:t})=>{const{pensionEmployeeAmount:s,pensionEmployeePercentage:o,pensionEmployerAmount:d,pensionEmployerPercentage:l,compensationsAmount:i,compensationsPercentage:n,pensionFund:c,trainingFund:y,trainingFundEmployeeAmount:j,trainingFundEmployeePercentage:v,trainingFundEmployerAmount:b,trainingFundEmployerPercentage:F}=w(De,t);return e.jsx("td",{className:"pl-5",children:e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-md font-bold text-gray-800",children:"Pension Fund"}),e.jsx("p",{className:"text-md font-medium text-gray-800",children:c?.name}),!!s?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employee Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[s?.formatted,o&&` (${o}%)`]})]}),!!d?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employer Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[d?.formatted,l&&` (${l}%)`]})]}),!!i?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Compensations Amount:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[i?.formatted,n&&` (${n}%)`]})]}),e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Training Fund"}),e.jsx("p",{className:"text-md font-medium text-gray-800",children:y?.name}),!!j?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employee Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[j?.formatted,v&&` (${v}%)`]})]}),!!b?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employer Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[b?.formatted,F&&` (${F}%)`]})]})]})})})},Ke=({data:t})=>{const{healthInsuranceAmount:s,socialSecurityEmployeeAmount:o,socialSecurityEmployerAmount:d,incomeTaxAmount:l,notionalExpense:i}=w(Ie,t),n=!!o||!!d;return e.jsx("td",{className:"pl-5",children:e.jsx("div",{className:"flex items-center pl-5",children:e.jsxs("div",{className:"flex flex-col",children:[n&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md font-bold text-gray-800",children:"Social Security"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employee Part:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:o?.formatted})]}),e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Pension Fund"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employer Part:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:d?.formatted})]})]}),!!s?.raw&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Health Insurance"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Amount:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:s?.formatted})]})]}),(!!l?.raw||!!i?.raw)&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Taxes"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Income Tax:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:l?.formatted})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Notional Expense:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:i?.formatted})]})]})]})})})},Xe=({data:t})=>{const{baseAmount:s,directAmount:o,globalAdditionalHoursAmount:d,bonus:l,gift:i,recovery:n,vacationTakeout:c}=w(Ae,t);return e.jsx("td",{className:"pl-24",children:e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Base Amount:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:s?.formatted})]}),e.jsxs("div",{className:"flex justify-between mb-2",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Global Extra Hours:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:d?.formatted})]}),!!l?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Bonus:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:l?.formatted})]}),!!i?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Gift:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:i?.formatted})]}),!!n?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Recovery:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:n?.formatted})]}),!!c?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Vacation Takeout:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:c?.formatted})]}),e.jsxs("div",{className:"flex justify-between mt-2",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Direct Amount:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:o?.formatted})]})]})})})},er=({data:t})=>{const{vacationDays:s,workDays:o,sicknessDays:d}=w(Pe,t),{added:l,taken:i,balance:n}=s??{},{balance:c}=d??{},y=!!l||!!i||!!n;return e.jsx("td",{className:"pl-5",children:e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{className:"flex flex-col",children:[!!o&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md leading-none text-gray-800",children:"Work Days:"}),e.jsx("div",{className:"flex justify-between",children:e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:o})})]}),y&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-md leading-none text-gray-800 mt-2",children:"Vacation Days:"}),!!l&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Added:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:l})]}),!!i&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Taken:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:i})]}),!!n&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Balance:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:n})]})]}),!!c&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md leading-none text-gray-800 mt-2",children:"Sickness Days:"}),e.jsx("div",{className:"flex justify-between",children:e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:c})})]})]})})})},rr=({setEditSalaryRecord:t,data:s})=>{const o=w(Te,s);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{tabIndex:0,className:"h-16 border border-gray-100 hover:bg-gray-100 rounded-sm",children:[e.jsx(Je,{data:o}),e.jsx(Xe,{data:o}),e.jsx(Ye,{data:o}),e.jsx(Ke,{data:o}),e.jsx(er,{data:o}),e.jsx("td",{className:"pl-2",children:e.jsx("div",{className:"flex items-center",children:e.jsx("div",{className:"flex flex-col",children:e.jsx(Re,{onClick:t})})})})]}),e.jsx("tr",{className:"h-3"})]})},sr=({setEditSalaryRecord:t,setInsertSalaryRecord:s,data:o})=>{const d=o?.map(l=>w(ke,l))??[];return e.jsxs(e.Fragment,{children:[e.jsx("tr",{className:"h-3"}),e.jsx(_e,{month:d[0].month,setInsertSalaryRecord:s}),e.jsx("tr",{className:"h-3"}),d.map(l=>e.jsx(rr,{data:l,setEditSalaryRecord:()=>t(l.employee?.id)},`${l.month} ${l.employee?.id}`))]})},ar=({setEditSalaryRecord:t,setInsertSalaryRecord:s,data:o})=>{const d=x.useMemo(()=>{const l=o?.map(n=>w(Me,n))??[],i=new Map;return l.map(n=>{const{month:c}=n,y=i.get(c)??[];i.set(c,[...y,n])}),i},[o]);return e.jsx("div",{className:"sm:px-6 w-full",children:e.jsxs("div",{className:"bg-white py-4 md:py-7 px-4 md:px-8 xl:px-10",children:[e.jsxs("div",{className:"sm:flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"rounded-full focus:outline-hidden focus:ring-2 focus:bg-indigo-50 focus:ring-indigo-800",children:e.jsx("div",{className:"py-2 px-8 bg-indigo-100 text-indigo-700 rounded-full",children:e.jsx("p",{children:"All"})})}),e.jsx("div",{className:"rounded-full focus:outline-hidden focus:ring-2 focus:bg-indigo-50 focus:ring-indigo-800 ml-4 sm:ml-8",children:e.jsx("div",{className:"py-2 px-8 text-gray-600 hover:text-indigo-700 hover:bg-indigo-100 rounded-full ",children:e.jsx("p",{children:"Done"})})}),e.jsx("div",{className:"rounded-full focus:outline-hidden focus:ring-2 focus:bg-indigo-50 focus:ring-indigo-800 ml-4 sm:ml-8",children:e.jsx("div",{className:"py-2 px-8 text-gray-600 hover:text-indigo-700 hover:bg-indigo-100 rounded-full ",children:e.jsx("p",{children:"Pending"})})})]}),e.jsx("button",{className:"focus:ring-2 focus:ring-offset-2 focus:ring-indigo-600 mt-4 sm:mt-0 inline-flex items-start justify-start px-6 py-3 bg-indigo-700 hover:bg-indigo-600 focus:outline-hidden rounded-sm",children:e.jsx("p",{className:"text-sm font-medium leading-none text-white",children:"Add Task"})})]}),e.jsx("div",{className:"mt-7 overflow-x-auto",children:e.jsx("table",{className:"w-full whitespace-nowrap",children:e.jsx("tbody",{children:Array.from(d).map(([l,i])=>e.jsx(sr,{data:i,setEditSalaryRecord:n=>t(n?{month:l,employeeId:n}:void 0),setInsertSalaryRecord:()=>s({month:l})},l))})})})]})})},tr=()=>{const{setFiltersContext:t}=x.useContext(Be),[s,o]=x.useState(void 0),[d,l]=x.useState(void 0),{get:i}=J(),[n,c]=x.useState(i("salariesFilters")?JSON.parse(decodeURIComponent(i("salariesFilters"))):{...L()}),[{data:y,fetching:j}]=D({query:Oe,variables:{...n}});return x.useEffect(()=>{t(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(Qe,{filter:n,setFilter:c}),e.jsx(Y,{variant:"default",onClick:()=>l({})})]}))},[y,j,n,t,c]),e.jsxs(Le,{title:"Salaries",description:"View and manage salaries of employees.",children:[j?e.jsx(Ze,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx(ar,{setEditSalaryRecord:o,setInsertSalaryRecord:l,data:y?.salaryRecordsByDates}),e.jsx(qe,{recordVariables:s,onDone:()=>o(void 0)}),d&&e.jsx(Ve,{insertSalaryRecordParams:d,setInsertSalaryRecord:l})]})};export{tr as Salaries};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as P,j as r,g as W,a as $,fb as q,L as E,u as Z,U as H,c_ as K,c$ as X,B as U,d0 as ee,k as te,cd as ne,bP as se,bQ as oe,dc as O,Z as S,fc as G,d1 as re,F as ie,c as ae,a0 as le,a2 as ce,a4 as ue}from"./index-DFO0fSvK.js";import{A as fe,a as he,c as de,b as pe}from"./accordion-aunUrlum.js";var v={},z;function ye(){if(z)return v;z=1,Object.defineProperty(v,"__esModule",{value:!0}),v.calcSlices=v.applyPatch=v.calcPatch=v.lcs=v.diff=v.diff_core=void 0;function c(e,n){const{b:t,eq:s,stack_base:i}=e;let{i:a,N:o,j:h,M:l,Z:u,stack_top:x}=e;for(;;)switch(n){case 0:{e:for(;o>0&&l>0;){t.fill(0,0,2*u);const V=o-l,_=o+l,B=_&1,Q=a+o-1,Y=h+l-1,J=(_+B)/2;let F;t:for(let M=0;M<=J;M++){const I=2*Math.max(0,M-l)-M,L=M-2*Math.max(0,M-o);for(let f=I;f<=L;f+=2){const A=t[f-1-u*Math.floor((f-1)/u)],R=t[f+1-u*Math.floor((f+1)/u)],w=f===-M||f!==M&&A<R?R:A+1,k=w-f;let b=w,C=k;for(;b<o&&C<l&&s(a+b,h+C);)b++,C++;if(t[f-u*Math.floor(f/u)]=b,B===1&&(F=V-f)>=1-M&&F<M&&b+t[u+F-u*Math.floor(F/u)]>=o)if(M>1||b!==w){i[x++]=a+b,i[x++]=o-b,i[x++]=h+C,i[x++]=l-C,o=w,l=k,u=2*(Math.min(o,l)+1);continue e}else break t}for(let f=I;f<=L;f+=2){const A=t[u+f-1-u*Math.floor((f-1)/u)],R=t[u+f+1-u*Math.floor((f+1)/u)],w=f===-M||f!==M&&A<R?R:A+1,k=w-f;let b=w,C=k;for(;b<o&&C<l&&s(Q-b,Y-C);)b++,C++;if(t[u+f-u*Math.floor(f/u)]=b,B===0&&(F=V-f)>=-M&&F<=M&&b+t[F-u*Math.floor(F/u)]>=o)if(M>0||b!==w){i[x++]=a+o-w,i[x++]=w,i[x++]=h+l-k,i[x++]=k,o=o-b,l=l-C,u=2*(Math.min(o,l)+1);continue e}else break t}}if(o!==l){l>o?(a+=o,h+=o,l-=o,o=0):(a+=l,h+=l,o-=l,l=0);break}}if(o+l!==0)if(e.pxe===a||e.pye===h)e.pxe=a+o,e.pye=h+l;else{const V=e.pxs;if(e.oxs=e.pxs,e.oxe=e.pxe,e.oys=e.pys,e.oye=e.pye,e.pxs=a,e.pxe=a+o,e.pys=h,e.pye=h+l,V>=0)return e.i=a,e.N=o,e.j=h,e.M=l,e.Z=u,e.stack_top=x,1}}case 1:{if(x===0)return 2;l=i[--x],h=i[--x],o=i[--x],a=i[--x],u=2*(Math.min(o,l)+1),n=0}}}class m{constructor(n){this.state=n,this.c=0,this.result={value:null,done:!1}}[Symbol.iterator](){return this}next(){const{state:n,result:t}=this;if(this.c>1)return t.done=!0,t.value=void 0,t;const s=c(n,this.c);return this.c=s,s===1?(t.value=[n.oxs,n.oxe,n.oys,n.oye],t):n.pxs>=0?(t.value=[n.pxs,n.pxe,n.pys,n.pye],t):(t.done=!0,t.value=void 0,t)}}function D(e,n,t,s,i){const a=(Math.min(n,s)+1)*2,o=n+s,h=new(o<256?Uint8Array:o<65536?Uint16Array:Uint32Array)(2*a);return new m({i:e,N:n,j:t,M:s,Z:a,b:h,eq:i,pxs:-1,pxe:-1,pys:-1,pye:-1,oxs:-1,oxe:-1,oys:-1,oye:-1,stack_top:0,stack_base:[]})}v.diff_core=D;function d(e,n,t){let[s,i,a]=[0,e.length,n.length];if(typeof t=="function"){for(;s<i&&s<a&&t(s,s);)s++;if(s===i&&s===a)return[][Symbol.iterator]();for(;t(--i,--a)&&i>s&&a>s;);}else{for(;s<i&&s<a&&e[s]===n[s];)s++;if(s===i&&s===a)return[][Symbol.iterator]();for(;e[--i]===n[--a]&&i>s&&a>s;);t=(o,h)=>e[o]===n[h]}return D(s,i+1-s,s,a+1-s,t)}v.diff=d;class p{constructor(n,t){this.diff=n,this.N=t,this.i=0,this.j=0}[Symbol.iterator](){return this}next(){const n=this.diff.next();if(n.done){const{i:l,j:u,N:x}=this;return l<x&&(n.done=!1,n.value=[l,u,x-l],this.i=x),n}const t=n.value,s=t[0],i=t[1],a=t[3],{i:o,j:h}=this;return o!==s&&(t.length--,t[0]=o,t[1]=h,t[2]=s-o),this.i=i,this.j=a,n}}function y(e,n,t){return new p(d(e,n,t),e.length)}v.lcs=y;function*g(e,n,t){const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const i of d(e,n,t))i[2]=s.call(n,i[2],i[3]),yield i}v.calcPatch=g;function*N(e,n){let t=0;const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[i,a,o]of n)t<i&&(yield s.call(e,t,i)),o.length>0&&(yield o),t=a;t<e.length&&(yield s.call(e,t))}v.applyPatch=N;function*j(e,n,t){let s=0;const i=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[a,o,h,l]of d(e,n,t))s<a&&(yield[0,i.call(e,s,a)]),a<o&&(yield[-1,i.call(e,a,o)]),h<l&&(yield[1,i.call(n,h,l)]),s=o;s<e.length&&(yield[0,e.slice(s)])}return v.calcSlices=j,v}var xe=ye();const me=({children:c})=>r.jsx("span",{className:"bg-green-100",children:c}),je=({children:c})=>r.jsx("span",{className:"bg-red-100 line-through",children:c}),T=({children:c})=>r.jsx("span",{children:c}),ge=({content:c,contentOrigin:m,monthDate:D})=>{const d=P.useMemo(()=>{const p=[];if(!m)return p;const y=c.split(""),g=m.split(""),N=Array.from(xe.calcPatch(g,y)),j=[];let e=0;for(const[t,s,i]of N)if(j.length===0&&t>=17&&s<=25&&i.length===s-t){if(N.length===1)return p;continue}else e<t&&j.push([g.slice(e,t).join(""),T]),s>t&&j.push([g.slice(t,s).join(""),je]),i.length>0&&j.push([i.join(""),me]),e=s;e<g.length&&j.push([g.slice(e).join(""),T]);let n=[];for(const[t,s]of j){const i=t.split(`
|
|
2
|
+
`);i.length===1?n.push(r.jsx(s,{children:t},`unchanged-${n.length}`)):i.map((a,o)=>{n.push(r.jsx(s,{children:a},o)),p.push(r.jsx("div",{children:n},p.length-1)),n=[]})}return n.length>0&&p.push(r.jsx("div",{children:n},p.length-1)),p},[c,m]);return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"text-sm text-gray-500 flex flex-row gap-2",children:[r.jsx("span",{className:"font-bold",children:"Month:"}),r.jsx("span",{children:D.slice(0,7)}),!d.length&&r.jsx(W,{className:"text-green-500"})]}),!!d.length&&d]})},Me=({filter:c})=>{const[{data:m,fetching:D,hasNext:d}]=$({query:q,variables:c}),p=P.useMemo(()=>m?.pcnByDate?m.pcnByDate.sort((y,g)=>g.date>y.date?1:g.date<y.date?-1:0):[],[m?.pcnByDate]);return D?r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}):r.jsxs("div",{className:"flex flex-col gap-4",children:[!!m&&d&&r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}),p.map((y,g)=>r.jsx(ge,{content:y.content,contentOrigin:y.diffContent,monthDate:y.date},g))]})};function be({filter:c,setFilter:m,closeModal:D}){const{control:d,handleSubmit:p,setValue:y}=te({defaultValues:{...c}}),{selectableBusinesses:g,fetching:N}=ne(),j=e=>{m(e),D()};return r.jsxs(r.Fragment,{children:[N?r.jsx("div",{children:"Loading..."}):r.jsx("div",{}),r.jsxs("form",{onSubmit:p(j),children:[r.jsx(se,{name:"businessId",control:d,defaultValue:void 0,render:({field:e,fieldState:n})=>r.jsx(oe,{...e,data:g,value:e.value,disabled:N,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message})}),r.jsx(O,{label:"From date",defaultValue:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,defaultDate:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("fromMonthDate",S(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsx(O,{label:"To date",defaultValue:c?.toMonthDate?new Date(c.toMonthDate):new Date,defaultDate:c?.toMonthDate?new Date(c.toMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("toMonthDate",S(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[r.jsx(U,{type:"submit",children:"Filter"}),r.jsx(U,{type:"button",onClick:D,children:"Cancel"})]})]})]})}function ve({filter:c,setFilter:m}){const[D,d]=P.useState(!1),{get:p,set:y}=Z(),{userContext:g}=P.useContext(H);function N(j){j||={businessId:g?.context.adminBusinessId??c.businessId,fromMonthDate:S(G(new Date),"yyyy-MM-15"),toMonthDate:S(new Date,"yyyy-MM-15")},re(j,c)||m(j)}return P.useEffect(()=>{const j=K(c??{})?null:encodeURIComponent(JSON.stringify(c)),e=p("validateReportsFilters");j!==e&&y("validateReportsFilters",j)},[c,p,y]),r.jsxs(r.Fragment,{children:[r.jsx(X,{opened:D,onClose:()=>d(!1),content:r.jsx(be,{filter:c,setFilter:N,closeModal:()=>d(!1)})}),r.jsx(U,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>d(!0),children:r.jsx(ee,{className:"size-5"})})]})}const Ce=()=>{const{get:c}=Z(),{setFiltersContext:m}=P.useContext(ie),D=P.useMemo(()=>{try{if(c("validateReportsFilters"))return JSON.parse(decodeURIComponent(c("validateReportsFilters")))}catch(y){console.error("Error parsing filter from URL",y)}return{fromMonthDate:S(G(new Date),"yyyy-MM-15"),toMonthDate:S(new Date,"yyyy-MM-15")}},[c]),[d,p]=P.useState(D);return P.useEffect(()=>{m(r.jsx("div",{className:"flex flex-row gap-2",children:r.jsx(ve,{filter:{...d},setFilter:p})}))},[d,m]),r.jsx(ae,{title:"Report Validations",children:r.jsx(fe,{type:"single",collapsible:!0,children:r.jsx(he,{value:"pcn874",children:r.jsxs(le,{className:"p-4",children:[r.jsx(de,{children:r.jsx(ce,{children:"Monthly VAT (PCN874)"})}),r.jsx(pe,{children:r.jsx(ue,{children:r.jsx(Me,{filter:d})})})]})})})})};export{Ce as ValidateReportsScreen};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as c,a as N,i as k,j as e,e as w,U as E,k as z,l as D,m as L,n as A,o as T,p as O,q as P,t as B,s as R,v as U,w as $,x as q,B as C,y as S,z as H,D as v,G as _,H as Q,P as F,b as I,J as V,K as G,N as J,u as M,O as K,Q as W,F as X,T as Y,c as Z,L as ee,R as se,S as te}from"./index-DFO0fSvK.js";import{C as ne,M as ie}from"./Checkbox-D7nOeER7.js";import{u as ae,S as re}from"./similar-charges-by-business-modal-BTts1hyT.js";function oe({businessID:t,updateBusiness:n}){const[r,u]=c.useState(void 0),[{data:o,fetching:i},l]=N({query:k,variables:{id:t}});return c.useEffect(()=>{i?u(void 0):o&&o.business.__typename==="LtdFinancialEntity"&&u(o.business)},[o,i]),c.useEffect(()=>{r&&n(r)},[r,n]),e.jsx("div",{className:"flex flex-col gap-5",children:r?e.jsx(le,{business:r,refetchBusiness:l}):i?e.jsx(w,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}):e.jsx("p",{children:"Error fetching extended information for this business"})})}function le({business:t,refetchBusiness:n}){const[r,u]=c.useState(!1),[o,i]=c.useState(!1),[l,d]=c.useState(void 0),{userContext:g}=c.useContext(E),{updateBusiness:f,fetching:a}=ae(),x=z({defaultValues:{...t,taxCategory:t.taxCategory?.id,sortCode:t?.sortCode?.key,irsCode:t?.irsCode}}),{handleSubmit:p,formState:{dirtyFields:h}}=x,b=async j=>{if(!t||!g?.context.adminBusinessId)return;const s=T(j,h);s&&Object.keys(s).length>0&&(s.sortCode&&=parseInt(s.sortCode.toString()),s.suggestions?.tags&&(s.suggestions.tags=s.suggestions.tags.map(m=>({id:m.id}))),s.suggestions?.phrases&&(s.suggestions.phrases=j.suggestions.phrases.map(m=>m)),s.suggestions?.emails&&(s.suggestions.emails=j.suggestions.emails.map(m=>m)),s.suggestions?.emailListener&&(s.suggestions.emailListener.attachments&&=j.suggestions.emailListener.attachments.map(m=>m),s.suggestions.emailListener.internalEmailLinks&&=j.suggestions.emailListener.internalEmailLinks.map(m=>m)),await f({businessId:t.id,ownerId:g.context.adminBusinessId,fields:s}),s.suggestions?.tags?.length||s.suggestions?.description?(d({tagIds:s.suggestions?.tags?.map(m=>({id:m.id})),description:s.suggestions?.description??void 0}),i(!0)):n())};return e.jsxs(e.Fragment,{children:[r&&e.jsx(w,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}),e.jsx("div",{className:"flex flex-row gap-5",children:e.jsx(D,{...x,children:e.jsxs("form",{onSubmit:p(b),children:[e.jsxs("div",{className:"flex flex-row mx-3 pt-3 sm:text-1xl gap-10",children:[e.jsx("h1",{className:"sm:text-2xl font-small text-gray-900",children:"Edit Business:"}),e.jsxs("div",{className:"flex flex-row gap-2",children:["ID: ",t.id,e.jsx(L,{content:t.id})]})]}),e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsx(A,{isInsert:!1,formManager:x,setFetching:u})}),e.jsx("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:e.jsx("button",{type:"submit",onClick:()=>p(b),className:"mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:a||Object.keys(h).length===0,children:"Update"})})]})})}),e.jsx(re,{businessId:t.id,tagIds:l?.tagIds,description:l?.description,open:o,onOpenChange:i,onClose:n})]})}const ce="mergeBusinesses",de=()=>{const[{fetching:t},n]=O(P),r=c.useCallback(async u=>{const o=`Error merging into business ID [${u.targetBusinessId}]`,i=`${ce}-${u.targetBusinessId}`;B.loading("Merging Businesses",{id:i});try{const l=await n(u),d=R(l,o,i);if(d)return B.success("Success",{id:i,description:"Businesses merged"}),d.mergeBusinesses.id}catch(l){console.error(`${o}: ${l}`),B.error("Error",{id:i,description:o,duration:1e5,closeButton:!0})}},[n]);return{fetching:t,mergeBusinesses:r}};function ue({businessIds:t,onDone:n,resetMerge:r}){const{mergeBusinesses:u,fetching:o}=de(),i=Array.from(new Set(t)),[{data:l,fetching:d}]=N({query:U,variables:{businessIds:i}}),[g,f]=c.useState(l?.businesses[0]),a=l?.businesses.length!==i.length&&"Some businesses were not Found"||void 0,x=l?.businesses||[],p=c.useCallback(async()=>{if(!g){B.error("Error",{description:"No main business selected"});return}if(i.length<2){B.error("Error",{description:"At least 2 businesses are required to execute a merge"});return}return await u({targetBusinessId:g.id,businessIdsToMerge:i.filter(h=>h!==g.id)}),r(),n()},[g,i,u,n,r]);return e.jsxs(e.Fragment,{children:[d&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx($,{})}),!d&&a&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:a})}),!d&&!a&&e.jsxs(e.Fragment,{children:[e.jsxs("table",{children:[e.jsxs("tr",{children:[e.jsx("th",{children:"Main"}),x.map(h=>e.jsx("td",{children:e.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:e.jsx(ne,{checked:h.id===g?.id,size:"xl",onClick:()=>{f(h)}})})},h.id))]}),e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),x.map(h=>e.jsx("td",{children:h.name},h.id))]})]}),e.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[e.jsx("button",{type:"button",className:" text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg",disabled:d||o,onClick:p,children:"Accept"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:n,children:"Cancel"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{r(),n()},children:"Reset Merge"})]})]})]})}function ge(t){const[n,{close:r,open:u}]=q(!1),{selected:o,resetMerge:i}=t,l=new Set(o.map(({id:x})=>x)),d=l.size>=1,[g,f]=c.useState(d?"default":"outline");c.useEffect(()=>{f(d?"default":"outline")},[d]);const a=c.useCallback(()=>{r(),o.map(({onChange:x})=>x())},[o,r]);return e.jsxs(e.Fragment,{children:[e.jsx(C,{onClick:()=>{d&&u()},disabled:!d,variant:g,className:S("size-7.5",d?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:e.jsx(ie,{className:"size-5"})}),e.jsx(H,{opened:n,onClose:r,size:"auto",centered:!0,children:e.jsx(ue,{businessIds:Array.from(l),onDone:a,resetMerge:i})})]})}const me=({data:t})=>{const n=v(_,t);return e.jsx("td",{children:e.jsx("div",{style:{whiteSpace:"nowrap"},children:n.hebrewName})})},xe=({data:t})=>{const n=v(Q,t);return e.jsx("td",{children:e.jsx("div",{style:{whiteSpace:"nowrap"},children:n.name})})},he=({data:t,isAllOpened:n,toggleMergeBusiness:r,isSelectedForMerge:u})=>{const[o,i]=c.useState(!1),[l,d]=c.useState(v(J,t));return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx(xe,{data:l}),e.jsx(me,{data:l}),e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>{i(g=>!g)},children:n||o?e.jsx(F,{className:"size-5"}):e.jsx(I,{className:"size-5"})}),r&&e.jsx(V,{toggleMergeSelected:()=>r(()=>{}),mergeSelected:u})]})})]}),(n||o)&&e.jsx("tr",{children:e.jsx("td",{colSpan:12,children:e.jsx(G,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(oe,{businessID:l.id,updateBusiness:d})})})})]})};function fe({activePage:t,setPage:n,totalPages:r=1,businessName:u,setBusinessName:o}){const{get:i,set:l}=M(),[d,g]=c.useState(u);c.useEffect(()=>{const a=t>1?t.toFixed(0):void 0,x=i("page");a!==x&&a!=="1"&&l("page",a)},[t,i,l]),c.useEffect(()=>{const a=setTimeout(()=>{o(d)},600);return()=>{clearTimeout(a)}},[d,o]);const f=a=>{g(a)};return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(K,{className:"flex-auto",value:t,onChange:n,total:r}),e.jsx(W,{className:"w-72",placeholder:"Business Name",defaultValue:u??void 0,onChange:a=>f(a.target.value===""?void 0:a.target.value)})]})}const Be=()=>{const{get:t}=M(),[n,r]=c.useState(!1),[u,o]=c.useState(t("page")?Number(t("page")):1),[i,l]=c.useState(t("name")?t("page"):void 0),{setFiltersContext:d}=c.useContext(X),[{data:g,fetching:f}]=N({query:te,variables:{page:u,limit:100,name:i}}),[a,x]=c.useState([]),p=c.useCallback((s,m)=>{a.map(y=>y.id).includes(s)?x(a.filter(y=>y.id!==s)):x([...a,{id:s,onChange:m}])},[a]);function h(){x([])}c.useEffect(()=>{d(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(fe,{activePage:u,setPage:o,businessName:i,setBusinessName:l,totalPages:g?.allBusinesses?.pageInfo.totalPages}),e.jsx(Y,{label:"Expand all businesses",children:e.jsx(C,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(s=>!s),children:n?e.jsx(F,{className:"size-5"}):e.jsx(I,{className:"size-5"})})}),e.jsx(ge,{selected:a,resetMerge:h})]}))},[g,u,i,n,d,o,l,r,a]);const b=g?.allBusinesses?.nodes.filter(s=>s.__typename==="LtdFinancialEntity").sort((s,m)=>s.name.toLowerCase()>m.name.toLowerCase()?1:-1)??[],j=new Set(a.map(s=>s.id));return e.jsx(Z,{title:`Businesses (${b.length})`,description:"All businesses",children:f?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(ee,{className:S("h-10 w-10 animate-spin mr-2")})}):e.jsxs(se,{striped:!0,highlightOnHover:!0,children:[e.jsx("thead",{className:"sticky top-0 z-20",children:e.jsxs("tr",{className:"px-10 py-10 title-font tracking-wider font-medium text-gray-900 text-sm bg-gray-100 rounded-tl rounded-bl",children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Hebrew Name"}),e.jsx("th",{children:"More Info"})]})}),e.jsx("tbody",{children:b.map(s=>e.jsx(he,{data:s,isAllOpened:n,toggleMergeBusiness:p?m=>p(s.id,m):void 0,isSelectedForMerge:j.has(s.id)??!1},s.id))})]})})};export{Be as Businesses};
|