From a93389f5c5ae870c44f4fe1e7e7c8614e7a10f63 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Thu, 26 Dec 2024 19:06:56 -0500
Subject: [PATCH 1/6] add simple verify email page
---
.../internal/views/verify_email_page.templ | 88 +++++++
.../internal/views/verify_email_page_templ.go | 221 ++++++++++++++++++
2 files changed, 309 insertions(+)
create mode 100644 backend/internal/views/verify_email_page.templ
create mode 100644 backend/internal/views/verify_email_page_templ.go
diff --git a/backend/internal/views/verify_email_page.templ b/backend/internal/views/verify_email_page.templ
new file mode 100644
index 00000000..ed71dda7
--- /dev/null
+++ b/backend/internal/views/verify_email_page.templ
@@ -0,0 +1,88 @@
+package views
+
+type VerifyEmailPageVariant string
+
+const (
+ SuccessVerifyEmailPage VerifyEmailPageVariant = "success"
+ FailVerifyEmailPage VerifyEmailPageVariant = "fail"
+)
+
+css main() {
+ background-color: #f8fafc;
+ height: 100vh;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
+
+css card() {
+ padding: 2rem;
+ border-width: 1px;
+ border-radius: 0.25rem;
+ border-style: solid;
+ border-color: #cbd5e1;
+ box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
+ max-width: 28rem;
+}
+
+templ VerifyEmailPage(variant VerifyEmailPageVariant, details string) {
+
+
+ ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var5 = []any{card()}
+ templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var5...)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var7 string
+ templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(getCardTitle(variant))
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/verify_email_page.templ`, Line: 45, Col: 32}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if details == "" {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var8 string
+ templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(getCardContent(variant))
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/verify_email_page.templ`, Line: 47, Col: 34}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ } else {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var9 string
+ templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(details)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/verify_email_page.templ`, Line: 49, Col: 18}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func getTitle(variant VerifyEmailPageVariant) string {
+ switch variant {
+ case SuccessVerifyEmailPage:
+ return "Email Verified"
+ case FailVerifyEmailPage:
+ return "Email Not Verified"
+ }
+
+ return "Oops... Something went wrong"
+}
+
+func getCardTitle(variant VerifyEmailPageVariant) string {
+ switch variant {
+ case SuccessVerifyEmailPage:
+ return "Your email has been verified."
+ case FailVerifyEmailPage:
+ return "Hmmm... something went wrong"
+ }
+
+ return "Oops... Something went wrong"
+}
+
+func getCardContent(variant VerifyEmailPageVariant) string {
+ switch variant {
+ case SuccessVerifyEmailPage:
+ return "You can close this window now."
+ case FailVerifyEmailPage:
+ return "Please try again by requesting a new verification email.\nIf the problem persists, please try again later."
+ }
+
+ return "Oops... Something went wrong"
+}
+
+var _ = templruntime.GeneratedTemplate
From aa28d30ccf8b33088a0bdd378e3809b032f468b3 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Thu, 26 Dec 2024 20:35:07 -0500
Subject: [PATCH 2/6] update verify email page template
---
.../internal/views/verify_email_page.templ | 83 ++++++-
.../internal/views/verify_email_page_templ.go | 230 ++++++++++++++++--
2 files changed, 283 insertions(+), 30 deletions(-)
diff --git a/backend/internal/views/verify_email_page.templ b/backend/internal/views/verify_email_page.templ
index ed71dda7..4dfa4334 100644
--- a/backend/internal/views/verify_email_page.templ
+++ b/backend/internal/views/verify_email_page.templ
@@ -15,8 +15,18 @@ css main() {
align-items: center;
}
+css xIcon() {
+ width: 4rem;
+ color: #dc2626;
+}
+
+css checkIcon() {
+ width: 4rem;
+ color: #22c55e;
+}
+
css card() {
- padding: 2rem;
+ padding: 1.5rem;
border-width: 1px;
border-radius: 0.25rem;
border-style: solid;
@@ -25,7 +35,32 @@ css card() {
max-width: 28rem;
}
-templ VerifyEmailPage(variant VerifyEmailPageVariant, details string) {
+css cardContent() {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ color: #475569;
+}
+
+css button() {
+ text-decoration: none;
+ color: white;
+ padding: 1rem 2rem;
+ background-color: black;
+ border-radius: 0.25rem;
+ max-width: 24rem;
+ display: inline-block;
+}
+
+css cardFooter() {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ margin-top: 1rem;
+}
+
+templ VerifyEmailPage(variant VerifyEmailPageVariant, url string, details string) {
+
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if variant == SuccessVerifyEmailPage {
+ var templ_7745c5c3_Var10 = []any{checkIcon()}
+ templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var10...)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ } else {
+ var templ_7745c5c3_Var12 = []any{xIcon()}
+ templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var12...)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
if details == "" {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- var templ_7745c5c3_Var8 string
- templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(getCardContent(variant))
+ var templ_7745c5c3_Var14 string
+ templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(getCardContent(variant))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/verify_email_page.templ`, Line: 47, Col: 34}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/verify_email_page.templ`, Line: 102, Col: 35}
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -163,12 +296,12 @@ func VerifyEmailPage(variant VerifyEmailPageVariant, details string) templ.Compo
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- var templ_7745c5c3_Var9 string
- templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(details)
+ var templ_7745c5c3_Var15 string
+ templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(details)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/verify_email_page.templ`, Line: 49, Col: 18}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/verify_email_page.templ`, Line: 104, Col: 19}
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -177,7 +310,66 @@ func VerifyEmailPage(variant VerifyEmailPageVariant, details string) templ.Compo
return templ_7745c5c3_Err
}
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var16 = []any{cardFooter()}
+ templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var16...)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if variant == SuccessVerifyEmailPage {
+ var templ_7745c5c3_Var18 = []any{button()}
+ templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var18...)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Go to Dashboard")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -188,7 +380,7 @@ func VerifyEmailPage(variant VerifyEmailPageVariant, details string) templ.Compo
func getTitle(variant VerifyEmailPageVariant) string {
switch variant {
case SuccessVerifyEmailPage:
- return "Email Verified"
+ return "Email Verified Successfully"
case FailVerifyEmailPage:
return "Email Not Verified"
}
@@ -199,9 +391,9 @@ func getTitle(variant VerifyEmailPageVariant) string {
func getCardTitle(variant VerifyEmailPageVariant) string {
switch variant {
case SuccessVerifyEmailPage:
- return "Your email has been verified."
+ return "Email Verified Successfully"
case FailVerifyEmailPage:
- return "Hmmm... something went wrong"
+ return "Failed to Verify Email"
}
return "Oops... Something went wrong"
@@ -210,7 +402,7 @@ func getCardTitle(variant VerifyEmailPageVariant) string {
func getCardContent(variant VerifyEmailPageVariant) string {
switch variant {
case SuccessVerifyEmailPage:
- return "You can close this window now."
+ return "Thank you for verifying your email address. You can now close this window or click the button below to go open the dashboard."
case FailVerifyEmailPage:
return "Please try again by requesting a new verification email.\nIf the problem persists, please try again later."
}
From 033e59569d2c7f52b2e89dce3f8fe5f53e715f3b Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Thu, 26 Dec 2024 20:54:39 -0500
Subject: [PATCH 3/6] add internal error variant view
---
backend/internal/views/verify_email_page.templ | 3 ++-
backend/internal/views/verify_email_page_templ.go | 11 ++++++-----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/backend/internal/views/verify_email_page.templ b/backend/internal/views/verify_email_page.templ
index 4dfa4334..396a4a9f 100644
--- a/backend/internal/views/verify_email_page.templ
+++ b/backend/internal/views/verify_email_page.templ
@@ -5,6 +5,7 @@ type VerifyEmailPageVariant string
const (
SuccessVerifyEmailPage VerifyEmailPageVariant = "success"
FailVerifyEmailPage VerifyEmailPageVariant = "fail"
+ InternalErrorEmailPage VerifyEmailPageVariant = "internal"
)
css main() {
@@ -105,7 +106,7 @@ templ VerifyEmailPage(variant VerifyEmailPageVariant, url string, details string
}