PageSourceSearch

https://www.purplebunny.ai/_next/static/chunks/pages/admin2/business-scenario-8adeb7493416d489.js

js purplebunny.ai collected 2026-10-05 14:28:08 UTC 14,550 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5631],{2163:function(e,s,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin2/business-scenario",function(){return t(1877)}])},9342:function(e,s,t){"use strict";t.d(s,{Q4:function(){return m},lq:function(){return d}});var a=t(5893);t(7294);var r=t(3606),n=t(9008),i=t.n(n),l=t(1664),c=t.n(l),o=t(4100);let d=e=>{let{children:s,title:t,description:n,pageTitle:l,loading:d=!1,error:m=null,onRetry:x,actions:h,maxWidth:u="7xl"}=e,{user:b}=(0,r.aF)();if(d&&!m){var g;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i(),{children:[(0,a.jsx)("title",{children:l||"".concat(null!=t?t:""," - Admin - PurpleBunny")}),(0,a.jsx)("meta",{name:"description",content:n||"Admin ".concat(null!=t?t:""," page")})]}),(0,a.jsxs)("div",{className:"min-h-screen bg-gray-50",children:[(0,a.jsx)(o.I,{}),(0,a.jsx)("div",{className:"flex items-center justify-center h-96",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),(0,a.jsxs)("p",{className:"mt-4 text-gray-600",children:["Loading ",null!==(g=null==t?void 0:t.toLowerCase())&&void 0!==g?g:"","..."]})]})})]})]})}return m&&x?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i(),{children:[(0,a.jsx)("title",{children:l||"".concat(null!=t?t:""," - Admin - PurpleBunny")}),(0,a.jsx)("meta",{name:"description",content:n||"Admin ".concat(null!=t?t:""," page")})]}),(0,a.jsxs)("div",{className:"min-h-screen bg-gray-50",children:[(0,a.jsx)(o.I,{}),(0,a.jsx)("div",{className:"flex items-center justify-center h-96",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"text-red-500 text-xl mb-4",children:"⚠️ Error"}),(0,a.jsx)("p",{className:"text-gray-700 mb-4 max-w-md",children:m}),(0,a.jsx)("button",{onClick:x,className:"bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded",disabled:!b,children:"Retry"})]})})]})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i(),{children:[(0,a.jsx)("title",{children:l||"".concat(null!=t?t:""," - Admin - PurpleBunny")}),(0,a.jsx)("meta",{name:"description",content:n||"Admin ".concat(null!=t?t:""," page")})]}),(0,a.jsxs)("div",{className:"min-h-screen bg-gray-50",children:[(0,a.jsx)(o.I,{}),(0,a.jsx)("div",{className:"py-8",children:(0,a.jsxs)("div",{className:"".concat({sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl","7xl":"max-w-7xl"}[u]," mx-auto px-4 sm:px-6 lg:px-8"),children:[(0,a.jsx)("div",{className:"mb-4",children:(0,a.jsxs)(c(),{href:"/admin2",className:"inline-flex items-center text-sm text-gray-600 hover:text-gray-900 transition-colors",children:[(0,a.jsx)("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back to Dashboard"]})}),(0,a.jsx)("div",{className:"mb-8",children:(0,a.jsxs)("div",{className:"flex flex-col lg:flex-row lg:items-start lg:justify-between space-y-4 lg:space-y-0",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-900 truncate",children:t}),n&&(0,a.jsx)("p",{className:"text-gray-600 mt-1 text-sm sm:text-base",children:n}),b&&(0,a.jsxs)("p",{className:"text-sm text-gray-500 mt-1 truncate",children:["Logged in as: ",b.email]})]}),h&&(0,a.jsx)("div",{className:"flex-shrink-0",children:h})]})}),m&&!x&&(0,a.jsx)("div",{className:"mb-6 bg-red-50 border border-red-200 rounded-md p-4",children:(0,a.jsx)("div",{className:"flex",children:(0,a.jsxs)("div",{className:"ml-3",children:[(0,a.jsx)("h3",{className:"text-sm font-medium text-red-800",children:"Error"}),(0,a.jsx)("div",{className:"mt-2 text-sm text-red-700",children:m})]})})}),s]})})]})]})},m=e=>{let{children:s,title:t="Admin Dashboard",subtitle:n}=e,{user:i}=(0,r.aF)();return(0,a.jsx)(d,{title:t,description:n||"Welcome ".concat(null==i?void 0:i.name,", access administrative tools and monitoring"),pageTitle:"Admin Dashboard - PurpleBunny",children:s})}},1877:function(e,s,t){"use strict";t.r(s);var a=t(5893),r=t(7294),n=t(3606),i=t(4273),l=t(9342),c=t(5086);let o=["Profitability","Market Entry","M&A","Pricing Strategy","Growth Strategy","Market Sizing","New Product Launch","Competitive Response"],d="https://www.purplebunny.ai";s.default=(0,c.k)(function(){let{user:e}=(0,n.aF)(),{accessToken:s}=(0,i.a)(),[t,c]=(0,r.useState)(""),[m,x]=(0,r.useState)(""),[h,u]=(0,r.useState)(!1),[b,g]=(0,r.useState)(""),[p,y]=(0,r.useState)(!1),[j,f]=(0,r.useState)([]),[N,w]=(0,r.useState)(1),[v,k]=(0,r.useState)(0),[S,A]=(0,r.useState)(""),[E,C]=(0,r.useState)(null),[B,_]=(0,r.useState)(!1),[F,P]=(0,r.useState)("");if(!e||!s)return(0,a.jsx)("div",{className:"flex items-center justify-center min-h-screen bg-white",children:(0,a.jsx)("div",{className:"text-lg text-gray-700 font-medium",children:"Loading..."})});let T=async()=>{u(!0),g("");try{let e=await fetch("".concat(d,"/business-scenario/generate"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(s)},body:JSON.stringify({case_type:t})});if(!e.ok)throw Error("Failed to generate scenario");let a=await e.json();x(a.description)}catch(e){g(e instanceof Error?e.message:"An error occurred")}finally{u(!1)}},D=async()=>{u(!0),g("");try{let e=await fetch("".concat(d,"/business-scenario/generate-all"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(s)}});if(!e.ok)throw Error("Failed to generate all scenarios");await e.json(),x("Successfully generated scenarios for all case types!"),p&&z(N)}catch(e){g(e instanceof Error?e.message:"An error occurred")}finally{u(!1)}},L=async()=>{u(!0),g("");try{let e=await fetch("".concat(d,"/business-scenario/random/").concat(t),{headers:{Authorization:"Bearer ".concat(s)}});if(!e.ok)throw Error("Failed to get random scenario");let a=await e.json();x(a.description)}catch(e){g(e instanceof Error?e.message:"An error occurred")}finally{u(!1)}},z=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;y(!0),u(!0),g("");try{let t=await fetch("".concat(d,"/business-scenario/?skip=").concat((e-1)*10,"&limit=").concat(10),{headers:{Authorization:"Bearer ".concat(s)}});if(!t.ok)throw Error("Failed to fetch scenarios");let a=await t.json();f(a.items||a),k(a.total||(a.items?a.items.length:a.length)),w(e)}catch(e){g(e instanceof Error?e.message:"An error occurred")}finally{u(!1)}},G=async()=>{_(!0),P(""),C(null);try{let e=await fetch("".concat(d,"/business-scenario/").concat(S),{headers:{Authorization:"Bearer ".concat(s)}});if(!e.ok)throw Error("Scenario not found");let t=await e.json();C(t)}catch(e){P(e instanceof Error?e.message:"An error occurred")}finally{_(!1)}};return(0,a.jsx)(l.Q4,{title:"Business Scenario Generator",children:(0,a.jsx)("div",{className:"max-w-4xl mx-auto",children:(0,a.jsxs)("div",{className:"bg-white rounded-xl shadow-lg p-8 border border-gray-100",children:[(0,a.jsx)("h1",{className:"text-3xl mb-8 text-gray-900 text-center",children:"Business Scenario Generator"}),(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsx)("label",{htmlFor:"caseType",className:"block text-base font-semibold text-gray-800 mb
1-2",children:"Case Type"}),(0,a.jsxs)("select",{id:"caseType",value:t,onChange:e=>c(e.target.value),className:"w-full p-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-600 focus:border-blue-600 bg-white text-gray-900 text-base",children:[(0,a.jsx)("option",{value:"",children:"Select a case type"}),(0,a.jsx)("option",{value:"random",children:"Random"}),o.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]})]}),(0,a.jsxs)("div",{className:"mb-6 flex flex-wrap gap-4",children:[(0,a.jsx)("button",{onClick:T,disabled:!t||h,className:"bg-blue-700 text-white px-5 py-2 rounded-md font-semibold shadow hover:bg-blue-800 transition disabled:opacity-50 disabled:cursor-not-allowed",children:"Generate New Scenario"}),(0,a.jsx)("button",{onClick:L,disabled:!t||h||"random"===t,className:"bg-white border border-blue-700 text-blue-700 px-5 py-2 rounded-md font-semibold shadow hover:bg-blue-50 transition disabled:opacity-50 disabled:cursor-not-allowed",children:"Get Random Existing"}),(0,a.jsx)("button",{onClick:D,disabled:h,className:"bg-bunny-700 text-white px-5 py-2 rounded-md font-semibold shadow hover:bg-bunny-800 transition disabled:opacity-50 disabled:cursor-not-allowed",children:"Generate All"}),(0,a.jsx)("button",{onClick:()=>z(1),disabled:h,className:"bg-gray-800 text-white px-5 py-2 rounded-md font-semibold shadow hover:bg-gray-900 transition disabled:opacity-50 disabled:cursor-not-allowed",children:"Show All Scenarios"})]}),(0,a.jsxs)("div",{className:"mb-6 flex items-center gap-2",children:[(0,a.jsx)("input",{type:"number",min:"1",value:S,onChange:e=>A(e.target.value),placeholder:"Enter scenario index (ID)",className:"p-2 border border-gray-300 rounded-md w-48 text-base text-gray-900 bg-white focus:ring-2 focus:ring-green-600 focus:border-green-600"}),(0,a.jsx)("button",{onClick:G,disabled:!S||B,className:"bg-green-700 text-white px-5 py-2 rounded-md font-semibold shadow hover:bg-green-800 transition disabled:opacity-50 disabled:cursor-not-allowed",children:"Get by Index"})]}),B&&(0,a.jsx)("div",{className:"text-gray-700 mb-2",children:"Loading scenario..."}),F&&(0,a.jsx)("div",{className:"text-red-600 mb-2 font-semibold",children:F}),E&&(0,a.jsxs)("div",{className:"bg-gray-50 p-4 rounded-lg shadow mb-4 border border-gray-200",children:[(0,a.jsxs)("div",{className:"text-lg text-gray-900",children:["Scenario #",E.id," ",(0,a.jsxs)("span",{className:"text-sm text-gray-600",children:["(",E.case_type,")"]})]}),(0,a.jsx)("div",{className:"whitespace-pre-wrap mt-2 text-gray-800 text-base",children:E.description})]}),h&&(0,a.jsx)("div",{className:"flex justify-center my-6",children:(0,a.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-700"})}),b&&(0,a.jsx)("div",{className:"text-red-600 mb-4 font-semibold",children:b}),m&&(0,a.jsx)("div",{className:"bg-blue-50 p-6 rounded-lg shadow-md mt-6 max-h-[500px] overflow-auto whitespace-pre-wrap border border-blue-200",children:(0,a.jsx)("p",{className:"text-gray-900 text-base",children:m})}),p&&(0,a.jsxs)("div",{className:"mt-10",children:[(0,a.jsx)("h2",{className:"text-2xl mb-4 text-gray-900 text-center",children:"All Business Scenarios"}),(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg border border-gray-200 bg-white",children:(0,a.jsxs)("table",{className:"min-w-full bg-white text-base text-gray-900",children:[(0,a.jsx)("thead",{className:"bg-gray-100",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-4 py-2 border-b font-bold",children:"ID"}),(0,a.jsx)("th",{className:"px-4 py-2 border-b font-bold",children:"Case Type"}),(0,a.jsx)("th",{className:"px-4 py-2 border-b font-bold",children:"Description"}),(0,a.jsx)("th",{className:"px-4 py-2 border-b font-bold",children:"Action"})]})}),(0,a.jsx)("tbody",{children:j.map(e=>(0,a.jsxs)("tr",{className:"hover:bg-blue-50 transition",children:[(0,a.jsx)("td",{className:"px-4 py-2 border-b text-center font-mono",children:e.id}),(0,a.jsx)("td",{className:"px-4 py-2 border-b",children:e.case_type}),(0,a.jsxs)("td",{className:"px-4 py-2 border-b truncate max-w-xs",title:e.description,children:[e.description.slice(0,80),e.description.length>80?"...":""]}),(0,a.jsx)("td",{className:"px-4 py-2 border-b text-center",children:(0,a.jsx)("button",{className:"text-blue-700 font-semibold underline hover:text-blue-900",onClick:()=>{C(e),A(e.id.toString())},children:"View"})})]},e.id))})]})}),(0,a.jsxs)("div",{className:"flex justify-between items-center mt-6",children:[(0,a.jsx)("button",{onClick:()=>z(N-1),disabled:N<=1||h,className:"px-4 py-2 bg-gray-200 text-gray-800 rounded font-semibold hover:bg-gray-300 transition disabled:opacity-50",children:"Previous"}),(0,a.jsxs)("span",{className:"text-lg font-semibold",children:["Page ",N]}),(0,a.jsx)("button",{onClick:()=>z(N+1),disabled:j.length<10||h,className:"px-4 py-2 bg-gray-200 text-gray-800 rounded font-semibold hover:bg-gray-300 transition disabled:opacity-50",children:"Next"})]})]})]})})})})},5086:function(e,s,t){"use strict";t.d(s,{k:function(){return d}});var a=t(5893),r=t(7294),n=t(1163),i=t(3606),l=t(7066),c=t(4273);let o=()=>{let{user:e}=(0,i.aF)(),{accessToken:s}=(0,c.a)(),[t,a]=(0,r.useState)(!1),[n,o]=(0,r.useState)(!0),[d,m]=(0,r.useState)(null);return(0,r.useEffect)(()=>{(async()=>
1{if(!e||!s){a(!1),o(!1);return}try{if(o(!0),m(null),"[email protected]"===e.email){a(!0),o(!1);return}let t=(await l.Z.get("".concat("https://www.purplebunny.ai","/user/profile"),{headers:{Authorization:s,"Content-Type":"application/json"}})).data,r=(null==t?void 0:t.permission)===999;a(r)}catch(e){console.error("[AdminAccess] Error checking admin status:",e),m(e instanceof Error?e.message:"Failed to check admin access"),a(!1)}finally{o(!1)}})()},[e,s]),{isAdmin:t,isLoading:n,error:d}};function d(e){let s=s=>{let t=(0,n.useRouter)(),{user:r,isLoading:l}=(0,i.aF)(),{isAdmin:c,isLoading:d,error:m}=o();return l||d?(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-600 mx-auto"}),(0,a.jsx)("p",{className:"mt-4 text-gray-600",children:"Checking access permissions..."})]})}):r?c?(0,a.jsx)(e,{...s}):(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:(0,a.jsxs)("div",{className:"max-w-md w-full bg-white shadow-lg rounded-lg p-8 text-center",children:[(0,a.jsx)("div",{className:"text-red-500 text-6xl mb-4",children:"\uD83D\uDEAB"}),(0,a.jsx)("h1",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Access Denied"}),(0,a.jsx)("p",{className:"text-gray-600 mb-6",children:"You don't have permission to access this admin area."}),m&&(0,a.jsxs)("p",{className:"text-sm text-red-600 mb-4",children:["Error: ",m]}),(0,a.jsx)("button",{onClick:()=>t.push("/dashboard"),className:"bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-2 px-4 rounded-md transition duration-150 ease-in-out",children:"Back to Dashboard"})]})}):(t.push("/api/auth/login"),null)};return s.displayName="withAdminAuthRequired(".concat(e.displayName||e.name,")"),s}}},function(e){e.O(0,[959,2090,4100,2888,9774,179],function(){return e(e.s=2163)}),_N_E=e.O()}]);

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.