1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[67639],{37993:(e,a,t)=>{"use strict";t.r(a),t.d(a,{default:()=>x});var l=t(37876),r=t(92400),o=t(46929);function s(e){let{icon:a,label:t,selected:r,onClick:o,className:s="",testId:n}=e;return(0,l.jsxs)("button",{type:"button",onClick:o,"data-testid":n,className:"\n relative\n w-full\n h-[112px]\n bg-white\n rounded-2xl\n p-4\n border\n transition-all\n duration-200\n hover:shadow-sm\n flex\n flex-row\n items-center\n justify-start\n gap-3\n ".concat(r?"border-v4-teal-500 bg-v4-teal-50":"border-gray-200 hover:border-gray-300","\n ").concat(s,"\n "),"aria-pressed":r,children:[r&&(0,l.jsx)("div",{className:"absolute top-2 right-2 w-5 h-5 bg-[#01C38D] rounded-full flex items-center justify-center",children:(0,l.jsx)("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})})}),(0,l.jsx)("div",{className:"w-20 h-20 flex items-center justify-center flex-shrink-0",children:a}),(0,l.jsx)("p",{className:"text-base font-medium text-[#22252B] text-left leading-5 flex-grow",children:t})]})}var n=t(77328),i=t.n(n),d=t(14232),c=t(89099),g=t(65488),u=t(91452),m=t(53403),p=t(28812),y=t(81603),h=t(60088);let f="pilgrimage",b=[{key:"hajj_umrah",label:"Hajj or Umrah",description:"Save towards a pilgrimage. Only Shariah-screened products are shown for it.",goalName:"Hajj/Umrah",preferredTypes:[f,"hajj","umrah","hajj/umrah"]},{key:"zakat_reserve",label:"Zakat reserve",description:"Set money aside so your Zakat is ready when it is due.",goalName:"Zakat reserve",preferredTypes:["zakat_reserve","zakat"]},{key:"family_support",label:"Family support",description:"Build a fund for supporting parents or relatives.",goalName:"Family support",preferredTypes:["family_support"]},{key:"waqf",label:"Waqf",description:"Save towards an endowment you plan to give.",goalName:"Waqf contribution",preferredTypes:["waqf"]}];function x(){var e;let a=(0,c.useRouter)(),{type:t}=a.query,{customerId:n,customerInfo:x}=(0,u.n)(),{state:v,setGoalCategory:j,setGoalName:w,setGoalId:N,setIsNoGoal:k,markGoalDataSaved:C,reset:P}=(0,g.cm)(),[_,T]=(0,d.useState)([]),[S,I]=(0,d.useState)([]),[E,F]=(0,d.useState)(""),[G,L]=(0,d.useState)(""),[U,W]=(0,d.useState)(""),[B,D]=(0,d.useState)(!1),[A,M]=(0,d.useState)(!1),[q,O]=(0,d.useState)(!0),[z,Z]=(0,d.useState)(""),[H,X]=(0,d.useState)(""),J=(0,h.r)(),R=(0,d.useMemo)(()=>(function(e,a){if(!a)return e;let t=e.filter(e=>e.categoryType===f);return 0===t.length?e:[...t,...e.filter(e=>e.categoryType!==f)]})(_,J),[_,J]),V=(0,d.useMemo)(()=>J?function(e){let a=new Map(e.map(e=>[e.categoryType,e])),t=a.get("custom_goal");return b.flatMap(e=>{var l;let{preferredTypes:r,...o}=e,s=null!=(l=r.map(e=>a.get(e)).find(Boolean))?l:t;if(!s)return[];let n="hajj_umrah"===o.key&&s.categoryType!==f?"Save towards a pilgrimage.":o.description;return[{...o,description:n,category:s}]})}(_):[],[_,J]);null==(e=_.find(e=>e.id===E))||e.categoryType,(0,d.useEffect)(()=>{(0,y.TA)("goal_select_type",{feature_category:"goals"})},[]),(0,d.useEffect)(()=>{(async()=>{if(n)try{var e;O(!0);let a=await m.Pb.getGoalConfiguration(n),l=a.goalTypes.sort((e,a)=>{let t=e.name.toLowerCase(),l=a.name.toLowerCase();return"net worth"===t?-1:"net worth"===l||"custom goal"===t?1:"custom goal"===l?-1:e.displayOrder-a.displayOrder}).map(e=>({id:e.id,label:"net worth"===e.name.toLowerCase()?"Net worth goal":e.name,iconPath:e.iconUrl,defaultPickerIconUrl:e.defaultPickerIconUrl,categoryType:e.name.toLowerCase().replace(/\s+/g,"_")}));if(T(l),I(a.goalIcons||[]),!E&&!(null==(e=v.goalCategory)?void 0:e.id)&&l.length>0){let e=l[0];if(t&&"string"==typeof t){let a=l.find(e=>e.categoryType===t||e.label.toLowerCase().replace(/\s+/g,"_")===t);a&&(e=a)}F(e.id);let a="custom_goal"===e.categoryType;W(a?"":e.label),e.defaultPickerIconUrl&&L(e.defaultPickerIconUrl)}}catch(e){console.error("Failed to fetch goal configuration:",e),Z("Failed to load goal t
1ypes. Please try again.")}finally{O(!1)}})()},[n,t]),(0,d.useEffect)(()=>{var e;if(t&&"string"==typeof t&&_.length>0&&!(null==(e=v.goalCategory)?void 0:e.id)){let e=_.find(e=>e.categoryType===t||e.label.toLowerCase().replace(/\s+/g,"_")===t);e&&e.id!==E&&(F(e.id),W("custom_goal"===e.categoryType?"":e.label),e.defaultPickerIconUrl&&L(e.defaultPickerIconUrl))}},[t,_]),(0,d.useEffect)(()=>{v.goalId||P()},[]),(0,d.useEffect)(()=>{var e,a;(null==(e=v.goalCategory)?void 0:e.id)&&F(v.goalCategory.id),v.goalName&&W(v.goalName),(null==(a=v.goalCategory)?void 0:a.iconPath)&&L(v.goalCategory.iconPath)},[v.goalCategory,v.goalName]);let Y=async()=>{let e=_.find(e=>e.id===E);if(!e||!n){n||Z("Session error. Please refresh the page and try again.");return}if(!U.trim())return void Z("Please enter a name for your goal.");if(!G)return void Z("Please select an icon for your goal.");try{D(!0),Z(""),X("");let t=U.trim(),l=G||e.iconPath,r=v.goalId;if(r)await m.Pb.updateGoalCreation(n,r,{name:t,iconUrl:l}),j({id:e.id,label:e.label,categoryType:e.categoryType,iconPath:l}),w(t),C({goalName:t}),p.tW.trackGoalNamed({goalName:t,goalId:r,email:(null==x?void 0:x.email)||"",customerId:n||"",goalCategory:e.categoryType}),a.push("/app/goals/create/investment-style");else{let r=await m.Pb.createGoal(n,{name:t,iconUrl:l});if(!r||!r.id)throw Error("Failed to create goal - no goal ID returned");N(r.id),j({id:e.id,label:e.label,categoryType:e.categoryType,iconPath:l}),w(t),C({goalName:t}),p.tW.trackGoalNamed({goalName:t,goalId:r.id,email:(null==x?void 0:x.email)||"",customerId:n||"",goalCategory:e.categoryType}),a.push("/app/goals/create/investment-style")}}catch(n){var t,l,r,o,s,i,d,c,g;console.error("â [Select Type] Failed:",n),console.error("â [Select Type] Error response:",null==(t=n.response)?void 0:t.data);let e=(null==(o=n.response)||null==(r=o.data)||null==(l=r.error)?void 0:l.toLowerCase())||"",a=null==(s=n.response)?void 0:s.status;if(400===a||412===a){if(e.includes("name already exists"))return void X("This goal name already exists. Please choose a different name.");if(e.includes("name cannot be null or empty"))return void X("Please enter a goal name.");if(e.includes("icon url cannot be null"))return void Z("Please select an icon for your goal.")}if(404===a&&e.includes("goal not found"))return void Z("Goal not found. Please try creating a new goal.");Z((null==(d=n.response)||null==(i=d.data)?void 0:i.message)||(null==(g=n.response)||null==(c=g.data)?void 0:c.error)||n.message||"Failed to create goal. Please try again.")}finally{D(!1)}},K=async()=>{if(!n)return void Z("Session error. Please refresh the page and try again.");try{M(!0),Z("");let e=await m.Pb.createGoal(n,{name:"No goal",isNoGoal:!0});if(!e||!e.id)throw Error("Failed to create goal - no goal ID returned");N(e.id),w("No goal"),k(!0),(0,y.GJ)(),p.tW.trackGoalCreationSkipped({email:null==x?void 0:x.email,customerId:n}),a.push("/app/goals/create/investment-style")}catch(a){var e,t,l,r;console.error("â [Select Type] Skip failed:",a),Z((null==(t=a.response)||null==(e=t.data)?void 0:e.message)||(null==(r=a.response)||null==(l=r.data)?void 0:l.error)||a.message||"Failed to skip. Please try again.")}finally{M(!1)}};return(0,l.jsxs)(o.A,{children:[(0,l.jsx)(i(),{children:(0,l.jsx)("title",{children:"New Goal | Vault22"})}),(0,l.jsx)(r.A,{children:(0,l.jsxs)("div",{className:"w-full px-2 py-6 pr-4",children:[(0,l.jsxs)("div",{className:"mb-8",children:[(0,l.jsxs)("button",{onClick:()=>a.push("/app/goals"),className:"inline-flex items-center text-gray-600 hover:text-gray-900 mb-4 transition-colors","aria-label":"Go back to goals",children:[(0,l.jsx)("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),(0,l.jsx)("span",{className:"font-semibold text-lg text-gray-900",children:"New Investment Goal"})]}),(0,l.jsx)("h2",{"data-testid":"goal-select-type-heading",className:"text-lg font-medium text-gray-900 mb-2",children:"Choose a goal to invest with a plan"}),(0,l.jsx)("div",{className:"w-full bg-gray-200 rounded-full h-1 mt-4",children:(0,l.jsx)("div",{className:"bg-v4-teal-500 h-1 rounded-full transition-all duration-300",style:{width:"20%"},role:"progressbar","aria-valuenow":20,"aria-valuemin":0,"aria-valuemax":100,"aria-label":"Progress: Step 1 of 5"})})]}),z&&(0,l.jsx)("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 rounded-lg",children:(0,l.jsx)("p",{className:"text-red-800 text-sm",children:z})}),q?(0,l.jsx)("div",{className:"flex justify-center items-center py-12",children:(0,l.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-v4-teal-500"})}):(0,l.jsxs)(l.Fragment,{children:[V.length>0&&(0,l.jsxs)("section",{className:"mb-6","data-testid":"islamic-hub-goal-suggestions","aria-labelledby":"islamic-hub-goal-suggestions-heading",children:[(0,l.jsx)("h3",{id:"islamic-hub-goal-suggestions-heading",className:"text-sm font-semibold text-gray-900 mb-1",children:"Suggested with your Islamic finance hub"}),(0,l.jsx)("p",{className:"text-xs text-gray-600 mb-3",children:"Choose one to start from it. You can change the name before you continue."}),(0,l.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:V.map(e=>{let a=E===e.category.id&&U.trim()===e.goalName;return(0,l.jsxs)("button",{type:"button","data-testid":"islamic-hub-goal-suggestion-".concat(e.key),"aria-pressed":a,onClick:()=>(e=>{let{category:a}=e;F(a.id),W(e.goalName),a.defaultPickerIconUrl&&L(a.defaultPickerIconUrl),Z(""),X(""),p.tW.trackGoalSetInitiated({goalType:a.categoryType,cta:"islamic_hub_suggestion_".concat(e.key),email:(null==x?void 0:x.email)||"",customerId:n||"",goalName:e.goalName,screen:"select_type"})})(e),className:"text-left rounded-xl border-2 p-3 transition-colors ".concat(a?"border-[#01C38D] bg-white":"border-transparent bg-[#F1F2F4] hover:bg-gray-100"),children:[(0,l.jsx)("span",{className:"block text-sm font-semibold text-gray-900",children:e.label}),(0,l.jsx)("span",{className:"mt-1 block text-xs text-gray-600",children:e.description})]},e.key)})})]}),(0,l.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 ga
1p-3 mb-6",role:"radiogroup","aria-label":"Goal categories",children:R.map(e=>(0,l.jsx)(s,{testId:"goal-category-".concat(e.id),icon:(0,l.jsx)("img",{src:e.iconPath,alt:e.label,className:"w-20 h-20 object-contain"}),label:e.label,selected:E===e.id,onClick:()=>(e=>{if(F(e),e!==E){let a=_.find(a=>a.id===e);if(a){let e="custom_goal"===a.categoryType;W(e?"":a.label),a.defaultPickerIconUrl?L(a.defaultPickerIconUrl):L(""),p.tW.trackGoalSetInitiated({goalType:a.categoryType,cta:"select_goal_type",email:(null==x?void 0:x.email)||"",customerId:n||"",goalName:e?"":a.label,screen:"select_type"})}}})(e.id)},e.id))}),E&&(0,l.jsxs)("div",{className:"mt-6 space-y-6",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"goalName",className:"block text-sm font-medium text-gray-900 mb-2",children:"Name your goal"}),(0,l.jsx)("input",{id:"goalName",type:"text",value:U,onChange:e=>{W(e.target.value),H&&X("")},placeholder:"Enter your goal name",className:"w-full px-4 py-3 bg-[#EAEBEE] border-0 border-b border-b-[#AAACB3] rounded-t-xl rounded-b-none focus:ring-0 focus:border-b-2 focus:border-b-v4-teal-500 outline-none transition-colors placeholder-[#6C6F7C] text-[#6C6F7C] ".concat(H?"border-b-red-500 bg-red-50":"")}),H&&(0,l.jsx)("p",{className:"mt-2 text-sm text-red-600",children:H})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-900 mb-3",children:"Goal icon"}),(0,l.jsx)("div",{className:"grid grid-cols-4 sm:grid-cols-6 md:grid-cols-10 lg:grid-cols-[repeat(13,minmax(0,1fr))] gap-2",children:S.map((e,a)=>(0,l.jsxs)("button",{type:"button",onClick:()=>L(e),className:"\n relative\n w-20 h-20 p-3 rounded-lg transition-all duration-200\n flex items-center justify-center\n border-2\n ".concat(G===e?"border-[#01C38D] bg-white":"border-transparent bg-transparent hover:bg-gray-100","\n "),"aria-label":"Select icon ".concat(a+1),"aria-pressed":G===e,children:[(0,l.jsx)("img",{src:e,alt:"",className:"w-14 h-14 object-contain"}),G===e&&(0,l.jsx)("div",{className:"absolute top-1.5 right-1.5 w-[18px] h-[18px] bg-[#01C38D] rounded-full flex items-center justify-center",children:(0,l.jsx)("svg",{className:"w-2.5 h-2.5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})})})]},a))})]})]})]}),(0,l.jsxs)("div",{className:"flex flex-col items-center gap-2 mt-8 w-full max-w-[403px] mx-auto",children:[(0,l.jsx)("button",{onClick:Y,disabled:!E||B||q||!U.trim()||!G,"data-testid":"goal-select-type-next-button",className:" w-full max-w-[403px] h-[40px] px-6 bg-[#01C38D] hover:bg-[#00B37F] disabled:bg-gray-300 disabled:cursor-not-allowed text-[#15171C] rounded-lg transition-all duration-300 flex flex-row items-center justify-center font-medium text-sm ",children:B?"Creating...":"Next"}),(0,l.jsx)("button",{onClick:K,disabled:A||B||q,className:" w-full max-w-[403px] h-[40px] px-6 bg-transparent hover:bg-gray-100 disabled:bg-gray-100 disabled:cursor-not-allowed text-[#01C38D] disabled:text-gray-400 rounded-lg transition-all duration-300 flex flex-row items-center justify-center font-medium text-sm ",children:A?"Skipping...":"Skip for now"})]})]})})]})}},94998:(e,a,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/app/goals/create/select-type",function(){return t(37993)}])}},e=>{e.O(0,[90636,46593,38792],()=>e(e.s=94998)),_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.