PageSourceSearch

https://app.wodbump.com/assets/WaiverEditPage-B-tqrrxP.js

js wodbump.com collected 2026-09-24 14:59:16 UTC 10,212 bytes, 1 lines download raw bytes

1import{j as e,ad as J,r,ar as _,ae as K,a2 as Q,u as X,a as Y,bk as Z,J as ee}from"./vendor-ZpyZOZKZ.js";import{S as se,W as ae,n as te,w as re,a as B,b as ie,c as ne,d as le,e as oe}from"./waiverNavigation-B20uwbHR.js";import{C as ce,hL as ue,c as A,g as V,b as z,u as U,sa as de,ih as me,sb as fe,sc as $,sd as he,se as G,sf as H,sg as ve,sh as pe,si as I,sj as O,sk as be,j as xe,ai as ge}from"./index-BvpNZgMf.js";import{P as ye}from"./PageTabs-D3XJmc9I.js";import{P as Se}from"./ProgramEditAlerts-o5_Flftq.js";import"./MemberDetailSection-D2cru2Pv.js";import"./AppSectionCard-WrKMU6wm.js";import"./RichTextEditor-BCi5iIde.js";import"./firebase-RkFr3iC1.js";import"./stripe-CuFmHH1H.js";function je({open:t,waiverTitle:m,publishing:a,loadingImpact:l=!1,waiversToArchive:i=[],error:c,confirmDisabled:b=!1,onClose:v,onConfirm:g}){const f=i.length===1?`“${i[0]}”`:i.map(s=>`“${s}”`).join(", "),x=a||l||b;return e.jsxs(ce,{open:t,onClose:v,closeDisabled:a||l,titleId:"settings-waiver-publish-title",title:"Publish This Waiver?",description:`“${m||"Untitled Waiver"}” will go live for its assigned checkout surfaces. Athletes will sign it at checkout.`,icon:e.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-amber-50 text-amber-700",children:e.jsx(J,{className:"h-5 w-5","aria-hidden":!0})}),actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:g,disabled:x,className:A(V,"flex-1"),children:a?"Publishing…":l?"Checking…":"Publish Live"}),e.jsx("button",{type:"button",onClick:v,disabled:a,className:z,children:"Cancel"})]}),children:[l?e.jsx("p",{className:"text-sm text-gray-500",children:"Checking existing published waivers…"}):i.length>0?e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-3 py-2.5",children:e.jsx("p",{className:"text-sm text-amber-900",children:i.length===1?`${f} will be archived so this waiver can go live.`:`These published waivers will be archived so this one can go live: ${f}.`})}):null,c?e.jsx("div",{className:ue,role:"alert",children:c}):null]})}function we({waiverId:t,waiverTitle:m,checkoutSurfaces:a,saving:l,publishing:i,deleting:c,canSaveDraft:b,canPublish:v,canDelete:g=!0,actionError:f,onSaveDraft:x,onPublish:s,onDelete:h}){const{companyData:w}=U(),[N,C]=r.useState(!1),[y,k]=r.useState(!1),[P,d]=r.useState(!1),[o,S]=r.useState([]),[M,W]=r.useState(!1),[L,T]=r.useState(null),D=l||i||c,q=!b||D,R=!v||D;return r.useEffect(()=>{if(!y)return;if(!w?.id){S([]),W(!1),d(!1);return}let p=!1;return d(!0),T(null),de({companyId:w.id,exceptWaiverId:t,surfaces:a}).then(E=>{p||(W(E.length>0),S(E.filter(n=>n.willArchive).map(n=>n.waiverTitle)))}).catch(E=>{p||(W(!1),S([]),T(E instanceof Error?E.message:"Unable to check existing published waivers."))}).finally(()=>{p||d(!1)}),()=>{p=!0}},[a,w?.id,y,t]),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-x-0 bottom-0 z-30 border-t border-gray-200 bg-white/95 backdrop-blur md:left-64",role:"toolbar","aria-label":"Waiver actions",children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-3 px-4 py-3 sm:gap-4 sm:px-10 lg:px-12",children:[g?e.jsxs("button",{type:"button",onClick:()=>C(!0),disabled:D,className:A(me,"shrink-0 px-3 py-2"),children:[e.jsx(_,{className:"h-4 w-4","aria-hidden":!0}),"Delete draft"]}):e.jsx("div",{}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("button",{type:"button",onClick:x,disabled:q,className:A(z,"shrink-0 px-4 py-2"),children:l?"Saving…":"Save Draft"}),e.jsx("button",{type:"button",onClick:()=>k(!0),disabled:R,className:A(V,"shrink-0 px-4 py-2"),children:i?"Publishing…":"Publish Live"})]})]})}),e.jsx(se,{open:N,waiverTitle:m,deleting:c,error:f??null,onClose:()=>{c||C(!1)},onConfirm:()=>{h().then(p=>{p&&C(!1)})}}),e.jsx(je,{open:y,waiverTitle:m,publishing:i,loadingImpact:P,waiversToArchive:o,error:L??f??null,confirmDisabled:!!L,onClose:()=>{i||k(!1)},onConfirm:()=>{s({reclaimSurfaces:M}).then(p=>{p&&k(!1)})}})]})}function Ce({waiver:t,form:m}){const a=m.title.trim()||t.title.trim()||"Untitled Waiver";return e.jsx("header",{className:"overflow-hidden rounded-xl border border-gray-200 bg-white",children:e.jsx("div",{className:"flex flex-col gap-4 p-4 sm:flex-row sm:items-center sm:justify-between sm:gap-6 sm:p-5",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h1",{className:"truncate text-lg font-semibold tracking-tight text-gray-900",children:a}),e.jsx(ae,{status:t.status})]}),e.jsx("p",{className:"mt-1 text-sm text-gray-600",children:fe(t)})]})})})}function ke({sections:t,activeSection:m,onChange:a}){return e.jsx(ye,{sticky:!0,tabs:t.map(l=>({id:l.id,label:l.label})),activeTab:m,onChange:a})}function Ee(t){const{companyData:m}=U(),a=m?.id,[l,i]=r.useState(null),[c,b]=r.useState($),[v,g]=r.useState($),[f,x]=r.useState(!0),[s,h]=r.useState(null),[w,N]=r.useState(!1),[C,y]=r.useState(!1),[k,P]=r.useState(!1),[d,o]=r.useState(null),S=he(c,v),M=G(c),W=H(c),L=M===null&&S,T=W===null,D=r.useCallback(n=>{o(null),b(n)},[]),q=r.useCallback(async()=>
1{if(!a||!t){i(null),h("Waiver not found."),x(!1);return}x(!0),h(null),o(null);try{const n=await ve(a,t);if(!n){i(null),h("Waiver not found.");return}if(n.status!=="draft"){i(null),h(n.status==="active"?"Published waivers are view-only. Duplicate as a draft to make changes.":"Archived waivers cannot be edited. Duplicate as a draft to create a new version.");return}const u=pe(n);i(n),b(u),g(I(u))}catch(n){i(null),h(n instanceof Error?n.message:"Failed to load waiver.")}finally{x(!1)}},[a,t]);r.useEffect(()=>{q()},[q]);const R=r.useCallback(async()=>{if(!a||!t||!l)return!1;const n=G(c);if(n)return o(n),!1;if(!S)return!1;N(!0),o(null);const u={...c,status:"draft"};try{return await O({waiverId:t,companyId:a,form:u}),b(u),g(I(u)),i(j=>j&&{...j,title:u.title.trim(),content:u.content,requiresSignature:!0,requiresGuardian:u.requiresGuardian,requiresDob:u.requiresDob,requiresEmergencyContact:u.requiresEmergencyContact,requiresContactInfo:u.requiresContactInfo,validity:{...u.validity},checkoutSurfaces:[...u.checkoutSurfaces]}),!0}catch(j){return o(j instanceof Error?j.message:"Failed to save waiver."),!1}finally{N(!1)}},[a,c,S,l,t]),p=r.useCallback(async n=>{if(!a||!t||!l)return!1;const u=H(c);if(u)return o(u),!1;y(!0),o(null);const j={...c,status:"active"};try{return await O({waiverId:t,companyId:a,form:j,publish:!0,reclaimSurfaces:n?.reclaimSurfaces===!0}),!0}catch(F){return F instanceof Error&&F.message==="SURFACE_CONFLICT"&&"conflicts"in F?(o(n?.reclaimSurfaces?"Unable to replace existing checkout surface assignments. Try again.":"Another published waiver already uses one of these checkout surfaces. Open Publish Live again to review and continue."),!1):(o(F instanceof Error?F.message:"Failed to publish waiver."),!1)}finally{y(!1)}},[a,c,l,t]),E=r.useCallback(async()=>{if(!a||!t)return!1;P(!0),o(null);try{return await be({waiverId:t,companyId:a}),!0}catch(n){return o(n instanceof Error?n.message:"Failed to delete waiver."),!1}finally{P(!1)}},[a,t]);return{waiver:l,form:c,setForm:D,isInitialLoad:f,loadError:s,saving:w,publishing:C,deleting:k,saveError:d,setSaveError:o,hasChanges:S,canSaveDraft:L,canPublish:T,saveDraft:R,publish:p,remove:E}}function Me(){const{waiverId:t}=K(),[m,a]=Q(),l=X(),i=Y(),{hasCoachPlatform:c,hasGymPlatform:b}=U(),{showToast:v,toastElement:g}=xe(),f=te(m.get("section")),x=r.useMemo(()=>re(),[]),s=Ee(t),h=l.state;r.useEffect(()=>{h?.successMessage&&(v(h.successMessage),i(l.pathname+l.search,{replace:!0,state:null}))},[l.pathname,l.search,h?.successMessage,i,v]);const w=d=>{const o=new URLSearchParams(m);d==="details"?o.delete("section"):o.set("section",d),a(o,{replace:!0})},N=()=>i(B()),C=async()=>{await s.saveDraft()&&v("Draft saved.")},y=async d=>{const o=await s.publish({reclaimSurfaces:d?.reclaimSurfaces===!0});return o&&i(B(),{state:{successMessage:"Published live."}}),o},k=async()=>{const d=await s.remove();return d&&i(B(),{state:{successMessage:"Draft waiver deleted."}}),d},P=s.form.title.trim()||s.waiver?.title.trim()||"Untitled Waiver";return e.jsxs(ge,{className:"max-w-3xl",children:[e.jsxs("button",{type:"button",onClick:N,className:"inline-flex items-center gap-2 text-sm font-medium text-gray-600 transition hover:text-gray-900",children:[e.jsx(Z,{className:"h-4 w-4","aria-hidden":!0}),"Waivers"]}),s.isInitialLoad?e.jsxs("div",{className:"mt-8 space-y-4","aria-busy":"true","aria-label":"Loading waiver",children:[e.jsx("div",{className:"h-28 animate-pulse rounded-xl bg-gray-100"}),e.jsx("div",{className:"h-10 animate-pulse rounded-lg bg-gray-100"}),e.jsx("div",{className:"h-64 animate-pulse rounded-xl bg-gray-100"})]}):s.loadError||!s.waiver?e.jsxs("div",{className:"mt-8 rounded-xl border border-gray-200 bg-white px-4 py-12 text-center",children:[e.jsx("p",{className:"text-sm text-gray-600",children:s.loadError??"Waiver not found."}),e.jsx(ee,{to:B(),className:"mt-3 inline-block text-sm font-medium text-gray-900 hover:underline",children:"Back to Waivers"}),s.loadError?.includes("Duplicate")||s.loadError?.includes("view-only")?e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"Open the published waiver from Settings and choose Duplicate as draft."}):null]}):e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsx(Ce,{waiver:s.waiver,form:s.form}),e.jsx(Se,{error:null,saveError:s.saveError}),e.jsx(ke,{sections:x,activeSection:f,onChange:w}),e.jsxs("div",{className:"space-y-4 pb-24",children:[f==="details"?e.jsx(ie,{form:s.form,setForm:s.setForm}):null,f==="requirements"?e.jsx(ne,{form:s.form,setForm:s.setForm}):null,f==="assignment"?e.jsxs("div",{className:"space-y-4",children:[e.jsx(le,{form:s.form,setForm:s.setForm}),e.jsx(oe,{form:s.form,setForm:s.setForm,hasCoachPlatform:c,hasGymPlatform:b})]}):null]}),e.jsx(we,{waiverId:s.waiver.id,waiverTitle:P,checkoutSurfaces:s.form.checkoutSurfaces,saving:s.saving,publishing:s.publishing,deleting:s.deleting,canSaveDraft:s.canSaveDraft,canPublish:s.canPublish,canDelete:s.waiver.status==="draft",actionError:s.saveError,onSaveDraft:()=>{C()},onPublish:y,onDelete:k})]}),g]})}export{Me 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.