{"version":3,"file":"useOrderGroupStatus.BvlyVJAe.mjs","names":["useState","useState","useCallback"],"sources":["https:/framerusercontent.com/modules/mFCWYcbZhjHbBKsrZDaV/WEX6bIWe5Lz4hPVBvVCO/useOrderGroupId.js","https:/framerusercontent.com/modules/o8RfWOXD9bBInyhTXMJJ/rx0Nvym1IrZV82z9vAnz/useOrderGroupStatus.js"],"sourcesContent":["import{useState,useEffect}from\"react\";import{debugLog}from\"https://framerusercontent.com/modules/lAZ2BZ9JYvlotEWncq8V/JCrDYHV6scQB7mfaxNpw/debugLog.js\";/**\n * URL hash에서 orderGroupId를 관리하는 훅\n * 주문서 페이지와 결제 페이지에서 draft orderGroup ID를 추적하는데 사용됩니다.\n *\n * @returns {Object} orderGroupId 관련 메서드들\n */export function useOrderGroupId(){const[orderGroupId,setOrderGroupIdState]=useState(null);// 초기 로드 시 URL hash에서 orderGroupId 읽기\nuseEffect(()=>{const hash=window.location.hash;debugLog(`[useOrderGroupId] 초기 로드 - hash: ${hash||\"(없음)\"}`);if(hash&&hash.startsWith(\"#\")){const id=hash.substring(1)// # 제거\n;if(id){setOrderGroupIdState(id);debugLog(`[useOrderGroupId] 초기 상태 설정: ${id}`);}}},[]);/**\n     * orderGroupId를 설정하고 URL hash에 반영\n     */const setOrderGroupId=id=>{debugLog(`[useOrderGroupId] 🎯 setOrderGroupId 호출됨! id: ${id}`);setOrderGroupIdState(id);if(id){// URL hash에 추가 (페이지 이동 없이)\ndebugLog(`[useOrderGroupId] URL hash 추가 전: ${window.location.href}`);const hashWithSymbol=id.startsWith(\"#\")?id:`#${id}`;window.location.hash=id;debugLog(`[useOrderGroupId] URL hash 추가 후: ${window.location.href}`);debugLog(`[useOrderGroupId] ✅ window.location.hash = ${window.location.hash}`);// ⭐ sessionStorage에도 저장 (PreserveHashOnNavigation을 위해)\ntry{sessionStorage.setItem(\"__ORDER_GROUP_HASH__\",hashWithSymbol);debugLog(`[useOrderGroupId] 💾 sessionStorage 저장 완료: ${hashWithSymbol}`);}catch(e){debugLog(`[useOrderGroupId] ⚠️ sessionStorage 저장 실패:`,e);}}else{// hash 제거\ndebugLog(`[useOrderGroupId] hash 제거`);window.history.replaceState(null,\"\",window.location.pathname+window.location.search);// sessionStorage도 제거\ntry{sessionStorage.removeItem(\"__ORDER_GROUP_HASH__\");debugLog(`[useOrderGroupId] 🗑️ sessionStorage 제거 완료`);}catch(e){debugLog(`[useOrderGroupId] ⚠️ sessionStorage 제거 실패:`,e);}}};/**\n     * URL hash에서 최신 orderGroupId 읽기\n     */const getOrderGroupId=()=>{const hash=window.location.hash;if(hash&&hash.startsWith(\"#\")){return hash.substring(1);}return null;};/**\n     * orderGroupId 삭제 (hash 제거)\n     */const clearOrderGroupId=()=>{setOrderGroupId(null);};return{orderGroupId,setOrderGroupId,getOrderGroupId,clearOrderGroupId};}\nexport const __FramerMetadata__ = {\"exports\":{\"useOrderGroupId\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./useOrderGroupId.map","import{useState,useCallback}from\"react\";import{debugError}from\"https://framerusercontent.com/modules/lAZ2BZ9JYvlotEWncq8V/JCrDYHV6scQB7mfaxNpw/debugLog.js\";/**\n * OrderGroup 상태 확인 API 엔드포인트\n */const API_ENDPOINT=\"https://checkordergroupstatusep-5ydstabw6q-du.a.run.app\";/**\n * 서버에서 orderGroup 상태를 조회하는 훅\n * 중복 결제 방지를 위해 사용됩니다.\n *\n * @param orderGroupId - 조회할 orderGroup의 ID\n * @returns {Object} 상태 조회 메서드들\n */export function useOrderGroupStatus(orderGroupId){const[isPaid,setIsPaid]=useState(false);const[isLoading,setIsLoading]=useState(false);const[error,setError]=useState(null);const[status,setStatus]=useState(null);const[orderGroupNumber,setOrderGroupNumber]=useState(null);/**\n     * 서버에서 orderGroup 상태 조회\n     */const checkStatus=useCallback(async()=>{if(!orderGroupId){setIsPaid(false);setStatus(null);setOrderGroupNumber(null);return;}setIsLoading(true);setError(null);try{// API 호출\nconst response=await fetch(API_ENDPOINT,{method:\"POST\",headers:{\"Content-Type\":\"application/json\",Accept:\"application/json\"},body:JSON.stringify({data:{orderGroupId}})});// HTTP 오류 처리\nif(!response.ok){const errorText=await response.text().catch(()=>\"\");throw new Error(`HTTP ${response.status} ${response.statusText}${errorText?` - ${errorText}`:\"\"}`);}// 응답 파싱\nconst text=await response.text();let json;try{json=JSON.parse(text);}catch{throw new Error(`JSON 파싱 실패: ${text.slice(0,200)}`);}// Firebase Functions onCall은 { result: <서버리턴> } 형태로 감쌉니다.\nconst envelope=json?.result??json;if(!envelope||typeof envelope!==\"object\"){throw new Error(\"유효하지 않은 응답 형식\");}// 응답이 실패인 경우\nif(envelope.result===false){throw new Error(envelope.message||\"상태 조회에 실패했습니다.\");}// 상태 업데이트\nsetIsPaid(envelope.isPaid??false);setStatus(envelope.status??null);setOrderGroupNumber(envelope.orderGroupNumber??null);}catch(err){const errorMessage=err instanceof Error?err.message:\"상태 조회 중 오류가 발생했습니다.\";setError(errorMessage);debugError(\"OrderGroup 상태 조회 오류:\",err);}finally{setIsLoading(false);}},[orderGroupId]);return{isPaid,isLoading,error,status,orderGroupNumber,checkStatus};}\nexport const __FramerMetadata__ = {\"exports\":{\"useOrderGroupStatus\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./useOrderGroupStatus.map"],"mappings":"0LAKG,SAAgB,GAAiB,CAAC,GAAK,CAAC,EAAa,GAAsBA,EAAS,KAAK,CAC5F,MAAc,CAAC,IAAM,EAAK,EAAO,SAAS,KAAiE,GAA5D,EAAS,mCAAmC,GAAM,SAAS,CAAI,GAAM,EAAK,WAAW,IAAI,CAAC,CAAC,IAAM,EAAG,EAAK,UAAU,EAAE,CAChK,IAAI,EAAqB,EAAG,CAAC,EAAS,+BAA+B,IAAK,IAAK,EAAE,CAAC,CAE/E,IAAM,EAAgB,GAAI,CAA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