randmarcomps 1.202.0 → 1.203.0
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/dist/randmarcomps.js
CHANGED
|
@@ -64084,7 +64084,7 @@ function ProductCard({
|
|
|
64084
64084
|
/* @__PURE__ */ jsx(Eye, { className: "mr-2" }),
|
|
64085
64085
|
"View Product"
|
|
64086
64086
|
] }) }),
|
|
64087
|
-
((zt = t.Distribution) == null ? void 0 : zt.Inventory) && /* @__PURE__ */ jsx("div", { className: "mt-4", children: Le != null && Le.IsReseller && et <= 0 ? /* @__PURE__ */ jsx(Fragment, { children:
|
|
64087
|
+
((zt = t.Distribution) == null ? void 0 : zt.Inventory) && /* @__PURE__ */ jsx("div", { className: "mt-4", children: Le != null && Le.IsReseller && et <= 0 ? /* @__PURE__ */ jsx(Fragment, { children: ge > 0 ? /* @__PURE__ */ jsxs(Dialog, { open: q, onOpenChange: z, children: [
|
|
64088
64088
|
/* @__PURE__ */ jsx(DialogTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "ghost", className: "flex items-center text-sm manufacturer-theme text-primary", children: [
|
|
64089
64089
|
/* @__PURE__ */ jsx(Warehouse, { size: "16", className: "mr-2" }),
|
|
64090
64090
|
ge,
|
|
@@ -956,7 +956,7 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
|
|
|
956
956
|
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")},pp.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
|
|
957
957
|
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return codePointToString(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var o=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],l=parseInt(o,8);return l>255&&(o=o.slice(0,-1),l=parseInt(o,8)),this.pos+=o.length-1,t=this.input.charCodeAt(this.pos),(o!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-o.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(l)}return isNewLine(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},pp.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n},pp.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,o=this.options.ecmaVersion>=6;this.pos<this.input.length;){var l=this.fullCharCodeAtPos();if(isIdentifierChar(l,o))this.pos+=l<=65535?1:2;else if(l===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var d=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var f=this.readCodePoint();(t?isIdentifierStart:isIdentifierChar)(f,o)||this.invalidStringToken(d,"Invalid Unicode escape"),e+=codePointToString(f),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},pp.readWord=function(){var e=this.readWord1(),t=types$1.name;return this.keywords.test(e)&&(t=keywords[e]),this.finishToken(t,e)};var version="8.12.1";Parser.acorn={Parser,version,defaultOptions,Position,SourceLocation,getLineInfo,Node:Node$1,TokenType,tokTypes:types$1,keywordTypes:keywords,TokContext,tokContexts:types,isIdentifierChar,isIdentifierStart,Token,isNewLine,lineBreak,lineBreakG,nonASCIIwhitespace};var AcornJSX=__toESM(require_acorn_jsx(),1),attributeNames_default={acceptcharset:"acceptCharset",accesskey:"accessKey",allowfullscreen:"allowFullScreen",autocapitalize:"autoCapitalize",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",colspan:"colSpan",contenteditable:"contentEditable",crossorigin:"crossOrigin",datetime:"dateTime",enctype:"encType",for:"htmlFor",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",httpequiv:"httpEquiv",inputmode:"inputMode",keyparams:"keyParams",keytype:"keyType",marginheight:"marginHeight",marginwidth:"marginWidth",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",novalidate:"noValidate",radiogroup:"radioGroup",readonly:"readOnly",referrerpolicy:"referrerPolicy",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"},VOID_ELEMENTS=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"],NO_WHITESPACE=["table","tbody","tfoot","thead","tr"];function canHaveChildren(e){return VOID_ELEMENTS.indexOf(e.toLowerCase())===-1}function canHaveWhitespace(e){return NO_WHITESPACE.indexOf(e.toLowerCase())!==-1}class NullishShortCircuit extends Error{constructor(t="Nullish value encountered"){super(t),this.name="NullishShortCircuit"}}var hash=(e="",t=16)=>{const n=String(e);let o=0;return n.split("").forEach(l=>{o=(o<<5)-o+l.charCodeAt(0),o&=o}),Math.abs(o).toString(t)},randomHash=()=>hash(Math.random().toString()),camelCase=e=>e.replace(/([A-Z])([A-Z])/g,"$1 $2").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z\u00C0-\u00ff]/g," ").toLowerCase().split(" ").filter(t=>t).map((t,n)=>n>0?t[0].toUpperCase()+t.slice(1):t).join(""),parseStyle=e=>{switch(typeof e){case"string":return e.split(";").filter(t=>t).reduce((t,n)=>{const o=n.slice(0,n.indexOf(":")).trim(),l=n.slice(n.indexOf(":")+1).trim();return{...t,[camelCase(o)]:l}},{});case"object":return e;default:return}},pathToArrayPath=e=>e==null||e===""?[]:e.split("."),resolveArrayPath=(e,t)=>{const[n,...o]=t;if(!(e==null||n==null))return o.length===0?e[n]:resolveArrayPath(e[n],o)},resolvePath=(e,t)=>resolveArrayPath(e,pathToArrayPath(t));function handleNaN(e){return Number.isNaN(e)?"NaN":e}class JsxParser extends React.Component{constructor(){super(...arguments);Yt(this,"ParsedChildren",null);mr(this,Jt,n=>{const o=Parser.extend(AcornJSX.default({autoCloseVoidElements:this.props.autoCloseVoidElements})),l=`<root>${n}</root>`;let d=[];try{d=o.parse(l,{ecmaVersion:"latest"}),d=d.body[0].expression.children||[]}catch(f){return this.props.showWarnings&&console.warn(f),this.props.onError&&this.props.onError(f),this.props.renderError?this.props.renderError({error:String(f)}):null}return d.map(f=>Xt(this,Ft).call(this,f)).filter(Boolean)});mr(this,Ft,(n,o)=>{var l,d;switch(n.type){case"JSXAttribute":return n.value===null?!0:Xt(this,Ft).call(this,n.value,o);case"JSXElement":case"JSXFragment":return Xt(this,Rr).call(this,n,o);case"JSXExpressionContainer":return Xt(this,Ft).call(this,n.expression,o);case"JSXText":const f=this.props.disableKeyGeneration?void 0:randomHash();return this.props.disableFragments?n.value:React.createElement(React.Fragment,{key:f},n.value);case"ArrayExpression":return n.elements.map(M=>Xt(this,Ft).call(this,M,o));case"BinaryExpression":const g=Xt(this,Ft).call(this,n.left,o),b=Xt(this,Ft).call(this,n.right,o);let _;switch(n.operator){case"-":_=g-b;break;case"!=":_=g!=b;break;case"!==":_=g!==b;break;case"*":_=g*b;break;case"**":_=g**b;break;case"/":_=g/b;break;case"%":_=g%b;break;case"+":_=g+b;break;case"<":_=g<b;break;case"<=":_=g<=b;break;case"==":_=g==b;break;case"===":_=g===b;break;case">":_=g>b;break;case">=":_=g>=b;break;default:this.props.onError(new Error(`Unsupported binary operator: ${n.operator}`));return}return handleNaN(_);case"CallExpression":const S=Xt(this,Ft).call(this,n.callee,o);if(S===void 0){if(n.optional)throw new NullishShortCircuit;this.props.onError(new Error(`The expression '${n.callee}' could not be resolved, resulting in an undefined return value.`));return}return S(...n.arguments.map(M=>Xt(this,Ft).call(this,M,o)));case"ConditionalExpression":return Xt(this,Ft).call(this,n.test,o)?Xt(this,Ft).call(this,n.consequent,o):Xt(this,Ft).call(this,n.alternate,o);case"ExpressionStatement":return Xt(this,Ft).call(this,n.expression,o);case"Identifier":return n.name==="Infinity"?1/0:n.name==="-Infinity"?-1/0:n.name==="NaN"?NaN:o&&n.name in o?handleNaN(o[n.name]):handleNaN((this.props.bindings||{})[n.name]);case"Literal":return n.value;case"LogicalExpression":const R=Xt(this,Ft).call(this,n.left,o);return n.operator==="||"&&R?R:n.operator==="&&"&&R||n.operator==="||"&&!R?Xt(this,Ft).call(this,n.right,o):!1;case"MemberExpression":return Xt(this,Tr).call(this,n,o);case"ChainExpression":return Xt(this,tr).call(this,n,o);case"ObjectExpression":const C={};return n.properties.forEach(M=>{C[M.key.name||M.key.value]=Xt(this,Ft).call(this,M.value,o)}),C;case"TemplateElement":return n.value.cooked;case"TemplateLiteral":return[...n.expressions,...n.quasis].sort((M,I)=>M.start<I.start?-1:1).map(M=>Xt(this,Ft).call(this,M,o)).join("");case"UnaryExpression":const E=Xt(this,Ft).call(this,n.argument,o);switch(n.operator){case"+":return+E;case"-":return-E;case"!":return!E}return;case"ArrowFunctionExpression":return(n.async||n.generator)&&((d=(l=this.props).onError)==null||d.call(l,new Error("Async and generator arrow functions are not supported."))),(...M)=>{const I={...o};return n.params.forEach((A,O)=>{I[A.name]=M[O]}),Xt(this,Ft).call(this,n.body,I)};default:this.props.onError(new Error(`The expression type '${n.type}' is not supported.`));return}});mr(this,tr,(n,o)=>{try{return Xt(this,Ft).call(this,n.expression,o)}catch(l){if(l instanceof NullishShortCircuit)return;throw l}});mr(this,Tr,(n,o)=>{const l=Xt(this,Ft).call(this,n.object,o);let d;if(n.computed)d=Xt(this,Ft).call(this,n.property,o);else if(n.property.type==="Identifier")d=n.property.name;else{this.props.onError(new Error("Only simple MemberExpressions are supported."));return}if(l==null&&n.optional)throw new NullishShortCircuit;let f;try{f=l[d]}catch{this.props.onError(new Error(`The property '${d}' could not be resolved on the object '${l}'.`));return}return typeof f=="function"?f.bind(l):f});mr(this,yr,n=>n.type==="JSXIdentifier"?n.name:`${Xt(this,yr).call(this,n.object)}.${Xt(this,yr).call(this,n.property)}`);mr(this,Rr,(n,o)=>{const{allowUnknownElements:l,components:d,componentsOnly:f,onError:g}=this.props,{children:b=[]}=n,_=n.type==="JSXElement"?n.openingElement:n.openingFragment,{attributes:S=[]}=_,R=n.type==="JSXElement"?Xt(this,yr).call(this,_.name):"",C=(this.props.blacklistedAttrs||[]).map(z=>z instanceof RegExp?z:new RegExp(z,"i")),E=(this.props.blacklistedTags||[]).map(z=>z.trim().toLowerCase()).filter(Boolean);if(/^(html|head|body)$/i.test(R))return b.map(z=>Xt(this,Rr).call(this,z,o));const M=R.trim().toLowerCase();if(E.indexOf(M)!==-1)return g(new Error(`The tag <${R}> is blacklisted, and will not be rendered.`)),null;if(R!==""&&!resolvePath(d,R)){if(f)return g(new Error(`The component <${R}> is unrecognized, and will not be rendered.`)),this.props.renderUnrecognized(R);if(!l&&document.createElement(R)instanceof HTMLUnknownElement)return g(new Error(`The tag <${R}> is unrecognized in this browser, and will not be rendered.`)),this.props.renderUnrecognized(R)}let I,A=n.type==="JSXElement"?resolvePath(d,R):React.Fragment;if(A||canHaveChildren(R)){if(I=b.map(Q=>Xt(this,Ft).call(this,Q,o)),R.includes(".")){const F=R.split(".").reduce((V,te)=>V?V[te]:d==null?void 0:d[te],null);F&&(A=F)}!A&&!canHaveWhitespace(R)&&(I=I.filter(Q=>typeof Q!="string"||!/^\s*$/.test(Q)));const z=I.find(Q=>typeof Q=="function");I.length===0?I=void 0:z?I=z:I.length===1?[I]=I:I.length>1&&!this.props.disableKeyGeneration&&(I=I.map((Q,F)=>Q!=null&&Q.type&&!(Q!=null&&Q.key)?{...Q,key:Q.key||F}:Q))}const O={key:this.props.disableKeyGeneration?void 0:randomHash()};S.forEach(z=>{if(z.type==="JSXAttribute"){const Q=z.name.name,F=attributeNames_default[Q]||Q,V=Xt(this,Ft).call(this,z,o);C.filter(ae=>ae.test(F)).length===0&&(O[F]=V)}else if(z.type==="JSXSpreadAttribute"&&z.argument.type==="Identifier"||z.argument.type==="MemberExpression"){const Q=Xt(this,Ft).call(this,z.argument,o);typeof Q=="object"&&Object.keys(Q).forEach(F=>{const V=attributeNames_default[F]||F;C.filter(ae=>ae.test(V)).length===0&&(O[V]=Q[F])})}}),typeof O.style=="string"&&(O.style=parseStyle(O.style));const q=R.toLowerCase();return q==="option"&&(I=I.props.children),React.createElement(A||q,O,I)})}render(){const n=(this.props.jsx||"").trim().replace(/<!DOCTYPE([^>]*)>/g,"");this.ParsedChildren=Xt(this,Jt).call(this,n);const o=[...new Set(["jsx-parser",...String(this.props.className).split(" ")])].filter(Boolean).join(" ");return this.props.renderInWrapper?React.createElement("div",{className:o},this.ParsedChildren):this.ParsedChildren}}Jt=new WeakMap,Ft=new WeakMap,tr=new WeakMap,Tr=new WeakMap,yr=new WeakMap,Rr=new WeakMap,Yt(JsxParser,"displayName","JsxParser"),Yt(JsxParser,"defaultProps",{allowUnknownElements:!0,autoCloseVoidElements:!1,bindings:{},blacklistedAttrs:[/^on.+/i],blacklistedTags:["script"],className:"",components:{},componentsOnly:!1,disableFragments:!1,disableKeyGeneration:!1,jsx:"",onError:()=>{},showWarnings:!1,renderError:void 0,renderInWrapper:!0,renderUnrecognized:()=>null});var source_default=JsxParser;function useIntersectionObserver({elementRef:e,threshold:t=0,rootMargin:n="0px"}){const[o,l]=React.useState(!1);return React.useEffect(()=>{const d=new IntersectionObserver(([g])=>{l(g.isIntersecting)},{threshold:t,rootMargin:n}),f=e.current;return f&&d.observe(f),()=>{f&&d.unobserve(f)}},[e,t,n]),o}const imgSizeMap={sm:100,md:200,lg:300,xl:400};function ProductImage({randmarSKU:e,size:t="md",alt:n,secondaryContent:o}){const[l,d]=React__namespace.useState(!1),[f,g]=React__namespace.useState(!1),[b,_]=React__namespace.useState(!1),[S,R]=React__namespace.useState(!1),[C,E]=React__namespace.useState(!1),M=`https://api.randmar.io/Product/${e}/Video`,I=React.useRef(null),A=useIntersectionObserver({elementRef:I,threshold:.1,rootMargin:"100px"});React__namespace.useEffect(()=>{const F=async()=>{try{const te=await(await fetch(M+"/Exists")).json();g(te)}catch(V){console.error("Error checking for video:",V),g(!1)}};A&&!b&&(_(!0),F())},[e,M,A,b]);async function O(){if(f){E(!0);try{const V=await(await fetch(M)).blob(),te=window.URL.createObjectURL(V),ae=document.createElement("a");ae.href=te,ae.download=`${e||"product"}-video.mp4`,document.body.appendChild(ae),ae.click(),document.body.removeChild(ae),window.URL.revokeObjectURL(te)}catch(F){console.error("Error downloading video:",F)}finally{E(!1)}}}function q(){navigator.clipboard.writeText(M),R(!0),setTimeout(()=>{R(!1)},2e3)}function z(){d(!0)}const Q=imgSizeMap[t||"xl"];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Dialog,{open:l,onOpenChange:d,children:jsxRuntime.jsx(DialogContent,{className:"max-w-4xl p-0 overflow-hidden",children:o?jsxRuntime.jsxs("div",{className:"flex flex-row",children:[jsxRuntime.jsxs("video",{className:"w-full rounded-l-lg max-h-[720px] object-contain",controls:!0,autoPlay:!0,muted:!0,loop:!0,children:[jsxRuntime.jsx("source",{src:M,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsx("div",{className:"flex-grow min-w-[400px] h-[70vh] p-6",children:o})]}):jsxRuntime.jsxs("div",{className:"w-full relative",children:[jsxRuntime.jsxs("video",{className:"w-full max-h-[720px] object-contain",controls:!0,autoPlay:!0,children:[jsxRuntime.jsx("source",{src:M,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsxs("div",{className:"absolute top-2 right-12 flex gap-1",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:q,children:S?jsxRuntime.jsx(Check,{className:"h-4 w-4"}):jsxRuntime.jsx(Copy,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Copy video link"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:O,disabled:C,children:jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download video"})})]})})]})]})})}),jsxRuntime.jsxs("div",{className:"relative w-max h-max",ref:I,children:[jsxRuntime.jsx("img",{alt:n||`Product ${e}`,className:`rounded-md ${f?"cursor-pointer":""}`,onClick:f?z:void 0,src:`https://api.randmar.io/Product/${e}/Image?width=${Q*1.5}&height=${Q*1.5}`,width:Q,height:Q}),f&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",className:"absolute top-2 right-2",onClick:z,children:jsxRuntime.jsx(Play,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Play video"})})]})})]})]})}const CountryFlag=({countryCode:e,className:t=""})=>{const[n,o]=React.useState(null),[l,d]=React.useState(!1);return React.useEffect(()=>{if(!e)return;const g=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${e.toUpperCase()}.svg`;fetch(g,{method:"HEAD"}).then(b=>{b.ok?(o(g),d(!1)):d(!0)}).catch(()=>{d(!0)})},[e]),l||!n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:n,alt:`${e} flag`,className:`inline-block ${t}`,style:{width:"24px",height:"auto"}})};function ProductCard({applicationId:e,item:t,addToCart:n=!1,syncToShopify:o=!1,customAction:l=jsxRuntime.jsx(jsxRuntime.Fragment,{}),defaultOpportunityNumber:d="",viewProductLink:f,addToCartAction:g,isAddToCartActionLoading:b=!1,syncToShopifyAction:_,isSyncToShopifyActionLoading:S=!1}){var ft,Qe,nt,dt,mt,Ct,It,Dt,Wt,We,rt,ot;const{toast:R}=useToast(),[C,E]=React.useState(1),[M,I]=React.useState(null),[A,O]=React.useState(0),[q,z]=React.useState(!1),[Q,F]=React.useState(!1),[V,te]=React.useState(!1),[ae]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),ie=React.useRef(null),oe=useIntersectionObserver({elementRef:ie,threshold:.1,rootMargin:"100px"}),se=((ft=t==null?void 0:t.Distribution)==null?void 0:ft.Cost)||0,Ae=((Qe=t==null?void 0:t.Distribution)==null?void 0:Qe.RegularPrice)||0,Ne=((nt=t==null?void 0:t.Distribution)==null?void 0:nt.Price)||0,ge=React.useMemo(()=>{var ct;return!((ct=t==null?void 0:t.Distribution)!=null&&ct.Inventory)||t.Distribution.Inventory.length===0?0:t.Distribution.Inventory.reduce((ut,pt)=>ut+(pt.PurchaseOrderQuantity||0),0)},[(dt=t==null?void 0:t.Distribution)==null?void 0:dt.Inventory]);React.useEffect(()=>{E(1),I(null),O(0),z(!1)},[t==null?void 0:t.RandmarSKU]);const[Oe,Fe]=React.useState(null),[ze,je]=React.useState(!1);React.useEffect(()=>{const ct=async()=>{if(t!=null&&t.ManufacturerId){je(!0);try{const ut=await fetch(`https://api.randmar.io/V4/Partner/${t.ManufacturerId}/Account/Logo?width=60&height=40`);if(ut.ok){const pt=await ut.blob();Fe(URL.createObjectURL(pt))}}catch(ut){console.error("Failed to load logo:",ut)}finally{je(!1)}}};oe&&(t!=null&&t.ManufacturerId)&&!Oe&&ct()},[t==null?void 0:t.ManufacturerId,oe,Oe]),React.useEffect(()=>{Fe(null)},[t==null?void 0:t.ManufacturerId]),React.useEffect(()=>{var ct;if(t&&d){const ut=(ct=t.Opportunities)==null?void 0:ct.find(pt=>pt.BidNumber==d);ut&&I(ut)}},[t,d]),React.useEffect(()=>{if(!t)return;const ct=M!=null&&M.Price?M.Price:Ne;O(Ae>0?Math.round((Ae-ct)/Ae*100):0)},[t,M,Ne,Ae]),React.useEffect(()=>{b||E(1)},[b]);const Be=ct=>{if(ct.Active!==!0)return!1;const ut=new Date().toISOString().split("T")[0];return!(ct.EndDate&&ct.EndDate.split("T")[0]<ut||ct.StartDate&&ct.StartDate.split("T")[0]>ut)},{data:Le,isLoading:Ge,isFetching:Ue}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e},{skip:!e});if(!t||Ge||Ue)return jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-28 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{className:"w-60 h-40",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full rounded-lg"})})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24 mb-3"}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-full rounded-md"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 mt-4"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-1 mb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 flex-1 rounded-md"})]})]})]})});const Xe=(t==null?void 0:t.Opportunities)||[],Je=Xe.length>0,Ye=()=>{if(C==null){E(1);return}C>1&&E(C-1)},it=()=>{if(C==null){E(1);return}E(C+1)},Ke=ct=>{const ut=Number.parseInt(ct.target.value,10);if(!isNaN(ut)&&ut>0){E(ut);return}E(void 0)},tt=()=>{(C==null||C<1)&&E(1)},Ze=()=>{Q||!(Le!=null&&Le.IsReseller)||(F(!0),ae({routeResellerId:Le.ApplicationId??"",randmarSku:t.RandmarSKU??""}).then(ct=>{if(ct.error){console.error(ct.error),R({title:"Error",description:"Error submitting your qualification.",variant:"destructive"});return}R({title:"Success",description:"Qualification successfully submitted.",variant:"success"}),te(!1)}).catch(ct=>{console.error(ct),R({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{F(!1)}))},et=((Ct=(mt=t.Distribution)==null?void 0:mt.Inventory)==null?void 0:Ct.reduce((ct,ut)=>ct+(ut.AvailableQuantity||0),0))||0,st=ct=>{try{return new Date(ct).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(ut){return console.error(ut),ct.split("T")[0]||"N/A"}},qe=()=>{g&&g({quantity:C??1,bidNumber:(M==null?void 0:M.BidNumber)??null})};return jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",ref:ie,children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:t.Title||t.RandmarTitle}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:ze?jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}):oe&&Oe&&jsxRuntime.jsx("img",{src:Oe||"/placeholder.svg",alt:t.ManufacturerName??"",className:"max-h-10 max-w-24 object-contain"})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[t.State&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.State==="Active"?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",t.State]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.SerialNumber?"bg-green-50 text-green-700 hover:bg-green-50":"bg-yellow-50 text-yellow-700 hover:bg-yellow-50"}`,children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",t.SerialNumber?"Serialized":"Unserialized"]}),t.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"outline",className:"rounded-full px-3 bg-green-50 text-green-700 hover:bg-green-50",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),t.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.AvailableToBuy?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(ShoppingCart,{size:"12",className:"mr-1.5"})," ",t.AvailableToBuy?"Available":"Unavailable"]}),t.ManufacturerCategory!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${(It=t.ManufacturerCategory)!=null&&It.QualificationRequired?"bg-blue-50 text-blue-700 hover:bg-blue-50":"bg-neutral-50 text-neutral-700 hover:bg-neutral-50"}`,children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(Dt=t.ManufacturerCategory)!=null&&Dt.QualificationRequired?"Qualified Only":"Available to all"]}),t.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.AutoUpdate?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",t.AutoUpdate?`Automatic Reorder (${t.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.BodyHTML&&t.Title&&t.MAP?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",t.BodyHTML&&t.Title&&t.MAP?"Shopify Ready":"Not Shopify Ready"]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MPN"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.MPN||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"UPC"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.UPC||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Unit Weight"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.UnitWeight?`${t.UnitWeight} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MAP"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.MAP?"$"+t.MAP.toFixed(2):"N/A"})]}),t.CountryCodeOfOrigin&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Origin"}),jsxRuntime.jsxs("div",{className:"font-medium flex items-center",children:[jsxRuntime.jsx(CountryFlag,{countryCode:t.CountryCodeOfOrigin,className:"mr-2"}),t.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx(ProductImage,{randmarSKU:t.RandmarSKU||"",alt:t.RandmarTitle||""})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:Je&&t.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+Xe.length+(Xe.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:Xe.map((ct,ut)=>{var pt;return jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted
|
|
958
958
|
${ct.BidNumber==(M==null?void 0:M.BidNumber)?"cursor-pointer border-2 border-purple-900":Be(ct)?"hover:bg-purple-200 cursor-pointer":"!bg-neutral-50"}
|
|
959
|
-
`,onClick:()=>{Be(ct)&&I(ct.BidNumber!=(M==null?void 0:M.BidNumber)?ct:null)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:ct.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-neutral-900",children:[ct.BidNumber," ",!Be(ct)&&jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs mx-1 h-5 bg-gray-100",children:"Currently unavailable"})]})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsxs("span",{className:"font-semibold",children:["$",(pt=ct.Price)==null?void 0:pt.toFixed(2)]}),ct.Rebate&&ct.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: $",ct.Rebate.toFixed(2)]}),ct.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",st(ct.EndDate)]})]})]},ut)})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[f&&jsxRuntime.jsx(reactRouterDom.Link,{to:f,children:jsxRuntime.jsxs(Button,{variant:"secondary",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})}),((Wt=t.Distribution)==null?void 0:Wt.Inventory)&&jsxRuntime.jsx("div",{className:"mt-4",children:Le!=null&&Le.IsReseller&&et<=0?jsxRuntime.jsx(jsxRuntime.Fragment,{children:
|
|
959
|
+
`,onClick:()=>{Be(ct)&&I(ct.BidNumber!=(M==null?void 0:M.BidNumber)?ct:null)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:ct.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-neutral-900",children:[ct.BidNumber," ",!Be(ct)&&jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs mx-1 h-5 bg-gray-100",children:"Currently unavailable"})]})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsxs("span",{className:"font-semibold",children:["$",(pt=ct.Price)==null?void 0:pt.toFixed(2)]}),ct.Rebate&&ct.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: $",ct.Rebate.toFixed(2)]}),ct.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",st(ct.EndDate)]})]})]},ut)})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[f&&jsxRuntime.jsx(reactRouterDom.Link,{to:f,children:jsxRuntime.jsxs(Button,{variant:"secondary",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})}),((Wt=t.Distribution)==null?void 0:Wt.Inventory)&&jsxRuntime.jsx("div",{className:"mt-4",children:Le!=null&&Le.IsReseller&&et<=0?jsxRuntime.jsx(jsxRuntime.Fragment,{children:ge>0?jsxRuntime.jsxs(Dialog,{open:q,onOpenChange:z,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"ghost",className:"flex items-center text-sm manufacturer-theme text-primary",children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),ge," Incoming"]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:t.Distribution.Inventory})]})]}):jsxRuntime.jsxs(Dialog,{open:V,onOpenChange:te,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"ghost",className:"flex items-center text-sm reseller-theme text-primary",children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"Request to stock"]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-md",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Request to stock"})}),jsxRuntime.jsx("p",{className:"py-4",children:"Are you sure you want to request this item to be stocked?"}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>te(!1),disabled:Q,children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:Ze,disabled:Q,children:Q?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Requesting..."]}):"Confirm"})]})]})]})}):jsxRuntime.jsxs(Dialog,{open:q,onOpenChange:z,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"ghost",className:`flex items-center text-sm ${et>0?"text-green-700":"text-red-700"}`,children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),et>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[et," in stock"]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Out of stock"})]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:t.Distribution.Inventory})]})]})})]})]}),t.Distribution&&jsxRuntime.jsxs("div",{className:"flex justify-between items-end mt-4",children:[jsxRuntime.jsx("div",{className:"flex-shrink-1 flex flex-col items-start gap-1",children:se>0?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:[jsxRuntime.jsx("span",{children:"Cost: $"}),se.toFixed(2),jsxRuntime.jsx("span",{children:" CAD"})]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap",children:[jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:[jsxRuntime.jsx("span",{children:"$"}),M?(rt=(We=t.Opportunities)==null?void 0:We.find(ct=>ct.BidNumber==M.BidNumber))==null?void 0:rt.Price:Ne.toFixed(2),jsxRuntime.jsx("span",{children:" CAD"})]}),A>0&&jsxRuntime.jsxs("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:["$",Ae.toFixed(2)]})]}),A>0&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Badge,{variant:"outline",className:"bg-red-50 text-red-700 rounded-full px-3 whitespace-nowrap",children:[jsxRuntime.jsxs("span",{children:[A,"% OFF"]}),((ot=t.InstantRebate)==null?void 0:ot.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",t.InstantRebate.EndDate.split("T")[0]]}),(M==null?void 0:M.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",M.EndDate.split("T")[0]]})]})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-shrink-0 gap-2 ml-4",children:[typeof n<"u"&&n&&jsxRuntime.jsxs("div",{className:"flex items-center border rounded-md",children:[jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"rounded-r-none",onClick:Ye,disabled:typeof C<"u"&&(C<=1||!t.AvailableToBuy||b||!g),children:"-"}),jsxRuntime.jsx("input",{value:C,onChange:Ke,onBlur:tt,onClick:ct=>ct.currentTarget.select(),className:`w-12 text-center border-0 focus:ring-0 focus:outline-none ${!t.AvailableToBuy||b||!g?"text-gray-400":""}`,disabled:!t.AvailableToBuy||b||!g}),jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"rounded-l-none",onClick:it,disabled:!t.AvailableToBuy||b||!g,children:"+"})]}),typeof n<"u"&&n&&jsxRuntime.jsx(Button,{className:"gap-2 whitespace-nowrap",onClick:qe,disabled:!t.AvailableToBuy||b||!g,children:b?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Adding..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Add to Cart"]})}),o&&jsxRuntime.jsx(Button,{className:"gap-2 whitespace-nowrap bg-green-600 hover:bg-green-700",onClick:_,disabled:S||!_,children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Sync to Shopify"]})}),l]})]})]})})}const complexComponents=[`----
|
|
960
960
|
PartnerCard: For data that fits this shape:
|
|
961
961
|
{ "ApplicationId": "19022", "PublicName": "BiOSS", "VoiceName": null, "VoiceStyle": null, "About": "example", "SceneName": "Kitchen Counter", "IsReseller": true, "IsManufacturer": true, "IsSalesAgency": false, "Socials": [ { "ApplicationId": "19022", "SocialNetwork": "Facebook", "Tag": "@bioss.ca" }, { "ApplicationId": "19022", "SocialNetwork": "Instagram", "Tag": "@bioss.ca" }, { "ApplicationId": "19022", "SocialNetwork": "LinkedIn", "Tag": "@biossinc" }, { "ApplicationId": "19022", "SocialNetwork": "Youtube", "Tag": "@biosssolutionssanitairessa4095" } ], "Manufacturer": null, "Reseller": null }
|
|
962
962
|
Use <PartnerCard account={data} action={<></>}>`,`----
|