PageSourceSearch

https://genealogydirect.net/assets/LegalPolicies-CtRUj5gn.js

js genealogydirect.net collected 2026-09-24 14:25:58 UTC 16,371 bytes, 6 lines download raw bytes

1import{u as te,r as n,j as e,ab as ae}from"./index-D1aKNduO.js";import{P as u,a as i,b as f}from"./PolicyService-BIKIpINx.js";import{S as re}from"./download-BRmjMDsW.js";import"./firebase-DGovvYsO.js";const oe=()=>{const{t:a}=te(),[d,U]=n.useState("tos"),[P,V]=n.useState([]),[B,T]=n.useState(!1),[p,A]=n.useState(!1),[h,o]=n.useState(null),[R,c]=n.useState(!1),[v,b]=n.useState(!1),[g,j]=n.useState("en"),[k,N]=n.useState({}),[m,C]=n.useState(""),[D,S]=n.useState(!0),E=ae,l=n.useMemo(()=>["en","fr","es","de","it","nl"],[]);n.useEffect(()=>{w()},[d]);const w=async()=>{T(!0);try{const t=M(d),r=await u.getAllVersions(t);V(r)}catch(t){console.error("Error loading versions:",t)}finally{T(!1)}},M=t=>{switch(t){case"tos":return i.TERMS_OF_SERVICE;case"privacy":return i.PRIVACY_POLICY;case"refunds":return i.REFUNDS_POLICY;case"mentions":return i.LEGAL_MENTIONS;default:return i.TERMS_OF_SERVICE}},$=()=>{b(!0),c(!0),j("en");const t={};l.forEach(r=>{t[r]={title:"",content:""}}),N(t),C(""),S(d!=="mentions"),o(null)},H=async t=>{try{const r=await u.getPolicyById(t);r&&(o(r),N(r.translations),C(r.effectiveDate?new Date(r.effectiveDate.toMillis()).toISOString().split("T")[0]:""),S(r.requiresAcceptance??r.type!==i.LEGAL_MENTIONS),c(!0),b(!1),j("en"))}catch(r){console.error("Error loading policy:",r),alert(a("admin.legal.errorLoading","Failed to load policy"))}},I=(t,r,s)=>{N(x=>({...x,[t]:{...x[t],[r]:s}}))},Y=()=>k[g]||{title:"",content:""},F=t=>{const r=k[t];return r&&r.title.trim()&&r.content.trim()},L=()=>l.every(t=>F(t)),z=async()=>{if(!m){alert(a("admin.legal.effectiveDateRequired","Please select an effective date before saving."));return}A(!0);try{if(v){const t={type:M(d),translations:k,effectiveDate:m?new Date(m):void 0,requiresAcceptance:D};await u.createDraft(t),alert(a("admin.legal.draftCreated","Draft created successfully"))}else if(h){for(const t of l){const r=k[t];if(r){const s={language:t,title:r.title,content:r.content,effectiveDate:m?new Date(m):void 0,requiresAcceptance:D};await u.updateDraft(h.id,s)}}alert(a("admin.legal.draftUpdated","Draft updated successfully"))}c(!1),b(!1),o(null),w()}catch(t){console.error("Error saving policy:",t),alert(a("admin.legal.errorSaving","Failed to save policy"))}finally{A(!1)}},O=async t=>{try{await u.publishPolicy(t),alert(a("admin.legal.published","Policy published successfully")),w(),c(!1),o(null)}catch(r){console.error("Error publishing policy:",r);const s=r instanceof Error?r.message:a("admin.legal.errorPublishing","Failed to publish policy");alert(s)}},W=async t=>{if(window.confirm(a("admin.legal.confirmDelete","Are you sure you want to delete this draft?")))try{await u.deleteDraft(t),alert(a("admin.legal.deleted","Draft deleted successfully")),w()}catch(r){console.error("Error deleting policy:",r),alert(a("admin.legal.errorDeleting","Failed to delete draft"))}},G=(t,r)=>{const s=t.translations?.[r];if(!s||!s.content){alert(a("admin.legal.noTranslationContent","No content available for this language"));return}const x=`# ${s.title}
2
3${s.content}`,Z=new Blob([x],{type:"text/markdown"}),_=URL.createObjectURL(Z),y=document.createElement("a"),ee=`${t.type===i.TERMS_OF_SERVICE?"tos":t.type===i.PRIVACY_POLICY?"privacy":t.type===i.REFUNDS_POLICY?"refunds":"mentions"}-v${t.version}-${r}.md`;y.href=_,y.download=ee,document.body.appendChild(y),y.click(),document.body.removeChild(y),URL.revokeObjectURL(_)},J=t=>{l.forEach(r=>{const s=t.translations?.[r];s&&s.content&&setTimeout(()=>G(t,r),100*l.indexOf(r))})},K=t=>l.every(r=>{const s=t.translations?.[r];return s&&s.title&&s.content}),Q=t=>{switch(t){case f.PUBLISHED:return e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:a("admin.legal.published","Published")});case f.DRAFT:return e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300",children:a("admin.legal.draft","Draft")});default:return null}},q=Y(),X=d==="mentions";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white",children:a("admin.legal.title","Legal Policies")}),e.jsx("p",{className:"mt-2 text-sm text-gray-600 dark:text-gray-400",children:a("admin.legal.subtitle","Manage Terms of Service, Privacy Policy, Refunds Policy, and Legal Mentions")})]}),!R&&e.jsxs("button",{onClick:$,className:"inline-flex items-center px-4 py-2 border border-transparent roun
3ded-md shadow-sm text-sm font-medium text-white bg-brand-600 hover:bg-brand-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brand-500",children:[e.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),a("admin.legal.createNew","Create New Draft")]})]}),e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:e.jsx("nav",{className:"-mb-px flex space-x-8",children:["tos","privacy","refunds","mentions"].map(t=>e.jsxs("button",{onClick:()=>{U(t),c(!1),o(null)},className:`
4                py-4 px-1 border-b-2 font-medium text-sm
5                ${d===t?"border-brand-500 text-brand-600 dark:text-brand-400":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:text-gray-300"}
6              `,children:[t==="tos"&&a("admin.legal.termsOfService","Terms of Service"),t==="privacy"&&a("common.privacy_policy","Privacy Policy"),t==="refunds"&&a("admin.legal.refundsPolicy","Refunds Policy"),t==="mentions"&&a("legal.legalMentions","Legal Mentions")]},t))})}),R?e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-sm border border-gray-200 dark:border-gray-800 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-white",children:v?a("admin.legal.createDraft","Create New Draft"):a("admin.legal.editDraft","Edit Draft")}),!v&&h&&h.status===f.DRAFT&&e.jsxs("button",{onClick:()=>O(h.id),disabled:!L(),className:`inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white ${L()?"bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500":"bg-gray-300 dark:bg-gray-700 cursor-not-allowed"}`,children:[e.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),a("admin.legal.publish","Publish")]})]}),e.jsxs("div",{className:"mb-6 space-y-3",children:[e.jsxs("div",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[a("admin.legal.selectLanguage","Select Language"),":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(t=>{const r=E[t]?.nativeName||t.toUpperCase(),s=g===t,x=F(t);return e.jsxs("button",{type:"button",onClick:()=>j(t),className:`inline-flex items-center gap-2 rounded-full px-3 py-1.5 text-sm font-medium transition ${s?"bg-brand-600 text-white shadow":"bg-white text-gray-600 hover:bg-gray-100 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600"}`,children:[e.jsx("span",{children:r}),x?e.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500",title:"Complete"}):e.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500",title:"Incomplete"})]},t)})}),!L()&&e.jsxs("p",{className:"text-sm text-amber-600 dark:text-amber-400 flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),a("admin.legal.allLanguagesRequired","All languages must be completed before publishing")]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[a("admin.legal.titleLabel","Title")," (",E[g]?.nativeName,") *"]}),e.jsx("input",{type:"text",value:q.title,onChange:t=>I(g,"title",t.target.value),className:"w-full rounded-md border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white shadow-sm focus:border-brand-500 focus:ring-brand-500",placeholder:a("admin.legal.titlePlaceholder","Enter policy title")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:a("admin.legal.effectiveDate","Effective Date")}),e.jsx("input",{type:"date",value:m,onChange:t=>C(t.target.value),className:"w-full rounded-md border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white shadow-sm focus:border-brand-500 focus:ring-brand-500"})]}),e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex items-center h-5",children:e.jsx("input",{id:"requiresAcceptance",type:"checkbox",checked:D,onChange:t=>
6S(t.target.checked),className:"h-4 w-4 rounded border-gray-300 text-brand-600 focus:ring-brand-500"})}),e.jsxs("div",{className:"ml-3 text-sm",children:[e.jsx("label",{htmlFor:"requiresAcceptance",className:"font-medium text-gray-700 dark:text-gray-300",children:a("admin.legal.requiresAcceptance","Requires User Acceptance")}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:a("admin.legal.requiresAcceptanceHint","When enabled, users will be prompted to accept this policy version. Disable for minor updates that don't require re-acceptance.")})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[a("admin.legal.contentLabel","Content (Markdown)")," (",E[g]?.nativeName,") *"]}),e.jsx("textarea",{value:q.content,onChange:t=>I(g,"content",t.target.value),rows:20,className:"w-full rounded-md border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white shadow-sm focus:border-brand-500 focus:ring-brand-500 font-mono text-sm",placeholder:X?a("admin.legal.mentionsPlaceholder","Enter Legal Mentions content in Markdown (use registered-agent address and [email protected], not a home address)."):a("admin.legal.contentPlaceholder","Enter policy content in Markdown format...")}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:a("admin.legal.markdownHint","Use Markdown formatting: # for headings, ** for bold, * for lists, etc.")})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-4",children:[e.jsx("button",{onClick:z,disabled:p,className:`inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white ${p?"bg-gray-400 cursor-not-allowed":"bg-brand-600 hover:bg-brand-700"} focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brand-500`,children:p?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),a("admin.legal.saving","Saving...")]}):a("admin.legal.saveDraft","Save Draft")}),e.jsx("button",{onClick:()=>{c(!1),b(!1),o(null)},disabled:p,className:"inline-flex items-center px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brand-500 disabled:opacity-50 disabled:cursor-not-allowed",children:a("admin.legal.cancel","Cancel")})]})]})]}):e.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-sm border border-gray-200 dark:border-gray-800 overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-800",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800/50",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:a("admin.legal.version","Version")}),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:a("admin.legal.status","Status")}),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:a("admin.legal.requiresAcceptance","Requires Acceptance")}),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:a("admin.legal.created","Created")}),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:a("admin.legal.languages","Languages")}),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:a("admin.legal.actions","Actions")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-800",children:B?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-6 py-4 text-center text-sm text-gray-500 dark:text-gray-400",children:a("common.loading","Loading...")})}):P.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-6 py-4 text-center text-sm text-gray-500 dark:text-gray-400",children:a("admin.legal.n
6oVersions","No versions found for this policy and language")})}):P.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[e.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dark:text-white",children:["v",t.version]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:Q(t.status)}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.requiresAcceptance??!0?e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300",children:a("admin.legal.yes","Yes")}):e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800 dark:bg-gray-900/30 dark:text-gray-300",children:a("admin.legal.no","No")})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:t.createdAt.toDate().toLocaleDateString()}),e.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:[l.filter(r=>{const s=t.translations?.[r];return s&&s.title&&s.content}).length," / ",l.length]}),e.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium space-x-2",children:[e.jsx("button",{onClick:()=>J(t),className:"inline-flex items-center text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-200",title:a("admin.legal.downloadAllTranslations","Download all translations"),children:e.jsx(re,{className:"w-4 h-4"})}),t.status===f.DRAFT&&e.jsxs(e.Fragment,{children:[K(t)&&e.jsx("button",{onClick:()=>O(t.id),className:"text-green-600 hover:text-green-900 dark:text-green-400 dark:hover:text-green-300 font-medium",children:a("admin.legal.publish","Publish")}),e.jsx("button",{onClick:()=>H(t.id),className:"text-brand-600 hover:text-brand-900 dark:text-brand-400 dark:hover:text-brand-300",children:a("admin.legal.edit","Edit")}),e.jsx("button",{onClick:()=>W(t.id),className:"text-red-600 hover:text-red-900 dark:text-red-400 dark:hover:text-red-300",children:a("admin.legal.delete","Delete")})]}),t.status===f.PUBLISHED&&e.jsx("span",{className:"text-gray-400 dark:text-gray-600",children:a("admin.legal.viewOnly","Published")})]})]},t.id))})]})})})]})};export{oe 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.