diff --git a/web-app/app/[locale]/email/unsubscribe/[id]/EmailUnsubscribePage.tsx b/web-app/app/[locale]/email/unsubscribe/[id]/EmailUnsubscribePage.tsx new file mode 100644 index 0000000..5d3d0b6 --- /dev/null +++ b/web-app/app/[locale]/email/unsubscribe/[id]/EmailUnsubscribePage.tsx @@ -0,0 +1,105 @@ +'use client'; + +import { useTranslations } from 'next-intl'; +import { useState } from 'react'; +import { unsubscribeTenantEmail } from '@/app/lib/actions/emailActions'; +import { CheckCircleIcon } from '@heroicons/react/24/outline'; + +interface EmailUnsubscribePageProps { + shareId: string; +} + +export default function EmailUnsubscribePage({ shareId }: EmailUnsubscribePageProps) { + const t = useTranslations('email-unsubscribe-page'); + const [isUnsubscribing, setIsUnsubscribing] = useState(false); + const [isUnsubscribed, setIsUnsubscribed] = useState(false); + const [error, setError] = useState(null); + + const handleUnsubscribe = async () => { + setIsUnsubscribing(true); + setError(null); + + try { + const result = await unsubscribeTenantEmail(shareId); + + if (result.success) { + setIsUnsubscribed(true); + } else { + setError(result.message || t('error.unknown')); + } + } catch (err) { + setError(t('error.unknown')); + } finally { + setIsUnsubscribing(false); + } + }; + + if (isUnsubscribed) { + return ( +
+
+
+ +
+

+ {t('success.title')} +

+

{t('success.message')}

+
+
+ ); + } + + if (error) { + return ( +
+
+

{t('error.title')}

+

{error}

+
+
+ ); + } + + return ( +
+
+

{t('title')}

+ +
+
+

{t('about.title')}

+

{t('about.description')}

+
+ +
+

{t('why.title')}

+

{t('why.description')}

+
+ +
+

{t('what-happens.title')}

+

{t('what-happens.description')}

+
+
+ +
+ +
+
+
+ ); +} diff --git a/web-app/app/[locale]/email/unsubscribe/[id]/page.tsx b/web-app/app/[locale]/email/unsubscribe/[id]/page.tsx new file mode 100644 index 0000000..4300d9e --- /dev/null +++ b/web-app/app/[locale]/email/unsubscribe/[id]/page.tsx @@ -0,0 +1,13 @@ +import { Suspense } from 'react'; +import EmailUnsubscribePage from './EmailUnsubscribePage'; +import { Main } from '@/app/ui/Main'; + +export default async function Page({ params: { id } }: { params: { id: string } }) { + return ( +
+ Loading...}> + + +
+ ); +} diff --git a/web-app/messages/en.json b/web-app/messages/en.json index 6c16d66..c1c1d43 100644 --- a/web-app/messages/en.json +++ b/web-app/messages/en.json @@ -446,6 +446,33 @@ "unknown": "An error occurred during verification. Please try again or contact your landlord." } }, + "email-unsubscribe-page": { + "title": "Unsubscribe from Email Notifications", + "about": { + "title": "About Evidencija Režija", + "description": "Evidencija Režija is a utility bills tracking application that helps landlords manage their properties and notify tenants about rent and utility bills." + }, + "why": { + "title": "Why are you receiving emails?", + "description": "Your landlord has configured the application to send rent due and/or utility bills notifications to your email address." + }, + "what-happens": { + "title": "What happens after unsubscribing?", + "description": "After you unsubscribe, you will no longer receive any rent due or utility bill notifications via email. Your landlord will need to contact you through other means." + }, + "button": { + "unsubscribe": "Confirm Unsubscribe", + "unsubscribing": "Unsubscribing..." + }, + "success": { + "title": "Successfully Unsubscribed", + "message": "You have been unsubscribed from email notifications. You will no longer receive rent or utility bill reminders." + }, + "error": { + "title": "Unsubscribe Failed", + "unknown": "An error occurred while unsubscribing. Please try again or contact your landlord." + } + }, "privacy-policy-page": { "title": "Privacy Policy for the Utility Bill Tracking Web App", "meta": { diff --git a/web-app/messages/hr.json b/web-app/messages/hr.json index 0f6c1a2..f20a9ee 100644 --- a/web-app/messages/hr.json +++ b/web-app/messages/hr.json @@ -443,6 +443,33 @@ "unknown": "Došlo je do greške prilikom potvrde. Molimo pokušajte ponovno ili kontaktirajte vašeg vlasnika nekretnine." } }, + "email-unsubscribe-page": { + "title": "Odjava od Email Obavijesti", + "about": { + "title": "O aplikaciji Evidencija Režija", + "description": "Evidencija Režija je aplikacija za praćenje režija koja pomaže vlasnicicama nekretnina da upravljaju svojim objektima i obavještavaju zakupce o dospjeloj najamnini i režijama." + }, + "why": { + "title": "Zašto primate emailove?", + "description": "Vaš vlasnik nekretnine je konfigurirao aplikaciju da šalje obavijesti o dospjeloj najamnini i/ili režijama na vašu email adresu." + }, + "what-happens": { + "title": "Što se događa nakon odjave?", + "description": "Nakon što se odjavite, više nećete primati nikakve obavijesti o dospjeloj najamnini ili režijama putem emaila. Vaš vlasnik nekretnine će vas morati kontaktirati drugim putem." + }, + "button": { + "unsubscribe": "Potvrdi Odjavu", + "unsubscribing": "Odjava u tijeku..." + }, + "success": { + "title": "Uspješno Odjavljeni", + "message": "Odjavljeni ste od email obavijesti. Više nećete primati podsjednike o najamnini ili režijama." + }, + "error": { + "title": "Odjava Nije Uspjela", + "unknown": "Došlo je do greške prilikom odjave. Molimo pokušajte ponovno ili kontaktirajte vašeg vlasnika nekretnine." + } + }, "privacy-policy-page": { "title": "Politika privatnosti za web aplikaciju za evidenciju režija", "meta": {