|
| 1 | +<script setup lang="ts"> |
| 2 | +import { computed } from 'vue' |
| 3 | +import { useRoute } from '#app' |
| 4 | +
|
| 5 | +// Get status and message from URL query parameters |
| 6 | +const route = useRoute() |
| 7 | +const status = computed(() => route.query.status as string) |
| 8 | +const message = computed(() => route.query.message as string) |
| 9 | +
|
| 10 | +const isSuccess = computed(() => status.value === 'success') |
| 11 | +const isError = computed(() => status.value === 'error') |
| 12 | +
|
| 13 | +// Props for customization |
| 14 | +interface Props { |
| 15 | + successTitle?: string |
| 16 | + errorTitle?: string |
| 17 | + loginButtonText?: string |
| 18 | + loginUrl?: string |
| 19 | + showLoginButton?: boolean |
| 20 | +} |
| 21 | +
|
| 22 | +const _props = withDefaults(defineProps<Props>(), { |
| 23 | + successTitle: 'Email Confirmed!', |
| 24 | + errorTitle: 'Confirmation Failed', |
| 25 | + loginButtonText: 'Continue to Login', |
| 26 | + loginUrl: '/login', |
| 27 | + showLoginButton: true |
| 28 | +}) |
| 29 | +</script> |
| 30 | + |
| 31 | +<template> |
| 32 | + <div class="n-users-section"> |
| 33 | + <div class="n-users-card"> |
| 34 | + <!-- Success state --> |
| 35 | + <div |
| 36 | + v-if="isSuccess" |
| 37 | + class="n-users-confirmation-content" |
| 38 | + > |
| 39 | + <slot name="success-icon"> |
| 40 | + <div class="n-users-confirmation-icon n-users-confirmation-success"> |
| 41 | + <svg |
| 42 | + viewBox="0 0 24 24" |
| 43 | + fill="none" |
| 44 | + stroke="currentColor" |
| 45 | + stroke-width="2" |
| 46 | + > |
| 47 | + <path d="m9 12 2 2 4-4" /> |
| 48 | + <circle |
| 49 | + cx="12" |
| 50 | + cy="12" |
| 51 | + r="10" |
| 52 | + /> |
| 53 | + </svg> |
| 54 | + </div> |
| 55 | + </slot> |
| 56 | + |
| 57 | + <div class="n-users-section-header"> |
| 58 | + <slot name="success-content"> |
| 59 | + <h1 class="n-users-login-title"> |
| 60 | + {{ successTitle }} |
| 61 | + </h1> |
| 62 | + <div class="n-users-success-message"> |
| 63 | + {{ message || 'Your email has been confirmed and your account is now active.' }} |
| 64 | + </div> |
| 65 | + </slot> |
| 66 | + </div> |
| 67 | + |
| 68 | + <slot name="success-actions"> |
| 69 | + <div |
| 70 | + v-if="showLoginButton" |
| 71 | + class="n-users-form-actions" |
| 72 | + > |
| 73 | + <a |
| 74 | + :href="loginUrl" |
| 75 | + class="n-users-btn n-users-btn-primary" |
| 76 | + > |
| 77 | + {{ loginButtonText }} |
| 78 | + </a> |
| 79 | + </div> |
| 80 | + </slot> |
| 81 | + </div> |
| 82 | + |
| 83 | + <!-- Error state --> |
| 84 | + <div |
| 85 | + v-else-if="isError" |
| 86 | + class="n-users-confirmation-content" |
| 87 | + > |
| 88 | + <slot name="error-icon"> |
| 89 | + <div class="n-users-confirmation-icon n-users-confirmation-error"> |
| 90 | + <svg |
| 91 | + viewBox="0 0 24 24" |
| 92 | + fill="none" |
| 93 | + stroke="currentColor" |
| 94 | + stroke-width="2" |
| 95 | + > |
| 96 | + <circle |
| 97 | + cx="12" |
| 98 | + cy="12" |
| 99 | + r="10" |
| 100 | + /> |
| 101 | + <line |
| 102 | + x1="15" |
| 103 | + y1="9" |
| 104 | + x2="9" |
| 105 | + y2="15" |
| 106 | + /> |
| 107 | + <line |
| 108 | + x1="9" |
| 109 | + y1="9" |
| 110 | + x2="15" |
| 111 | + y2="15" |
| 112 | + /> |
| 113 | + </svg> |
| 114 | + </div> |
| 115 | + </slot> |
| 116 | + |
| 117 | + <div class="n-users-section-header"> |
| 118 | + <slot name="error-content"> |
| 119 | + <h1 class="n-users-login-title"> |
| 120 | + {{ errorTitle }} |
| 121 | + </h1> |
| 122 | + <div class="n-users-error-message"> |
| 123 | + {{ message || 'The confirmation link is invalid or has expired. Please try registering again or contact support.' }} |
| 124 | + </div> |
| 125 | + </slot> |
| 126 | + </div> |
| 127 | + |
| 128 | + <slot name="error-actions"> |
| 129 | + <div class="n-users-form-actions"> |
| 130 | + <a |
| 131 | + :href="loginUrl" |
| 132 | + class="n-users-btn n-users-btn-secondary" |
| 133 | + > |
| 134 | + Back to Login |
| 135 | + </a> |
| 136 | + </div> |
| 137 | + </slot> |
| 138 | + </div> |
| 139 | + |
| 140 | + <!-- Loading/unknown state --> |
| 141 | + <div |
| 142 | + v-else |
| 143 | + class="n-users-confirmation-content" |
| 144 | + > |
| 145 | + <slot name="loading-content"> |
| 146 | + <div class="n-users-confirmation-icon"> |
| 147 | + <div class="n-users-loading-spinner n-users-confirmation-spinner" /> |
| 148 | + </div> |
| 149 | + <div class="n-users-section-header"> |
| 150 | + <h1 class="n-users-login-title"> |
| 151 | + Processing... |
| 152 | + </h1> |
| 153 | + <div class="n-users-form-help"> |
| 154 | + Please wait while we process your email confirmation. |
| 155 | + </div> |
| 156 | + </div> |
| 157 | + </slot> |
| 158 | + </div> |
| 159 | + </div> |
| 160 | + </div> |
| 161 | +</template> |
| 162 | + |
| 163 | +<style scoped> |
| 164 | +/* Only add minimal styles needed for this specific component */ |
| 165 | +.n-users-confirmation-content { |
| 166 | + text-align: center; |
| 167 | + padding: 2rem; |
| 168 | +} |
| 169 | +
|
| 170 | +.n-users-confirmation-icon { |
| 171 | + width: 80px; |
| 172 | + height: 80px; |
| 173 | + margin: 0 auto 2rem; |
| 174 | + border-radius: 50%; |
| 175 | + display: flex; |
| 176 | + align-items: center; |
| 177 | + justify-content: center; |
| 178 | +} |
| 179 | +
|
| 180 | +.n-users-confirmation-icon svg { |
| 181 | + width: 40px; |
| 182 | + height: 40px; |
| 183 | +} |
| 184 | +
|
| 185 | +.n-users-confirmation-success { |
| 186 | + background-color: var(--nu-color-success-light); |
| 187 | + color: var(--nu-color-success); |
| 188 | +} |
| 189 | +
|
| 190 | +.n-users-confirmation-error { |
| 191 | + background-color: var(--nu-color-error-light); |
| 192 | + color: var(--nu-color-error); |
| 193 | +} |
| 194 | +
|
| 195 | +.n-users-confirmation-spinner { |
| 196 | + width: 40px; |
| 197 | + height: 40px; |
| 198 | + border-width: 4px; |
| 199 | + border-color: var(--nu-color-primary); |
| 200 | + border-top-color: transparent; |
| 201 | +} |
| 202 | +
|
| 203 | +/* Mobile responsiveness */ |
| 204 | +@media (max-width: 640px) { |
| 205 | + .n-users-confirmation-content { |
| 206 | + padding: 1.5rem; |
| 207 | + } |
| 208 | +
|
| 209 | + .n-users-confirmation-icon { |
| 210 | + width: 60px; |
| 211 | + height: 60px; |
| 212 | + margin-bottom: 1.5rem; |
| 213 | + } |
| 214 | +
|
| 215 | + .n-users-confirmation-icon svg { |
| 216 | + width: 30px; |
| 217 | + height: 30px; |
| 218 | + } |
| 219 | +} |
| 220 | +</style> |
0 commit comments