Kaynağa Gözat

Merge branch 'feature/family-info'

# Conflicts:
#	src/app/app.routes.ts
#	src/app/pages/danka-detail/danka-detail.ts
poohr 3 hafta önce
ebeveyn
işleme
ef51927ee1

+ 11
- 0
src/app/app.routes.ts Dosyayı Görüntüle

@@ -3,6 +3,8 @@ import { Dashboard } from './pages/dashboard/dashboard';
3 3
 import { DankaList } from './pages/danka-list/danka-list';
4 4
 import { DankaDetail } from './pages/danka-detail/danka-detail';
5 5
 import { DankaEdit } from './pages/danka-edit/danka-edit';
6
+import {FamilyEdit} from './pages/family-edit/family-edit';
7
+
6 8
 import { KakochoEdit } from './pages/kakocho-edit/kakocho-edit';
7 9
 
8 10
 export const routes: Routes = [
@@ -26,6 +28,15 @@ export const routes: Routes = [
26 28
     path: 'danka-edit/:id',
27 29
     component: DankaEdit,
28 30
   },
31
+  {
32
+    path: 'danka/:dankaId/family-new',
33
+    component: FamilyEdit,
34
+  },
35
+  {
36
+    path: 'danka/:dankaId/family/:familyId/edit',
37
+    component: FamilyEdit,
38
+  },
39
+  },
29 40
   {
30 41
     path: 'kakocho-edit/:dankaId',
31 42
     component: KakochoEdit,

+ 10
- 1
src/app/pages/danka-detail/danka-detail.html Dosyayı Görüntüle

@@ -257,6 +257,7 @@
257 257
                     <div>年齢</div>
258 258
                     <div>生年月日</div>
259 259
                     <div>備考</div>
260
+                    <div>操作</div>
260 261
                   </div>
261 262
 
262 263
                   @for (family of families; track family.id) {
@@ -274,7 +275,7 @@
274 275
                       </div>
275 276
 
276 277
                       <div>
277
-                        -
278
+                        {{ getAge(family.birthDate) }}
278 279
                       </div>
279 280
 
280 281
                       <div>
@@ -284,6 +285,14 @@
284 285
                       <div>
285 286
                         {{ family.note || '' }}
286 287
                       </div>
288
+                      <div class="family-table-action">
289
+                        <a
290
+                          class="family-edit-link"
291
+                          [routerLink]="['/danka', danka.id, 'family', family.id, 'edit']"
292
+                        >
293
+                          編集
294
+                        </a>
295
+                      </div>
287 296
                     </div>
288 297
                   }
289 298
                 </div>

+ 28
- 2
src/app/pages/danka-detail/danka-detail.scss Dosyayı Görüntüle

@@ -462,11 +462,37 @@
462 462
 .family-table-header,
463 463
 .family-table-row {
464 464
   display: grid;
465
-  grid-template-columns: 1.2fr 1.2fr 0.8fr 0.6fr 1fr 1.4fr;
465
+  grid-template-columns: 1.1fr 1.1fr 0.8fr 0.6fr 1fr 1.2fr 80px;
466 466
   gap: 10px;
467 467
   align-items: center;
468 468
 }
469 469
 
470
+.family-table-action {
471
+  display: flex;
472
+  justify-content: center;
473
+  align-items: center;
474
+}
475
+
476
+.family-edit-link {
477
+  width: 64px;
478
+  height: 34px;
479
+  border: 2px solid #8a6543;
480
+  border-radius: 6px;
481
+  background: #ffffff;
482
+  color: #8a6543;
483
+  font-size: 14px;
484
+  font-weight: 800;
485
+  text-decoration: none;
486
+  display: flex;
487
+  align-items: center;
488
+  justify-content: center;
489
+  box-sizing: border-box;
490
+}
491
+
492
+.family-edit-link:hover {
493
+  background: #f6efe6;
494
+}
495
+
470 496
 .family-table-header {
471 497
   padding: 12px 14px;
472 498
   background: #efe4d6;
@@ -553,7 +579,7 @@
553 579
 
554 580
   .family-table-header,
555 581
   .family-table-row {
556
-    min-width: 760px;
582
+    min-width: 880px;
557 583
   }
558 584
 
559 585
   .family-support-area {

+ 29
- 1
src/app/pages/danka-detail/danka-detail.ts Dosyayı Görüntüle

@@ -1,5 +1,5 @@
1 1
 import { Component } from '@angular/core';
2
-import { ActivatedRoute, RouterLink } from '@angular/router';
2
+import { ActivatedRoute, Router, RouterLink } from '@angular/router';
3 3
 import { DankaService } from '../../services/dankaService';
4 4
 import { FamilyService } from '../../services/family-service';
5 5
 import { Danka } from '../../models/danka';
@@ -29,6 +29,16 @@ export class DankaDetail {
29 29
     private kakochoService: KakochoService,
30 30
     private route: ActivatedRoute,
31 31
   ) {
32
+    //遷移先からタブ情報を取得
33
+    const tab = this.route.snapshot.queryParams['tab'];
34
+    if (tab === 'family') {
35
+      this.selectedTab = 'family';
36
+    } else if (tab === 'kakocho') {
37
+      this.selectedTab = 'kakocho';
38
+    } else if (tab === 'familyTree') {
39
+      this.selectedTab = 'familyTree';
40
+    }
41
+    //遷移先のIDから該当の世帯と家族基本を取得
32 42
     const id = this.route.snapshot.params['id'];
33 43
     if (id) {
34 44
       this.danka = this.dankaService.getDankaById(id);
@@ -37,6 +47,24 @@ export class DankaDetail {
37 47
     }
38 48
     console.log(this.danka);
39 49
     console.log(this.families);
50
+    console.log(tab);
51
+  }
52
+
53
+  getAge(birthDate: string) {
54
+    if (birthDate === '') {
55
+      return '-';
56
+    }
57
+
58
+    const birth = new Date(birthDate);
59
+    const today: Date = new Date();
60
+    const thisYearBirthday = new Date(today.getFullYear(), birth.getMonth(), birth.getDate());
61
+
62
+    let age = today.getFullYear() - birth.getFullYear();
63
+
64
+    if (thisYearBirthday > today) {
65
+      age--;
66
+    }
67
+    return age.toString();
40 68
     console.log(this.kakocholist);
41 69
   }
42 70
 

+ 150
- 0
src/app/pages/family-edit/family-edit.html Dosyayı Görüntüle

@@ -0,0 +1,150 @@
1
+<app-header></app-header>
2
+
3
+<div class="breadcrumb">
4
+  ホーム &gt; 檀家(世帯) &gt; 家族 &gt; 編集
5
+</div>
6
+
7
+<div class="danka-edit-page">
8
+  <app-side-menu></app-side-menu>
9
+
10
+  <main class="danka-edit-main">
11
+    <section class="edit-panel">
12
+      <div class="page-title-area">
13
+        <h1>家族(個人)編集</h1>
14
+      </div>
15
+
16
+      <form [formGroup]="familyForm" class="edit-form">
17
+        <div class="edit-content">
18
+          <section class="basic-edit-section">
19
+            <h2>個人情報</h2>
20
+
21
+            <div class="form-list">
22
+              <div class="form-row">
23
+                <label for="name">氏名</label>
24
+                <div class="form-field">
25
+                  <input
26
+                    id="name"
27
+                    type="text"
28
+                    formControlName="name"
29
+                  />
30
+                  @if (familyForm.get('name')?.invalid && familyForm.get('name')?.touched) {
31
+                    <p class="error-message">氏名を入力してください。</p>
32
+                  }
33
+                </div>
34
+              </div>
35
+
36
+              <div class="form-row">
37
+                <label for="furigana">ふりがな</label>
38
+                <div class="form-field">
39
+                  <input
40
+                    id="furigana"
41
+                    type="text"
42
+                    formControlName="furigana"
43
+                  />
44
+                  @if (familyForm.get('furigana')?.invalid && familyForm.get('furigana')?.touched) {
45
+                    <p class="error-message">ふりがなを入力してください。</p>
46
+                  }
47
+                </div>
48
+              </div>
49
+
50
+              <div class="form-row">
51
+                <label for="relationship">世帯主との関係</label>
52
+                <div class="form-field">
53
+                  <select
54
+                    id="relationship"
55
+                    formControlName="relationship"
56
+                  >
57
+                    <option value="">選択してください</option>
58
+                    <option value="世帯主">世帯主</option>
59
+                    <option value="配偶者">配偶者</option>
60
+                    <option value="父">父</option>
61
+                    <option value="母">母</option>
62
+                    <option value="長男">長男</option>
63
+                    <option value="長女">長女</option>
64
+                    <option value="次男">次男</option>
65
+                    <option value="次女">次女</option>
66
+                    <option value="その他">その他</option>
67
+                  </select>
68
+
69
+                  @if (familyForm.get('relationship')?.invalid && familyForm.get('relationship')?.touched) {
70
+                    <p class="error-message">世帯主との関係を選択してください。</p>
71
+                  }
72
+                </div>
73
+              </div>
74
+
75
+              <div class="form-row">
76
+                <label for="birthDate">生年月日</label>
77
+                <div class="form-field">
78
+                  <input
79
+                    id="birthDate"
80
+                    type="date"
81
+                    formControlName="birthDate"
82
+                  />
83
+                </div>
84
+              </div>
85
+
86
+              <div class="form-row">
87
+                <label for="age">年齢</label>
88
+                <div class="form-field">
89
+                  <input
90
+                    id="age"
91
+                    type="text"
92
+                    [value]="getAgeText()"
93
+                    readonly
94
+                  />
95
+                </div>
96
+              </div>
97
+
98
+              <div class="form-row">
99
+                <label for="note">備考</label>
100
+                <div class="form-field">
101
+                  <textarea
102
+                    id="note"
103
+                    formControlName="note"
104
+                    rows="4"
105
+                  ></textarea>
106
+                </div>
107
+              </div>
108
+            </div>
109
+          </section>
110
+
111
+          <section class="phone-edit-section">
112
+            <div class="householder-area">
113
+              <h3>この方を世帯主にする</h3>
114
+
115
+              <button
116
+                type="button"
117
+                class="set-householder-button"
118
+                (click)="setAsHouseholder()"
119
+              >
120
+                世帯主に設定
121
+              </button>
122
+            </div>
123
+          </section>
124
+        </div>
125
+
126
+        <div class="bottom-actions">
127
+          <button
128
+            type="button"
129
+            class="delete-button"
130
+            (click)="deleteFamily()">
131
+            削除
132
+          </button>
133
+
134
+          <button type="button" class="cancel-button" (click)="cancelFamilyEdit()">
135
+            キャンセル
136
+          </button>
137
+
138
+          <button
139
+            type="button"
140
+            class="save-button"
141
+            [disabled]="familyForm.invalid"
142
+            (click)="saveFamily()"
143
+          >
144
+            保存
145
+          </button>
146
+        </div>
147
+      </form>
148
+    </section>
149
+  </main>
150
+</div>

+ 324
- 0
src/app/pages/family-edit/family-edit.scss Dosyayı Görüntüle

@@ -0,0 +1,324 @@
1
+:host {
2
+  position: relative;
3
+  display: block;
4
+  min-height: 100vh;
5
+  background: #f4eee4;
6
+  color: #2f2720;
7
+}
8
+
9
+.breadcrumb {
10
+  position: absolute;
11
+  top: 28px;
12
+  left: 50%;
13
+  transform: translateX(-50%);
14
+  color: #7b6b5c;
15
+  font-size: 14px;
16
+  z-index: 2;
17
+}
18
+
19
+.danka-edit-page {
20
+  display: flex;
21
+  align-items: flex-start;
22
+  gap: 8px;
23
+  background: #f4eee4;
24
+}
25
+
26
+.danka-edit-main {
27
+  flex: 1;
28
+  padding-right: 34px;
29
+  box-sizing: border-box;
30
+}
31
+
32
+.edit-panel {
33
+  min-height: 650px;
34
+  padding: 26px 34px 36px;
35
+  background: #ffffff;
36
+  border: 2px solid #d8caba;
37
+  border-radius: 76px;
38
+  box-sizing: border-box;
39
+}
40
+
41
+.page-title-area {
42
+  margin-bottom: 28px;
43
+}
44
+
45
+.page-title-area h1 {
46
+  margin: 0;
47
+  color: #2f2720;
48
+  font-size: 32px;
49
+  line-height: 1.2;
50
+  font-weight: 800;
51
+  letter-spacing: 0.02em;
52
+}
53
+
54
+.edit-form {
55
+  width: 100%;
56
+}
57
+
58
+.edit-content {
59
+  display: grid;
60
+  grid-template-columns: minmax(0, 1fr) 500px;
61
+  gap: 48px;
62
+  align-items: start;
63
+}
64
+
65
+.basic-edit-section {
66
+  padding-left: 8px;
67
+}
68
+
69
+.basic-edit-section h2,
70
+.section-heading h2 {
71
+  margin: 0 0 18px;
72
+  color: #2f2720;
73
+  font-size: 22px;
74
+  font-weight: 800;
75
+}
76
+
77
+.section-heading {
78
+  margin-bottom: 18px;
79
+}
80
+
81
+.section-heading p {
82
+  margin: 3px 0 0;
83
+  color: #7b6b5c;
84
+  font-size: 14px;
85
+}
86
+
87
+.form-list {
88
+  width: 650px;
89
+}
90
+
91
+.form-row {
92
+  display: grid;
93
+  grid-template-columns: 150px 1fr;
94
+  align-items: start;
95
+  column-gap: 18px;
96
+  margin-top: 14px;
97
+}
98
+
99
+.form-row label {
100
+  padding-top: 10px;
101
+  color: #4b3c31;
102
+  font-size: 17px;
103
+  font-weight: 800;
104
+}
105
+
106
+.form-field {
107
+  width: 100%;
108
+}
109
+
110
+.form-row input,
111
+.form-row select,
112
+.form-row textarea {
113
+  width: 100%;
114
+  min-height: 46px;
115
+  padding: 8px 12px;
116
+  border: 2px solid #d8caba;
117
+  border-radius: 6px;
118
+  background: #fffdf9;
119
+  color: #2f2720;
120
+  font-size: 17px;
121
+  font-family: inherit;
122
+  box-sizing: border-box;
123
+  outline: none;
124
+}
125
+
126
+.form-row textarea {
127
+  min-height: 104px;
128
+  resize: vertical;
129
+  line-height: 1.6;
130
+}
131
+
132
+.form-row input:focus,
133
+.form-row select:focus,
134
+.form-row textarea:focus {
135
+  border-color: #8a6543;
136
+  background: #ffffff;
137
+}
138
+
139
+.form-row input[readonly] {
140
+  background: #f6efe6;
141
+  color: #7b6b5c;
142
+}
143
+
144
+.error-message {
145
+  margin: 6px 0 0;
146
+  color: #9a3f32;
147
+  font-size: 13px;
148
+  font-weight: 700;
149
+}
150
+
151
+.phone-edit-section {
152
+  min-height: 382px;
153
+  padding: 30px 24px 22px;
154
+  border: 2px solid #d8caba;
155
+  border-radius: 62px;
156
+  background: #fffdf9;
157
+  box-sizing: border-box;
158
+}
159
+
160
+.family-edit-guide {
161
+  padding: 18px 22px;
162
+  border: 2px solid #d8caba;
163
+  border-radius: 14px;
164
+  background: #ffffff;
165
+  box-sizing: border-box;
166
+}
167
+
168
+.family-edit-guide ul {
169
+  margin: 0;
170
+  padding-left: 20px;
171
+  color: #7b6b5c;
172
+  font-size: 15px;
173
+  line-height: 2;
174
+}
175
+
176
+.householder-area {
177
+  margin-top: 28px;
178
+  padding: 22px 26px;
179
+  border: 2px solid #d8caba;
180
+  border-radius: 14px;
181
+  background: #eadfce;
182
+  box-sizing: border-box;
183
+}
184
+
185
+.householder-area h3 {
186
+  margin: 0 0 14px;
187
+  color: #2f2720;
188
+  font-size: 18px;
189
+  font-weight: 800;
190
+}
191
+
192
+.set-householder-button {
193
+  width: 170px;
194
+  height: 42px;
195
+  border: 2px solid #d8caba;
196
+  border-radius: 6px;
197
+  background: #ffffff;
198
+  color: #2f2720;
199
+  font-size: 16px;
200
+  font-weight: 800;
201
+  cursor: pointer;
202
+  box-sizing: border-box;
203
+}
204
+
205
+.set-householder-button:hover {
206
+  background: #f6efe6;
207
+}
208
+
209
+.bottom-actions {
210
+  display: flex;
211
+  justify-content: flex-end;
212
+  align-items: center;
213
+  gap: 14px;
214
+  margin-top: 72px;
215
+}
216
+
217
+.delete-button,
218
+.cancel-button,
219
+.save-button {
220
+  width: 120px;
221
+  height: 46px;
222
+  border-radius: 6px;
223
+  font-size: 17px;
224
+  font-weight: 800;
225
+  cursor: pointer;
226
+  box-sizing: border-box;
227
+}
228
+
229
+.delete-button,
230
+.cancel-button {
231
+  border: 2px solid #d8caba;
232
+  background: #ffffff;
233
+  color: #2f2720;
234
+}
235
+
236
+.delete-button:hover {
237
+  border-color: #9a3f32;
238
+  color: #9a3f32;
239
+}
240
+
241
+.cancel-button:hover {
242
+  background: #f6efe6;
243
+}
244
+
245
+.save-button {
246
+  border: 2px solid #8a6543;
247
+  background: #8a6543;
248
+  color: #ffffff;
249
+}
250
+
251
+.save-button:hover {
252
+  background: #765639;
253
+}
254
+
255
+.save-button:disabled {
256
+  opacity: 0.5;
257
+  cursor: not-allowed;
258
+}
259
+
260
+/* 画面幅が狭い場合 */
261
+@media (max-width: 1100px) {
262
+  .edit-content {
263
+    grid-template-columns: 1fr;
264
+    gap: 28px;
265
+  }
266
+
267
+  .form-list {
268
+    width: 100%;
269
+  }
270
+
271
+  .bottom-actions {
272
+    margin-top: 40px;
273
+  }
274
+}
275
+
276
+@media (max-width: 800px) {
277
+  .breadcrumb {
278
+    position: static;
279
+    transform: none;
280
+    padding: 16px 20px 0;
281
+  }
282
+
283
+  .danka-edit-page {
284
+    flex-direction: column;
285
+  }
286
+
287
+  .danka-edit-main {
288
+    width: 100%;
289
+    padding: 16px 20px 32px;
290
+  }
291
+
292
+  .edit-panel {
293
+    padding: 24px 20px 30px;
294
+    border-radius: 32px;
295
+  }
296
+
297
+  .page-title-area h1 {
298
+    font-size: 26px;
299
+  }
300
+
301
+  .form-row {
302
+    grid-template-columns: 1fr;
303
+    row-gap: 6px;
304
+  }
305
+
306
+  .form-row label {
307
+    padding-top: 0;
308
+  }
309
+
310
+  .phone-edit-section {
311
+    border-radius: 28px;
312
+  }
313
+
314
+  .bottom-actions {
315
+    flex-direction: column;
316
+    align-items: stretch;
317
+  }
318
+
319
+  .delete-button,
320
+  .cancel-button,
321
+  .save-button {
322
+    width: 100%;
323
+  }
324
+}

+ 22
- 0
src/app/pages/family-edit/family-edit.spec.ts Dosyayı Görüntüle

@@ -0,0 +1,22 @@
1
+import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+import { FamilyEdit } from './family-edit';
4
+
5
+describe('FamilyEdit', () => {
6
+  let component: FamilyEdit;
7
+  let fixture: ComponentFixture<FamilyEdit>;
8
+
9
+  beforeEach(async () => {
10
+    await TestBed.configureTestingModule({
11
+      imports: [FamilyEdit],
12
+    }).compileComponents();
13
+
14
+    fixture = TestBed.createComponent(FamilyEdit);
15
+    component = fixture.componentInstance;
16
+    await fixture.whenStable();
17
+  });
18
+
19
+  it('should create', () => {
20
+    expect(component).toBeTruthy();
21
+  });
22
+});

+ 109
- 0
src/app/pages/family-edit/family-edit.ts Dosyayı Görüntüle

@@ -0,0 +1,109 @@
1
+import { Component, inject } from '@angular/core';
2
+import {
3
+  FormBuilder,
4
+  FormGroup,
5
+  FormControl,
6
+  ReactiveFormsModule,
7
+  Validators,
8
+} from '@angular/forms';
9
+import { ActivatedRoute, Router, RouterLink } from '@angular/router';
10
+import { AppHeader } from '../../share/header/app-header';
11
+import { AppSideMenu } from '../../share/side-menu/app-side-menu';
12
+import { FamilyService } from '../../services/family-service';
13
+import { Danka } from '../../models/danka';
14
+import { Family } from '../../models/family';
15
+
16
+@Component({
17
+  selector: 'app-family-edit',
18
+  imports: [AppHeader, AppSideMenu, ReactiveFormsModule],
19
+  templateUrl: './family-edit.html',
20
+  styleUrl: './family-edit.scss',
21
+})
22
+export class FamilyEdit {
23
+  danka: Danka | undefined;
24
+  family: Family | undefined;
25
+  dankaId: string = '';
26
+  familyId: string | null = null;
27
+  isEditing = false;
28
+
29
+  constructor(
30
+    private familyService: FamilyService,
31
+    private route: ActivatedRoute,
32
+    private router: Router,
33
+  ) {
34
+    this.dankaId = this.route.snapshot.params['dankaId'];
35
+    this.familyId = this.route.snapshot.params['familyId'];
36
+    if (this.familyId) {
37
+      this.family = this.familyService.getFamilyById(this.familyId);
38
+      if (this.family) {
39
+        this.familyForm.patchValue({
40
+          furigana: this.family.furigana,
41
+          name: this.family.name,
42
+          relationship: this.family.relationship,
43
+          birthDate: this.family.birthDate,
44
+          note: this.family.note,
45
+        });
46
+      }
47
+    }
48
+  }
49
+
50
+  familyForm = new FormGroup({
51
+    furigana: new FormControl('', [Validators.required]),
52
+    name: new FormControl('', [Validators.required]),
53
+    relationship: new FormControl(''),
54
+    birthDate: new FormControl('', Validators.required),
55
+    note: new FormControl(''),
56
+  });
57
+
58
+  getAgeText() {
59
+    const birthDate = this.familyForm.get('birthDate')?.value;
60
+    if (!birthDate) {
61
+      return;
62
+    }
63
+    const birth = new Date(birthDate);
64
+    const today = new Date();
65
+    let age = today.getFullYear() - birth.getFullYear();
66
+    const thisYearsBirthday = new Date(today.getFullYear(), birth.getMonth(), birth.getDate());
67
+
68
+    if (thisYearsBirthday > today) {
69
+      age--;
70
+    }
71
+    return `${age}歳`;
72
+  }
73
+
74
+  saveFamily() {
75
+    if (this.familyForm.invalid) {
76
+      return;
77
+    }
78
+
79
+    const familyId = this.familyId ?? Date.now().toString();
80
+    const dankaId = this.dankaId;
81
+    const formValue = this.familyForm.value;
82
+    const updatedFamily = {
83
+      id: familyId,
84
+      dankaId: dankaId,
85
+      furigana: formValue.furigana?.trim() ?? '',
86
+      name: formValue.name?.trim() ?? '',
87
+      relationship: formValue.relationship?.trim() ?? '',
88
+      birthDate: formValue.birthDate?.trim() ?? '',
89
+      note: formValue.note?.trim() ?? '',
90
+    };
91
+    this.familyService.saveFamily(updatedFamily);
92
+    this.router.navigate(['/danka-detail', dankaId], { queryParams: { tab: 'family' } });  }
93
+
94
+  cancelFamilyEdit(): void {
95
+    const dankaId = this.dankaId;
96
+    this.router.navigate(['/danka-detail', dankaId], { queryParams: { tab: 'family' } });
97
+  }
98
+
99
+  deleteFamily() {
100
+    const dankaId = this.dankaId;
101
+    if (!this.familyId) {
102
+      return;
103
+    }
104
+    this.familyService.deleteFamily(this.familyId);
105
+    this.router.navigate(['/danka-detail', dankaId], { queryParams: { tab: 'family' } });
106
+  }
107
+
108
+  setAsHouseholder() {}
109
+}

+ 24
- 4
src/app/services/family-service.ts Dosyayı Görüntüle

@@ -31,11 +31,31 @@ export class FamilyService {
31 31
   //   return this.dankaList;
32 32
   // }
33 33
 
34
+  //檀家と紐づいている家族情報の取得
34 35
   getFamiliesByDankaId(dankaId: string): Family[] {
35 36
     return this.families.filter((family) => family.dankaId === dankaId);
36 37
   }
37
-  // getFamilyById(id: string);
38
-  // addFamily(family: Family);
39
-  // updateFamily(family: Family);
40
-  // deleteFamily(id: string);
38
+
39
+  //家族の情報を取得
40
+  getFamilyById(id: string): Family | undefined {
41
+    return this.families.find((family) => family.id === id);
42
+  }
43
+
44
+  //家族の情報を更新
45
+  saveFamily(updateFamily: Family) {
46
+    const index = this.families.findIndex((families) => families.id === updateFamily.id);
47
+    if (index === -1) {
48
+      this.families.push(updateFamily);
49
+      return;
50
+    }
51
+    this.families[index] = updateFamily;
52
+  }
53
+  //家族の情報を削除
54
+  deleteFamily(id: string | undefined) {
55
+    const index = this.families.findIndex((family) => family.id === id);
56
+    if (index === -1) {
57
+      return;
58
+    }
59
+    this.families.splice(index, 1);
60
+  }
41 61
 }

Loading…
İptal
Kaydet