PageSourceSearch

https://hamaidanfx.com/assets/indicator-packages-CupNPirq.js

js hamaidanfx.com collected 2026-10-09 22:13:58 UTC 10,359 bytes, 5 lines download raw bytes

1import{ar as Q,as as R,a as K,u as $,bf as _,r as f,b as V,c as y,j as e,I as Y,bv as z,k as x,av as G,J,K as U,M as W,V as t,a0 as d,ao as b,q as N,aL as X,f as C,b6 as Z,b7 as ee,b8 as ae,b9 as A,aG as se,Q as D,bo as re,bp as te,bn as ie}from"./index-CXjvyV58.js";import{A as ne}from"./admin-layout-CntIBtfk.js";import{S as P}from"./switch-BoXYAolg.js";import{T as de,a as ce,b as w,c,d as oe,e as o}from"./table-DICYk68n.js";import{R as le}from"./read-only-access-banner-qMEjWyqO.js";import{E as ue}from"./ellipsis-DYplvwi0.js";import{S as me}from"./square-pen-DBuevGYY.js";import"./file-down-2kkV1RPk.js";import"./dollar-sign-IXvZjJwN.js";import"./megaphone-BzDTWkrU.js";import"./history-87yQ8wks.js";import"./alert-Bkdt7TUs.js";const he=[["path",{d:"M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43",key:"16m0ql"}],["path",{d:"M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91",key:"1vt8nq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]],xe=Q("star-off",he);function Ce(){const p=R(),{toast:E}=K(),{t:S}=$(),{hasPermission:M,isLoading:O}=_(),i=M("canManageIndicators"),j=(a,n)=>{if(re(a)){E({...te,variant:"destructive"});return}E({title:"Error",description:ie(a,n),variant:"destructive"})},[T,l]=f.useState(!1),[u,F]=f.useState(null),[s,r]=f.useState({nameEn:"",nameAr:"",descriptionEn:"",descriptionAr:"",price:"",currency:"BHD",durationDays:"30",features:"",isActive:!0,isFeatured:!1,sortOrder:0}),{data:g=[],isLoading:k}=V({queryKey:["/api/indicator-packages"]}),v=y({mutationFn:async a=>D("POST","/api/indicator-packages",a),onSuccess:()=>{p.invalidateQueries({queryKey:["/api/indicator-packages"]}),h(),l(!1)},onError:a=>j(a,"Failed to create package")}),m=y({mutationFn:async({id:a,data:n})=>D("PATCH",`/api/indicator-packages/${a}`,n),onSuccess:()=>{p.invalidateQueries({queryKey:["/api/indicator-packages"]}),h(),l(!1)},onError:a=>j(a,"Failed to update package")}),q=y({mutationFn:async a=>D("DELETE",`/api/indicator-packages/${a}`),onSuccess:()=>{p.invalidateQueries({queryKey:["/api/indicator-packages"]})},onError:a=>j(a,"Failed to delete package")}),h=()=>{r({nameEn:"",nameAr:"",descriptionEn:"",descriptionAr:"",price:"",currency:"BHD",durationDays:"30",features:"",isActive:!0,isFeatured:!1,sortOrder:0}),F(null)},I=a=>{F(a),r({nameEn:a.nameEn,nameAr:a.nameAr,descriptionEn:a.descriptionEn,descriptionAr:a.descriptionAr,price:a.price,currency:a.currency,durationDays:String(a.durationDays),features:a.features?.join(`
2`)||"",isActive:a.isActive,isFeatured:a.isFeatured||!1,sortOrder:a.sortOrder}),l(!0)},L=a=>{a.preventDefault();const n={...s,price:s.price,durationDays:parseInt(s.durationDays),features:s.features.split(`
3`).filter(H=>H.trim()),sortOrder:s.sortOrder};u?m.mutate({id:u.id,data:n}):v.mutate(n)},B=a=>a===30?"Monthly":a===90?"Quarterly":a===365?"Yearly":`${a} days`;return e.jsxs(ne,{children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between mb-8 gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold font-heading","data-testid":"text-page-title",children:"Indicator Packages"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage TradingView indicator subscription packages."})]}),e.jsxs(Y,{open:T,onOpenChange:a=>{!i&&a||(l(a),a||h())},children:[e.jsx(z,{asChild:!0,children:e.jsxs(x,{"data-testid":"button-add-package",disabled:!i,title:i?void 0:"You don't have permission to manage indicators",children:[e.jsx(G,{className:"mr-2 h-4 w-4"})," Add Package"]})}),e.jsxs(J,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(U,{children:e.jsx(W,{children:u?"Edit Package":"Create New Package"})}),e.jsxs("form",{onSubmit:L,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"nameEn",children:"Name (English)"}),e.jsx(d,{id:"nameEn","data-testid":"input-name-en",value:s.nameEn,onChange:a=>r({...s,nameEn:a.target.value}),placeholder:"Monthly Plan",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"nameAr",children:"Name (Arabic)"}),e.jsx(d,{id:"nameAr","data-testid":"input-name-ar",value:s.nameAr,onChange:a=>r({...s,nameAr:a.target.value}),placeholder:"الباقة الشهرية",dir:"rtl",required:!0})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"descriptionEn",children:"Description (English)"}),e.jsx(b,{id:"descriptionEn","data-testid":"input-description-en",value:s.descriptionEn,onChange:a=>r({...s,descriptionEn:a.target.value}),placeholder:"Access to Private indicator for 30 days",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"descriptionAr",children:"Description (Arabic)"}),e.jsx(b,{id:"descriptionAr","data-testid":"input-description-ar",value:s.descriptionAr,onChange:a=>r({...s,descriptionAr:a.target.value}),placeholder:"الوصول إلى المؤشر الخاص لمدة 30 يومًا",dir:"rtl",required:!0})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"price",children:"Price"}),e.jsx(d,{id:"price","data-testid":"input-price",type:"number",step:"0.01",value:s.price,onChange:a=>r({...s,price:a.target.value}),placeholder:"30.00",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"currency",children:"Currency"}),e.jsx(d,{id:"currency","data-testid":"input-currency",value:s.currency,onChange:a=>r({...s,currency:a.target.value}),placeholder:"BHD",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"durationDays",children:"Duration (Days)"}),e.jsx(d,{id:"durationDays","data-testid":"input-duration",type:"number",value:s.durationDays,onChange:a=>r({...s,durationDays:a.target.value}),placeholder:"30",required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"features",children:"Features (one per line)"}),e.jsx(b,{id:"features","data-testid":"input-features",value:s.features,onChange:a=>r({...s,features:a.target.value}),placeholder:`Access to Private Indicator
4Real-time Buy/Sell Signals
5Telegram Support`,rows:4})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"sortOrder",children:"Sort Order"}),e.jsx(d,{id:"sortOrder","data-testid":"input-sort-order",type:"number",value:s.sortOrder,onChange:a=>r({...s,sortOrder:parseInt(a.target.value)||0}),placeholder:"0"})]}),e.jsxs("div",{className:"flex items-center space-x-2 pt-6",children:[e.jsx(P,{id:"isActive","data-testid":"switch-is-active",checked:s.isActive,onCheckedChange:a=>r({...s,isActive:a})}),e.jsx(t,{htmlFor:"isActive",children:"Active"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2 p-4 border rounded-lg bg-amber-500/5 border-amber-500/20",children:[e.jsx(P,{id:"isFeatured","data-testid":"switch-is-featured",checked:s.isFeatured,onCheckedChange:a=>r({...s,isFeatured:a})}),e.jsxs("div",{children:[e.jsxs(t,{htmlFor:"isFeatured",className:"flex items-center gap-2",children:[e.jsx(N,{className:"h-4 w-4 text-amber-500"}),"Most Popular"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'Display this package with a golden frame and "Most Popular" badge'})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(x,{type:"button",variant:"outline",onClick:()=>{l(!1),h()},children:"Cancel"}),e.jsx(x,{type:"submit","data-testid":"button-submit-package",disabled:v.isPending||m.isPending,children:v.isPending||m.isPending?"Saving...":u?"Update Package":"Create Package"})]})]})]})]})]}),!O&&!i&&e.jsx(le,{permissionLabel:"Manage Indicators",className:"mb-6",testId:"alert-indicator-packages-readonly"}),e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-sm",children:[e.jsx("div",{className:"p-4 border-b border-border flex items-center justify-end",children:e.jsx("span",{className:"text-sm text-muted-foreground","data-testid":"text-row-count-indicator-packages",children:S("admin.common.resultsCount").replace("{count}",String(g.length))})}),k?e.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"Loading packages..."}):g.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(X,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No packages yet. Create your first indicator package."})]}):e.jsxs(de,{children:[e.jsx(ce,{children:e.jsxs(w,{children:[e.jsx(c,{children:"Name"}),e.jsx(c,{children:"Duration"}),e.jsx(c,{children:"Price"}),e.jsx(c,{children:"Status"}),e.jsx(c,{children:"Order"}),e.jsx(c,{className:"text-right",children:"Actions"})]})}),e.jsx(oe,{children:g.map(a=>e.jsxs(w,{"data-testid":`row-package-${a.id}`,children:[e.jsx(o,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:a.nameEn}),e.jsx("p",{className:"text-sm text-muted-foreground",dir:"rtl",children:a.nameAr})]})}),e.jsx(o,{children:B(a.durationDays)}),e.jsxs(o,{className:"font-bold",children:[a.price," ",a.currency]}),e.jsx(o,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:a.isActive?"default":"secondary",children:a.isActive?"Active":"Inactive"}),a.isFeatured&&e.jsxs(C,{className:"bg-amber-500 hover:bg-amber-600",children:[e.jsx(N,{className:"h-3 w-3 mr-1"})," Popular"]})]})}),e.jsx(o,{children:a.sortOrder}),e.jsx(o,{className:"text-right",children:e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsx(x,{variant:"ghost",size:"icon","data-testid":`button-actions-${a.id}`,children:e.jsx(ue,{className:"h-4 w-4"})})}),e.jsxs(ae,{align:"end",children:[e.jsxs(A,{onClick:()=>I(a),disabled:!i,children:[e.jsx(me,{className:"mr-2 h-4 w-4"})," Edit"]}),e.jsx(A,{onClick:()=>m.mutate({id:a.id,data:{isFeatured:!a.isFeatured}}),disabled:!i,children:a.isFeatured?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"mr-2 h-4 w-4"})," Remove Popular"]}):e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"mr-2 h-4 w-4 text-amber-500"})," Set as Popular"]})}),e.jsxs(A,{className:"text-destructive",disabled:!i,onClick:()=>{confirm("Are you sure you want to delete this package?")&&q.mutate(a.id)},children:[e.jsx(se,{className:"mr-2 h-4 w-4"})," Delete"]})]})]})})]},a.id))})]})]})]})}export{Ce 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.