@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Flux\Flux;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\Locked;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Component;
|
||||
|
||||
new #[Title('Notes limits')] class extends Component
|
||||
{
|
||||
public function mount(): void
|
||||
{
|
||||
if (! auth()->user()->isAdmin()) {
|
||||
abort(403);
|
||||
}
|
||||
}
|
||||
|
||||
#[Locked]
|
||||
public ?int $editingUserId = null;
|
||||
|
||||
public bool $showLimitForm = false;
|
||||
|
||||
public string $notesLimitInput = '';
|
||||
|
||||
#[Computed]
|
||||
public function users(): Collection
|
||||
{
|
||||
return User::query()
|
||||
->orderBy('name')
|
||||
->get();
|
||||
}
|
||||
|
||||
public function startEditLimit(int $userId): void
|
||||
{
|
||||
$user = $this->userById($userId);
|
||||
|
||||
$this->editingUserId = $user->id;
|
||||
$this->notesLimitInput = (string) $user->notesLimit();
|
||||
$this->resetErrorBag('notesLimitInput');
|
||||
$this->showLimitForm = true;
|
||||
}
|
||||
|
||||
public function saveNotesLimit(): void
|
||||
{
|
||||
$user = $this->userById($this->editingUserId);
|
||||
|
||||
$validated = $this->validate([
|
||||
'notesLimitInput' => ['required', 'integer', 'min:1', 'max:1000000'],
|
||||
]);
|
||||
|
||||
$user->update(['notes_limit' => (int) $validated['notesLimitInput']]);
|
||||
|
||||
$this->reset('showLimitForm', 'editingUserId', 'notesLimitInput');
|
||||
|
||||
Flux::toast(variant: 'success', text: __('Notes limit updated.'));
|
||||
}
|
||||
|
||||
private function userById(int $userId): User
|
||||
{
|
||||
return User::query()->findOrFail($userId);
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<div class="flex h-full w-full flex-1 flex-col gap-6">
|
||||
<div>
|
||||
<flux:heading size="xl">{{ __('Notes limits') }}</flux:heading>
|
||||
<flux:text class="mt-1">{{ __('Set how many characters each user may write in todo notes.') }}</flux:text>
|
||||
</div>
|
||||
|
||||
<flux:card>
|
||||
<flux:table>
|
||||
<flux:table.columns>
|
||||
<flux:table.column>{{ __('Name') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Email') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Role') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Notes limit') }}</flux:table.column>
|
||||
<flux:table.column align="end" width="5rem">{{ __('Actions') }}</flux:table.column>
|
||||
</flux:table.columns>
|
||||
|
||||
<flux:table.rows>
|
||||
@foreach ($this->users as $user)
|
||||
<flux:table.row :key="$user->id" data-test="user-row-{{ $user->id }}">
|
||||
<flux:table.cell>{{ $user->name }}</flux:table.cell>
|
||||
<flux:table.cell class="text-zinc-500">{{ $user->email }}</flux:table.cell>
|
||||
<flux:table.cell>
|
||||
@if ($user->isAdmin())
|
||||
<flux:badge size="sm" color="blue">{{ __('Admin') }}</flux:badge>
|
||||
@else
|
||||
<flux:badge size="sm" color="zinc">{{ __('Member') }}</flux:badge>
|
||||
@endif
|
||||
</flux:table.cell>
|
||||
<flux:table.cell data-test="notes-limit-{{ $user->id }}">
|
||||
{{ $user->notesLimit() }} {{ __('characters') }}
|
||||
</flux:table.cell>
|
||||
<flux:table.cell class="py-0">
|
||||
<div class="flex justify-end gap-1">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="pencil-square"
|
||||
:title="__('Edit notes limit')"
|
||||
wire:click="startEditLimit({{ $user->id }})"
|
||||
data-test="edit-notes-limit-{{ $user->id }}"
|
||||
/>
|
||||
</div>
|
||||
</flux:table.cell>
|
||||
</flux:table.row>
|
||||
@endforeach
|
||||
</flux:table.rows>
|
||||
</flux:table>
|
||||
</flux:card>
|
||||
|
||||
<flux:modal wire:model.self="showLimitForm" class="md:w-lg">
|
||||
<form wire:submit="saveNotesLimit" class="space-y-6">
|
||||
<div>
|
||||
<flux:heading size="lg">{{ __('Edit notes limit') }}</flux:heading>
|
||||
<flux:text class="mt-2">{{ __('Enter the maximum number of characters allowed in todo notes.') }}</flux:text>
|
||||
</div>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Notes limit (characters)') }}</flux:label>
|
||||
<flux:input
|
||||
wire:model="notesLimitInput"
|
||||
type="number"
|
||||
min="1"
|
||||
max="1000000"
|
||||
inputmode="numeric"
|
||||
data-test="notes-limit-input"
|
||||
/>
|
||||
<flux:error name="notesLimitInput" />
|
||||
</flux:field>
|
||||
|
||||
<div class="flex justify-end gap-3">
|
||||
<flux:modal.close>
|
||||
<flux:button variant="ghost">{{ __('Cancel') }}</flux:button>
|
||||
</flux:modal.close>
|
||||
<flux:button type="submit" variant="primary">{{ __('Save') }}</flux:button>
|
||||
</div>
|
||||
</form>
|
||||
</flux:modal>
|
||||
</div>
|
||||
@@ -0,0 +1,36 @@
|
||||
<x-layouts::auth :title="__('Confirm password')">
|
||||
<div class="flex flex-col gap-6">
|
||||
<x-auth-header
|
||||
:title="__('Confirm password')"
|
||||
:description="__('This is a secure area of the application. Please confirm your password before continuing.')"
|
||||
/>
|
||||
|
||||
<x-auth-session-status class="text-center" :status="session('status')" />
|
||||
|
||||
<x-passkey-verify
|
||||
options-route="passkey.confirm-options"
|
||||
submit-route="passkey.confirm"
|
||||
:label="__('Confirm with passkey')"
|
||||
:loading-label="__('Confirming...')"
|
||||
:separator="__('Or confirm with password')"
|
||||
/>
|
||||
|
||||
<form method="POST" action="{{ route('password.confirm.store') }}" class="flex flex-col gap-6">
|
||||
@csrf
|
||||
|
||||
<flux:input
|
||||
name="password"
|
||||
:label="__('Password')"
|
||||
type="password"
|
||||
required
|
||||
autocomplete="current-password"
|
||||
:placeholder="__('Password')"
|
||||
viewable
|
||||
/>
|
||||
|
||||
<flux:button variant="primary" type="submit" class="w-full" data-test="confirm-password-button">
|
||||
{{ __('Confirm') }}
|
||||
</flux:button>
|
||||
</form>
|
||||
</div>
|
||||
</x-layouts::auth>
|
||||
@@ -0,0 +1,31 @@
|
||||
<x-layouts::auth :title="__('Forgot password')">
|
||||
<div class="flex flex-col gap-6">
|
||||
<x-auth-header :title="__('Forgot password')" :description="__('Enter your email to receive a password reset link')" />
|
||||
|
||||
<!-- Session Status -->
|
||||
<x-auth-session-status class="text-center" :status="session('status')" />
|
||||
|
||||
<form method="POST" action="{{ route('password.email') }}" class="flex flex-col gap-6">
|
||||
@csrf
|
||||
|
||||
<!-- Email Address -->
|
||||
<flux:input
|
||||
name="email"
|
||||
:label="__('Email address')"
|
||||
type="email"
|
||||
required
|
||||
autofocus
|
||||
placeholder="email@example.com"
|
||||
/>
|
||||
|
||||
<flux:button variant="primary" type="submit" class="w-full" data-test="email-password-reset-link-button">
|
||||
{{ __('Email password reset link') }}
|
||||
</flux:button>
|
||||
</form>
|
||||
|
||||
<div class="space-x-1 rtl:space-x-reverse text-center text-sm text-zinc-400">
|
||||
<span>{{ __('Or, return to') }}</span>
|
||||
<flux:link :href="route('login')" wire:navigate>{{ __('log in') }}</flux:link>
|
||||
</div>
|
||||
</div>
|
||||
</x-layouts::auth>
|
||||
@@ -0,0 +1,59 @@
|
||||
<x-layouts::auth :title="__('Log in')">
|
||||
<div class="flex flex-col gap-6">
|
||||
<x-auth-header :title="__('Log in to your account')" :description="__('Enter your email and password below to log in')" />
|
||||
|
||||
<!-- Session Status -->
|
||||
<x-auth-session-status class="text-center" :status="session('status')" />
|
||||
|
||||
<x-passkey-verify />
|
||||
|
||||
<form method="POST" action="{{ route('login.store') }}" class="flex flex-col gap-6">
|
||||
@csrf
|
||||
|
||||
<!-- Email Address -->
|
||||
<flux:input
|
||||
name="email"
|
||||
:label="__('Email address')"
|
||||
:value="old('email')"
|
||||
type="email"
|
||||
required
|
||||
autofocus
|
||||
autocomplete="email"
|
||||
placeholder="email@example.com"
|
||||
/>
|
||||
|
||||
<!-- Password -->
|
||||
<div class="relative">
|
||||
<flux:input
|
||||
name="password"
|
||||
:label="__('Password')"
|
||||
type="password"
|
||||
required
|
||||
autocomplete="current-password"
|
||||
:placeholder="__('Password')"
|
||||
viewable
|
||||
/>
|
||||
|
||||
@if (Route::has('password.request'))
|
||||
<flux:link class="absolute top-0 text-sm end-0" :href="route('password.request')" wire:navigate>
|
||||
{{ __('Forgot your password?') }}
|
||||
</flux:link>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<!-- Remember Me -->
|
||||
<flux:checkbox name="remember" :label="__('Remember me')" :checked="old('remember')" />
|
||||
|
||||
<div class="flex items-center justify-end">
|
||||
<flux:button variant="primary" type="submit" class="w-full" data-test="login-button">
|
||||
{{ __('Log in') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="space-x-1 text-sm text-center rtl:space-x-reverse text-zinc-600 dark:text-zinc-400">
|
||||
<span>{{ __('Don\'t have an account?') }}</span>
|
||||
<flux:link :href="route('register')" wire:navigate>{{ __('Sign up') }}</flux:link>
|
||||
</div>
|
||||
</div>
|
||||
</x-layouts::auth>
|
||||
@@ -0,0 +1,69 @@
|
||||
<x-layouts::auth :title="__('Register')">
|
||||
<div class="flex flex-col gap-6">
|
||||
<x-auth-header :title="__('Create an account')" :description="__('Enter your details below to create your account')" />
|
||||
|
||||
<!-- Session Status -->
|
||||
<x-auth-session-status class="text-center" :status="session('status')" />
|
||||
|
||||
<form method="POST" action="{{ route('register.store') }}" class="flex flex-col gap-6">
|
||||
@csrf
|
||||
<!-- Name -->
|
||||
<flux:input
|
||||
name="name"
|
||||
:label="__('Name')"
|
||||
:value="old('name')"
|
||||
type="text"
|
||||
required
|
||||
autofocus
|
||||
autocomplete="name"
|
||||
:placeholder="__('Full name')"
|
||||
/>
|
||||
|
||||
<!-- Email Address -->
|
||||
<flux:input
|
||||
name="email"
|
||||
:label="__('Email address')"
|
||||
:value="old('email')"
|
||||
type="email"
|
||||
required
|
||||
autocomplete="email"
|
||||
placeholder="email@example.com"
|
||||
/>
|
||||
|
||||
<!-- Password -->
|
||||
<flux:input
|
||||
name="password"
|
||||
:label="__('Password')"
|
||||
type="password"
|
||||
required
|
||||
autocomplete="new-password"
|
||||
:placeholder="__('Password')"
|
||||
passwordrules="{{ \Illuminate\Validation\Rules\Password::defaults()->toPasswordRulesString() }}"
|
||||
viewable
|
||||
/>
|
||||
|
||||
<!-- Confirm Password -->
|
||||
<flux:input
|
||||
name="password_confirmation"
|
||||
:label="__('Confirm password')"
|
||||
type="password"
|
||||
required
|
||||
autocomplete="new-password"
|
||||
:placeholder="__('Confirm password')"
|
||||
passwordrules="{{ \Illuminate\Validation\Rules\Password::defaults()->toPasswordRulesString() }}"
|
||||
viewable
|
||||
/>
|
||||
|
||||
<div class="flex items-center justify-end">
|
||||
<flux:button type="submit" variant="primary" class="w-full" data-test="register-user-button">
|
||||
{{ __('Create account') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="space-x-1 rtl:space-x-reverse text-center text-sm text-zinc-600 dark:text-zinc-400">
|
||||
<span>{{ __('Already have an account?') }}</span>
|
||||
<flux:link :href="route('login')" wire:navigate>{{ __('Log in') }}</flux:link>
|
||||
</div>
|
||||
</div>
|
||||
</x-layouts::auth>
|
||||
@@ -0,0 +1,54 @@
|
||||
<x-layouts::auth :title="__('Reset password')">
|
||||
<div class="flex flex-col gap-6">
|
||||
<x-auth-header :title="__('Reset password')" :description="__('Please enter your new password below')" />
|
||||
|
||||
<!-- Session Status -->
|
||||
<x-auth-session-status class="text-center" :status="session('status')" />
|
||||
|
||||
<form method="POST" action="{{ route('password.update') }}" class="flex flex-col gap-6">
|
||||
@csrf
|
||||
<!-- Token -->
|
||||
<input type="hidden" name="token" value="{{ request()->route('token') }}">
|
||||
|
||||
<!-- Email Address -->
|
||||
<flux:input
|
||||
name="email"
|
||||
value="{{ request('email') }}"
|
||||
:label="__('Email')"
|
||||
type="email"
|
||||
required
|
||||
autocomplete="email"
|
||||
/>
|
||||
|
||||
<!-- Password -->
|
||||
<flux:input
|
||||
name="password"
|
||||
:label="__('Password')"
|
||||
type="password"
|
||||
required
|
||||
autocomplete="new-password"
|
||||
:placeholder="__('Password')"
|
||||
passwordrules="{{ \Illuminate\Validation\Rules\Password::defaults()->toPasswordRulesString() }}"
|
||||
viewable
|
||||
/>
|
||||
|
||||
<!-- Confirm Password -->
|
||||
<flux:input
|
||||
name="password_confirmation"
|
||||
:label="__('Confirm password')"
|
||||
type="password"
|
||||
required
|
||||
autocomplete="new-password"
|
||||
:placeholder="__('Confirm password')"
|
||||
passwordrules="{{ \Illuminate\Validation\Rules\Password::defaults()->toPasswordRulesString() }}"
|
||||
viewable
|
||||
/>
|
||||
|
||||
<div class="flex items-center justify-end">
|
||||
<flux:button type="submit" variant="primary" class="w-full" data-test="reset-password-button">
|
||||
{{ __('Reset password') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</x-layouts::auth>
|
||||
@@ -0,0 +1,101 @@
|
||||
<x-layouts::auth :title="__('Two-factor authentication')">
|
||||
<div class="flex flex-col gap-6">
|
||||
<div
|
||||
class="relative w-full h-auto"
|
||||
x-cloak
|
||||
x-data="{
|
||||
showRecoveryInput: @js($errors->has('recovery_code')),
|
||||
code: '',
|
||||
recovery_code: '',
|
||||
focusOtp() {
|
||||
this.$nextTick(() => this.$refs.otp?.querySelector('input')?.focus());
|
||||
},
|
||||
init() {
|
||||
if (! this.showRecoveryInput) {
|
||||
this.focusOtp();
|
||||
}
|
||||
},
|
||||
toggleInput() {
|
||||
this.showRecoveryInput = !this.showRecoveryInput;
|
||||
|
||||
this.code = '';
|
||||
this.recovery_code = '';
|
||||
|
||||
$nextTick(() => {
|
||||
this.showRecoveryInput
|
||||
? this.$refs.recovery_code?.focus()
|
||||
: this.focusOtp();
|
||||
});
|
||||
},
|
||||
}"
|
||||
>
|
||||
<div x-show="!showRecoveryInput">
|
||||
<x-auth-header
|
||||
:title="__('Authentication code')"
|
||||
:description="__('Enter the authentication code provided by your authenticator application.')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div x-show="showRecoveryInput">
|
||||
<x-auth-header
|
||||
:title="__('Recovery code')"
|
||||
:description="__('Please confirm access to your account by entering one of your emergency recovery codes.')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<form method="POST" action="{{ route('two-factor.login.store') }}">
|
||||
@csrf
|
||||
|
||||
<div class="space-y-5 text-center">
|
||||
<div x-show="!showRecoveryInput">
|
||||
<div class="flex items-center justify-center my-5" x-ref="otp">
|
||||
<flux:otp
|
||||
x-model="code"
|
||||
length="6"
|
||||
name="code"
|
||||
label="OTP Code"
|
||||
label:sr-only
|
||||
class="mx-auto"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div x-show="showRecoveryInput">
|
||||
<div class="my-5">
|
||||
<flux:input
|
||||
type="text"
|
||||
name="recovery_code"
|
||||
x-ref="recovery_code"
|
||||
x-bind:required="showRecoveryInput"
|
||||
autocomplete="one-time-code"
|
||||
x-model="recovery_code"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@error('recovery_code')
|
||||
<flux:text color="red">
|
||||
{{ $message }}
|
||||
</flux:text>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<flux:button
|
||||
variant="primary"
|
||||
type="submit"
|
||||
class="w-full"
|
||||
>
|
||||
{{ __('Continue') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
|
||||
<div class="mt-5 space-x-0.5 text-sm leading-5 text-center">
|
||||
<span class="opacity-50">{{ __('or you can') }}</span>
|
||||
<div class="inline font-medium underline cursor-pointer opacity-80">
|
||||
<span x-show="!showRecoveryInput" @click="toggleInput()">{{ __('login using a recovery code') }}</span>
|
||||
<span x-show="showRecoveryInput" @click="toggleInput()">{{ __('login using an authentication code') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</x-layouts::auth>
|
||||
@@ -0,0 +1,29 @@
|
||||
<x-layouts::auth :title="__('Email verification')">
|
||||
<div class="mt-4 flex flex-col gap-6">
|
||||
<flux:text class="text-center">
|
||||
{{ __('Please verify your email address by clicking on the link we just emailed to you.') }}
|
||||
</flux:text>
|
||||
|
||||
@if (session('status') == 'verification-link-sent')
|
||||
<flux:text class="text-center font-medium !dark:text-green-400 !text-green-600">
|
||||
{{ __('A new verification link has been sent to the email address you provided during registration.') }}
|
||||
</flux:text>
|
||||
@endif
|
||||
|
||||
<div class="flex flex-col items-center justify-between space-y-3">
|
||||
<form method="POST" action="{{ route('verification.send') }}">
|
||||
@csrf
|
||||
<flux:button type="submit" variant="primary" class="w-full">
|
||||
{{ __('Resend verification email') }}
|
||||
</flux:button>
|
||||
</form>
|
||||
|
||||
<form method="POST" action="{{ route('logout') }}">
|
||||
@csrf
|
||||
<flux:button variant="ghost" type="submit" class="text-sm cursor-pointer" data-test="logout-button">
|
||||
{{ __('Log out') }}
|
||||
</flux:button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</x-layouts::auth>
|
||||
@@ -0,0 +1,20 @@
|
||||
<div class="flex items-start max-md:flex-col">
|
||||
<div class="me-10 w-full pb-4 md:w-[220px]">
|
||||
<flux:navlist aria-label="{{ __('Settings') }}">
|
||||
<flux:navlist.item :href="route('profile.edit')" wire:navigate>{{ __('Profile') }}</flux:navlist.item>
|
||||
<flux:navlist.item :href="route('security.edit')" wire:navigate>{{ __('Security') }}</flux:navlist.item>
|
||||
<flux:navlist.item :href="route('appearance.edit')" wire:navigate>{{ __('Appearance') }}</flux:navlist.item>
|
||||
</flux:navlist>
|
||||
</div>
|
||||
|
||||
<flux:separator class="md:hidden" />
|
||||
|
||||
<div class="flex-1 self-stretch max-md:pt-6">
|
||||
<flux:heading>{{ $heading ?? '' }}</flux:heading>
|
||||
<flux:subheading>{{ $subheading ?? '' }}</flux:subheading>
|
||||
|
||||
<div class="mt-5 w-full max-w-lg">
|
||||
{{ $slot }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
use Laravel\Fortify\Actions\GenerateNewRecoveryCodes;
|
||||
use Livewire\Attributes\Locked;
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component {
|
||||
#[Locked]
|
||||
public array $recoveryCodes = [];
|
||||
|
||||
/**
|
||||
* Mount the component.
|
||||
*/
|
||||
public function mount(): void
|
||||
{
|
||||
$this->loadRecoveryCodes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate new recovery codes for the user.
|
||||
*/
|
||||
public function regenerateRecoveryCodes(GenerateNewRecoveryCodes $generateNewRecoveryCodes): void
|
||||
{
|
||||
$generateNewRecoveryCodes(auth()->user());
|
||||
|
||||
$this->loadRecoveryCodes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the recovery codes for the user.
|
||||
*/
|
||||
private function loadRecoveryCodes(): void
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->hasEnabledTwoFactorAuthentication() && $user->two_factor_recovery_codes) {
|
||||
try {
|
||||
$this->recoveryCodes = json_decode(decrypt($user->two_factor_recovery_codes), true);
|
||||
} catch (Exception) {
|
||||
$this->addError('recoveryCodes', 'Failed to load recovery codes');
|
||||
|
||||
$this->recoveryCodes = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<div
|
||||
class="py-6 space-y-6 border shadow-sm rounded-xl border-zinc-200 dark:border-white/10"
|
||||
wire:cloak
|
||||
x-data="{ showRecoveryCodes: false }"
|
||||
>
|
||||
<div class="px-6 space-y-2">
|
||||
<div class="flex items-center gap-2">
|
||||
<flux:icon.lock-closed variant="outline" class="size-4"/>
|
||||
<flux:heading size="lg" level="3">{{ __('2FA recovery codes') }}</flux:heading>
|
||||
</div>
|
||||
<flux:text variant="subtle">
|
||||
{{ __('Recovery codes let you regain access if you lose your 2FA device. Store them in a secure password manager.') }}
|
||||
</flux:text>
|
||||
</div>
|
||||
|
||||
<div class="px-6">
|
||||
<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
||||
<flux:button
|
||||
x-show="!showRecoveryCodes"
|
||||
icon="eye"
|
||||
icon:variant="outline"
|
||||
variant="primary"
|
||||
@click="showRecoveryCodes = true;"
|
||||
aria-expanded="false"
|
||||
aria-controls="recovery-codes-section"
|
||||
>
|
||||
{{ __('View recovery codes') }}
|
||||
</flux:button>
|
||||
|
||||
<flux:button
|
||||
x-show="showRecoveryCodes"
|
||||
icon="eye-slash"
|
||||
icon:variant="outline"
|
||||
variant="primary"
|
||||
@click="showRecoveryCodes = false"
|
||||
aria-expanded="true"
|
||||
aria-controls="recovery-codes-section"
|
||||
>
|
||||
{{ __('Hide recovery codes') }}
|
||||
</flux:button>
|
||||
|
||||
@if (filled($recoveryCodes))
|
||||
<flux:button
|
||||
x-show="showRecoveryCodes"
|
||||
icon="arrow-path"
|
||||
variant="filled"
|
||||
wire:click="regenerateRecoveryCodes"
|
||||
>
|
||||
{{ __('Regenerate codes') }}
|
||||
</flux:button>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div
|
||||
x-show="showRecoveryCodes"
|
||||
x-transition
|
||||
id="recovery-codes-section"
|
||||
class="relative overflow-hidden"
|
||||
x-bind:aria-hidden="!showRecoveryCodes"
|
||||
>
|
||||
<div class="mt-3 space-y-3">
|
||||
@error('recoveryCodes')
|
||||
<flux:callout variant="danger" icon="x-circle" heading="{{$message}}"/>
|
||||
@enderror
|
||||
|
||||
@if (filled($recoveryCodes))
|
||||
<div
|
||||
class="grid gap-1 p-4 font-mono text-sm rounded-lg bg-zinc-100 dark:bg-white/5"
|
||||
role="list"
|
||||
aria-label="{{ __('Recovery codes') }}"
|
||||
>
|
||||
@foreach($recoveryCodes as $code)
|
||||
<div
|
||||
role="listitem"
|
||||
class="select-text"
|
||||
wire:loading.class="opacity-50 animate-pulse"
|
||||
>
|
||||
{{ $code }}
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
<flux:text variant="subtle" class="text-xs">
|
||||
{{ __('Each recovery code can be used once to access your account and will be removed after use. If you need more, click Regenerate codes above.') }}
|
||||
</flux:text>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Livewire\Component;
|
||||
use Livewire\Attributes\Title;
|
||||
|
||||
new #[Title('Appearance settings')] class extends Component {
|
||||
//
|
||||
}; ?>
|
||||
|
||||
<section class="w-full">
|
||||
@include('partials.settings-heading')
|
||||
|
||||
<flux:heading level="2" class="sr-only">{{ __('Appearance settings') }}</flux:heading>
|
||||
|
||||
<x-pages::settings.layout :heading="__('Appearance')" :subheading="__('Update the appearance settings for your account')">
|
||||
<flux:radio.group x-data variant="segmented" x-model="$flux.appearance">
|
||||
<flux:radio value="light" icon="sun">{{ __('Light') }}</flux:radio>
|
||||
<flux:radio value="dark" icon="moon">{{ __('Dark') }}</flux:radio>
|
||||
<flux:radio value="system" icon="computer-desktop">{{ __('System') }}</flux:radio>
|
||||
</flux:radio.group>
|
||||
</x-pages::settings.layout>
|
||||
</section>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component {}; ?>
|
||||
|
||||
<section class="mt-10 space-y-6">
|
||||
<div class="relative mb-5">
|
||||
<flux:heading>{{ __('Delete account') }}</flux:heading>
|
||||
<flux:subheading>{{ __('Delete your account and all of its resources') }}</flux:subheading>
|
||||
</div>
|
||||
|
||||
<flux:modal.trigger name="confirm-user-deletion">
|
||||
<flux:button variant="danger" data-test="delete-user-button">
|
||||
{{ __('Delete account') }}
|
||||
</flux:button>
|
||||
</flux:modal.trigger>
|
||||
|
||||
<livewire:pages::settings.delete-user-modal />
|
||||
</section>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use App\Concerns\PasswordValidationRules;
|
||||
use App\Livewire\Actions\Logout;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component {
|
||||
use PasswordValidationRules;
|
||||
|
||||
public string $password = '';
|
||||
|
||||
/**
|
||||
* Delete the currently authenticated user.
|
||||
*/
|
||||
public function deleteUser(Logout $logout): void
|
||||
{
|
||||
$this->validate([
|
||||
'password' => $this->currentPasswordRules(),
|
||||
]);
|
||||
|
||||
tap(Auth::user(), $logout(...))->delete();
|
||||
|
||||
$this->redirect('/', navigate: true);
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<flux:modal name="confirm-user-deletion" :show="$errors->isNotEmpty()" focusable class="max-w-lg">
|
||||
<form method="POST" wire:submit="deleteUser" class="space-y-6">
|
||||
<div>
|
||||
<flux:heading size="lg">{{ __('Are you sure you want to delete your account?') }}</flux:heading>
|
||||
|
||||
<flux:subheading>
|
||||
{{ __('Once your account is deleted, all of its resources and data will be permanently deleted. Please enter your password to confirm you would like to permanently delete your account.') }}
|
||||
</flux:subheading>
|
||||
</div>
|
||||
|
||||
<flux:input wire:model="password" :label="__('Password')" type="password" viewable />
|
||||
|
||||
<div class="flex justify-end space-x-2 rtl:space-x-reverse">
|
||||
<flux:modal.close>
|
||||
<flux:button variant="filled">{{ __('Cancel') }}</flux:button>
|
||||
</flux:modal.close>
|
||||
|
||||
<flux:button variant="danger" type="submit" data-test="confirm-delete-user-button">
|
||||
{{ __('Delete account') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</form>
|
||||
</flux:modal>
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
use App\Concerns\ProfileValidationRules;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Flux\Flux;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Component;
|
||||
|
||||
new #[Title('Profile settings')] class extends Component {
|
||||
use ProfileValidationRules;
|
||||
|
||||
public string $name = '';
|
||||
public string $email = '';
|
||||
|
||||
/**
|
||||
* Mount the component.
|
||||
*/
|
||||
public function mount(): void
|
||||
{
|
||||
$this->name = Auth::user()->name;
|
||||
$this->email = Auth::user()->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the profile information for the currently authenticated user.
|
||||
*/
|
||||
public function updateProfileInformation(): void
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$validated = $this->validate($this->profileRules($user->id));
|
||||
|
||||
$user->fill($validated);
|
||||
|
||||
if ($user->isDirty('email')) {
|
||||
$user->email_verified_at = null;
|
||||
}
|
||||
|
||||
$user->save();
|
||||
|
||||
Flux::toast(variant: 'success', text: __('Profile updated.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an email verification notification to the current user.
|
||||
*/
|
||||
public function resendVerificationNotification(): void
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if ($user->hasVerifiedEmail()) {
|
||||
$this->redirectIntended(default: route('dashboard', absolute: false));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$user->sendEmailVerificationNotification();
|
||||
|
||||
Session::flash('status', 'verification-link-sent');
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function hasUnverifiedEmail(): bool
|
||||
{
|
||||
return Auth::user() instanceof MustVerifyEmail && ! Auth::user()->hasVerifiedEmail();
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function showDeleteUser(): bool
|
||||
{
|
||||
return ! Auth::user() instanceof MustVerifyEmail
|
||||
|| (Auth::user() instanceof MustVerifyEmail && Auth::user()->hasVerifiedEmail());
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<section class="w-full">
|
||||
@include('partials.settings-heading')
|
||||
|
||||
<flux:heading level="2" class="sr-only">{{ __('Profile settings') }}</flux:heading>
|
||||
|
||||
<x-pages::settings.layout :heading="__('Profile')" :subheading="__('Update your name and email address')">
|
||||
<form wire:submit="updateProfileInformation" class="my-6 w-full space-y-6">
|
||||
<flux:input wire:model="name" :label="__('Name')" type="text" required autofocus autocomplete="name" />
|
||||
|
||||
<div>
|
||||
<flux:input wire:model="email" :label="__('Email')" type="email" required autocomplete="email" />
|
||||
|
||||
@if ($this->hasUnverifiedEmail)
|
||||
<div>
|
||||
<flux:text class="mt-4">
|
||||
{{ __('Your email address is unverified.') }}
|
||||
|
||||
<flux:link class="text-sm cursor-pointer" wire:click.prevent="resendVerificationNotification">
|
||||
{{ __('Click here to re-send the verification email.') }}
|
||||
</flux:link>
|
||||
</flux:text>
|
||||
|
||||
@if (session('status') === 'verification-link-sent')
|
||||
<flux:text class="mt-2 font-medium !dark:text-green-400 !text-green-600">
|
||||
{{ __('A new verification link has been sent to your email address.') }}
|
||||
</flux:text>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="flex items-center justify-end">
|
||||
<flux:button variant="primary" type="submit" class="w-full" data-test="update-profile-button">
|
||||
{{ __('Save') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@if ($this->showDeleteUser)
|
||||
<livewire:pages::settings.delete-user-form />
|
||||
@endif
|
||||
</x-pages::settings.layout>
|
||||
</section>
|
||||
@@ -0,0 +1,341 @@
|
||||
<?php
|
||||
|
||||
use App\Concerns\PasswordValidationRules;
|
||||
use Flux\Flux;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Laravel\Fortify\Actions\DisableTwoFactorAuthentication;
|
||||
use Laravel\Fortify\Features;
|
||||
use Laravel\Fortify\Fortify;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Component;
|
||||
use Laravel\Passkeys\Actions\DeletePasskey;
|
||||
use Livewire\Attributes\Locked;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
new #[Title('Security settings')] class extends Component {
|
||||
use PasswordValidationRules;
|
||||
|
||||
public string $current_password = '';
|
||||
public string $password = '';
|
||||
public string $password_confirmation = '';
|
||||
|
||||
public bool $canManageTwoFactor;
|
||||
|
||||
public bool $twoFactorEnabled;
|
||||
|
||||
public bool $requiresConfirmation;
|
||||
|
||||
#[Locked]
|
||||
public bool $canManagePasskeys;
|
||||
|
||||
#[Locked]
|
||||
public array $passkeys = [];
|
||||
|
||||
public bool $showDeleteModal = false;
|
||||
|
||||
#[Locked]
|
||||
public ?int $deletingPasskeyId = null;
|
||||
|
||||
#[Locked]
|
||||
public string $deletingPasskeyName = '';
|
||||
|
||||
/**
|
||||
* Mount the component.
|
||||
*/
|
||||
public function mount(DisableTwoFactorAuthentication $disableTwoFactorAuthentication): void
|
||||
{
|
||||
$this->canManageTwoFactor = Features::canManageTwoFactorAuthentication();
|
||||
|
||||
if ($this->canManageTwoFactor) {
|
||||
if (Fortify::confirmsTwoFactorAuthentication() && is_null(auth()->user()->two_factor_confirmed_at)) {
|
||||
$disableTwoFactorAuthentication(auth()->user());
|
||||
}
|
||||
|
||||
$this->twoFactorEnabled = auth()->user()->hasEnabledTwoFactorAuthentication();
|
||||
$this->requiresConfirmation = Features::optionEnabled(Features::twoFactorAuthentication(), 'confirm');
|
||||
}
|
||||
|
||||
$this->canManagePasskeys = Features::canManagePasskeys();
|
||||
|
||||
if ($this->canManagePasskeys) {
|
||||
$this->loadPasskeys();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the password for the currently authenticated user.
|
||||
*/
|
||||
public function updatePassword(): void
|
||||
{
|
||||
try {
|
||||
$validated = $this->validate([
|
||||
'current_password' => $this->currentPasswordRules(),
|
||||
'password' => $this->passwordRules(),
|
||||
]);
|
||||
} catch (ValidationException $e) {
|
||||
$this->reset('current_password', 'password', 'password_confirmation');
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
Auth::user()->update([
|
||||
'password' => $validated['password'],
|
||||
]);
|
||||
|
||||
$this->reset('current_password', 'password', 'password_confirmation');
|
||||
|
||||
Flux::toast(variant: 'success', text: __('Password updated.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the user's passkeys.
|
||||
*/
|
||||
public function loadPasskeys(): void
|
||||
{
|
||||
$this->passkeys = auth()->user()->passkeys()
|
||||
->select(['id', 'name', 'credential', 'created_at', 'last_used_at'])
|
||||
->latest()
|
||||
->get()
|
||||
->map(fn ($passkey) => [
|
||||
'id' => $passkey->id,
|
||||
'name' => $passkey->name,
|
||||
'authenticator' => $passkey->authenticator,
|
||||
'created_at_diff' => $passkey->created_at->diffForHumans(),
|
||||
'last_used_at_diff' => $passkey->last_used_at?->diffForHumans(),
|
||||
])
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the delete confirmation modal.
|
||||
*/
|
||||
public function confirmDelete(int $passkeyId): void
|
||||
{
|
||||
$passkey = auth()->user()->passkeys()->findOrFail($passkeyId);
|
||||
|
||||
$this->deletingPasskeyId = $passkey->id;
|
||||
$this->deletingPasskeyName = $passkey->name;
|
||||
$this->showDeleteModal = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the passkey.
|
||||
*/
|
||||
public function deletePasskey(DeletePasskey $deletePasskey): void
|
||||
{
|
||||
if (! $this->deletingPasskeyId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$passkey = auth()->user()->passkeys()->findOrFail($this->deletingPasskeyId);
|
||||
|
||||
$deletePasskey(auth()->user(), $passkey);
|
||||
|
||||
$this->closeDeleteModal();
|
||||
$this->loadPasskeys();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the delete confirmation modal.
|
||||
*/
|
||||
public function closeDeleteModal(): void
|
||||
{
|
||||
$this->showDeleteModal = false;
|
||||
$this->deletingPasskeyId = null;
|
||||
$this->deletingPasskeyName = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the two-factor authentication enabled event.
|
||||
*/
|
||||
#[On('two-factor-enabled')]
|
||||
public function onTwoFactorEnabled(): void
|
||||
{
|
||||
$this->twoFactorEnabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable two-factor authentication for the user.
|
||||
*/
|
||||
public function disable(DisableTwoFactorAuthentication $disableTwoFactorAuthentication): void
|
||||
{
|
||||
$disableTwoFactorAuthentication(auth()->user());
|
||||
|
||||
$this->twoFactorEnabled = false;
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<section class="w-full">
|
||||
@include('partials.settings-heading')
|
||||
|
||||
<flux:heading level="2" class="sr-only">{{ __('Security settings') }}</flux:heading>
|
||||
|
||||
<x-pages::settings.layout :heading="__('Update password')" :subheading="__('Ensure your account is using a long, random password to stay secure')">
|
||||
<form method="POST" wire:submit="updatePassword" class="mt-6 space-y-6">
|
||||
<flux:input
|
||||
wire:model="current_password"
|
||||
:label="__('Current password')"
|
||||
type="password"
|
||||
required
|
||||
autocomplete="current-password"
|
||||
viewable
|
||||
/>
|
||||
<flux:input
|
||||
wire:model="password"
|
||||
:label="__('New password')"
|
||||
type="password"
|
||||
required
|
||||
autocomplete="new-password"
|
||||
passwordrules="{{ \Illuminate\Validation\Rules\Password::defaults()->toPasswordRulesString() }}"
|
||||
viewable
|
||||
/>
|
||||
<flux:input
|
||||
wire:model="password_confirmation"
|
||||
:label="__('Confirm password')"
|
||||
type="password"
|
||||
required
|
||||
autocomplete="new-password"
|
||||
passwordrules="{{ \Illuminate\Validation\Rules\Password::defaults()->toPasswordRulesString() }}"
|
||||
viewable
|
||||
/>
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<flux:button variant="primary" type="submit" data-test="update-password-button">
|
||||
{{ __('Save') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@if ($canManageTwoFactor)
|
||||
<section class="mt-12">
|
||||
<flux:heading>{{ __('Two-factor authentication') }}</flux:heading>
|
||||
<flux:subheading>{{ __('Manage your two-factor authentication settings') }}</flux:subheading>
|
||||
|
||||
<div class="flex flex-col w-full mx-auto space-y-6 text-sm" wire:cloak>
|
||||
@if ($twoFactorEnabled)
|
||||
<div class="space-y-4">
|
||||
<flux:text>
|
||||
{{ __('You will be prompted for a secure, random pin during login, which you can retrieve from the TOTP-supported application on your phone.') }}
|
||||
</flux:text>
|
||||
|
||||
<div class="flex justify-start">
|
||||
<flux:button
|
||||
variant="danger"
|
||||
wire:click="disable"
|
||||
>
|
||||
{{ __('Disable 2FA') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
|
||||
<livewire:pages::settings.two-factor.recovery-codes :$requiresConfirmation />
|
||||
</div>
|
||||
@else
|
||||
<div class="space-y-4">
|
||||
<flux:text variant="subtle">
|
||||
{{ __('When you enable two-factor authentication, you will be prompted for a secure pin during login. This pin can be retrieved from a TOTP-supported application on your phone.') }}
|
||||
</flux:text>
|
||||
|
||||
<flux:modal.trigger name="two-factor-setup-modal">
|
||||
<flux:button
|
||||
variant="primary"
|
||||
wire:click="$dispatch('start-two-factor-setup')"
|
||||
>
|
||||
{{ __('Enable 2FA') }}
|
||||
</flux:button>
|
||||
</flux:modal.trigger>
|
||||
|
||||
<livewire:pages::settings.two-factor-setup-modal :requires-confirmation="$requiresConfirmation" />
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</section>
|
||||
@endif
|
||||
|
||||
@if ($canManagePasskeys)
|
||||
<section class="mt-12">
|
||||
<flux:heading>{{ __('Passkeys') }}</flux:heading>
|
||||
<flux:subheading>{{ __('Manage your passkeys for passwordless sign-in') }}</flux:subheading>
|
||||
|
||||
<div class="mt-6 flex flex-col w-full mx-auto space-y-6 text-sm" wire:cloak>
|
||||
<div class="border rounded-lg border-zinc-200 dark:border-zinc-700 overflow-hidden">
|
||||
@forelse ($passkeys as $passkey)
|
||||
<div class="flex items-center justify-between p-4 {{ ! $loop->last ? 'border-b border-zinc-200 dark:border-zinc-700' : '' }}">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="flex size-10 shrink-0 items-center justify-center rounded-xl bg-zinc-100 dark:bg-zinc-800">
|
||||
<flux:icon.key class="size-5 text-zinc-500 dark:text-zinc-400" />
|
||||
</div>
|
||||
<div class="space-y-1">
|
||||
<div class="flex items-center gap-2.5">
|
||||
<p class="font-medium tracking-tight">{{ $passkey['name'] }}</p>
|
||||
@if ($passkey['authenticator'])
|
||||
<flux:badge size="sm">{{ $passkey['authenticator'] }}</flux:badge>
|
||||
@endif
|
||||
</div>
|
||||
<p class="text-zinc-500 dark:text-zinc-400 text-xs">
|
||||
{{ __('Added :time', ['time' => $passkey['created_at_diff']]) }}
|
||||
@if ($passkey['last_used_at_diff'])
|
||||
<span class="opacity-50 mx-1">/</span>
|
||||
{{ __('Last used :time', ['time' => $passkey['last_used_at_diff']]) }}
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<flux:button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
icon="trash"
|
||||
icon:variant="outline"
|
||||
wire:click="confirmDelete({{ $passkey['id'] }})"
|
||||
class="text-red-500 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-950/50"
|
||||
/>
|
||||
</div>
|
||||
@empty
|
||||
<div class="p-8 text-center">
|
||||
<div class="mx-auto mb-4 flex size-14 items-center justify-center rounded-2xl bg-zinc-100 dark:bg-zinc-800">
|
||||
<flux:icon.key class="size-7 text-zinc-400 dark:text-zinc-500" />
|
||||
</div>
|
||||
<p class="font-medium">{{ __('No passkeys yet') }}</p>
|
||||
<flux:text class="mt-1">{{ __('Add a passkey to sign in without a password') }}</flux:text>
|
||||
</div>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
<x-passkey-registration />
|
||||
</div>
|
||||
</section>
|
||||
@endif
|
||||
</x-pages::settings.layout>
|
||||
|
||||
<flux:modal
|
||||
name="delete-passkey-modal"
|
||||
class="max-w-md md:min-w-md"
|
||||
@close="closeDeleteModal"
|
||||
wire:model="showDeleteModal"
|
||||
>
|
||||
<div class="space-y-6">
|
||||
<div class="space-y-2">
|
||||
<flux:heading size="lg">{{ __('Remove passkey') }}</flux:heading>
|
||||
<flux:text>
|
||||
{{ __('Are you sure you want to remove the passkey ":name"? You will no longer be able to use it to sign in.', ['name' => $deletingPasskeyName]) }}
|
||||
</flux:text>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3 justify-end">
|
||||
<flux:button
|
||||
variant="outline"
|
||||
wire:click="closeDeleteModal"
|
||||
>
|
||||
{{ __('Cancel') }}
|
||||
</flux:button>
|
||||
<flux:button
|
||||
variant="danger"
|
||||
wire:click="deletePasskey"
|
||||
>
|
||||
{{ __('Remove passkey') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</div>
|
||||
</flux:modal>
|
||||
</section>
|
||||
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
|
||||
use Laravel\Fortify\Actions\ConfirmTwoFactorAuthentication;
|
||||
use Laravel\Fortify\Actions\EnableTwoFactorAuthentication;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\Locked;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Attributes\Validate;
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component {
|
||||
#[Locked]
|
||||
public bool $requiresConfirmation;
|
||||
|
||||
#[Locked]
|
||||
public string $qrCodeSvg = '';
|
||||
|
||||
#[Locked]
|
||||
public string $manualSetupKey = '';
|
||||
|
||||
public bool $showVerificationStep = false;
|
||||
|
||||
public bool $setupComplete = false;
|
||||
|
||||
#[Validate('required|string|size:6', onUpdate: false)]
|
||||
public string $code = '';
|
||||
|
||||
/**
|
||||
* Mount the component.
|
||||
*/
|
||||
public function mount(bool $requiresConfirmation): void
|
||||
{
|
||||
$this->requiresConfirmation = $requiresConfirmation;
|
||||
}
|
||||
|
||||
#[On('start-two-factor-setup')]
|
||||
public function startTwoFactorSetup(): void
|
||||
{
|
||||
$enableTwoFactorAuthentication = app(EnableTwoFactorAuthentication::class);
|
||||
$enableTwoFactorAuthentication(auth()->user());
|
||||
|
||||
$this->loadSetupData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the two-factor authentication setup data for the user.
|
||||
*/
|
||||
private function loadSetupData(): void
|
||||
{
|
||||
$user = auth()->user()?->fresh();
|
||||
|
||||
try {
|
||||
if (! $user || ! $user->two_factor_secret) {
|
||||
throw new Exception('Two-factor setup secret is not available.');
|
||||
}
|
||||
|
||||
$this->qrCodeSvg = $user->twoFactorQrCodeSvg();
|
||||
$this->manualSetupKey = decrypt($user->two_factor_secret);
|
||||
} catch (Exception) {
|
||||
$this->addError('setupData', 'Failed to fetch setup data.');
|
||||
|
||||
$this->reset('qrCodeSvg', 'manualSetupKey');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the two-factor verification step if necessary.
|
||||
*/
|
||||
public function showVerificationIfNecessary(): void
|
||||
{
|
||||
if ($this->requiresConfirmation) {
|
||||
$this->showVerificationStep = true;
|
||||
|
||||
$this->resetErrorBag();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->closeModal();
|
||||
$this->dispatch('two-factor-enabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm two-factor authentication for the user.
|
||||
*/
|
||||
public function confirmTwoFactor(ConfirmTwoFactorAuthentication $confirmTwoFactorAuthentication): void
|
||||
{
|
||||
$this->validate();
|
||||
|
||||
$confirmTwoFactorAuthentication(auth()->user(), $this->code);
|
||||
|
||||
$this->setupComplete = true;
|
||||
|
||||
$this->closeModal();
|
||||
|
||||
$this->dispatch('two-factor-enabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset two-factor verification state.
|
||||
*/
|
||||
public function resetVerification(): void
|
||||
{
|
||||
$this->reset('code', 'showVerificationStep');
|
||||
|
||||
$this->resetErrorBag();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the two-factor authentication modal.
|
||||
*/
|
||||
public function closeModal(): void
|
||||
{
|
||||
$this->reset(
|
||||
'code',
|
||||
'manualSetupKey',
|
||||
'qrCodeSvg',
|
||||
'showVerificationStep',
|
||||
'setupComplete',
|
||||
);
|
||||
|
||||
$this->resetErrorBag();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current modal configuration state.
|
||||
*/
|
||||
#[Computed]
|
||||
public function modalConfig(): array
|
||||
{
|
||||
if ($this->setupComplete) {
|
||||
return [
|
||||
'title' => __('Two-factor authentication enabled'),
|
||||
'description' => __('Two-factor authentication is now enabled. Scan the QR code or enter the setup key in your authenticator app.'),
|
||||
'buttonText' => __('Close'),
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->showVerificationStep) {
|
||||
return [
|
||||
'title' => __('Verify authentication code'),
|
||||
'description' => __('Enter the 6-digit code from your authenticator app.'),
|
||||
'buttonText' => __('Continue'),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'title' => __('Enable two-factor authentication'),
|
||||
'description' => __('To finish enabling two-factor authentication, scan the QR code or enter the setup key in your authenticator app.'),
|
||||
'buttonText' => __('Continue'),
|
||||
];
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<flux:modal
|
||||
name="two-factor-setup-modal"
|
||||
class="max-w-md md:min-w-md"
|
||||
@close="closeModal"
|
||||
>
|
||||
<div class="space-y-6">
|
||||
<div class="flex flex-col items-center space-y-4">
|
||||
<div class="p-0.5 w-auto rounded-full border border-stone-100 dark:border-stone-600 bg-white dark:bg-stone-800 shadow-sm">
|
||||
<div class="p-2.5 rounded-full border border-stone-200 dark:border-stone-600 overflow-hidden bg-stone-100 dark:bg-stone-200 relative">
|
||||
<div class="flex items-stretch absolute inset-0 w-full h-full divide-x [&>div]:flex-1 divide-stone-200 dark:divide-stone-300 justify-around opacity-50">
|
||||
@for ($i = 1; $i <= 5; $i++)
|
||||
<div></div>
|
||||
@endfor
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col items-stretch absolute w-full h-full divide-y [&>div]:flex-1 inset-0 divide-stone-200 dark:divide-stone-300 justify-around opacity-50">
|
||||
@for ($i = 1; $i <= 5; $i++)
|
||||
<div></div>
|
||||
@endfor
|
||||
</div>
|
||||
|
||||
<flux:icon.qr-code class="relative z-20 dark:text-accent-foreground"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2 text-center">
|
||||
<flux:heading size="lg">{{ $this->modalConfig['title'] }}</flux:heading>
|
||||
<flux:text>{{ $this->modalConfig['description'] }}</flux:text>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if ($showVerificationStep)
|
||||
<div class="space-y-6">
|
||||
<div
|
||||
class="flex flex-col items-center space-y-3 justify-center"
|
||||
x-data
|
||||
x-init="$nextTick(() => $el.querySelector('input')?.focus())"
|
||||
>
|
||||
<flux:otp
|
||||
name="code"
|
||||
wire:model="code"
|
||||
length="6"
|
||||
label="OTP Code"
|
||||
label:sr-only
|
||||
class="mx-auto"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center space-x-3">
|
||||
<flux:button
|
||||
variant="outline"
|
||||
class="flex-1"
|
||||
wire:click="resetVerification"
|
||||
>
|
||||
{{ __('Back') }}
|
||||
</flux:button>
|
||||
|
||||
<flux:button
|
||||
variant="primary"
|
||||
class="flex-1"
|
||||
wire:click="confirmTwoFactor"
|
||||
x-bind:disabled="$wire.code.length < 6"
|
||||
>
|
||||
{{ __('Confirm') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
@error('setupData')
|
||||
<flux:callout variant="danger" icon="x-circle" heading="{{ $message }}"/>
|
||||
@enderror
|
||||
|
||||
<div class="flex justify-center">
|
||||
<div class="relative w-64 overflow-hidden border rounded-lg border-stone-200 dark:border-stone-700 aspect-square">
|
||||
@empty($qrCodeSvg)
|
||||
<div class="absolute inset-0 flex items-center justify-center bg-white dark:bg-stone-700 animate-pulse">
|
||||
<flux:icon.loading/>
|
||||
</div>
|
||||
@else
|
||||
<div x-data class="flex items-center justify-center h-full p-4">
|
||||
<div
|
||||
class="bg-white p-3 rounded"
|
||||
:style="($flux.appearance === 'dark' || ($flux.appearance === 'system' && $flux.dark)) ? 'filter: invert(1) brightness(1.5)' : ''"
|
||||
>
|
||||
{!! $qrCodeSvg !!}
|
||||
</div>
|
||||
</div>
|
||||
@endempty
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<flux:button
|
||||
:disabled="$errors->has('setupData')"
|
||||
variant="primary"
|
||||
class="w-full"
|
||||
wire:click="showVerificationIfNecessary"
|
||||
>
|
||||
{{ $this->modalConfig['buttonText'] }}
|
||||
</flux:button>
|
||||
</div>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div class="relative flex items-center justify-center w-full">
|
||||
<div class="absolute inset-0 w-full h-px top-1/2 bg-stone-200 dark:bg-stone-600"></div>
|
||||
<span class="relative px-2 text-sm bg-white dark:bg-stone-800 text-stone-600 dark:text-stone-400">
|
||||
{{ __('or, enter the code manually') }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex items-center space-x-2"
|
||||
x-data="{
|
||||
copied: false,
|
||||
async copy() {
|
||||
try {
|
||||
await navigator.clipboard.writeText('{{ $manualSetupKey }}');
|
||||
this.copied = true;
|
||||
setTimeout(() => this.copied = false, 1500);
|
||||
} catch (e) {
|
||||
console.warn('Could not copy to clipboard');
|
||||
}
|
||||
}
|
||||
}"
|
||||
>
|
||||
<div class="flex items-stretch w-full border rounded-xl dark:border-stone-700">
|
||||
@empty($manualSetupKey)
|
||||
<div class="flex items-center justify-center w-full p-3 bg-stone-100 dark:bg-stone-700">
|
||||
<flux:icon.loading variant="mini"/>
|
||||
</div>
|
||||
@else
|
||||
<input
|
||||
type="text"
|
||||
readonly
|
||||
value="{{ $manualSetupKey }}"
|
||||
class="w-full p-3 bg-transparent outline-none text-stone-900 dark:text-stone-100"
|
||||
/>
|
||||
|
||||
<button
|
||||
@click="copy()"
|
||||
class="px-3 transition-colors border-l cursor-pointer border-stone-200 dark:border-stone-600"
|
||||
>
|
||||
<flux:icon.document-duplicate x-show="!copied" variant="outline"></flux:icon>
|
||||
<flux:icon.check
|
||||
x-show="copied"
|
||||
variant="solid"
|
||||
class="text-green-500"
|
||||
></flux:icon>
|
||||
</button>
|
||||
@endempty
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</flux:modal>
|
||||
@@ -0,0 +1,534 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Folder;
|
||||
use App\Models\Todo;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\Locked;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
new #[Title('Dashboard')] class extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
#[Locked]
|
||||
public ?int $editingTodoId = null;
|
||||
|
||||
public string $search = '';
|
||||
|
||||
public ?int $folderId = null;
|
||||
|
||||
public string $status = 'all';
|
||||
|
||||
public bool $showTodoForm = false;
|
||||
|
||||
public string $description = '';
|
||||
|
||||
public ?string $dueDate = null;
|
||||
|
||||
public string $notes = '';
|
||||
|
||||
public ?int $formFolderId = null;
|
||||
|
||||
#[Locked]
|
||||
public ?int $confirmingTodoDelete = null;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$folderId = request()->query('folder');
|
||||
|
||||
if ($folderId === null || $folderId === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$folderId = (int) $folderId;
|
||||
|
||||
if (Folder::query()->forUser(auth()->id())->whereKey($folderId)->exists()) {
|
||||
$this->folderId = $folderId;
|
||||
}
|
||||
}
|
||||
|
||||
public function updatedSearch(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedFolderId(): void
|
||||
{
|
||||
$this->folderId = $this->folderId === null || $this->folderId === '' ? null : (int) $this->folderId;
|
||||
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedStatus(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function openCreateForm(?int $folderId = null): void
|
||||
{
|
||||
$this->reset('editingTodoId', 'description', 'dueDate', 'notes', 'formFolderId');
|
||||
$this->resetErrorBag();
|
||||
|
||||
if ($folderId !== null && $this->folderTree->contains(fn ($node) => $node['folder']->id === $folderId)) {
|
||||
$this->formFolderId = $folderId;
|
||||
} elseif ($this->folderId !== null) {
|
||||
$this->formFolderId = $this->folderId;
|
||||
}
|
||||
|
||||
$this->showTodoForm = true;
|
||||
}
|
||||
|
||||
public function openEditForm(int $todoId): void
|
||||
{
|
||||
$todo = $this->todoForUser($todoId);
|
||||
|
||||
$this->editingTodoId = $todo->id;
|
||||
$this->description = $todo->description;
|
||||
$this->dueDate = $todo->due_date?->format('Y-m-d') ?? '';
|
||||
$this->notes = $todo->notes ?? '';
|
||||
$this->formFolderId = $todo->folder_id;
|
||||
|
||||
$this->resetErrorBag();
|
||||
$this->showTodoForm = true;
|
||||
}
|
||||
|
||||
public function saveTodo(): void
|
||||
{
|
||||
$validated = $this->validate([
|
||||
'description' => ['required', 'string', 'max:255'],
|
||||
'dueDate' => ['nullable', 'date'],
|
||||
'notes' => ['nullable', 'string', 'max:'.auth()->user()->notesLimit()],
|
||||
'formFolderId' => ['required', 'integer', Rule::exists('folders', 'id')->where('user_id', auth()->id())],
|
||||
]);
|
||||
|
||||
$data = [
|
||||
'folder_id' => $validated['formFolderId'],
|
||||
'description' => $validated['description'],
|
||||
'due_date' => filled($validated['dueDate']) ? Carbon::parse($validated['dueDate']) : null,
|
||||
'notes' => filled($validated['notes']) ? $validated['notes'] : null,
|
||||
];
|
||||
|
||||
if ($this->editingTodoId !== null) {
|
||||
$this->todoForUser($this->editingTodoId)->update($data);
|
||||
} else {
|
||||
Todo::create($data + ['user_id' => auth()->id()]);
|
||||
}
|
||||
|
||||
$this->reset('showTodoForm', 'editingTodoId', 'description', 'dueDate', 'notes', 'formFolderId');
|
||||
}
|
||||
|
||||
public function toggleComplete(int $todoId): void
|
||||
{
|
||||
$todo = $this->todoForUser($todoId);
|
||||
|
||||
$todo->update([
|
||||
'completed_at' => $todo->completed_at === null ? now() : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function confirmTodoDelete(int $todoId): void
|
||||
{
|
||||
$this->todoForUser($todoId);
|
||||
|
||||
$this->confirmingTodoDelete = $todoId;
|
||||
$this->modal('confirm-todo-delete')->show();
|
||||
}
|
||||
|
||||
public function deleteTodo(): void
|
||||
{
|
||||
$this->todoForUser($this->confirmingTodoDelete)->delete();
|
||||
|
||||
$this->confirmingTodoDelete = null;
|
||||
$this->modal('confirm-todo-delete')->close();
|
||||
}
|
||||
|
||||
public function resetFilters(): void
|
||||
{
|
||||
$this->reset('search', 'folderId', 'status');
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function todoCounts(): array
|
||||
{
|
||||
$query = Todo::query()->forUser(auth()->id());
|
||||
|
||||
return [
|
||||
'open' => (clone $query)->incomplete()->count(),
|
||||
'completed' => (clone $query)->completed()->count(),
|
||||
'overdue' => (clone $query)->overdue()->count(),
|
||||
'dueToday' => (clone $query)->dueToday()->count(),
|
||||
];
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function folderTree(): Collection
|
||||
{
|
||||
return Folder::treeForUser(auth()->id());
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function filterFolderScope(): array
|
||||
{
|
||||
if ($this->folderId === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->descendantIds($this->folderId);
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function folderCounts(): Collection
|
||||
{
|
||||
$tree = $this->folderTree;
|
||||
|
||||
$openByFolder = Todo::query()
|
||||
->forUser(auth()->id())
|
||||
->incomplete()
|
||||
->pluck('folder_id')
|
||||
->countBy();
|
||||
$overdueByFolder = Todo::query()
|
||||
->forUser(auth()->id())
|
||||
->overdue()
|
||||
->pluck('folder_id')
|
||||
->countBy();
|
||||
|
||||
return $tree
|
||||
->where('depth', 0)
|
||||
->values()
|
||||
->map(fn (array $node) => [
|
||||
'folder' => $node['folder'],
|
||||
'open' => collect($openByFolder)->only($this->descendantIds($node['folder']->id))->sum(),
|
||||
'overdue' => collect($overdueByFolder)->only($this->descendantIds($node['folder']->id))->sum(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function hasActiveFilters(): bool
|
||||
{
|
||||
return $this->search !== '' || $this->folderId !== null || $this->status !== 'all';
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function todos(): LengthAwarePaginator
|
||||
{
|
||||
return Todo::query()
|
||||
->forUser(auth()->id())
|
||||
->with('folder.parent')
|
||||
->when(
|
||||
$this->search !== '',
|
||||
fn (Builder $query) => $query->where('description', 'like', '%'.$this->search.'%')
|
||||
)
|
||||
->when(
|
||||
$this->folderId !== null,
|
||||
fn (Builder $query) => $query->whereIn('folder_id', $this->filterFolderScope)
|
||||
)
|
||||
->when($this->status, function (Builder $query) {
|
||||
return match ($this->status) {
|
||||
'open' => $query->incomplete(),
|
||||
'completed' => $query->completed(),
|
||||
'overdue' => $query->overdue(),
|
||||
default => $query,
|
||||
};
|
||||
})
|
||||
->orderByRaw('completed_at IS NOT NULL')
|
||||
->orderByRaw('due_date IS NULL')
|
||||
->orderBy('due_date')
|
||||
->orderByDesc('id')
|
||||
->paginate(10);
|
||||
}
|
||||
|
||||
private function descendantIds(int $folderId): array
|
||||
{
|
||||
$ids = [$folderId];
|
||||
|
||||
foreach ($this->folderTree->where('folder.parent_id', $folderId)->values() as $child) {
|
||||
$ids = [...$ids, ...$this->descendantIds($child['folder']->id)];
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
private function todoForUser(int $todoId): Todo
|
||||
{
|
||||
return Todo::query()->forUser(auth()->id())->findOrFail($todoId);
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<div class="flex h-full w-full flex-1 flex-col gap-6">
|
||||
<div class="flex flex-wrap items-center justify-between gap-4">
|
||||
<div>
|
||||
<flux:heading size="xl">{{ __('Dashboard') }}</flux:heading>
|
||||
<flux:text class="mt-1">Track your todos across folders.</flux:text>
|
||||
</div>
|
||||
|
||||
<flux:button
|
||||
variant="primary"
|
||||
wire:click="openCreateForm"
|
||||
data-test="add-todo-button"
|
||||
>
|
||||
{{ __('New Todo') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
|
||||
@if ($this->folderTree->isEmpty())
|
||||
<flux:callout variant="warning" icon="folder">
|
||||
<x-slot name="text">
|
||||
{{ __('Create a folder to start adding todos.') }}
|
||||
</x-slot>
|
||||
<x-slot name="actions">
|
||||
<flux:button size="sm" :href="route('folders')" wire:navigate variant="primary">
|
||||
{{ __('Manage folders') }}
|
||||
</flux:button>
|
||||
</x-slot>
|
||||
</flux:callout>
|
||||
@endif
|
||||
|
||||
<div class="grid grid-cols-4 gap-3">
|
||||
<flux:card size="sm">
|
||||
<flux:heading size="sm" class="text-zinc-500">{{ __('Open') }}</flux:heading>
|
||||
<flux:heading size="xl" class="mt-1" data-test="count-open">{{ $this->todoCounts['open'] }}</flux:heading>
|
||||
</flux:card>
|
||||
|
||||
<flux:card size="sm">
|
||||
<flux:heading size="sm" class="text-zinc-500">{{ __('Overdue') }}</flux:heading>
|
||||
<flux:heading size="xl" class="mt-1 text-red-600 dark:text-red-400" data-test="count-overdue">{{ $this->todoCounts['overdue'] }}</flux:heading>
|
||||
</flux:card>
|
||||
|
||||
<flux:card size="sm">
|
||||
<flux:heading size="sm" class="text-zinc-500">{{ __('Due today') }}</flux:heading>
|
||||
<flux:heading size="xl" class="mt-1" data-test="count-due-today">{{ $this->todoCounts['dueToday'] }}</flux:heading>
|
||||
</flux:card>
|
||||
|
||||
<flux:card size="sm">
|
||||
<flux:heading size="sm" class="text-zinc-500">{{ __('Completed') }}</flux:heading>
|
||||
<flux:heading size="xl" class="mt-1" data-test="count-completed">{{ $this->todoCounts['completed'] }}</flux:heading>
|
||||
</flux:card>
|
||||
</div>
|
||||
|
||||
@if ($this->folderCounts->isNotEmpty())
|
||||
<div class="grid gap-4 sm:grid-cols-2 xl:grid-cols-3">
|
||||
@foreach ($this->folderCounts as $stat)
|
||||
<flux:card
|
||||
class="cursor-pointer transition hover:ring-2 hover:ring-zinc-300 dark:hover:ring-zinc-600"
|
||||
wire:click="$set('folderId', {{ $stat['folder']->id }})"
|
||||
data-test="folder-stat"
|
||||
>
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<flux:heading size="sm" class="truncate">{{ $stat['folder']->name }}</flux:heading>
|
||||
@if ($folderId === $stat['folder']->id)
|
||||
<flux:badge size="sm" color="blue">{{ __('Filtered') }}</flux:badge>
|
||||
@endif
|
||||
</div>
|
||||
<div class="mt-3 flex items-baseline gap-4">
|
||||
<flux:heading size="xl">{{ $stat['open'] }}</flux:heading>
|
||||
<flux:text class="text-sm">{{ __('open') }}</flux:text>
|
||||
@if ($stat['overdue'] > 0)
|
||||
<flux:text class="text-sm font-medium text-red-600 dark:text-red-400" data-test="folder-overdue-{{ $stat['folder']->id }}">
|
||||
{{ $stat['overdue'] }} {{ __('overdue') }}
|
||||
</flux:text>
|
||||
@endif
|
||||
</div>
|
||||
</flux:card>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
@foreach (['all' => 'All', 'open' => 'Open', 'completed' => 'Completed', 'overdue' => 'Overdue'] as $value => $label)
|
||||
<flux:button
|
||||
size="sm"
|
||||
:variant="$status === $value ? 'primary' : 'ghost'"
|
||||
wire:click="$set('status', '{{ $value }}')"
|
||||
:data-test="'status-' . $value"
|
||||
>
|
||||
{{ __($label) }}
|
||||
</flux:button>
|
||||
@endforeach
|
||||
|
||||
<flux:spacer />
|
||||
|
||||
<flux:input
|
||||
size="sm"
|
||||
type="search"
|
||||
icon="magnifying-glass"
|
||||
wire:model.live.debounce.300ms="search"
|
||||
placeholder="{{ __('Search todos…') }}"
|
||||
class="w-full sm:w-64"
|
||||
data-test="search-input"
|
||||
/>
|
||||
|
||||
<flux:select size="sm" wire:model.live="folderId" class="w-full sm:w-56" data-test="folder-filter">
|
||||
<flux:select.option value="">{{ __('All folders') }}</flux:select.option>
|
||||
@foreach ($this->folderTree as $node)
|
||||
<flux:select.option :value="$node['folder']->id">{{ str_repeat('— ', $node['depth']) }}{{ $node['folder']->name }}</flux:select.option>
|
||||
@endforeach
|
||||
</flux:select>
|
||||
|
||||
@if ($this->hasActiveFilters)
|
||||
<flux:button size="sm" variant="danger" icon="x-mark" wire:click="resetFilters" class="shrink-0">
|
||||
{{ __('Clear') }}
|
||||
</flux:button>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<flux:card>
|
||||
<flux:table :paginate="$this->todos">
|
||||
<flux:table.columns>
|
||||
<flux:table.column width="3rem">{{ __('Done') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Description') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Folder') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Due') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Created') }}</flux:table.column>
|
||||
<flux:table.column align="end" width="7rem">{{ __('Actions') }}</flux:table.column>
|
||||
</flux:table.columns>
|
||||
|
||||
<flux:table.rows>
|
||||
@forelse ($this->todos as $todo)
|
||||
<flux:table.row :key="$todo->id" data-test="todo-row">
|
||||
<flux:table.cell class="py-0">
|
||||
<flux:checkbox
|
||||
:checked="$todo->completed_at !== null"
|
||||
:title="$todo->completed_at ? __('Mark as not done') : __('Mark as done')"
|
||||
wire:click="toggleComplete({{ $todo->id }})"
|
||||
data-test="toggle-complete-{{ $todo->id }}"
|
||||
/>
|
||||
</flux:table.cell>
|
||||
|
||||
<flux:table.cell :variant="$todo->completed_at ? 'strong' : 'default'" data-test="todo-description-{{ $todo->id }}">
|
||||
<span :class="$todo->completed_at ? 'line-through text-zinc-400' : ''">{{ $todo->description }}</span>
|
||||
@if ($todo->notes)
|
||||
<flux:text size="sm" class="mt-1 block max-w-md truncate text-zinc-500">{{ $todo->notes }}</flux:text>
|
||||
@endif
|
||||
</flux:table.cell>
|
||||
|
||||
<flux:table.cell class="text-zinc-500">
|
||||
{{ $todo->folder?->parent?->name }}@if ($todo->folder?->parent) / @endif{{ $todo->folder?->name }}
|
||||
</flux:table.cell>
|
||||
|
||||
<flux:table.cell>
|
||||
@if ($todo->completed_at)
|
||||
<flux:badge size="sm" color="zinc">{{ $todo->due_date?->format('M j, Y') ?? __('—') }}</flux:badge>
|
||||
@elseif ($todo->due_date?->isPast())
|
||||
<flux:badge size="sm" color="red">{{ $todo->due_date->format('M j, Y') }}</flux:badge>
|
||||
@elseif ($todo->due_date?->isToday())
|
||||
<flux:badge size="sm" color="amber">{{ __('Today') }} · {{ $todo->due_date->format('M j') }}</flux:badge>
|
||||
@else
|
||||
<flux:text>{{ $todo->due_date?->format('M j, Y') ?? __('No due date') }}</flux:text>
|
||||
@endif
|
||||
</flux:table.cell>
|
||||
|
||||
<flux:table.cell class="text-zinc-500" data-test="todo-created-{{ $todo->id }}">
|
||||
{{ $todo->created_at->format('M j, Y') }}
|
||||
</flux:table.cell>
|
||||
|
||||
<flux:table.cell class="py-0">
|
||||
<div class="flex justify-end gap-1">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="pencil-square"
|
||||
:title="__('Edit todo')"
|
||||
wire:click="openEditForm({{ $todo->id }})"
|
||||
data-test="edit-todo-{{ $todo->id }}"
|
||||
/>
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="trash"
|
||||
:title="__('Delete todo')"
|
||||
wire:click="confirmTodoDelete({{ $todo->id }})"
|
||||
data-test="delete-todo-{{ $todo->id }}"
|
||||
/>
|
||||
</div>
|
||||
</flux:table.cell>
|
||||
</flux:table.row>
|
||||
@empty
|
||||
<flux:table.row>
|
||||
<flux:table.cell colspan="6" align="center" class="py-10">
|
||||
<flux:text>{{ __('No todos match your filters.') }}</flux:text>
|
||||
</flux:table.cell>
|
||||
</flux:table.row>
|
||||
@endforelse
|
||||
</flux:table.rows>
|
||||
</flux:table>
|
||||
</flux:card>
|
||||
|
||||
<flux:modal wire:model.self="showTodoForm" class="md:w-xl">
|
||||
<form wire:submit="saveTodo" class="space-y-6">
|
||||
<div>
|
||||
<flux:heading size="lg">{{ $editingTodoId === null ? __('New todo') : __('Edit todo') }}</flux:heading>
|
||||
<flux:text class="mt-2">{{ __('Add a task with a description and folder. A due date is optional.') }}</flux:text>
|
||||
</div>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Description') }}</flux:label>
|
||||
<flux:input
|
||||
wire:model="description"
|
||||
type="text"
|
||||
autofocus
|
||||
placeholder="{{ __('What needs to be done?') }}"
|
||||
data-test="description-input"
|
||||
/>
|
||||
<flux:error name="description" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Due date') }}</flux:label>
|
||||
<flux:input wire:model="dueDate" type="date" data-test="due-date-input" />
|
||||
<flux:error name="dueDate" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Notes') }}</flux:label>
|
||||
<flux:textarea
|
||||
wire:model="notes"
|
||||
rows="3"
|
||||
placeholder="{{ __('Add any extra details…') }}"
|
||||
data-test="notes-input"
|
||||
/>
|
||||
<flux:error name="notes" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Folder') }}</flux:label>
|
||||
<flux:select wire:model="formFolderId" data-test="folder-select">
|
||||
<flux:select.option value="">{{ __('Select a folder…') }}</flux:select.option>
|
||||
@foreach ($this->folderTree as $node)
|
||||
<flux:select.option :value="$node['folder']->id">{{ str_repeat('— ', $node['depth']) }}{{ $node['folder']->name }}</flux:select.option>
|
||||
@endforeach
|
||||
</flux:select>
|
||||
<flux:error name="formFolderId" />
|
||||
</flux:field>
|
||||
|
||||
<div class="flex justify-end gap-3">
|
||||
<flux:modal.close>
|
||||
<flux:button variant="ghost">{{ __('Cancel') }}</flux:button>
|
||||
</flux:modal.close>
|
||||
<flux:button type="submit" variant="primary">{{ __('Save todo') }}</flux:button>
|
||||
</div>
|
||||
</form>
|
||||
</flux:modal>
|
||||
|
||||
<flux:modal name="confirm-todo-delete" class="md:w-lg">
|
||||
<div class="space-y-6">
|
||||
<div>
|
||||
<flux:heading size="lg">{{ __('Delete todo?') }}</flux:heading>
|
||||
<flux:text class="mt-2">{{ __('This todo will be permanently deleted. This action cannot be undone.') }}</flux:text>
|
||||
</div>
|
||||
<div class="flex justify-end gap-3">
|
||||
<flux:modal.close>
|
||||
<flux:button variant="ghost">{{ __('Cancel') }}</flux:button>
|
||||
</flux:modal.close>
|
||||
<flux:button variant="danger" wire:click="deleteTodo">{{ __('Delete') }}</flux:button>
|
||||
</div>
|
||||
</div>
|
||||
</flux:modal>
|
||||
</div>
|
||||
@@ -0,0 +1,410 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Folder;
|
||||
use App\Models\Todo;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\Locked;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Component;
|
||||
|
||||
new #[Title('Folders')] class extends Component
|
||||
{
|
||||
public string $newFolderName = '';
|
||||
|
||||
#[Locked]
|
||||
public ?int $creatingChildOf = null;
|
||||
|
||||
public string $newChildName = '';
|
||||
|
||||
#[Locked]
|
||||
public ?int $renamingFolderId = null;
|
||||
|
||||
public string $renameName = '';
|
||||
|
||||
#[Locked]
|
||||
public ?int $confirmingFolderDelete = null;
|
||||
|
||||
public bool $showTodoForm = false;
|
||||
|
||||
#[Locked]
|
||||
public ?int $todoFolderId = null;
|
||||
|
||||
public string $todoDescription = '';
|
||||
|
||||
public ?string $todoDueDate = null;
|
||||
|
||||
public string $todoNotes = '';
|
||||
|
||||
public function createTopLevelFolder(): void
|
||||
{
|
||||
$validated = $this->validate([
|
||||
'newFolderName' => $this->folderNameRules(parentId: null),
|
||||
]);
|
||||
|
||||
Folder::create([
|
||||
'user_id' => auth()->id(),
|
||||
'name' => $validated['newFolderName'],
|
||||
'parent_id' => null,
|
||||
]);
|
||||
|
||||
$this->reset('newFolderName');
|
||||
}
|
||||
|
||||
public function startChildCreate(int $folderId): void
|
||||
{
|
||||
$this->folderForUser($folderId);
|
||||
|
||||
$this->creatingChildOf = $folderId;
|
||||
$this->reset('newChildName');
|
||||
$this->resetErrorBag('newChildName');
|
||||
}
|
||||
|
||||
public function cancelChildCreate(): void
|
||||
{
|
||||
$this->reset('creatingChildOf', 'newChildName');
|
||||
}
|
||||
|
||||
public function createChildFolder(): void
|
||||
{
|
||||
$this->folderForUser($this->creatingChildOf);
|
||||
|
||||
$validated = $this->validate([
|
||||
'newChildName' => $this->folderNameRules(parentId: $this->creatingChildOf),
|
||||
]);
|
||||
|
||||
Folder::create([
|
||||
'user_id' => auth()->id(),
|
||||
'name' => $validated['newChildName'],
|
||||
'parent_id' => $this->creatingChildOf,
|
||||
]);
|
||||
|
||||
$this->reset('creatingChildOf', 'newChildName');
|
||||
}
|
||||
|
||||
public function startRename(int $folderId): void
|
||||
{
|
||||
$folder = $this->folderForUser($folderId);
|
||||
|
||||
$this->renamingFolderId = $folder->id;
|
||||
$this->renameName = $folder->name;
|
||||
$this->resetErrorBag('renameName');
|
||||
}
|
||||
|
||||
public function cancelRename(): void
|
||||
{
|
||||
$this->reset('renamingFolderId', 'renameName');
|
||||
}
|
||||
|
||||
public function saveRename(): void
|
||||
{
|
||||
$folder = $this->folderForUser($this->renamingFolderId);
|
||||
|
||||
$validated = $this->validate([
|
||||
'renameName' => $this->folderNameRules(parentId: $folder->parent_id, ignoreId: $folder->id),
|
||||
]);
|
||||
|
||||
$folder->update(['name' => $validated['renameName']]);
|
||||
|
||||
$this->reset('renamingFolderId', 'renameName');
|
||||
}
|
||||
|
||||
public function confirmFolderDelete(int $folderId): void
|
||||
{
|
||||
$this->folderForUser($folderId);
|
||||
|
||||
$this->confirmingFolderDelete = $folderId;
|
||||
$this->modal('confirm-folder-delete')->show();
|
||||
}
|
||||
|
||||
public function deleteFolder(): void
|
||||
{
|
||||
$this->folderForUser($this->confirmingFolderDelete)->delete();
|
||||
|
||||
$this->confirmingFolderDelete = null;
|
||||
$this->modal('confirm-folder-delete')->close();
|
||||
}
|
||||
|
||||
public function startTodoCreate(int $folderId): void
|
||||
{
|
||||
$this->folderForUser($folderId);
|
||||
|
||||
$this->todoFolderId = $folderId;
|
||||
$this->reset('todoDescription', 'todoDueDate', 'todoNotes');
|
||||
$this->resetErrorBag('todoDescription', 'todoDueDate', 'todoNotes');
|
||||
$this->showTodoForm = true;
|
||||
}
|
||||
|
||||
public function saveFolderTodo(): void
|
||||
{
|
||||
$folder = $this->folderForUser($this->todoFolderId ?? 0);
|
||||
|
||||
$validated = $this->validate([
|
||||
'todoDescription' => ['required', 'string', 'max:255'],
|
||||
'todoDueDate' => ['nullable', 'date'],
|
||||
'todoNotes' => ['nullable', 'string', 'max:'.auth()->user()->notesLimit()],
|
||||
]);
|
||||
|
||||
Todo::create([
|
||||
'user_id' => auth()->id(),
|
||||
'folder_id' => $folder->id,
|
||||
'description' => $validated['todoDescription'],
|
||||
'due_date' => filled($validated['todoDueDate']) ? Carbon::parse($validated['todoDueDate']) : null,
|
||||
'notes' => filled($validated['todoNotes']) ? $validated['todoNotes'] : null,
|
||||
]);
|
||||
|
||||
$this->reset('showTodoForm', 'todoFolderId', 'todoDescription', 'todoDueDate', 'todoNotes');
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function folderTree(): Collection
|
||||
{
|
||||
return Folder::treeForUser(auth()->id());
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function openCounts(): Collection
|
||||
{
|
||||
return Todo::query()
|
||||
->forUser(auth()->id())
|
||||
->incomplete()
|
||||
->pluck('folder_id')
|
||||
->countBy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, mixed>
|
||||
*/
|
||||
private function folderNameRules(?int $parentId = null, ?int $ignoreId = null): array
|
||||
{
|
||||
return [
|
||||
'required',
|
||||
'string',
|
||||
'max:255',
|
||||
Rule::unique('folders', 'name')
|
||||
->ignore($ignoreId)
|
||||
->where(fn ($query) => $query
|
||||
->where('user_id', auth()->id())
|
||||
->where('parent_id', $parentId)),
|
||||
];
|
||||
}
|
||||
|
||||
private function folderForUser(int $folderId): Folder
|
||||
{
|
||||
return Folder::query()->forUser(auth()->id())->findOrFail($folderId);
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<div class="flex h-full w-full flex-1 flex-col gap-6">
|
||||
<div class="flex flex-wrap items-center justify-between gap-4">
|
||||
<div>
|
||||
<flux:heading size="xl">{{ __('Folders') }}</flux:heading>
|
||||
<flux:text class="mt-1">{{ __('Organize your todos into a top-level and nested folder hierarchy.') }}</flux:text>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if ($this->folderTree->isEmpty())
|
||||
<flux:callout variant="warning" icon="folder">
|
||||
{{ __('No folders yet. Create your first top-level folder below.') }}
|
||||
</flux:callout>
|
||||
@endif
|
||||
|
||||
<flux:card>
|
||||
<form wire:submit="createTopLevelFolder" class="flex flex-wrap items-end gap-3">
|
||||
<div class="min-w-64 flex-1">
|
||||
<flux:label>{{ __('New top-level folder') }}</flux:label>
|
||||
<flux:input
|
||||
wire:model="newFolderName"
|
||||
placeholder="{{ __('e.g. Work, Business, Personal') }}"
|
||||
data-test="new-folder-input"
|
||||
/>
|
||||
<flux:error name="newFolderName" />
|
||||
</div>
|
||||
|
||||
<flux:button variant="primary" type="submit" icon="plus" data-test="add-folder-button">
|
||||
{{ __('Add folder') }}
|
||||
</flux:button>
|
||||
</form>
|
||||
</flux:card>
|
||||
|
||||
<div class="flex flex-col divide-y divide-zinc-200 rounded-xl border border-zinc-200 bg-white dark:divide-zinc-700 dark:border-zinc-700 dark:bg-zinc-900" data-test="folder-list">
|
||||
@forelse ($this->folderTree as $node)
|
||||
<div class="p-4" :style="'margin-left: {{ $node['depth'] * 1.5 }}rem'">
|
||||
<div class="flex flex-wrap items-center gap-3" data-test="folder-row-{{ $node['folder']->id }}">
|
||||
@if ($renamingFolderId === $node['folder']->id)
|
||||
<form wire:submit="saveRename" class="flex flex-1 flex-wrap items-center gap-3">
|
||||
<flux:input
|
||||
wire:model="renameName"
|
||||
size="sm"
|
||||
class="min-w-48 flex-1"
|
||||
autofocus
|
||||
data-test="rename-input"
|
||||
/>
|
||||
<div class="flex gap-2">
|
||||
<flux:button size="sm" type="submit" variant="primary" icon="check" data-test="save-rename-button">
|
||||
{{ __('Save') }}
|
||||
</flux:button>
|
||||
<flux:button size="sm" variant="ghost" wire:click="cancelRename">
|
||||
{{ __('Cancel') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
<flux:error name="renameName" />
|
||||
</form>
|
||||
@else
|
||||
<flux:heading size="sm" class="truncate" data-test="folder-name-{{ $node['folder']->id }}">
|
||||
{{ $node['folder']->name }}
|
||||
</flux:heading>
|
||||
|
||||
<flux:badge size="sm" color="blue">
|
||||
{{ $this->openCounts->get($node['folder']->id, 0) }} {{ __('open') }}
|
||||
</flux:badge>
|
||||
|
||||
<flux:spacer />
|
||||
|
||||
<div class="flex items-center gap-1">
|
||||
<flux:tooltip :content="__('View todos')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="magnifying-glass"
|
||||
:href="route('dashboard', ['folder' => $node['folder']->id])"
|
||||
wire:navigate
|
||||
data-test="view-todos-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
<flux:tooltip :content="__('Add todo')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="document-plus"
|
||||
wire:click="startTodoCreate({{ $node['folder']->id }})"
|
||||
data-test="add-todo-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
<flux:tooltip :content="__('Add sub-folder')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="folder-plus"
|
||||
wire:click="startChildCreate({{ $node['folder']->id }})"
|
||||
data-test="add-child-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
<flux:tooltip :content="__('Rename')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="pencil-square"
|
||||
wire:click="startRename({{ $node['folder']->id }})"
|
||||
data-test="rename-folder-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
<flux:tooltip :content="__('Delete')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="trash"
|
||||
wire:click="confirmFolderDelete({{ $node['folder']->id }})"
|
||||
data-test="delete-folder-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@if ($creatingChildOf === $node['folder']->id)
|
||||
<form wire:submit="createChildFolder" class="mt-3 flex flex-wrap items-end gap-3">
|
||||
<div class="min-w-64 flex-1">
|
||||
<flux:label size="sm">{{ __('Sub-folder of') }} {{ $node['folder']->name }}</flux:label>
|
||||
<flux:input
|
||||
wire:model="newChildName"
|
||||
size="sm"
|
||||
placeholder="{{ __('Sub-folder name') }}"
|
||||
data-test="new-child-input"
|
||||
/>
|
||||
<flux:error name="newChildName" />
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<flux:button size="sm" variant="primary" type="submit" icon="plus" data-test="add-child-button">
|
||||
{{ __('Add') }}
|
||||
</flux:button>
|
||||
<flux:button size="sm" variant="ghost" wire:click="cancelChildCreate">
|
||||
{{ __('Cancel') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
@empty
|
||||
<div class="p-8">
|
||||
<flux:text align="center" class="text-sm text-zinc-500">{{ __('No folders to display.') }}</flux:text>
|
||||
</div>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
<flux:modal wire:model.self="showTodoForm" class="md:w-xl">
|
||||
<form wire:submit="saveFolderTodo" class="space-y-6">
|
||||
<div>
|
||||
<flux:heading size="lg">{{ __('Add todo') }}</flux:heading>
|
||||
<flux:text class="mt-2">{{ __('Add a task with a description. A due date is optional.') }}</flux:text>
|
||||
</div>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Description') }}</flux:label>
|
||||
<flux:input
|
||||
wire:model="todoDescription"
|
||||
type="text"
|
||||
autofocus
|
||||
placeholder="{{ __('What needs to be done?') }}"
|
||||
data-test="todo-description-input"
|
||||
/>
|
||||
<flux:error name="todoDescription" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Due date') }}</flux:label>
|
||||
<flux:input wire:model="todoDueDate" type="date" data-test="todo-due-date-input" />
|
||||
<flux:error name="todoDueDate" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Notes') }}</flux:label>
|
||||
<flux:textarea
|
||||
wire:model="todoNotes"
|
||||
rows="3"
|
||||
placeholder="{{ __('Add any extra details…') }}"
|
||||
data-test="todo-notes-input"
|
||||
/>
|
||||
<flux:error name="todoNotes" />
|
||||
</flux:field>
|
||||
|
||||
<div class="flex justify-end gap-3">
|
||||
<flux:modal.close>
|
||||
<flux:button variant="ghost">{{ __('Cancel') }}</flux:button>
|
||||
</flux:modal.close>
|
||||
<flux:button type="submit" variant="primary">{{ __('Add todo') }}</flux:button>
|
||||
</div>
|
||||
</form>
|
||||
</flux:modal>
|
||||
|
||||
<flux:modal name="confirm-folder-delete" class="md:w-lg">
|
||||
<div class="space-y-6">
|
||||
<div>
|
||||
<flux:heading size="lg">{{ __('Delete folder?') }}</flux:heading>
|
||||
<flux:text class="mt-2">
|
||||
{{ __('Deleting a folder also deletes its sub-folders and every todo inside them. This action cannot be undone.') }}
|
||||
</flux:text>
|
||||
</div>
|
||||
<div class="flex justify-end gap-3">
|
||||
<flux:modal.close>
|
||||
<flux:button variant="ghost">{{ __('Cancel') }}</flux:button>
|
||||
</flux:modal.close>
|
||||
<flux:button variant="danger" wire:click="deleteFolder" data-test="confirm-delete-folder">
|
||||
{{ __('Delete folder') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</div>
|
||||
</flux:modal>
|
||||
</div>
|
||||
Reference in New Issue
Block a user