PageSourceSearch

https://nicheretail.com/assets/WorkshopOrgCheckupTool-6bAzWLzp.js

js nicheretail.com collected 2026-10-05 01:14:27 UTC 10,747 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-query-CX6kXpPt.js";import{bU as y,Q as U,s as N,B as C,bG as q,V as b,a1 as W,a2 as V,a3 as Q,L as B}from"./index-QfuKfl9m.js";import{r as c}from"./vendor-react-9c9vGjwA.js";import{A as J,h as K,a as G,b as H,c as X,d as Y,e as Z,f as ee,g as te}from"./alert-dialog-03KxAwdN.js";import{u as re,F as se}from"./FontScaleControls-BHC1THqH.js";import{a as ae}from"./useVTOLongTermIssues-CawyBQ-_.js";import{C as oe}from"./chart-pie-CJAUsps4.js";import{S as ne}from"./save-CZrn9Pzp.js";import"./vendor-supabase-DrACM_MH.js";import"./vendor-radix-DhfCpOlC.js";import"./vendor-charts-BM6lVqmw.js";import"./vendor-date-Bf3HPMEs.js";import"./resolveCompanyDepartmentId-Dyjfx9G2.js";import"./useRealtimeCollection-D1l3YLOD.js";import"./rowSync-Dx_YRBAj.js";import"./resilientWrite-D_KnXRfP.js";const w=["We have a clear vision in writing that has been properly communicated and is shared by everyone in the company.","Our core values are clear, and we are hiring, reviewing, rewarding, and firing around them.","Our Core Focus™ (core business) is clear, and we keep our people, systems, and processes aligned and focused on it.","Our 10-Year Target™ (big, long-range business goal) is clear, communicated regularly, and is shared by all.","Our target market (definition of our ideal customer) is clear, and all of our marketing and sales efforts are focused on it.","Our 3 Uniques™ (differentiators) are clear, and all of our marketing and sales efforts communicate them.","We have a proven process for doing business with our customers. It has been named and visually illustrated, and all of our salespeople use it.",'All of the people in our organization are the "right people" (they fit our culture and share our core values).',"Our Accountability Chart™ (organizational chart that includes roles/responsibilities) is clear, complete, and constantly updated.",'Everyone is in the "right seat" (they "get it, want it, and have the capacity to do their jobs well").',"Our leadership team is open and honest, and demonstrates a high level of trust.","Everyone has Rocks (1 to 7 priorities per quarter) and is focused on them.","Everyone is engaged in a regular Meeting Pulse™ (weekly, quarterly, annually).","All meetings are on the same day and at the same time, have the same agenda, start on time, and end on time.","All teams clearly identify, discuss, and solve issues for the long-term greater good of the company.","Our Core Processes are documented, simplified, and followed by all to consistently produce the results we want.","We have systems for receiving regular feedback from customers and employees, so we always know their level of satisfaction.","A Scorecard for tracking weekly metrics/measurables is in place.","Everyone in the organization has at least one number they are accountable for keeping on track each week.","We have a budget and are monitoring it regularly (e.g., monthly or quarterly)."],ie=[1,2,3,4,5];function le(l){if(l.length===0)return{avg:0,stddev:0,count:0};const o=l.reduce((d,u)=>d+u,0)/l.length,h=l.reduce((d,u)=>d+(u-o)**2,0)/l.length;return{avg:o,stddev:Math.sqrt(h),count:l.length}}function Se({contactId:l}){const x=`workshop:org-checkup:votes:${l}`,[o,h]=c.useState(()=>{try{const r=localStorage.getItem(x);return r?JSON.parse(r):{}}catch{return{}}}),[d,u]=c.useState(0),[S,O]=c.useState(!1),{scale:T,inc:D,dec:I}=re("workshop:org-checkup",1),{addLongTermIssue:A}=ae(l),E=c.useRef([]);c.useEffect(()=>{try{localStorage.setItem(x,JSON.stringify(o))}catch{}},[x,o]);const j=c.useCallback((r,t)=>{h(a=>{const s={...a};return s[r]=[...a[r]??[],t],s})},[]),_=c.useCallback((r,t)=>{h(a=>{const s=a[r]??[],p=(()=>{for(let f=s.length-1;f>=0;f--)if(s[f]===t)return f;return-1})();if(p<0)return a;const v={...a};return v[r]=[...s.slice(0,p),...s.slice(p+1)],v})},[]);c.useEffect(()=>{const r=t=>{const a=t.target?.tagName;if(!(a==="INPUT"||a==="TEXTAREA")){if(t.key>="1"&&t.key<="5"){const s=parseInt(t.key,10);j(d,s),t.preventDefault();return}t.key==="ArrowDown"||t.key==="j"?(u(s=>Math.min(w.length-1,s+1)),t.preventDefault()):(t.key==="ArrowUp"||t.key==="k")&&(u(s=>Math.max(0,s-1)),t.preventDefault())}};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[d,j]),c.useEffect(()=>{E.current[d]?.scrollIntoView({block:"nearest",behavior:"smooth"})},[d]);const R=c.useMemo(()=>w.map((r,t)=>le(o[t]??[])),[o]),g=c.useMemo(()=>{let r=0,t=0;for(const a of Object.values(o))for(const s of a)r+=s,t+=1;return t===0?{pct:0,count:0}
1:{pct:r/t/5*100,count:t}},[o]),F=c.useCallback(async r=>{const t=`Org Checkup #${r+1}: ${w[r]}`;try{await A(t),y({title:"Added to Long-Term Issues"})}catch{y({title:"Could not add to Long-Term Issues",variant:"destructive"})}},[A]),M=g.pct>=80,$=c.useCallback(async()=>{if(g.count===0){y({title:"Nothing to save",description:"Record at least one tick first.",variant:"destructive"});return}O(!0);try{const{data:r}=await U(),t=r.user?.id??null,{data:a,error:s}=await N.from("org_checkups").insert({contact_id:l,is_active:!1,started_at:new Date().toISOString(),ends_at:new Date().toISOString(),created_by:t,source:"workshop"}).select("id").single();if(s||!a)throw s??new Error("Failed to create checkup");const p=Object.values(o).reduce((i,k)=>Math.max(i,k.length),0);if(p===0)throw new Error("No votes to save");const v=Array.from({length:p},(i,k)=>({checkup_id:a.id,email:`workshop+${k+1}@session.local`,access_token:crypto.randomUUID(),participant_name:`Workshop Participant ${k+1}`,started_at:new Date().toISOString(),completed_at:new Date().toISOString()})),{data:f,error:n}=await N.from("org_checkup_invites").insert(v).select("id");if(n||!f)throw n??new Error("Failed to create invites");const m=[];for(const[i,k]of Object.entries(o)){const z=Number(i)+1;k.forEach((L,P)=>{m.push({invite_id:f[P].id,question_number:z,score:L})})}if(m.length>0){const{error:i}=await N.from("org_checkup_responses").insert(m);if(i)throw i}y({title:"Saved to Org Checkup",description:"Marked as a workshop-sourced result."})}catch(r){y({title:"Save failed",description:r?.message??"Unknown error",variant:"destructive"})}finally{O(!1)}},[l,o,g.count]);return e.jsxs("div",{className:"w-full h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b",children:[e.jsx("h3",{className:"font-semibold text-sm",children:"Organizational Checkup - 20 Questions"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{scale:T,onIncrease:D,onDecrease:I,size:"sm"}),e.jsxs(J,{children:[e.jsx(K,{asChild:!0,children:e.jsxs(C,{variant:"outline",size:"sm",className:"h-8 gap-1.5",disabled:g.count===0,children:[e.jsx(q,{className:"w-3.5 h-3.5"}),"Reset"]})}
1),e.jsxs(G,{children:[e.jsxs(H,{children:[e.jsx(X,{children:"Reset all ticks?"}),e.jsx(Y,{children:"This clears every recorded score across all 20 questions for this checkup. This cannot be undone."})]}),e.jsxs(Z,{children:[e.jsx(ee,{children:"Cancel"}),e.jsx(te,{onClick:()=>{h({}),y({title:"Checkup reset"})},children:"Reset everything"})]})]})]})]})]}),e.jsx("div",{className:"flex-1 overflow-auto",style:{fontSize:`${T}rem`},children:e.jsx("div",{className:"w-full px-4 py-4 space-y-2",children:w.map((r,t)=>{const a=R[t],s=a.count>0,p=s&&(a.avg<4||a.stddev>1),v=s?p?"ring-2 ring-red-500":"ring-2 ring-green-500":"ring-1 ring-border",f=t===d;return e.jsx("div",{ref:n=>E.current[t]=n,onClick:()=>u(t),className:b("rounded-md bg-card transition-colors cursor-pointer",v,f&&"bg-primary/5 outline outline-2 outline-primary"),children:e.jsxs("div",{className:"grid grid-cols-[2.5em_1fr_auto_auto] gap-3 items-center px-3 py-2",children:[e.jsxs("div",{className:"text-right font-bold text-muted-foreground tabular-nums",children:[t+1,"."]}),e.jsx("div",{className:"leading-snug break-words",children:r}),e.jsx("div",{className:"flex items-center gap-1.5",children:ie.map(n=>{const m=(o[t]??[]).filter(i=>i===n).length;return e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),u(t),j(t,n)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),u(t),_(t,n)},className:b("w-10 h-10 rounded border-2 font-bold flex items-center justify-center transition-colors",m>0?"border-orange-500 bg-orange-500/10 text-orange-600 dark:text-orange-300":"border-orange-500/60 hover:bg-orange-500/10 text-orange-600/80 dark:text-orange-300/80"),title:`Click to add a ${n} • Click tally below or right-click to remove • Or press ${n} on keyboard`,children:n}),e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),m!==0&&(u(t),_(t,n))},disabled:m===0,title:m>0?`Click to remove a ${n}`:void 0,className:b("h-4 mt-0.5 min-w-[1.5rem] px-1 font-mono leading-none text-[0.9em] tabular-nums text-foreground/80 select-none rounded",m>0?"cursor-pointer hover:bg-red-500/15 hover:text-red-500":"cursor-default"),children:ce(m)})]},n)})}),e.jsxs("div",{className:"flex items-center gap-3 pl-2",children:[e.jsxs("div",{className:"text-right tabular-nums leading-tight",children:[e.jsx("div",{className:b("font-bold",p&&"text-red-500"),children:s?a.avg.toFixed(2):" - "}),e.jsxs("div",{className:"text-[0.75em] text-muted-foreground",children:[e.jsxs("span",{className:b(s&&a.stddev>.5&&"text-red-500 font-semibold"),children:["σ ",s?a.stddev.toFixed(2):" - "]})," · n ",a.count]})]}),e.jsxs(W,{children:[e.jsx(V,{asChild:!0,children:e.jsx(C,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 text-amber-600",onClick:n=>{n.stopPropagation(),F(t)},children:e.jsx(oe,{className:"w-4 h-4"})})}),e.jsx(Q,{className:"text-xs",children:"Long-term issue"})]})]})]})},t)})})}),e.jsxs("div",{className:"border-t px-4 py-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:[g.count," ticks recorded across ",w.length," questions"]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:$,disabled:S||g.count===0,className:"gap-1.5",children:[S?e.jsx(B,{className:"w-4 h-4 animate-spin"}):e.jsx(ne,{className:"w-4 h-4"}),"Save to Client Checkup"]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Total"}),e.jsx("span",{className:b("text-3xl font-black tabular-nums",g.count===0?"text-muted-foreground":M?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"),children:g.count===0?" - ":`${g.pct.toFixed(0)}%`})]})]})]})]})}function ce(l){if(l<=0)return"";const x=Math.floor(l/5),o=l%5,h=[];for(let d=0;d<x;d++)h.push("卌");return o>0&&h.push("|".repeat(o)),h.join(" ")}export{Se as WorkshopOrgCheckupTool,Se 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.