Fixed: Add default model for members

This commit is contained in:
Philipp Lang 2023-09-07 16:33:40 +02:00
parent c89973032b
commit 3a96b00307
4 changed files with 60 additions and 13 deletions

View File

@ -36,15 +36,7 @@ class MemberController extends Controller
session()->put('title', 'Mitglied erstellen');
return \Inertia::render('member/VForm', [
'data' => [
'country_id' => Country::default(),
'efz' => null,
'ps_at' => null,
'without_education_at' => null,
'without_efz_at' => null,
'more_ps_at' => null,
'joined_at' => now()->format('Y-m-d'),
],
'data' => MemberResource::defaultModel(),
'mode' => 'create',
'meta' => MemberResource::meta(),
]);

View File

@ -149,4 +149,51 @@ class MemberResource extends JsonResource
],
];
}
/**
* @return array<string, mixed>
*/
public static function defaultModel(): array
{
return [
'gender_id' => null,
'salutation' => '',
'nationality_id' => null,
'firstname' => '',
'lastname' => '',
'address' => '',
'further_address' => '',
'zip' => '',
'location' => '',
'birthday' => '',
'region_id' => null,
'country_id' => Country::default(),
'other_country' => '',
'main_phone' => '',
'mobile_phone' => '',
'work_phone' => '',
'children_phone' => '',
'email' => '',
'email_parents' => '',
'fax' => '',
'letter_address' => '',
'bill_kind' => null,
'subscription_id' => null,
'has_nami' => false,
'send_newspaper' => false,
'joined_at' => now()->format('Y-m-d'),
'comment' => '',
'first_activity_id' => null,
'first_subactivity_id' => null,
'efz' => null,
'ps_at' => null,
'more_ps_at' => null,
'without_education_at' => null,
'without_efz_at' => null,
'has_vk' => false,
'has_svk' => false,
'multiply_pv' => false,
'multiply_more_pv' => false,
];
}
}

View File

@ -32,7 +32,14 @@ class CreateTest extends TestCase
$this->assertInertiaHas('€ Mitglied', $response, "meta.formActivities.{$activity->id}");
$this->assertInertiaHas(['name' => 'E-Mail', 'id' => 'E-Mail'], $response, 'meta.billKinds.0');
$this->assertInertiaHas(['efz' => null, 'ps_at' => null, 'more_ps_at' => null, 'without_education_at' => null, 'without_efz_at' => null], $response, 'data');
$this->assertInertiaHas([
'efz' => null,
'ps_at' => null,
'more_ps_at' => null,
'without_education_at' => null,
'without_efz_at' => null,
'address' => '',
], $response, 'data');
}
public function testItDoesntDisplayActivitiesAndSubactivitiesNotInNami(): void

View File

@ -75,9 +75,10 @@ class StoreTest extends TestCase
'salutation' => 'Doktor',
'comment' => 'Lorem bla',
]);
NamiPutMemberAction::spy()->shouldHaveReceived('handle')->withArgs(fn (Member $memberParam, Activity $activityParam, Subactivity $subactivityParam) => $memberParam->is($member)
&& $activityParam->is($activity)
&& $subactivityParam->is($subactivity)
NamiPutMemberAction::spy()->shouldHaveReceived('handle')->withArgs(
fn (Member $memberParam, Activity $activityParam, Subactivity $subactivityParam) => $memberParam->is($member)
&& $activityParam->is($activity)
&& $subactivityParam->is($subactivity)
)->once();
}