kuni 3 viikkoa sitten
vanhempi
commit
ce5ff462e4
2 muutettua tiedostoa jossa 22 lisäystä ja 16 poistoa
  1. 16
    11
      src/app/pages/dashboard/dashboard.ts
  2. 6
    5
      src/app/pages/family-edit/family-edit.ts

+ 16
- 11
src/app/pages/dashboard/dashboard.ts Näytä tiedosto

@@ -104,21 +104,20 @@ export class Dashboard {
104 104
     const today = this.toDateOnly(new Date());
105 105
     const endDate = this.addDays(today, 30);
106 106
 
107
-    this.upcomingMemorials = (await this.kakochoService
108
-      .getKakochoList())
109
-      .map((kakocho): UpcomingMemorial | null => {
107
+    const kakochoList = await this.kakochoService.getKakochoList();
108
+
109
+    const results = await Promise.all(
110
+      kakochoList.map(async (kakocho): Promise<UpcomingMemorial | null> => {
110 111
         const deathDate = this.parseDate(kakocho.deathDate);
111
-        if (!deathDate) {
112
-          return null;
113
-        }
112
+        if (!deathDate) return null;
114 113
 
115 114
         const eventDate = new Date(this.targetYear, deathDate.getMonth(), deathDate.getDate());
116
-        if (eventDate < today || eventDate > endDate) {
117
-          return null;
118
-        }
115
+        if (eventDate < today || eventDate > endDate) return null;
119 116
 
120 117
         const memorialType = this.getMemorialType(deathDate);
121
-        const danka = this.dankaService.getDankaById(kakocho.dankaId);
118
+
119
+        const danka = await this.dankaService.getDankaById(kakocho.dankaId);
120
+
122 121
         const type = memorialType ? '年忌法要' : '命日';
123 122
         const status = memorialType ? '準備確認' : '要確認';
124 123
 
@@ -133,8 +132,14 @@ export class Dashboard {
133 132
           status,
134 133
         };
135 134
       })
135
+    );
136
+
137
+    this.upcomingMemorials = results
136 138
       .filter((memorial): memorial is UpcomingMemorial => memorial !== null)
137
-      .sort((a, b) => a.date.getTime() - b.date.getTime() || a.title.localeCompare(b.title, 'ja'))
139
+      .sort((a, b) =>
140
+        a.date.getTime() - b.date.getTime() ||
141
+        a.title.localeCompare(b.title, 'ja')
142
+      )
138 143
       .slice(0, 3);
139 144
   }
140 145
 

+ 6
- 5
src/app/pages/family-edit/family-edit.ts Näytä tiedosto

@@ -163,7 +163,7 @@ export class FamilyEdit implements OnInit {
163 163
     );
164 164
   }
165 165
 
166
-  saveFamily() {
166
+  async saveFamily() {
167 167
     if (this.familyForm.invalid) {
168 168
       return;
169 169
     }
@@ -190,9 +190,10 @@ export class FamilyEdit implements OnInit {
190 190
     };
191 191
 
192 192
     if (spouseId) {
193
-      const existingRelation = this.findMarriageRelation(familyId, spouseId);
194
-      const errors = this.marriageRelationService.saveMarriageRelation({
195
-        id: existingRelation?.id ?? Date.now().toString(),
193
+      const existingRelation = await this.findMarriageRelation(familyId, spouseId);
194
+
195
+      const errors = await this.marriageRelationService.saveMarriageRelation({
196
+        id: existingRelation?.id ?? crypto.randomUUID(),
196 197
         dankaId,
197 198
         person1Id: familyId,
198 199
         person2Id: spouseId,
@@ -207,7 +208,7 @@ export class FamilyEdit implements OnInit {
207 208
         return;
208 209
       }
209 210
     } else {
210
-      const currentMarriage = this.marriageRelationService.getCurrentMarriageByFamilyId(familyId);
211
+      const currentMarriage = await this.marriageRelationService.getCurrentMarriageByFamilyId(familyId);
211 212
       if (currentMarriage) {
212 213
         this.marriageRelationService.deleteMarriageRelation(currentMarriage.id);
213 214
       }

Loading…
Peruuta
Tallenna