PageSourceSearch

https://promakod.uz/assets/AdminAppGiftCards-CfDoPY8t.js

js promakod.uz collected 2026-09-24 15:14:52 UTC 14,741 bytes, 1 lines download raw bytes

1import{r as d,j as e}from"./vendor-react-CdSkYK6A.js";import{s as g,k as h,B as c,v as I,w as O,J as R,K as z,I as x}from"./index-Bkpzml6u.js";import{L as l}from"./label-BTRMdqOW.js";import{S as C}from"./switch-DgfYnKBh.js";import{T as E}from"./textarea-DWJY7fZi.js";import{B as H}from"./badge-B_eWvTFw.js";import{A as ne,b as de,c as ce,d as oe,e as he,f as me,g as xe,h as pe}from"./alert-dialog-DsrN9C58.js";import{S as ue,a as ge,b as je,c as _e,d as fe}from"./select-DSJqW_7d.js";import{T as U,a as L,b as p,c as o,d as K,e as t}from"./table-BVX0sFaL.js";import{A as V}from"./AdminImageField-cjQz5krA.js";import{ae as ve,a3 as S,aG as Z,ax as Y}from"./vendor-icons-B6Pw7kvU.js";import"./vendor-radix-DZ5WJj_n.js";import"./vendor-supabase-C0gOjPry.js";import"./vendor-query-Cv6EpE7x.js";import"./uploadAdminImage-mv09A65w.js";import"./uploadImageVariants-BnC7WLl0.js";const $={title:"",title_ru:"",description:"",description_ru:"",image_url:"",logo_url:"",website_url:"",expiry_date:"",display_order:"",is_active:!0,show_in_app:!0},J={gift_card_id:"",nominal:"",price:"",quantity:"",display_order:"",is_active:!0,show_in_app:!0},Ne=u=>u.toLocaleString("ru-RU").replace(/[\u00a0\u202f]/g," "),Re=()=>{const[u,D]=d.useState("cards"),[v,Q]=d.useState([]),[B,W]=d.useState([]),[F,q]=d.useState(!0),[N,y]=d.useState(!1),[M,_]=d.useState(!1),[A,P]=d.useState(null),[s,n]=d.useState({...$}),[X,f]=d.useState(!1),[T,G]=d.useState(null),[i,m]=d.useState({...J}),[j,w]=d.useState(null);d.useEffect(()=>{b()},[]);const b=async()=>{q(!0);const[a,r]=await Promise.all([g.from("gift_cards").select("*, prices:gift_card_prices(id)").order("display_order",{ascending:!0,nullsFirst:!1}).order("created_at",{ascending:!1}),g.from("gift_card_prices").select("*, gift:gift_cards(title)").order("display_order",{ascending:!0,nullsFirst:!1}).order("created_at",{ascending:!1})]);if(a.error||r.error){h.error("Gift kartalarni yuklashda xatolik"),q(!1);return}Q(a.data||[]),W(r.data||[]),q(!1)},ee=()=>{P(null),n({...$}),_(!0)},ae=a=>{P(a),n({title:a.title||"",title_ru:a.title_ru||"",description:a.description||"",description_ru:a.description_ru||"",image_url:a.image_url||"",logo_url:a.logo_url||"",website_url:a.website_url||"",expiry_date:a.expiry_date||"",display_order:a.display_order==null?"":String(a.display_order),is_active:a.is_active,show_in_app:a.show_in_app}),_(!0)},se=async()=>{if(!s.title.trim()){h.error("Nomi majburiy");return}y(!0);const a={title:s.title.trim(),title_ru:s.title_ru.trim()||null,description:s.description.trim()||null,description_ru:s.description_ru.trim()||null,image_url:s.image_url.trim()||null,logo_url:s.logo_url.trim()||null,website_url:s.website_url.trim()||null,expiry_date:s.expiry_date||null,display_order:s.display_order?Number(s.display_order):null,is_active:s.is_active,show_in_app:s.show_in_app},{error:r}=A?await g.from("gift_cards").update(a).eq("id",A.id):await g.from("gift_cards").insert(a);if(y(!1),r){h.error(r.message);return}h.success("Saqlandi"),_(!1),b()},ie=()=>{G(null),m({...J,gift_card_id:v[0]?.id||""}),f(!0)},re=a=>{G(a),m({gift_card_id:a.gift_card_id,nominal:a.nominal||"",price:a.price==null?"":String(a.price),quantity:a.quantity==null?"":String(a.quantity),display_order:a.display_order==null?"":String(a.display_order),is_active:a.is_active,show_in_app:a.show_in_app}),f(!0)},le=async()=>{if(!i.gift_card_id){h.error("Gift karta tanlang");return}if(!i.nominal.trim()){h.error("Nominal majburiy");return}y(!0);const a={gift_card_id:i.gift_card_id,nominal:i.nominal.trim(),price:i.price?Number(i.price):null,quantity:i.quantity?Number(i.quantity):null,display_order:i.display_order?Number(i.display_order):null,is_active:i.is_active,show_in_app:i.show_in_app},{error:r}=T?await g.from("gift_card_prices").update(a).eq("id",T.id):await g.from("gift_card_prices").insert(a);if(y(!1),r){h.error(r.message);return}h.success("Saqlandi"),f(!1),b()},te=async()=>{if(!j)return;const a=j.kind==="card"?"gift_cards":"gift_card_prices",{error:r}=await g.from(a).delete().eq("id",j.id);if(w(null),r){h.error(r.message);return}h.success("O'chirildi"),b()}
1,k=({active:a,inApp:r})=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[!r&&e.jsx(H,{variant:"outline",title:"Ilovada yashirilgan",children:"📵"}),e.jsx(H,{variant:a?"default":"secondary",children:a?"Faol":"O'chiq"})]});return e.jsxs("div",{className:"p-4 md:p-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:"Gift kartalar"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Ilovadagi sovg'a kartalari va ularning nominal narxlari. Faqat ilovaga ta'sir qiladi."})]}),e.jsxs(c,{onClick:u==="cards"?ee:ie,children:[e.jsx(ve,{className:"w-4 h-4 mr-2"}),u==="cards"?"Gift karta":"Narx"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(c,{variant:u==="cards"?"default":"outline",size:"sm",onClick:()=>D("cards"),children:"🎁 Kartalar"}),e.jsx(c,{variant:u==="prices"?"default":"outline",size:"sm",onClick:()=>D("prices"),children:"💲 Narxlar"})]}),e.jsx("div",{className:"border border-border rounded-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:u==="cards"?e.jsxs(U,{className:"[&_td]:px-2 [&_th]:px-2 md:[&_td]:px-4 md:[&_th]:px-4",children:[e.jsx(L,{children:e.jsxs(p,{children:[e.jsx(o,{className:"w-[1%] whitespace-nowrap",children:"Rasm"}),e.jsx(o,{children:"Nomi"}),e.jsx(o,{className:"hidden md:table-cell",children:"Narxlar"}),e.jsx(o,{className:"hidden md:table-cell",children:"Holat"}),e.jsx(o,{className:"w-[1%] whitespace-nowrap text-right",children:"Amallar"})]})}),e.jsx(K,{children:F?e.jsx(p,{children:e.jsx(t,{colSpan:5,className:"text-center py-10",children:e.jsx(S,{className:"w-5 h-5 animate-spin mx-auto text-muted-foreground"})})}):v.length===0?e.jsx(p,{children:e.jsx(t,{colSpan:5,className:"text-center py-10 text-muted-foreground",children:"Gift karta yo'q"})}):v.map(a=>{const r=a.image_url||a.logo_url;return e.jsxs(p,{children:[e.jsx(t,{className:"w-[1%] whitespace-nowrap",children:r?e.jsx("img",{src:r,alt:"",className:"w-10 h-10 rounded-lg object-contain border border-border"}):e.jsx("div",{className:"w-10 h-10 rounded-lg border border-border grid place-items-center",children:"🎁"})}),e.jsxs(t,{children:[e.jsx("span",{className:"block truncate max-w-[150px] md:max-w-[280px] font-medium",title:a.title,children:a.title}),a.title_ru&&e.jsx("span",{className:"block truncate max-w-[150px] md:max-w-[280px] text-xs text-muted-foreground",children:a.title_ru}),e.jsxs("div",{className:"md:hidden mt-1 flex items-center gap-1.5 flex-wrap text-xs text-muted-foreground",children:[e.jsxs("span",{children:[(a.prices||[]).length," ta narx"]}),e.jsx(k,{active:a.is_active,inApp:a.show_in_app})]})]}),e.jsxs(t,{className:"hidden md:table-cell text-muted-foreground text-sm",children:[(a.prices||[]).length," ta narx"]}),e.jsx(t,{className:"hidden md:table-cell",children:e.jsx(k,{active:a.is_active,inApp:a.show_in_app})}),e.jsxs(t,{className:"w-[1%] text-right whitespace-nowrap",children:[e.jsx(c,{variant:"ghost",size:"icon",onClick:()=>ae(a),children:e.jsx(Z,{className:"w-4 h-4"})}),e.jsx(c,{variant:"ghost",size:"icon",onClick:()=>w({kind:"card",id:a.id}),children:e.jsx(Y,{className:"w-4 h-4 text-destructive"})})]})]},a.id)})})]}):e.jsxs(U,{className:"[&_td]:px-2 [&_th]:px-2 md:[&_td]:px-4 md:[&_th]:px-4",children:[e.jsx(L,{children:e.jsxs(p,{children:[e.jsx(o,{children:"Gift karta"}),e.jsx(o,{className:"hidden md:table-cell",children:"Nominal"}),e.jsx(o,{className:"w-[1%] whitespace-nowrap",children:"Narx"}),e.jsx(o,{className:"hidden md:table-cell",children:"Zaxira"}),e.jsx(o,{className:"hidden md:table-cell",children:"Holat"}),e.jsx(o,{className:"w-[1%] whitespace-nowrap text-right",children:"Amallar"})]})}),e.jsx(K,{children:F?e.jsx(p,{children:e.jsx(t,{colSpan:6,className:"text-center py-10",children:e.jsx(S,{className:"w-5 h-5 animate-spin mx-auto text-muted-foreground"})})}):B.length===0?e.jsx(p,{children:e.jsx(t,{colSpan:6,className:"text-center py-10 text-muted-foreground",children:"Narx yo'q"})}):B.map(a=>e.jsxs(p,{children:[e.jsxs(t,{className:"font-medium",children:[e.jsx("span",{className:"block truncate max-w-[130px] md:max-w-[220px]",title:a.gift?.title||void 0,children:a.gift?.title||"—"}),e.jsxs("div",{className:"md:hidden mt-1 flex items-center gap-1.5 flex-wrap text-xs font-normal text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground",children:a.nominal||"—"}),a.quantity!=null&&e.jsxs("span",{children:[a.quantity," ta"]}),e.jsx(k,{active:a.is_active,inApp:a.show_in_app})]})]}),e.jsx(t,{className:"hidden md:table-cell font-semibold",children:a.nominal||"—"}),e.jsx(t,{className:"w-[1%] text-emerald-600 font-semibold whitespace-nowrap",children:a.price!=null?`${Ne(a.price)} so'm`:"—"}),e.jsx(t,{className:"hidden md:table-cell text-muted-foreground text-sm",children:a.quantity!=null?`${a.quantity} ta`:"—"}),e.jsx(t,{className:"hidden md:table-cell",children:e.jsx(k,{active:a.is_active,inApp:a.show_in_app})}),e.jsxs(t,{className:"w-[1%] text-right whitespace-nowrap",children:[e.jsx(c,{variant:"ghost",size:"icon",onClick:()=>re(a),children:e.jsx(Z,{className:"w-4 h-4"})}),e.jsx(c,{variant:"ghost",size:"icon",onClick:()=>w({kind:"price",id:a.id}),children:e.jsx(Y,{className:"w-4 h-4 text-destructive"})})]})]},a.id))})]})})}),e.jsx(I,{open:M,onOpenChange:_,children:e.jsxs(O,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(R,{children:e.jsx(z,{children:A?"Gift kartani tahrirlash":"Yangi gift karta"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Nomi (UZ) *"}),e.jsx(x,{value:s.title,onChange:a=>n({...s,title:a.target.value}),placeholder:"Roblox US"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Nomi (RU)"}),e.jsx(x,{value:s.title_ru,onChange:a=>n({...s,title_ru:a.target.value})})]})]}),e.jsx(V,{label:"Gift karta rasmi",value:s.image_url,onChange:a=>n({...s,image_url:a}),prefix:"gift",hint:"Ilovaning bosh sahifasidagi kvadratda ko'rinadi."}),e.jsx(V,{label:"Kvadrat logo",value:s.logo_url,onChange:a=>n({...s,logo_url:a}),prefix:"gift-logo",hint:"Ichki ekran sarlavhasida va narx kartochkalarida ko'rinadi. Bo'sh qolsa — gift karta rasmi ishlatiladi.",maxWidth:512}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Tavsif (UZ)"}),e.jsx(E,{value:s.description,onChange:a=>n({...s,description:a.target.value}),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Tavsif (RU)"}),e.jsx(E,{value:s.description_ru,onChange:a=>n({...s,description_ru:a.target.value}),rows:3})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Havola"}),e.jsx(x,{value:s.website_url,onChange:a=>n({...s,website_url:a.target.value}),placeholder:"«Sotib olish» bosilganda ochiladi"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Tugash sanasi"}),e.jsx(x,{type:"date",value:s.expiry_date,onChange:a=>n({...s,expiry_date:a.target.value})})]})]}),e.jsxs("div",{className:"grid sm:grid-cols-3 gap-4 items-center",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Tartib"}),e.jsx(x,{type:"number",value:s.display_order,onChange:a=>n({...s,display_order:a.target.value})})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(C,{checked:s.show_in_app,onCheckedChange:a=>n({...s,show_in_app:a})}),e.jsx(l,{children:"Ilovada ko'rsatish"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(C,{checked:s.is_active,onCheckedChange:a=>n({...s,is_active:a})}),e.jsx(l,{children:"Faol"})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(c,{variant:"outline",onClick:()=>_(!1),children:"Bekor qilish"}),e.jsxs(c,{onClick:se,disabled:N,children:[N&&e.jsx(S,{className:"w-4 h-4 mr-2 animate-spin"}),"Saqlash"]})]})]})}),e.jsx(I,{open:X,onOpenChange:f,children:e.jsxs(O,{className:"max-w-lg",children:[e.jsx(R,{children:e.jsx(z,{children:T?"Narxni tahrirlash":"Yangi narx"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Qaysi gift karta *"}),e.jsxs(ue,{value:i.gift_card_id,onValueChange:a=>m({...i,gift_card_id:a}),children:[e.jsx(ge,{children:e.jsx(je,{placeholder:"Tanlang"})}),e.jsx(_e,{children:v.map(a=>e.jsx(fe,{value:a.id,children:a.title},a.id))})]})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Nominal *"}
1),e.jsx(x,{value:i.nominal,onChange:a=>m({...i,nominal:a.target.value}),placeholder:"5 USD"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Narx (so'm)"}),e.jsx(x,{type:"number",value:i.price,onChange:a=>m({...i,price:a.target.value}),placeholder:"70100"})]})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Nechta bor (zaxira)"}),e.jsx(x,{type:"number",value:i.quantity,onChange:a=>m({...i,quantity:a.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Bo'sh qolsa — cheklanmaydi."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Tartib"}),e.jsx(x,{type:"number",value:i.display_order,onChange:a=>m({...i,display_order:a.target.value})})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{checked:i.show_in_app,onCheckedChange:a=>m({...i,show_in_app:a})}),e.jsx(l,{children:"Ilovada ko'rsatish"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{checked:i.is_active,onCheckedChange:a=>m({...i,is_active:a})}),e.jsx(l,{children:"Faol"})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(c,{variant:"outline",onClick:()=>f(!1),children:"Bekor qilish"}),e.jsxs(c,{onClick:le,disabled:N,children:[N&&e.jsx(S,{className:"w-4 h-4 mr-2 animate-spin"}),"Saqlash"]})]})]})}),e.jsx(ne,{open:!!j,onOpenChange:a=>!a&&w(null),children:e.jsxs(de,{children:[e.jsxs(ce,{children:[e.jsx(oe,{children:j?.kind==="card"?"Gift karta o'chirilsinmi?":"Narx o'chirilsinmi?"}),e.jsx(he,{children:j?.kind==="card"?"Kartaga bog'langan barcha narxlar ham o'chishi mumkin. Bu amalni ortga qaytarib bo'lmaydi.":"Bu amalni ortga qaytarib bo'lmaydi."})]}),e.jsxs(me,{children:[e.jsx(xe,{children:"Bekor qilish"}),e.jsx(pe,{onClick:te,children:"O'chirish"})]})]})})]})};export{Re 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.