PageSourceSearch

https://www.karispizza.fi/assets/PrivacySettingsPage-23ccc61e.js

js karispizza.fi collected 2026-10-03 02:48:12 UTC 14,740 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-radix-08a60bdd.js";import{u as s,r as t}from"./vendor-react-9016e4a2.js";import{N as a,y as r,x as i,n,B as l,a5 as c,A as d,C as o,E as m,F as x,Q as h,S as g,I as u,M as p,T as j}from"./index-06245da3.js";import{C as y}from"./vendor-capacitor-43d743f6.js";import{aa as f,t as w,V as N,a$ as b,O as v,N as k,aC as _,ab as D,j as C,a2 as S,ay as q}from"./vendor-icons-f2656d21.js";import"./vendor-supabase-36eb0853.js";import"./vendor-motion-a26fe6c4.js";function O(){const j=s(),{user:O,deleteAccount:P,signOut:R}=a(),{toast:L}=r(),{t:A,language:E}=i(),[F,z]=t.useState(!0),[M,W]=t.useState({marketing_email:!1,marketing_push:!1}),[U,$]=t.useState(!1),[B,I]=t.useState(!1),[Y,J]=t.useState(1),[K,V]=t.useState(""),[G,Q]=t.useState(""),[Z,H]=t.useState(!1),[X,ee]=t.useState(null),[se,te]=t.useState(null),[ae,re]=t.useState(null),ie=A("deleteConfirmKeyword"),ne=!y.isNativePlatform(),le=p(E,"en-GB");t.useEffect(()=>{O?ce():j("/",{replace:!0})},[O]);const ce=async()=>{try{z(!0);const{data:e}=await n.from("user_consents").select("consent_categories").eq("user_id",O.id).is("withdrawn_at",null).order("consented_at",{ascending:!1}).limit(1).maybeSingle();if(e?.consent_categories){const s=e.consent_categories;W(e=>({...e,marketing_email:!!s.marketing_email,marketing_push:!!s.marketing_push}))}else{const{data:e}=await n.from("profiles").select("marketing_consent").eq("id",O.id).single();e&&W(s=>({...s,marketing_email:e.marketing_consent||!1}))}const{data:s}=await n.from("profiles").select("deleted_at").eq("id",O.id).single();if(s?.deleted_at){const e=new Date(s.deleted_at);e.setDate(e.getDate()+30),re(e)}const{data:t}=await n.from("gdpr_data_exports").select("id, status, created_at, expires_at, download_token").eq("user_id",O.id).order("created_at",{ascending:!1}).limit(1).maybeSingle();t&&te(t)}catch(e){}finally{z(!1)}},de=t.useCallback(async(e,s)=>{const t={...M,[e]:s};W(t),$(!0);try{const{error:e}=await n.rpc("save_user_consent",{p_policy_version:"1.0",p_categories:t,p_ip_address:null,p_user_agent:navigator.userAgent});if(e)throw e;L({title:A("success"),description:A("consentSavedDesc")})}catch(a){W(t=>({...t,[e]:!s})),L({title:A("errorOccurred"),description:A("updateFailed"),variant:"destructive"})}finally{$(!1)}},[M,L,A]);return F?e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-gray-50",children:e.jsx(f,{className:"h-8 w-8 animate-spin text-orange-500"})}):e.jsxs("div",{className:"min-h-screen bg-gray-50 pb-24",children:[e.jsx("div",{className:"bg-white border-b sticky top-0 z-10",children:e.jsxs("div",{className:"max-w-md lg:max-w-2xl mx-auto px-4 h-16 flex items-center gap-3",children:[e.jsx(l,{variant:"ghost",size:"icon",className:"-ml-2 text-gray-500 hover:text-gray-900",onClick:()=>j("/profile"),children:e.jsx(w,{className:"h-6 w-6"})}),e.jsx(N,{className:"h-5 w-5 text-orange-500"}),e.jsx("h1",{className:"text-xl font-bold text-gray-900",children:A("privacySettingsTitle")})]})}),e.jsxs("div",{className:"max-w-md lg:max-w-2xl mx-auto px-4 py-6 space-y-4",children:[ae&&e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-2xl p-4 flex items-start gap-3",children:[e.jsx(b,{className:"h-5 w-5 text-red-500 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-red-800",children:A("pendingDeletionTitle")}),e.jsx("p",{className:"text-xs text-red-600 mt-1",children:A("pendingDeletionDesc",{date:ae.toLocaleDateString(le,{day:"numeric",month:"long",year:"numeric"})})}),e.jsx(l,{variant:"outline",size:"sm",className:"mt-3 text-red-700 border-red-300 hover:bg-red-100",onClick:async()=>{try{const{data:e,error:s}=await n.rpc("cancel_account_deletion");if(s)throw s;re(null),L({title:A("success"),description:A("deletionCancelledDesc")})}catch(e){L({title:A("errorOccurred"),description:A("cancelDeletionFailedDesc"),variant:"destructive"})}},children:A("cancelDeletion")})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl overflow-hidden shadow-sm border border-gray-100",children:[e.jsxs("div",{className:"p-4 border-b border-gray-50 bg-gray-50/50",children:[e.jsx("h3",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:A("consentManagementTitle")}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:A("consentManagementDesc")})]}),e.jsxs("div",{className:"divide-y divide-gray-50",children:[e.jsx(T,{icon:v,label:A("marketingEmailConsentLabel"),description:A("marketingEmailConsentDesc"),checked:M.marketing_email,onChange:e=>de("marketing_email",e),disabled:U}),e.jsx(T,{icon:k,label:A("marketingPushConsentLabel"),description:A("marketingPushConsentDesc"),checked:M.marketing_push,onChange:e=>de("marketing_push",e),disabled:U}),ne&&e.jsxs("div",{className:"flex items-center justify-between p-4 hover:bg-gray-50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-4 flex-1 min-w-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-gray-100 flex items-center justify-center text-gray-600 shrink-0",children:e.jsx(_,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900 block",children:A("cookieSettingsLabel")}),e.jsx("span",{className:"text-xs text-gray-500 block mt-0.5",children:A("cookieSettingsDesc")})]})]}),e.jsx(l,{type:"button",variant:"outline",size:"sm",className:"shrink-0 ml-3",onClick:c,"data-testid":"cookie-sett
1ings-link",children:A("cookieSettingsLabel")})]})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl overflow-hidden shadow-sm border border-gray-100",children:[e.jsxs("div",{className:"p-4 border-b border-gray-50 bg-gray-50/50",children:[e.jsx("h3",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:A("myDataTitle")}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:A("myDataDesc")})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-blue-50 flex items-center justify-center text-blue-600 shrink-0",children:e.jsx(D,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:A("downloadYourData")}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:A("downloadYourDataDesc")})]})]}),"ready"===se?.status&&e.jsxs(l,{variant:"outline",className:"w-full",onClick:async()=>{if(se?.download_token)try{const e=await n.auth.getSession(),s=e.data.session?.access_token,t=await fetch("https://pqgaupwlfkwouqbotqzf.supabase.co/functions/v1/export-user-data",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({action:"download",token:se.download_token})});if(!t.ok){const e=await t.json();throw new Error(e.error||"Download failed")}const a=await t.blob(),r=URL.createObjectURL(a),i=document.createElement("a");i.href=r,i.download=`pitza-fi-tietoni-${(new Date).toISOString().split("T")[0]}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r),L({title:A("success"),description:A("exportDownloadedDesc")})}catch(e){L({title:A("errorOccurred"),description:e.message||A("operationFailed"),variant:"destructive"})}},children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),A("downloadLatestExport")]}),e.jsx(l,{className:"w-full bg-orange-500 hover:bg-orange-600",onClick:async()=>{ee("requesting");try{const{data:e,error:s}=await n.rpc("request_data_export");if(s)throw s;if(!e?.success){if("export_in_progress"===e?.error)return L({title:A("loading"),description:A("exportInProgressDesc")}),void ee(null);throw new Error(e?.error||"Export failed")}const t=await n.auth.getSession(),a=t.data.session?.access_token;if(a){const e=await fetch("https://pqgaupwlfkwouqbotqzf.supabase.co/functions/v1/export-user-data",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({action:"request"})});if((await e.json()).success)return ee("ready"),L({title:A("success"),description:A("exportReadyDesc")}),void(await ce())}ee("ready"),L({title:A("exportRequestedTitle"),description:A("exportRequestedDesc")}),await ce()}catch(e){ee("error"),L({title:"Virhe",description:"Tietojen vientipyynto epaonnistui. Yrita myohemmin uudelleen.",variant:"destructive"})}},disabled:"requesting"===X,children:"requesting"===X?e.jsxs(e.Fragment,{children:[e.jsx(f,{className:"h-4 w-4 mr-2 animate-spin"}),A("preparing")]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"h-4 w-4 mr-2"}),A("requestDataExport")]})}),se&&e.jsxs("p",{className:"text-xs text-gray-400 text-center",children:[A("latestRequest",{date:new Date(se.created_at).toLocaleDateString(le)}),"expired"===se.status&&` ${A("expiredShort")}`]})]})]}),e.jsx("div",{className:"bg-white rounded-2xl overflow-hidden shadow-sm border border-gray-100",children:e.jsxs("div",{className:"divide-y divide-gray-50",children:[e.jsxs("button",{onClick:()=>j("/privacy"),className:"w-full flex items-center gap-4 p-4 hover:bg-gray-50 text-left",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-gray-100 flex items-center justify-center text-gray-600",children:e.jsx(C,{className:"h-5 w-5"})}),e.jsx("span",{className:"text-sm font-medium text-gray-900",children:A("privacyPolicy")})]}),e.jsxs("button",{onClick:()=>j("/terms"),className:"w-full flex items-center gap-4 p-4 hover:bg-gray-50 text-left",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-gray-100 flex items-center justify-center text-gray-600",children:e.jsx(C,{className:"h-5 w-5"})}),e.jsx("span",{className:"text-sm font-medium text-gray-900",children:A("termsOfService")})]})]})}),!ae&&e.jsxs("div",{className:"bg-white rounded-2xl overflow-hidden shadow-sm border border-red-100",children:[e.jsx("div",{className:"p-4 border-b border-red-50 bg-red-50/30",children:e.jsx("h3",{className:"text-xs font-semibold text-red-500 uppercase tracking-wider",children:A("dangerZone")})}),e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-red-50 flex items-center justify-center text-red-500 shrink-0",children:e.jsx(S,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:A("deleteAccountTitle")}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:A("deleteAccountDesc")})]})]}),e.jsxs(l,{variant:"outline",className:"w-full mt-4 text-red-600 border-red-200 hover:bg-red-50 hover:text-red-700",onClick:()=>{I(!0),J(1),Q("")},children:[e.jsx(S,{className:"h-4 w-4 mr-2"}),A("deleteMyAccount")]})]})]})]}),e.jsx(d,{open:B,onOpenChange:I,children:e.jsx(o,{children:e.jsxs("div",{className:"mx-auto w-full max-w-sm",children:[e.jsx(m,{children:e.jsxs(x,{className:"text-red-600 flex items-center gap-2",children:[e.jsx(b,{className:"h-5 w-5"}),A("deleteDrawerTitle")]})}),1===Y&&e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"bg-red-50 border border-red-100 rounded-xl p-4 space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-red-800",children:A("deleteWarningTitle")}),e.jsxs("ul",{className:"text-sm text-red-700 space-y-1.5",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-3.5 w-3.5"})," ",A("deleteWarningProfileData")]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-3.5 w-3.5"})," ",A("deleteWarningLoyalty")]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-3.5 w-3.5"})," ",A("deleteWarningAddresses")]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-3.5 w-3.5"})," ",A("deleteWarningPushSettings")]})]}),e.jsx("p",{className:"text-xs text-red-600 mt-2",children:A("deleteWarningRetention")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700",children:A("deleteReasonLabel")}),e.jsxs("select",{className:"w-full rounded-lg border border-gray-200 p-2.5 text-sm text-gray-700 bg-white",value:K,onChange:e=>V(e.target.value),children:[e.jsx("option",{value:"",children:A("deleteReasonPlaceholder")}),e.jsx("option",{value:"no_longer_use",children:A("deleteReasonNoLongerUse")}),e.jsx("option",{value:"privacy_concerns",children:A("deleteReasonPrivacyConcerns")}),e.jsx("option",{value:"too_many_notifications",children:A("deleteReasonTooManyNotifications")}),e.jsx("option",{value:"other",children:A("deleteReasonOther")})]})]}),e.jsxs(h,{className:"px-0",children:[e.jsx(l,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:()=>J(2),children:A("continue")}),e.jsx(g,{asChild:!0,children:e.jsx(l,{variant:"outline",children:A("cancelAction")})})]})]}),2===Y&&e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-700",children:A("confirmDeleteInstruction",{keyword:ie})}),e.jsx(u,{value:G,onChange:e=>Q(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:A("typeDeletePlaceholder",{keyword:ie}),className:"text-center font-mono text-lg tracking-widest",autoFocus:!0}),e.jsxs(h,{className:"px-0",children:[e.jsx(l,{className:"bg-red-600 hover:bg-red-700 text-white",disabled:G!==ie||Z,onClick:async()=>
1{if(G===ie){H(!0);try{await P(K||null),L({title:A("accountDeletionScheduledTitle"),description:A("accountDeletionScheduledDesc")}),I(!1),j("/",{replace:!0})}catch(e){let s=A("deleteAccountFailedDesc");e.message?.includes("pending_orders")&&(s=A("deleteAccountPendingOrdersDesc")),L({title:A("errorOccurred"),description:s,variant:"destructive"})}finally{H(!1)}}},children:Z?e.jsxs(e.Fragment,{children:[e.jsx(f,{className:"h-4 w-4 mr-2 animate-spin"}),A("deleting")]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"h-4 w-4 mr-2"}),A("deleteMyAccountPermanently")]})}),e.jsx(l,{variant:"outline",onClick:()=>J(1),children:A("back")})]})]})]})})})]})}function T({icon:s,label:t,description:a,checked:r,onChange:i,disabled:n}){return e.jsxs("div",{className:"flex items-center justify-between p-4 hover:bg-gray-50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-4 flex-1 min-w-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-gray-100 flex items-center justify-center text-gray-600 shrink-0",children:e.jsx(s,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900 block",children:t}),a&&e.jsx("span",{className:"text-xs text-gray-500 block mt-0.5",children:a})]})]}),e.jsx(j,{checked:r,onCheckedChange:i,disabled:n,className:"data-[state=checked]:bg-orange-500 shrink-0 ml-3"})]})}export{O 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.