PageSourceSearch

https://audaxa-qms-cloudflare-deployment.pages.dev/assets/useBmrMbrVersioning-BkRedD1Q.js

js audaxa-qms-cloudflare-deployment.pages.dev collected 2026-10-03 05:38:43 UTC 3,218 bytes, 1 lines download raw bytes

1import{as as n,r as v,at as m,au as l}from"./vendor-DAhHXCkI.js";import{s as o}from"./index-ErfH8nLi.js";import{b as h}from"./bmrChannelName-BusrbCpn.js";const s=o;function F(e){return m({enabled:!!e,queryKey:["bmr_mbr_full_record",e],queryFn:async()=>{const{data:r,error:t}=await s.from("bmr_master_batch_records").select("*, bmr_industries(*)").eq("id",e).maybeSingle();if(t)throw t;if(!r)return null;const[a,_,f,y,p,q]=await Promise.all([s.from("bmr_mbr_sections").select("*").eq("mbr_id",e).order("sort_order"),s.from("bmr_mbr_steps").select("*").eq("mbr_id",e).order("sort_order"),s.from("bmr_mbr_materials").select("*").eq("mbr_id",e).order("sort_order"),s.from("bmr_mbr_equipment").select("*").eq("mbr_id",e).order("sort_order"),s.from("bmr_mbr_line_clearance_items").select("*").eq("mbr_id",e).order("sort_order"),s.from("bmr_mbr_step_reconciliation").select("*").eq("mbr_id",e)]),c=(_.data||[]).map(i=>i.id);let d=[];if(c.length){const{data:i}=await s.from("bmr_mbr_step_parameters").select("*").in("step_id",c).order("sort_order");d=i||[]}let u=null;if(r.document_id){const{data:i}=await s.from("documents").select("id, document_id, document_code, title, version, status").eq("id",r.document_id).maybeSingle();u=i}let b=null;if(r.previous_mbr_id){const{data:i}=await s.from("bmr_master_batch_records").select("id, mbr_code, version, status").eq("id",r.previous_mbr_id).maybeSingle();b=i}return{mbr:r,document:u,previous:b,sections:a.data||[],steps:_.data||[],params:d,materials:f.data||[],equipment:y.data||[],clearance:p.data||[],reconciliation:q.data||[]}}})}function M(e){const r=n();return v.useEffect(()=>{if(!e)return;const t=o.channel(h(`bmr-mbr-versions-${e}`)).on("postgres_changes",{event:"*",schema:"public",table:"bmr_master_batch_records"},()=>r.invalidateQueries({queryKey:["bmr_mbr_versions",e]})).subscribe();return()=>{o.removeChannel(t)}},[e,r]),m({enabled:!!e,queryKey:["bmr_mbr_versions",e],queryFn:async()=>{const{data:t,error:a}=await s.from("bmr_master_batch_records").select("id, mbr_code, version, status, previous_mbr_id, superseded_by_mbr_id, is_latest_version, document_id, effective_from, effective_to").eq("mbr_code",e).order("version",{ascending:!0});if(a)throw a;return t||[]}})}function Q(){const e=n();return l({mutationFn:async r=>{const{data:t,error:a}=await s.rpc("bmr_create_mbr_revision",{p_mbr_id:r});if(a)throw a;return t},onSuccess:()=>{e.invalidateQueries({queryKey:["bmr_masters"]}),e.invalidateQueries({queryKey:["bmr_mbr_versions"]})}})}function S(){const e=n();return l({mutationFn:async r=>{const{data:{user:t}}=await o.auth.getUser();if(!t)throw new Error("Not authenticated");const{error:a}=await s.from("bmr_mbr_print_log").insert({mbr_id:r.mbr_id,mbr_code:r.mbr_code,mbr_version:r.mbr_version,printed_by:t.id,printed_by_name:t.email,reason:r.reason});if(a)throw a;return!0},onSuccess:(r,t)=>e.invalidateQueries({queryKey:["bmr_mbr_print_log",t.mbr_id]})})}function E(e){return m({enabled:!!e,queryKey:["bmr_mbr_linked_document",e],queryFn:async()=>{const{data:r,error:t}=await s.from("documents").select("id, document_id, document_code, title, version, status").eq("id",e).maybeSingle();if(t)throw t;return r}})}export{S as a,M as b,Q as c,E as d,F as u};

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.