From 21aed7c58b4e8e538af9bae6d55b23e7732706b2 Mon Sep 17 00:00:00 2001
From: Hangzhi Yu <hangzhi@protonmail.com>
Date: Wed, 26 Mar 2025 01:06:54 +0100
Subject: [PATCH] Complete account wizard summary

---
 .../account/AccountRegistrationForm.vue       | 23 +++++++++++++--
 .../components/person/PersonDetailsCard.vue   | 28 ++++++++++++++++++-
 aleksis/core/frontend/messages/en.json        |  3 +-
 3 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/aleksis/core/frontend/components/account/AccountRegistrationForm.vue b/aleksis/core/frontend/components/account/AccountRegistrationForm.vue
index 6df9a9951..340644118 100644
--- a/aleksis/core/frontend/components/account/AccountRegistrationForm.vue
+++ b/aleksis/core/frontend/components/account/AccountRegistrationForm.vue
@@ -520,7 +520,7 @@ import PersonDetailsCard from "../person/PersonDetailsCard.vue";
 
           <v-stepper-content :step="getStepIndex('confirm')">
             <h2 class="text-h6 mb-4">{{ $t(getStepTitleKey("confirm")) }}</h2>
-            <person-details-card class="mb-4" :person="personDataForSummary" />
+            <person-details-card class="mb-4" :person="personDataForSummary" :show-username="true" title-key="accounts.signup.form.steps.confirm.card_title" />
 
             <ApolloMutation
               :mutation="require('./accountRegistrationMutation.graphql')"
@@ -644,9 +644,26 @@ export default {
       if (!this.data.email.localPart && !this.data.email.domain) {
         const { email, ...filteredData } = data;
         data = filteredData;
+      } else {
+        data = {
+          ...data,
+          email: {
+            localPart: data.email.localPart,
+            domain: data.email.domain.id,
+          },
+        };
       }
       return data;
     },
+    currentEmail() {
+      if (this.emailMode === 0 && this.data.email.localPart && this.data.email.domain) {
+        return `${this.data.email.localPart}@${this.data.email.domain.domain}`;
+      } else if (this.data.user.email) {
+        return this.data.user.email;
+      } else {
+        return null;
+      }
+    },
     personDataForSummary() {
       return {
         ...this.data.person,
@@ -659,6 +676,8 @@ export default {
             country: this.data.person.country,
           },
         ],
+        username: this.data.user.username,
+        email: this.currentEmail,
       }
     },
     steps() {
@@ -715,7 +734,7 @@ export default {
       data: {
         email: {
           localPart: "",
-          domain: "",
+          domain: {},
         },
         person: {
           firstName: "",
diff --git a/aleksis/core/frontend/components/person/PersonDetailsCard.vue b/aleksis/core/frontend/components/person/PersonDetailsCard.vue
index c7aeaef77..b0468cca2 100644
--- a/aleksis/core/frontend/components/person/PersonDetailsCard.vue
+++ b/aleksis/core/frontend/components/person/PersonDetailsCard.vue
@@ -1,6 +1,6 @@
 <template>
   <v-card v-bind="$attrs">
-    <v-card-title>{{ $t("person.details") }}</v-card-title>
+    <v-card-title>{{ $t(titleKey) }}</v-card-title>
 
     <v-list two-line>
       <v-list-item>
@@ -21,6 +21,22 @@
       </v-list-item>
       <v-divider inset />
 
+      <v-list-item v-if="showUsername">
+        <v-list-item-icon>
+          <v-icon> mdi-login-variant</v-icon>
+        </v-list-item-icon>
+
+        <v-list-item-content>
+          <v-list-item-title>
+            {{ person.username }}
+          </v-list-item-title>
+          <v-list-item-subtitle>
+            {{ $t("person.username") }}
+          </v-list-item-subtitle>
+        </v-list-item-content>
+      </v-list-item>
+      <v-divider inset />
+
       <v-list-item>
         <v-list-item-icon>
           <v-icon> mdi-human-non-binary</v-icon>
@@ -186,6 +202,16 @@ export default {
       type: Object,
       required: true,
     },
+    showUsername: {
+      type: Boolean,
+      required: false,
+      default: false,
+    },
+    titleKey: {
+      type: String,
+      required: false,
+      default: "person.details",
+    },
   },
 }
 </script>
diff --git a/aleksis/core/frontend/messages/en.json b/aleksis/core/frontend/messages/en.json
index 970256ff3..c5dcea2a6 100644
--- a/aleksis/core/frontend/messages/en.json
+++ b/aleksis/core/frontend/messages/en.json
@@ -148,7 +148,8 @@
             }
           },
           "confirm": {
-            "title": "Confirm"
+            "title": "Confirm account registration",
+            "card_title": "Your account data"
           }
         },
         "rules": {
-- 
GitLab