Add user account management features including Appearance, Password, and Profile controllers for handling user preferences. Implement corresponding requests for validation and create views for each setting. Update routes for new account functionality and enhance UI components for user navigation in the account layout.
This commit is contained in:
parent
f6891dbe24
commit
9798150994
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin\Setting;
|
namespace App\Http\Controllers\Admin\Account;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\Admin\Setting\UpdateAppearanceRequest;
|
use App\Http\Requests\Admin\Account\UpdateAppearanceRequest;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Inertia\Inertia;
|
use Inertia\Inertia;
|
||||||
use Inertia\Response;
|
use Inertia\Response;
|
||||||
@ -13,7 +13,7 @@ class AppearanceController extends Controller
|
|||||||
{
|
{
|
||||||
public function edit(): Response
|
public function edit(): Response
|
||||||
{
|
{
|
||||||
return Inertia::render('admin/setting/Appearance', [
|
return Inertia::render('admin/account/Appearance', [
|
||||||
'appearance' => request()->cookie('appearance', 'system'),
|
'appearance' => request()->cookie('appearance', 'system'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ public function update(UpdateAppearanceRequest $request): RedirectResponse
|
|||||||
Inertia::flash('success', 'Tampilan berhasil diperbarui.');
|
Inertia::flash('success', 'Tampilan berhasil diperbarui.');
|
||||||
|
|
||||||
return redirect()
|
return redirect()
|
||||||
->route('admin.setting.appearance')
|
->route('admin.account.appearance')
|
||||||
->withCookie(Cookie::create('appearance')
|
->withCookie(Cookie::create('appearance')
|
||||||
->withValue($appearance)
|
->withValue($appearance)
|
||||||
->withExpires(now()->addYear())
|
->withExpires(now()->addYear())
|
||||||
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin\Setting;
|
namespace App\Http\Controllers\Admin\Account;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\Admin\Setting\UpdatePasswordRequest;
|
use App\Http\Requests\Admin\Account\UpdatePasswordRequest;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Inertia\Inertia;
|
use Inertia\Inertia;
|
||||||
@ -13,7 +13,7 @@ class PasswordController extends Controller
|
|||||||
{
|
{
|
||||||
public function edit(): Response
|
public function edit(): Response
|
||||||
{
|
{
|
||||||
return Inertia::render('admin/setting/Password');
|
return Inertia::render('admin/account/Password');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(UpdatePasswordRequest $request): RedirectResponse
|
public function update(UpdatePasswordRequest $request): RedirectResponse
|
||||||
@ -24,6 +24,6 @@ public function update(UpdatePasswordRequest $request): RedirectResponse
|
|||||||
|
|
||||||
Inertia::flash('success', 'Kata sandi berhasil diperbarui.');
|
Inertia::flash('success', 'Kata sandi berhasil diperbarui.');
|
||||||
|
|
||||||
return redirect()->route('admin.setting.password');
|
return redirect()->route('admin.account.password');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin\Setting;
|
namespace App\Http\Controllers\Admin\Account;
|
||||||
|
|
||||||
use App\Enums\Gender;
|
use App\Enums\Gender;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\Admin\Setting\UpdateProfileRequest;
|
use App\Http\Requests\Admin\Account\UpdateProfileRequest;
|
||||||
use App\Services\Setting\ProfileService;
|
use App\Services\Account\ProfileService;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Inertia\Inertia;
|
use Inertia\Inertia;
|
||||||
use Inertia\Response;
|
use Inertia\Response;
|
||||||
@ -20,7 +20,7 @@ public function edit(): Response
|
|||||||
{
|
{
|
||||||
$user = auth()->user()->load('profile');
|
$user = auth()->user()->load('profile');
|
||||||
|
|
||||||
return Inertia::render('admin/setting/Profile', [
|
return Inertia::render('admin/account/Profile', [
|
||||||
'genders' => Gender::selectOptions(),
|
'genders' => Gender::selectOptions(),
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
]);
|
]);
|
||||||
@ -32,6 +32,6 @@ public function update(UpdateProfileRequest $request): RedirectResponse
|
|||||||
|
|
||||||
Inertia::flash('success', 'Profil berhasil diperbarui.');
|
Inertia::flash('success', 'Profil berhasil diperbarui.');
|
||||||
|
|
||||||
return redirect()->route('admin.setting.profile');
|
return redirect()->route('admin.account.profile');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Requests\Admin\Setting;
|
namespace App\Http\Requests\Admin\Account;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Requests\Admin\Setting;
|
namespace App\Http\Requests\Admin\Account;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Validation\Rules\Password;
|
use Illuminate\Validation\Rules\Password;
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Requests\Admin\Setting;
|
namespace App\Http\Requests\Admin\Account;
|
||||||
|
|
||||||
use App\Enums\Gender;
|
use App\Enums\Gender;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Services\Setting;
|
namespace App\Services\Account;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ function logout() {
|
|||||||
</div>
|
</div>
|
||||||
</DropdownMenuLabel>
|
</DropdownMenuLabel>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<DropdownMenuItem @click="router.visit('/admin/setting/profile')">
|
<DropdownMenuItem @click="router.visit('/admin/account/profile')">
|
||||||
<User />
|
<User />
|
||||||
Profil
|
Profil
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import type { AppearanceMode } from '@/types/settings';
|
import type { AppearanceMode } from '@/types/account';
|
||||||
|
|
||||||
export function applyAppearance(mode: AppearanceMode): void {
|
export function applyAppearance(mode: AppearanceMode): void {
|
||||||
const root = document.documentElement;
|
const root = document.documentElement;
|
||||||
|
|||||||
@ -11,17 +11,17 @@ const currentPath = computed(() => page.url.split('?')[0]);
|
|||||||
|
|
||||||
const navItems = [
|
const navItems = [
|
||||||
{
|
{
|
||||||
href: '/admin/setting/profile',
|
href: '/admin/account/profile',
|
||||||
label: 'Profil',
|
label: 'Profil',
|
||||||
icon: User,
|
icon: User,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
href: '/admin/setting/password',
|
href: '/admin/account/password',
|
||||||
label: 'Kata Sandi',
|
label: 'Kata Sandi',
|
||||||
icon: KeyRound,
|
icon: KeyRound,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
href: '/admin/setting/appearance',
|
href: '/admin/account/appearance',
|
||||||
label: 'Tampilan',
|
label: 'Tampilan',
|
||||||
icon: Palette,
|
icon: Palette,
|
||||||
},
|
},
|
||||||
@ -29,11 +29,11 @@ const navItems = [
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AdminLayout title="Pengaturan">
|
<AdminLayout title="Akun">
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
<h2 class="text-2xl font-bold tracking-tight">
|
<h2 class="text-2xl font-bold tracking-tight">
|
||||||
Pengaturan
|
Akun
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -14,9 +14,9 @@ import {
|
|||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
|
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
|
||||||
import { applyAppearance } from '@/composables/useAppearance';
|
import { applyAppearance } from '@/composables/useAppearance';
|
||||||
import SettingsLayout from '@/layouts/SettingsLayout.vue';
|
import AccountLayout from '@/layouts/AccountLayout.vue';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import type { AppearanceFormData, AppearanceMode } from '@/types/settings';
|
import type { AppearanceFormData, AppearanceMode } from '@/types/account';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
appearance: AppearanceMode;
|
appearance: AppearanceMode;
|
||||||
@ -58,7 +58,7 @@ function onAppearanceChange(value: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function submit() {
|
function submit() {
|
||||||
form.put('/admin/setting/appearance', {
|
form.put('/admin/account/appearance', {
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error('Gagal menyimpan tampilan.');
|
toast.error('Gagal menyimpan tampilan.');
|
||||||
},
|
},
|
||||||
@ -70,7 +70,7 @@ function submit() {
|
|||||||
|
|
||||||
<Head title="Tampilan" />
|
<Head title="Tampilan" />
|
||||||
|
|
||||||
<SettingsLayout>
|
<AccountLayout>
|
||||||
<form @submit.prevent="submit">
|
<form @submit.prevent="submit">
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
@ -117,5 +117,5 @@ function submit() {
|
|||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</form>
|
</form>
|
||||||
</SettingsLayout>
|
</AccountLayout>
|
||||||
</template>
|
</template>
|
||||||
@ -12,8 +12,8 @@ import {
|
|||||||
FieldSet,
|
FieldSet,
|
||||||
} from '@/components/ui/field';
|
} from '@/components/ui/field';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import SettingsLayout from '@/layouts/SettingsLayout.vue';
|
import AccountLayout from '@/layouts/AccountLayout.vue';
|
||||||
import type { PasswordFormData } from '@/types/settings';
|
import type { PasswordFormData } from '@/types/account';
|
||||||
|
|
||||||
const form = useForm<PasswordFormData>({
|
const form = useForm<PasswordFormData>({
|
||||||
current_password: '',
|
current_password: '',
|
||||||
@ -22,7 +22,7 @@ const form = useForm<PasswordFormData>({
|
|||||||
});
|
});
|
||||||
|
|
||||||
function submit() {
|
function submit() {
|
||||||
form.put('/admin/setting/password', {
|
form.put('/admin/account/password', {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
form.reset();
|
form.reset();
|
||||||
},
|
},
|
||||||
@ -37,7 +37,7 @@ function submit() {
|
|||||||
|
|
||||||
<Head title="Kata Sandi" />
|
<Head title="Kata Sandi" />
|
||||||
|
|
||||||
<SettingsLayout>
|
<AccountLayout>
|
||||||
<form @submit.prevent="submit">
|
<form @submit.prevent="submit">
|
||||||
<div class="grid gap-6">
|
<div class="grid gap-6">
|
||||||
<Card>
|
<Card>
|
||||||
@ -85,5 +85,5 @@ function submit() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</SettingsLayout>
|
</AccountLayout>
|
||||||
</template>
|
</template>
|
||||||
@ -16,8 +16,8 @@ import { Input } from '@/components/ui/input';
|
|||||||
import { PhoneNumberInput } from '@/components/ui/phone-number-input';
|
import { PhoneNumberInput } from '@/components/ui/phone-number-input';
|
||||||
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
|
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
|
||||||
import { Textarea } from '@/components/ui/textarea';
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
import SettingsLayout from '@/layouts/SettingsLayout.vue';
|
import AccountLayout from '@/layouts/AccountLayout.vue';
|
||||||
import type { EnumOption, ProfileFormData, ProfileUser } from '@/types/settings';
|
import type { EnumOption, ProfileFormData, ProfileUser } from '@/types/account';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
user: ProfileUser;
|
user: ProfileUser;
|
||||||
@ -35,7 +35,7 @@ const form = useForm<ProfileFormData>({
|
|||||||
});
|
});
|
||||||
|
|
||||||
function submit() {
|
function submit() {
|
||||||
form.put('/admin/setting/profile', {
|
form.put('/admin/account/profile', {
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error('Gagal menyimpan profil. Periksa kembali formulir.');
|
toast.error('Gagal menyimpan profil. Periksa kembali formulir.');
|
||||||
},
|
},
|
||||||
@ -47,7 +47,7 @@ function submit() {
|
|||||||
|
|
||||||
<Head title="Profil" />
|
<Head title="Profil" />
|
||||||
|
|
||||||
<SettingsLayout>
|
<AccountLayout>
|
||||||
<form @submit.prevent="submit">
|
<form @submit.prevent="submit">
|
||||||
<div class="grid gap-6">
|
<div class="grid gap-6">
|
||||||
<Card>
|
<Card>
|
||||||
@ -133,5 +133,5 @@ function submit() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</SettingsLayout>
|
</AccountLayout>
|
||||||
</template>
|
</template>
|
||||||
@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Enums\Permission;
|
use App\Enums\Permission;
|
||||||
|
use App\Http\Controllers\Admin\Account\AppearanceController;
|
||||||
|
use App\Http\Controllers\Admin\Account\PasswordController;
|
||||||
|
use App\Http\Controllers\Admin\Account\ProfileController;
|
||||||
use App\Http\Controllers\Admin\DashboardController;
|
use App\Http\Controllers\Admin\DashboardController;
|
||||||
use App\Http\Controllers\Admin\Finance\CashController;
|
use App\Http\Controllers\Admin\Finance\CashController;
|
||||||
use App\Http\Controllers\Admin\Finance\EmployeeAdvanceController;
|
use App\Http\Controllers\Admin\Finance\EmployeeAdvanceController;
|
||||||
@ -15,9 +18,6 @@
|
|||||||
use App\Http\Controllers\Admin\Master\ProductController;
|
use App\Http\Controllers\Admin\Master\ProductController;
|
||||||
use App\Http\Controllers\Admin\Master\RawMaterialController;
|
use App\Http\Controllers\Admin\Master\RawMaterialController;
|
||||||
use App\Http\Controllers\Admin\Master\SupplierController;
|
use App\Http\Controllers\Admin\Master\SupplierController;
|
||||||
use App\Http\Controllers\Admin\Setting\AppearanceController;
|
|
||||||
use App\Http\Controllers\Admin\Setting\PasswordController;
|
|
||||||
use App\Http\Controllers\Admin\Setting\ProfileController;
|
|
||||||
use App\Http\Controllers\Auth\LoginController;
|
use App\Http\Controllers\Auth\LoginController;
|
||||||
use App\Http\Controllers\Auth\LogoutController;
|
use App\Http\Controllers\Auth\LogoutController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
@ -153,7 +153,7 @@
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('setting')->name('setting.')->group(function () {
|
Route::prefix('account')->name('account.')->group(function () {
|
||||||
Route::get('profile', [ProfileController::class, 'edit'])->name('profile');
|
Route::get('profile', [ProfileController::class, 'edit'])->name('profile');
|
||||||
Route::put('profile', [ProfileController::class, 'update'])->name('profile.update');
|
Route::put('profile', [ProfileController::class, 'update'])->name('profile.update');
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user