PageSourceSearch

https://genealogydirect.net/assets/index-zHJYxqVi.js

js genealogydirect.net collected 2026-09-24 14:24:59 UTC 15,538 bytes, 1 lines download raw bytes

1import{r as l,d as b,u as D,j as e}from"./index-D1aKNduO.js";import{S as z}from"./plus-Dij65dNZ.js";import{S as q}from"./check-circle-DIA_JIpY.js";import{S as L}from"./trash-BIKL8xtG.js";import{S as U}from"./pencil-Cud-UKjS.js";import{S as F}from"./external-link-B_uGxnKc.js";import{e as C,T as f,u as E,J as R,j as A,k as M,q as O,x as B,h as Q,d as N,B as $}from"./firebase-DGovvYsO.js";import{S as P}from"./close-DomYtwOS.js";const J=t=>l.createElement("svg",{width:"1em",height:"1em",viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},l.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.05394 4.78033C3.76105 4.48744 3.76105 4.01256 4.05394 3.71967C4.34684 3.42678 4.82171 3.42678 5.1146 3.71967L8.33437 6.93944L11.5521 3.72173C11.845 3.42883 12.3199 3.42883 12.6127 3.72173C12.9056 4.01462 12.9056 4.48949 12.6127 4.78239L9.39503 8.0001L12.6127 11.2178C12.9056 11.5107 12.9056 11.9856 12.6127 12.2785C12.3198 12.5713 11.845 12.5713 11.5521 12.2785L8.33437 9.06076L5.11462 12.2805C4.82173 12.5734 4.34685 12.5734 4.05396 12.2805C3.76107 11.9876 3.76107 11.5127 4.05396 11.2199L7.27371 8.0001L4.05394 4.78033Z",fill:"currentColor"})),h="AppClipEvents";function S(t,a){return{id:t,eventSlug:a.eventSlug,eventName:a.eventName,quizId:a.quizId,badgeId:a.badgeId,bannerUrl:a.bannerUrl,introText:a.introText,isActive:a.isActive,startDate:a.startDate?a.startDate.toDate():void 0,endDate:a.endDate?a.endDate.toDate():void 0,createdAt:a.createdAt?a.createdAt.toDate():void 0,updatedAt:a.updatedAt?a.updatedAt.toDate():void 0}}async function W(){const t=O(A(b,h),B("createdAt","desc"));return(await Q(t)).docs.map(i=>S(i.id,i.data()))}async function Z(t){const a={eventSlug:t.eventSlug,eventName:t.eventName,quizId:t.quizId,isActive:t.isActive,createdAt:N(),updatedAt:N()};t.badgeId&&(a.badgeId=t.badgeId),t.bannerUrl&&(a.bannerUrl=t.bannerUrl),t.introText&&(a.introText=t.introText),t.startDate&&(a.startDate=f.fromDate(t.startDate)),t.endDate&&(a.endDate=f.fromDate(t.endDate));const i=await R(A(b,h),a),r=await M(i);return S(r.id,r.data())}async function _(t,a){const i=C(b,h,t),r={updatedAt:N()};a.eventName!==void 0&&(r.eventName=a.eventName),a.quizId!==void 0&&(r.quizId=a.quizId),a.badgeId!==void 0&&(r.badgeId=a.badgeId),a.bannerUrl!==void 0&&(r.bannerUrl=a.bannerUrl),a.introText!==void 0&&(r.introText=a.introText),a.isActive!==void 0&&(r.isActive=a.isActive),a.startDate!==void 0&&(r.startDate=f.fromDate(a.startDate)),a.endDate!==void 0&&(r.endDate=f.fromDate(a.endDate)),await E(i,r)}async function G(t){const a=C(b,h,t);await $(a)}async function H(t,a){const i=C(b,h,t);await E(i,{isActive:a,updatedAt:N()})}const K=({event:t,onClose:a,onSave:i})=>{const{t:r}=D(),[m,p]=l.useState(!1),[u,v]=l.useState(null),[d,y]=l.useState({eventSlug:"",eventName:"",quizId:"",badgeId:"",bannerUrl:"",introText:"",isActive:!0,startDate:"",endDate:""});l.useEffect(()=>{t&&y({eventSlug:t.eventSlug,eventName:t.eventName,quizId:t.quizId,badgeId:t.badgeId||"",bannerUrl:t.bannerUrl||"",introText:t.introText||"",isActive:t.isActive,startDate:t.startDate?t.startDate.toISOString().split("T")[0]:"",endDate:t.endD
1ate?t.endDate.toISOString().split("T")[0]:""})},[t]);const n=c=>{const{name:o,value:j,type:k}=c.target;y(w=>({...w,[o]:k==="checkbox"?c.target.checked:j}))},g=async c=>{c.preventDefault(),v(null),p(!0);try{const o={eventSlug:d.eventSlug.toLowerCase().replace(/[^a-z0-9-]/g,"-"),eventName:d.eventName,quizId:d.quizId,badgeId:d.badgeId||void 0,bannerUrl:d.bannerUrl||void 0,introText:d.introText||void 0,isActive:d.isActive,startDate:d.startDate?new Date(d.startDate):void 0,endDate:d.endDate?new Date(d.endDate):void 0};t?await _(t.id,o):await Z(o),i()}catch(o){console.error("Failed to save event:",o),v("Failed to save event. Please try again.")}finally{p(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:e.jsxs("div",{className:"flex min-h-full items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50",onClick:a,"aria-hidden":"true"}),e.jsxs("div",{className:"relative bg-white dark:bg-gray-900 rounded-xl shadow-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:t?r("admin.appClipEvents.editEvent","Edit Event"):r("admin.appClipEvents.createEvent","Create Event")}),e.jsx("button",{onClick:a,className:"text-gray-400 hover:text-gray-500",children:e.jsx(P,{className:"w-6 h-6"})})]}),e.jsxs("form",{onSubmit:g,className:"p-6 space-y-6",children:[u&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 rounded-lg",children:u}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[r("admin.appClipEvents.eventName","Event Name")," *"]}),e.jsx("input",{type:"text",name:"eventName",value:d.eventName,onChange:n,required:!0,placeholder:"e.g., RootsTech 2026 Special Quiz",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-brand-500"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[r("admin.appClipEvents.slug","Event Slug")," *"]}),e.jsx("input",{type:"text",name:"eventSlug",value:d.eventSlug,onChange:n,required:!0,placeholder:"e.g., rootstech-2026",disabled:!!t,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-brand-500 disabled:opacity-50"}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:["URL: https://genealogydirect.net/clip/",d.eventSlug||"your-slug"]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[r("admin.appClipEvents.quizId","Quiz ID")," *"]}),e.jsx("input",{type:"text",name:"quizId",value:d.quizId,onChange:n,required:!0,placeholder:"Quiz identifier",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("admin.appClipEvents.badgeId","Badge ID")}),e.jsx("input",{type:"text",name:"badgeId",value:d.badgeId,onChange:n,placeholder:"Optional badge to award",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("admin.appClipEvents.startDate","Start Date")}),e.jsx("input",{type:"date",name:"startDate",value:d.startDate,onChange:n,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("admin.appClipEvents.endDate","End Date")}),e.jsx("input",{type:"date",name:"endDate",value:d.endDate,onChange:n,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-brand-500"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("admin.appClipEvents.bannerUrl","Banner Image URL")}),e.jsx("input",{type:"url",name:"bannerUrl",value:d.bannerUrl,onChange:n,placeholder:"https://example.com/banner.jpg",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("admin.appClipEvents.introText","Introduction Text")}),e.jsx("textarea",{name:"introText",value:d.introText,onChange:n,rows:3,placeholder:"Welcome message shown on the landing screen",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-brand-500"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"isActive",name:"isActive",checked:d.isActive,onChange:n,className:"w-4 h-4 text-brand-600 border-gray-300 rounded focus:ring-brand-500"}),e.jsx("label",{htmlFor:"isActive",className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:r("admin.appClipEvents.isActive","Event is active")})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("button",{type:"button",onClick:a,className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",children:r("common.cancel","Cancel")}),e.jsx("button",{type:"submit",disabled:m,className:"px-4 py-2 bg-brand-600 text-white rounded-lg hover:bg-brand-700 transition-colors disabled:opacity-50",children:m?r("common.saving","Saving..."):r("common.save","Save")})]})]})]})]})})},de=()=>{const{t}=D(),[a,i]=l.useState([]),[r,m]=l.useState(!0),[p,u]=l.useState(null),[v,d]=l.useState(!1),[y,n]=l.useState(null),g=async()=>{try{m(!0);const s=await W();i(s),u(null)}catch(s){u("Failed to load App Clip events"),console.error(s)}finally{m(!1)}};l.useEffect(()=>{g()},[]);const c=()=>{n(null),d(!0)},o=s=>{n(s),d(!0)},j=async s=>{if(confirm(`Are you sure you want to delete "${s.eventName}"?`))try{await G(s.id),await g()}catch(x){console.error("Failed to delete event:",x),alert("Failed to delete event")}},k=async s=>{try{await H(s.id,!s.isActive),await g()}catch(x){console.error("Failed to toggle event status:",x),alert("Failed to update event status")}},w=()=>{d(!1),n(null)},I=()=>{d(!1),n(null),g()},T=s=>{const x=`https://genealogydirect.net/clip/${s}`;navigator.clipboard.writeText(x),alert(`Copied: ${x}`)};return r?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-brand-600"})}):e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:t("admin.appClipEvents.title","App Clip Events")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:t("admin.appClipEvents.description","Manage Discovery Quiz events for App Clip invocations")})]}),e.jsxs("button",{onClick:c,className:"inline-flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-lg hover:bg-brand-700 transition-colors",children:[e.jsx(z,{className:"w-5 h-5"}),t("admin.appClipEvents.createEvent","Create Event")]})]}),p&&e.jsx("div",{className:"mb-4 p-4 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 rounded-lg",children:p}),a.length===0?e.jsxs("div",{className:"text-center py-12 bg-gray-50 dark:bg-gray-800 rounded-lg",children:[e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:t("admin.appClipEvents.noEvents","No App Clip events created yet")}),e.jsx("button",{onClick:c,className:"mt-4 text-brand-600 hover:text-brand-700",children:t("admin.appClipEvents.createFirst","Create your first event")})]}):e.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow overflow-hidden",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("admin.appClipEvents.eventName","Event Name")}
1),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("admin.appClipEvents.slug","Slug")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("admin.appClipEvents.quizId","Quiz ID")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("admin.appClipEvents.badge","Badge")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("admin.appClipEvents.status","Status")}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("admin.appClipEvents.actions","Actions")})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:a.map(s=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-800",children:[e.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:s.eventName}),s.startDate&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[s.startDate.toLocaleDateString()," -"," ",s.endDate?.toLocaleDateString()||"No end date"]})]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"text-sm bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded",children:s.eventSlug}),e.jsx("button",{onClick:()=>T(s.eventSlug),className:"text-gray-400 hover:text-brand-600",title:"Copy App Clip URL",children:e.jsx(F,{className:"w-4 h-4"})})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:s.quizId}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:s.badgeId||"-"}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("button",{onClick:()=>k(s),className:`inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium ${s.isActive?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"}`,children:s.isActive?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-3 h-3"}),t("admin.appClipEvents.active","Active")]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-3 h-3"}),t("admin.appClipEvents.inactive","Inactive")]})})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>o(s),className:"text-brand-600 hover:text-brand-700",title:"Edit",children:e.jsx(U,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>j(s),className:"text-red-600 hover:text-red-700",title:"Delete",children:e.jsx(L,{className:"w-5 h-5"})})]})})]},s.id))})]})}),v&&e.jsx(K,{event:y,onClose:w,onSave:I})]})};export{K as AppClipEventModal,de as AppClipEventsAdmin};

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.