kuni 3 weeks ago
parent
commit
ce5ff462e4
2 changed files with 22 additions and 16 deletions
  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 View File

104
     const today = this.toDateOnly(new Date());
104
     const today = this.toDateOnly(new Date());
105
     const endDate = this.addDays(today, 30);
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
         const deathDate = this.parseDate(kakocho.deathDate);
111
         const deathDate = this.parseDate(kakocho.deathDate);
111
-        if (!deathDate) {
112
-          return null;
113
-        }
112
+        if (!deathDate) return null;
114
 
113
 
115
         const eventDate = new Date(this.targetYear, deathDate.getMonth(), deathDate.getDate());
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
         const memorialType = this.getMemorialType(deathDate);
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
         const type = memorialType ? '年忌法要' : '命日';
121
         const type = memorialType ? '年忌法要' : '命日';
123
         const status = memorialType ? '準備確認' : '要確認';
122
         const status = memorialType ? '準備確認' : '要確認';
124
 
123
 
133
           status,
132
           status,
134
         };
133
         };
135
       })
134
       })
135
+    );
136
+
137
+    this.upcomingMemorials = results
136
       .filter((memorial): memorial is UpcomingMemorial => memorial !== null)
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
       .slice(0, 3);
143
       .slice(0, 3);
139
   }
144
   }
140
 
145
 

+ 6
- 5
src/app/pages/family-edit/family-edit.ts View File

163
     );
163
     );
164
   }
164
   }
165
 
165
 
166
-  saveFamily() {
166
+  async saveFamily() {
167
     if (this.familyForm.invalid) {
167
     if (this.familyForm.invalid) {
168
       return;
168
       return;
169
     }
169
     }
190
     };
190
     };
191
 
191
 
192
     if (spouseId) {
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
         dankaId,
197
         dankaId,
197
         person1Id: familyId,
198
         person1Id: familyId,
198
         person2Id: spouseId,
199
         person2Id: spouseId,
207
         return;
208
         return;
208
       }
209
       }
209
     } else {
210
     } else {
210
-      const currentMarriage = this.marriageRelationService.getCurrentMarriageByFamilyId(familyId);
211
+      const currentMarriage = await this.marriageRelationService.getCurrentMarriageByFamilyId(familyId);
211
       if (currentMarriage) {
212
       if (currentMarriage) {
212
         this.marriageRelationService.deleteMarriageRelation(currentMarriage.id);
213
         this.marriageRelationService.deleteMarriageRelation(currentMarriage.id);
213
       }
214
       }

Loading…
Cancel
Save