PageSourceSearch

https://divinetalk.in/assets/FormPage-CYt8JNXm.js

js divinetalk.in collected 2026-09-24 13:20:21 UTC 5,838 bytes, 1 lines download raw bytes

1import{u as q,m as R,r as i,j as s,N as $,q as T,L as A,p as V,aA as z,aB as M,aC as O,aD as Y,A as p}from"./index-CjBBelq3.js";import{L as G}from"./Loader-CF2CbKhT.js";import{A as H}from"./index-BLixvo9X.js";import{m as S}from"./proxy-DnCE_IE5.js";const x={address_id:"",address_title:"",flat_no:"",locality:"",landmark:"",city:"",state:"",pincode:"",phone_no:""},Z=()=>{var N;const g=q(),v=(N=R().state)==null?void 0:N.productData,[u,k]=i.useState([]),[L,y]=i.useState(!0),[j,b]=i.useState(!1),[_,r]=i.useState(!1),[o,c]=i.useState(!1),[t,d]=i.useState(x),[l,h]=i.useState({}),[D,E]=i.useState(!1);i.useEffect(()=>{if(!localStorage.getItem("userData")){E(!0);return}},[]);const P=()=>{let e={};return["address_title","flat_no","locality","landmark","city","state","pincode","phone_no"].forEach(n=>{String(t[n]||"").trim()||(e[n]="This field is required")}),t.pincode&&!/^\d{6}$/.test(String(t.pincode))&&(e.pincode="Pincode must be 6 digits"),t.phone_no&&!/^[6-9]\d{9}$/.test(String(t.phone_no))&&(e.phone_no="Enter valid 10-digit phone number"),h(e),Object.keys(e).length===0},f=async()=>{var e;try{y(!0);const a=await p.getUserAddress();if(a.status_code===200){const m=(((e=a==null?void 0:a.data)==null?void 0:e.addresses)||[]).map(w=>({...w,address_id:w.id}));k(m),m.length===0?r(!0):r(!1)}}catch(a){console.log(a)}finally{y(!1)}};i.useEffect(()=>{f()},[]);const C=e=>{const{name:a,value:n}=e.target;d({...t,[a]:n}),l[a]&&h({...l,[a]:""})},F=async e=>{e.preventDefault();const a=P();if(console.log("isValid:",a),!a)return;const n={address_id:t.address_id,address_title:t.address_title.trim(),flat_no:t.flat_no.trim(),locality:t.locality.trim(),landmark:t.landmark.trim(),city:t.city.trim(),state:t.state.trim(),pincode:String(t.pincode).trim(),phone_no:String(t.phone_no).trim(),alternate_phone_no:""};try{b(!0),o?await p.editUserAddress(n):await p.saveUserAddress(n),d(x),h({}),r(!1),c(!1),f()}catch(m){console.log(m)}finally{b(!1)}},U=async e=>{if(window.confirm("Are you sure you want to delete?"))try{await p.deleteUserAddress({address_id:e}),f()}catch(n){console.log(n)}},B=e=>{d({address_id:e.address_id||"",address_title:e.address_title||"",flat_no:e.flat_no||"",locality:e.locality||"",landmark:e.landmark||"",city:e.city||"",state:e.state||"",pincode:e.pincode||"",phone_no:e.phone_no||""}),c(!0),r(!0)},I=e=>{g("/shop/product-summary",{state:{productData:v,selectedAddress:e}})};return s.jsxs(s.Fragment,{children:[s.jsx($,{}),D?s.jsx("div",{className:"fixed inset-0 flex items-center  justify-center bg-black bg-opacity-50 z-20",children:s.jsx(T,{})}):s.jsxs("div",{className:"mx-6 lg:mx-11 xl:mx-40 pt-5 lg:pt-8",children:[s.jsxs("div",{className:"flex items-center gap-2 md:gap-3 lg:gap-4 font-medium mb-5 lg:mb-8",children:[s.jsx(A,{to:"/",children:s.jsx("img",{src:V,alt:"home",className:"w-4 md:w-6"})}),s.jsx("span",{className:"",children:">"}),s.jsx(A,{onClick:()=>g(-1),className:"text-xs md:text-[15px] text-gray-500 cursor-pointer",children:"Shop"}),s.jsx("span",{className:"",children:">"}),s.jsx("span",{className:"text-xs md:text-[15px]",children:"Address"})]}),L?s.jsx(G,{}):s.jsxs(H,{mode:"wait",children:[!_&&u.length>0&&s.jsxs(S.div,{initial:{x:300,opacity:0},animate:{x:0,opacity:1},exit:{x:300,opacity:0},transition:{duration:.4},children:[s.jsxs("div",{className:"flex justify-between items-center mb-5",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Your Addresses"}),s.jsx("button",{onClick:()=>{r(!0),c(!1),d(x)},className:"bg-primary text-white px-3 py-1 rounded-lg",children:"Add New"})]}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:u.map(e=>s.jsxs("div",{className:"shadow px-3 py-3 rounded-xl",children:[s.jsxs("div",{className:"flex justify-between mb-3",children:[s.jsx("p",{className:"font-semibold",children:e.address_title||"Address"}),s.jsxs("div",{className:"flex gap-4",children:[s.jsx(z,{onClick:()=>U(e.address_id),className:"text-red-600 cursor-pointer"}),s.jsx(M,{onClick:()=>B(e),className:"cursor-pointer"})]})]}),s.jsxs("div",{className:"flex gap-2 items-start",children:[s.jsx(O,{className:"shrink-0"}),s.jsxs("p",{className:"text-sm",children:[e.flat_no,", ",e.locality,", ",e.city," -"," ",e.pincode]})]}),s.jsxs("div",{className:"flex justify-between items-center mt-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Y,{}),s.jsx("p",{children:e.phone_no})]}),s.jsx("button",{onClick:()=>I(e),className:"bg-primary text-white px-2 py-1 rounded",children:"Select"})]})]},e.address_id))})]},"addressList"),(_||u.length===0)&&s.jsxs(S.form,{onSubmit:F,initial:{x:-300,opacity:0}
1,animate:{x:0,opacity:1},exit:{x:-300,opacity:0},transition:{duration:.4},className:"w-full max-w-2xl mx-auto space-y-4 my-10",children:[s.jsx("h2",{className:"text-xl font-semibold",children:o?"Update Address":"Add Address"}),[{label:"Address Title",name:"address_title"},{label:"Flat No",name:"flat_no"},{label:"Locality",name:"locality"},{label:"Landmark",name:"landmark"},{label:"City",name:"city"},{label:"State",name:"state"},{label:"Pincode",name:"pincode"},{label:"Phone No",name:"phone_no"}].map(e=>s.jsxs("div",{children:[s.jsx("label",{className:"block mb-1 text-sm font-medium",children:e.label}),s.jsx("input",{type:"text",name:e.name,value:t[e.name]||"",onChange:C,className:`w-full border rounded-lg px-3 py-2 focus:ring-2 focus:ring-primary ${l[e.name]?"border-red-500":""}`}),l[e.name]&&s.jsx("p",{className:"text-red-500 text-xs mt-1",children:l[e.name]})]},e.name)),s.jsx("button",{type:"submit",disabled:j,className:"w-full bg-primary text-white py-2 rounded-lg",children:j?"Please wait...":o?"Update Address":"Proceed"}),o&&s.jsx("button",{type:"button",onClick:()=>{c(!1),r(!1),d(x)},className:"w-full border py-2 rounded-lg",children:"Cancel"})]},"form")]})]})]})};export{Z as default};

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.