diff --git a/app/Setting/BillSettings.php b/app/Setting/BillSettings.php new file mode 100644 index 00000000..2f477365 --- /dev/null +++ b/app/Setting/BillSettings.php @@ -0,0 +1,29 @@ + + */ + public function handle(BillSettings $settings): array + { + return [ + 'bill_from_long' => $settings->from_long, + 'bill_from' => $settings->from, + 'bill_mobile' => $settings->mobile, + 'bill_email' => $settings->email, + 'bill_website' => $settings->website, + 'bill_address' => $settings->address, + 'bill_place' => $settings->place, + 'bill_zip' => $settings->zip, + ]; + } + + public function asController(BillSettings $settings): Response + { + session()->put('menu', 'setting'); + session()->put('title', 'Einstellungen'); + + return Inertia::render('setting/Index', [ + 'data' => $this->handle($settings), + ]); + } +} diff --git a/app/Setting/SettingSaveAction.php b/app/Setting/SettingSaveAction.php new file mode 100644 index 00000000..6e963b97 --- /dev/null +++ b/app/Setting/SettingSaveAction.php @@ -0,0 +1,34 @@ +from_long = $input['bill_from_long'] ?? ''; + $settings->from = $input['bill_from'] ?? ''; + $settings->mobile = $input['bill_mobile'] ?? ''; + $settings->email = $input['bill_email'] ?? ''; + $settings->website = $input['bill_website'] ?? ''; + $settings->address = $input['bill_address'] ?? ''; + $settings->place = $input['bill_place'] ?? ''; + $settings->zip = $input['bill_zip'] ?? ''; + $settings->save(); + } + + public function asController(ActionRequest $request): RedirectResponse + { + $this->handle($request->all()); + + return redirect()->back()->success('Einstellungen gespeichert'); + } +} diff --git a/database/settings/2022_09_05_213938_bill_settings.php b/database/settings/2022_09_05_213938_bill_settings.php new file mode 100644 index 00000000..7676b8e5 --- /dev/null +++ b/database/settings/2022_09_05_213938_bill_settings.php @@ -0,0 +1,18 @@ +migrator->add('bill.from_long', ''); + $this->migrator->add('bill.from', ''); + $this->migrator->add('bill.mobile', ''); + $this->migrator->add('bill.email', ''); + $this->migrator->add('bill.website', ''); + $this->migrator->add('bill.address', ''); + $this->migrator->add('bill.place', ''); + $this->migrator->add('bill.zip', ''); + } +} diff --git a/resources/img/svg/setting.svg b/resources/img/svg/setting.svg new file mode 100644 index 00000000..006eecc4 --- /dev/null +++ b/resources/img/svg/setting.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/js/components/VTabs.vue b/resources/js/components/VTabs.vue new file mode 100644 index 00000000..1750f823 --- /dev/null +++ b/resources/js/components/VTabs.vue @@ -0,0 +1,31 @@ + + + diff --git a/resources/js/layouts/AppLayout.vue b/resources/js/layouts/AppLayout.vue index be89711c..c9987c2b 100644 --- a/resources/js/layouts/AppLayout.vue +++ b/resources/js/layouts/AppLayout.vue @@ -15,6 +15,7 @@ Zuschüsse
+ Einstellungen Abmelden
diff --git a/resources/js/views/member/VForm.vue b/resources/js/views/member/VForm.vue index 9714e4fb..22a7ce20 100644 --- a/resources/js/views/member/VForm.vue +++ b/resources/js/views/member/VForm.vue @@ -17,20 +17,8 @@ -
-
- -
-
+ +
-
+
@@ -277,9 +265,6 @@ export default { confirm() { this.$inertia.post(`/member/${this.inner.id}/confirm`); }, - openMenu(index) { - this.active = index; - }, submit() { this.mode === 'create' ? this.$inertia.post(`/member`, this.inner) @@ -292,7 +277,8 @@ export default { }, components: { - popup: () => import('../../components/Popup.vue'), + 'popup': () => import('../../components/Popup.vue'), + 'v-tabs': () => import('../../components/VTabs.vue'), }, computed: { diff --git a/resources/js/views/setting/Index.vue b/resources/js/views/setting/Index.vue new file mode 100644 index 00000000..162149ae --- /dev/null +++ b/resources/js/views/setting/Index.vue @@ -0,0 +1,67 @@ + + + diff --git a/routes/web.php b/routes/web.php index 3295ff7e..168d720c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -15,7 +15,8 @@ use App\Payment\SendpaymentController; use App\Payment\SubscriptionController; use App\Pdf\MemberEfzController; use App\Pdf\MemberPdfController; -use App\Setting\Controllers\SettingController; +use App\Setting\SettingIndexAction; +use App\Setting\SettingSaveAction; Route::group(['namespace' => 'App\\Http\\Controllers'], function (): void { Auth::routes(['register' => false]); @@ -35,7 +36,8 @@ Route::group(['middleware' => 'auth:web'], function (): void { Route::get('/sendpayment', [SendpaymentController::class, 'create'])->name('sendpayment.create'); Route::get('/sendpayment/pdf', [SendpaymentController::class, 'send'])->name('sendpayment.pdf'); Route::apiResource('member.membership', MembershipController::class); - Route::resource('setting', SettingController::class); + Route::get('setting', SettingIndexAction::class); + Route::post('setting', SettingSaveAction::class); Route::resource('member.course', CourseController::class); Route::get('/member/{member}/efz', MemberEfzController::class)->name('efz'); Route::get('/member/{member}/resync', MemberResyncController::class)->name('member.resync'); diff --git a/tests/Feature/Setting/SettingTest.php b/tests/Feature/Setting/SettingTest.php new file mode 100644 index 00000000..400ea15f --- /dev/null +++ b/tests/Feature/Setting/SettingTest.php @@ -0,0 +1,61 @@ +withoutExceptionHandling()->login()->loginNami(); + BillSettings::fake([ + 'from_long' => 'DPSG Stamm Muster', + 'from' => 'Stamm Muster', + 'mobile' => '+49 176 55555', + 'email' => 'max@muster.de', + 'website' => 'https://example.com', + 'address' => 'Musterstr 4', + 'place' => 'Solingen', + 'zip' => '12345', + ]); + + $response = $this->get('/setting'); + + $response->assertOk(); + $this->assertInertiaHas([ + 'bill_from_long' => 'DPSG Stamm Muster', + 'bill_from' => 'Stamm Muster', + 'bill_mobile' => '+49 176 55555', + 'bill_email' => 'max@muster.de', + 'bill_website' => 'https://example.com', + 'bill_address' => 'Musterstr 4', + 'bill_place' => 'Solingen', + 'bill_zip' => '12345', + ], $response, 'data'); + } + + public function testItCanChangeSettings(): void + { + $this->withoutExceptionHandling()->login()->loginNami(); + + $response = $this->from('/setting')->post('/setting', [ + 'bill_from_long' => 'DPSG Stamm Muster', + 'bill_from' => 'Stamm Muster', + 'bill_mobile' => '+49 176 55555', + 'bill_email' => 'max@muster.de', + 'bill_website' => 'https://example.com', + 'bill_address' => 'Musterstr 4', + 'bill_place' => 'Solingen', + 'bill_zip' => '12345', + ]); + + $response->assertRedirect('/setting'); + $settings = app(BillSettings::class); + $this->assertEquals('DPSG Stamm Muster', $settings->from_long); + } +}