From 6e6f3d55b5575d20d6ddd00c3a0142292d04f8a8 Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Tue, 19 May 2026 12:25:21 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=9A=A8=20resolve=20php=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/MakeUser.php | 18 +- app/Enums/NoticeTypeEnum.php | 1 - .../Back/InvoiceCompanyController.php | 10 +- .../Back/InvoicePackageController.php | 10 +- .../Controllers/Back/NoticeController.php | 10 +- .../Back/Notices/StoreNoticeRequest.php | 2 +- app/Mails/Auth/LinkResetPasswordMail.php | 11 +- app/Mails/Auth/ResetPassword.php | 2 +- app/Models/InvoiceCompany.php | 3 +- app/Models/InvoicePackage.php | 3 +- app/Models/Notice.php | 3 +- app/Models/User.php | 6 +- app/Models/UserPassword.php | 7 +- app/Providers/AppServiceProvider.php | 2 +- database/factories/InvoiceCompanyFactory.php | 2 +- database/factories/InvoicePackageFactory.php | 2 +- database/factories/NoticeFactory.php | 2 +- ...165712_add_password_reset_tokens_table.php | 6 +- lang/fr/auth.php | 36 +-- .../ts/back/Components/Inputs/MultiSelect.tsx | 268 ++++++++++-------- .../Components/Layout/Sidebar/AppSidebar.tsx | 8 - resources/ts/back/types/global.d.ts | 7 +- resources/ts/hooks/use-translations.tsx | 2 +- resources/ts/lib/mapPivotOptions.tsx | 6 +- routes/auth.php | 4 +- routes/back/web-back.php | 4 - routes/breadcrumbs/back.php | 1 - routes/breadcrumbs/invoice-companies.php | 22 +- routes/breadcrumbs/invoice-packages.php | 22 +- routes/breadcrumbs/notices.php | 22 +- 30 files changed, 264 insertions(+), 238 deletions(-) delete mode 100644 routes/back/web-back.php delete mode 100644 routes/breadcrumbs/back.php diff --git a/app/Console/Commands/MakeUser.php b/app/Console/Commands/MakeUser.php index 0041dfa..ac39798 100644 --- a/app/Console/Commands/MakeUser.php +++ b/app/Console/Commands/MakeUser.php @@ -106,17 +106,23 @@ class MakeUser extends Command /** * Ask for a role and return the corresponding RoleEnum. * - * @return object + * @return object{name: string, value: int|string, label: string} */ private function askRole(): object { - $options = collect(UserRoleRegistry::all())->mapWithKeys(fn(object $role) => [ - Str::ucFirst($role->label) => $role - ]); + $roles = UserRoleRegistry::all(); + $defaultRole = UserRoleRegistry::get('client'); - $choice = $this->choice('Role', $options->keys()->all(), Str::ucFirst(UserRoleRegistry::get('client')->label)); + $options = collect($roles)->mapWithKeys( + fn(object $role) => [Str::ucFirst($role->label) => $role]); + + $choice = $this->choice( + 'Role', + $options->keys()->all(), + Str::ucFirst($defaultRole->label), + ); $choiceKey = is_string($choice) ? $choice : (string) $choice[0]; - return $options->get($choiceKey) ?? UserRoleRegistry::get('client'); + return $options->get($choiceKey) ?? $defaultRole; } /** diff --git a/app/Enums/NoticeTypeEnum.php b/app/Enums/NoticeTypeEnum.php index 0931a8c..3a76e39 100644 --- a/app/Enums/NoticeTypeEnum.php +++ b/app/Enums/NoticeTypeEnum.php @@ -54,4 +54,3 @@ enum NoticeTypeEnum: int return self::CLASSES; } } - \ No newline at end of file diff --git a/app/Http/Controllers/Back/InvoiceCompanyController.php b/app/Http/Controllers/Back/InvoiceCompanyController.php index 838c5e6..6b1c432 100644 --- a/app/Http/Controllers/Back/InvoiceCompanyController.php +++ b/app/Http/Controllers/Back/InvoiceCompanyController.php @@ -48,11 +48,11 @@ class InvoiceCompanyController extends BackendController $query, $search, null, - // TODO: Fields here. + 'name', ); } $searchFields = \implode(', ', [ - // TODO: Translations here. + trans('validation.attributes.name'), ]); /** Sort columns with a query */ @@ -104,7 +104,7 @@ class InvoiceCompanyController extends BackendController { return DB::transaction(function () use ($request) { $invoice_company = new InvoiceCompany(); - $invoice_company->inertiaFill($request->validated()); + $invoice_company->fill($request->validated()); if ($invoice_company->saveOrFail()) { return redirect()->route("back.$this->modelName.edit", $invoice_company) @@ -136,7 +136,7 @@ class InvoiceCompanyController extends BackendController * Update the specified resource. * * @param \App\Http\Requests\Back\InvoiceCompanies\UpdateInvoiceCompanyRequest $request - * @param \App\Models\InvoiceCompany $invoice_company + * @param \App\Models\InvoiceCompany $invoice_company * @return \Illuminate\Http\RedirectResponse */ public function update( @@ -144,7 +144,7 @@ class InvoiceCompanyController extends BackendController InvoiceCompany $invoice_company ): \Illuminate\Http\RedirectResponse { return DB::transaction(function () use ($request, $invoice_company) { - $invoice_company->inertiaFill($request->validated()); + $invoice_company->fill($request->validated()); if ($invoice_company->saveOrFail()) { return redirect()->route("back.$this->modelName.edit", $invoice_company) diff --git a/app/Http/Controllers/Back/InvoicePackageController.php b/app/Http/Controllers/Back/InvoicePackageController.php index 8a42611..7b9df64 100644 --- a/app/Http/Controllers/Back/InvoicePackageController.php +++ b/app/Http/Controllers/Back/InvoicePackageController.php @@ -48,11 +48,11 @@ class InvoicePackageController extends BackendController $query, $search, null, - // TODO: Fields here. + 'name', ); } $searchFields = \implode(', ', [ - // TODO: Translations here. + trans('validation.attributes.name'), ]); /** Sort columns with a query */ @@ -104,7 +104,7 @@ class InvoicePackageController extends BackendController { return DB::transaction(function () use ($request) { $invoice_package = new InvoicePackage(); - $invoice_package->inertiaFill($request->validated()); + $invoice_package->fill($request->validated()); if ($invoice_package->saveOrFail()) { return redirect()->route("back.$this->modelName.edit", $invoice_package) @@ -136,7 +136,7 @@ class InvoicePackageController extends BackendController * Update the specified resource. * * @param \App\Http\Requests\Back\InvoicePackages\UpdateInvoicePackageRequest $request - * @param \App\Models\InvoicePackage $invoice_package + * @param \App\Models\InvoicePackage $invoice_package * @return \Illuminate\Http\RedirectResponse */ public function update( @@ -144,7 +144,7 @@ class InvoicePackageController extends BackendController InvoicePackage $invoice_package ): \Illuminate\Http\RedirectResponse { return DB::transaction(function () use ($request, $invoice_package) { - $invoice_package->inertiaFill($request->validated()); + $invoice_package->fill($request->validated()); if ($invoice_package->saveOrFail()) { return redirect()->route("back.$this->modelName.edit", $invoice_package) diff --git a/app/Http/Controllers/Back/NoticeController.php b/app/Http/Controllers/Back/NoticeController.php index 9cc679d..7a2e878 100644 --- a/app/Http/Controllers/Back/NoticeController.php +++ b/app/Http/Controllers/Back/NoticeController.php @@ -48,11 +48,11 @@ class NoticeController extends BackendController $query, $search, null, - // TODO: Fields here. + 'title', ); } $searchFields = \implode(', ', [ - // TODO: Translations here. + trans('validation.attributes.title'), ]); /** Sort columns with a query */ @@ -104,7 +104,7 @@ class NoticeController extends BackendController { return DB::transaction(function () use ($request) { $notice = new Notice(); - $notice->inertiaFill($request->validated()); + $notice->fill($request->validated()); if ($notice->saveOrFail()) { return redirect()->route("back.$this->modelName.edit", $notice) @@ -136,7 +136,7 @@ class NoticeController extends BackendController * Update the specified resource. * * @param \App\Http\Requests\Back\Notices\UpdateNoticeRequest $request - * @param \App\Models\Notice $notice + * @param \App\Models\Notice $notice * @return \Illuminate\Http\RedirectResponse */ public function update( @@ -144,7 +144,7 @@ class NoticeController extends BackendController Notice $notice ): \Illuminate\Http\RedirectResponse { return DB::transaction(function () use ($request, $notice) { - $notice->inertiaFill($request->validated()); + $notice->fill($request->validated()); if ($notice->saveOrFail()) { return redirect()->route("back.$this->modelName.edit", $notice) diff --git a/app/Http/Requests/Back/Notices/StoreNoticeRequest.php b/app/Http/Requests/Back/Notices/StoreNoticeRequest.php index 5067d66..a8d59bc 100644 --- a/app/Http/Requests/Back/Notices/StoreNoticeRequest.php +++ b/app/Http/Requests/Back/Notices/StoreNoticeRequest.php @@ -32,7 +32,7 @@ class StoreNoticeRequest extends FormRequest public function rules(): array { return [ - 'title' => 'required|string|min:3|max:255', + 'title' => 'required|string|between:3,255', 'message' => ['required', 'string', new WysiwygLength()], 'type' => ['required', 'integer', new Enum(NoticeTypeEnum::class)], ]; diff --git a/app/Mails/Auth/LinkResetPasswordMail.php b/app/Mails/Auth/LinkResetPasswordMail.php index 4123d2a..9c3f5c9 100644 --- a/app/Mails/Auth/LinkResetPasswordMail.php +++ b/app/Mails/Auth/LinkResetPasswordMail.php @@ -10,15 +10,20 @@ class LinkResetPasswordMail extends Mailable { /** * Create a new message instance. + * + * @param string $url + * @param mixed $user + * @return void */ public function __construct( public string $url, public mixed $user, - ) {} + ) { + } /** * Get the message envelope. - * + * * @return \Illuminate\Mail\Mailables\Envelope */ public function envelope(): \Illuminate\Mail\Mailables\Envelope @@ -35,7 +40,7 @@ class LinkResetPasswordMail extends Mailable /** * Get the message content definition. - * + * * @return \Illuminate\Mail\Mailables\Content */ public function content(): \Illuminate\Mail\Mailables\Content diff --git a/app/Mails/Auth/ResetPassword.php b/app/Mails/Auth/ResetPassword.php index 0c6919a..b7f748f 100644 --- a/app/Mails/Auth/ResetPassword.php +++ b/app/Mails/Auth/ResetPassword.php @@ -57,4 +57,4 @@ class ResetPassword extends Mailable ], ); } -} \ No newline at end of file +} diff --git a/app/Models/InvoiceCompany.php b/app/Models/InvoiceCompany.php index 114e30b..bcc5775 100644 --- a/app/Models/InvoiceCompany.php +++ b/app/Models/InvoiceCompany.php @@ -8,7 +8,6 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Uwil\LaravelActivityLogs\Traits\HasActivityLog; use Uwil\LaravelBackend\Traits\Models\HasCache; use Uwil\LaravelBackend\Traits\Models\HasModelNaming; -use Uwil\LaravelBackend\Traits\Models\HasUwilImages; use Uwil\LaravelI18n\Traits\Models\HasTranslations; /** @@ -22,10 +21,10 @@ class InvoiceCompany extends Model { use HasActivityLog; use HasCache; + /** @use \Illuminate\Database\Eloquent\Factories\HasFactory<\Database\Factories\InvoiceCompanyFactory> */ use HasFactory; use HasModelNaming; use HasTranslations; - use HasUwilImages; use SoftDeletes; /** diff --git a/app/Models/InvoicePackage.php b/app/Models/InvoicePackage.php index 432b5de..32dd8b3 100644 --- a/app/Models/InvoicePackage.php +++ b/app/Models/InvoicePackage.php @@ -8,7 +8,6 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Uwil\LaravelActivityLogs\Traits\HasActivityLog; use Uwil\LaravelBackend\Traits\Models\HasCache; use Uwil\LaravelBackend\Traits\Models\HasModelNaming; -use Uwil\LaravelBackend\Traits\Models\HasUwilImages; use Uwil\LaravelI18n\Traits\Models\HasTranslations; /** @@ -24,10 +23,10 @@ class InvoicePackage extends Model { use HasActivityLog; use HasCache; + /** @use \Illuminate\Database\Eloquent\Factories\HasFactory<\Database\Factories\InvoicePackageFactory> */ use HasFactory; use HasModelNaming; use HasTranslations; - use HasUwilImages; use SoftDeletes; /** diff --git a/app/Models/Notice.php b/app/Models/Notice.php index dba2d71..f22f991 100644 --- a/app/Models/Notice.php +++ b/app/Models/Notice.php @@ -9,7 +9,6 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Uwil\LaravelActivityLogs\Traits\HasActivityLog; use Uwil\LaravelBackend\Traits\Models\HasCache; use Uwil\LaravelBackend\Traits\Models\HasModelNaming; -use Uwil\LaravelBackend\Traits\Models\HasUwilImages; use Uwil\LaravelI18n\Traits\Models\HasTranslations; /** @@ -25,10 +24,10 @@ class Notice extends Model { use HasActivityLog; use HasCache; + /** @use \Illuminate\Database\Eloquent\Factories\HasFactory<\Database\Factories\NoticeFactory> */ use HasFactory; use HasModelNaming; use HasTranslations; - use HasUwilImages; use SoftDeletes; /** diff --git a/app/Models/User.php b/app/Models/User.php index ea412d2..42b2163 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -43,7 +43,7 @@ class User extends BackendUser url(route('back.reset-password', ['token' => $token], false)), urlencode($this->getEmailForPasswordReset()) ); - + Mail::send(new LinkResetPasswordMail($url, $this)); } @@ -52,10 +52,10 @@ class User extends BackendUser /** * Get the user's associated password. * - * @return \Illuminate\Database\Eloquent\Relations\HasOne<\App\Models\UserPassword> + * @return \Illuminate\Database\Eloquent\Relations\HasOne<\App\Models\UserPassword,\App\Models\User> */ public function userPassword(): \Illuminate\Database\Eloquent\Relations\HasOne { return $this->hasOne(UserPassword::class); } -} \ No newline at end of file +} diff --git a/app/Models/UserPassword.php b/app/Models/UserPassword.php index fe50c68..0528ec4 100644 --- a/app/Models/UserPassword.php +++ b/app/Models/UserPassword.php @@ -5,8 +5,9 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; /** - * @property \App\Models\User $user_id User associated. - * @property string $password User password. + * @property integer $id Id of the user password. + * @property \App\Models\User $user_id Associated user. + * @property string $password Password of the user. * @property-read \Illuminate\Support\Carbon $created_at Date on which the password was created. * @property-read \Illuminate\Support\Carbon $updated_at Date on which the password was updated. */ @@ -22,4 +23,4 @@ class UserPassword extends Model 'user_id', 'password', ]; -} \ No newline at end of file +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 2f3e788..81571dc 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -19,4 +19,4 @@ class AppServiceProvider extends ServiceProvider UserRoleRegistry::add(4, 'developper', trans('enums.user-role.developper')); UserRoleRegistry::add(5, 'client', trans('enums.user-role.client')); } -} \ No newline at end of file +} diff --git a/database/factories/InvoiceCompanyFactory.php b/database/factories/InvoiceCompanyFactory.php index d785edd..cbeff38 100644 --- a/database/factories/InvoiceCompanyFactory.php +++ b/database/factories/InvoiceCompanyFactory.php @@ -25,7 +25,7 @@ class InvoiceCompanyFactory extends Factory public function definition(): array { return [ - "name" => fake()->word(), + "name" => fake()->words(3, true), ]; } } diff --git a/database/factories/InvoicePackageFactory.php b/database/factories/InvoicePackageFactory.php index 39521ce..8ffc5ae 100644 --- a/database/factories/InvoicePackageFactory.php +++ b/database/factories/InvoicePackageFactory.php @@ -25,7 +25,7 @@ class InvoicePackageFactory extends Factory public function definition(): array { return [ - "name" => fake()->word(), + "name" => fake()->words(3, true), "amount" => fake()->randomFloat(2, 1, 1000), "published" => fake()->boolean(75), ]; diff --git a/database/factories/NoticeFactory.php b/database/factories/NoticeFactory.php index b85f049..19eb9b3 100644 --- a/database/factories/NoticeFactory.php +++ b/database/factories/NoticeFactory.php @@ -26,7 +26,7 @@ class NoticeFactory extends Factory public function definition(): array { return [ - "title" => fake()->word(), + "title" => fake()->words(3, true), "message" => sprintf("

%s

", fake()->text(\rand(20, 40))), "type" => fake()->randomElement(NoticeTypeEnum::cases()), ]; diff --git a/database/migrations/2026_04_28_165712_add_password_reset_tokens_table.php b/database/migrations/2026_04_28_165712_add_password_reset_tokens_table.php index f9fa68c..6663db4 100644 --- a/database/migrations/2026_04_28_165712_add_password_reset_tokens_table.php +++ b/database/migrations/2026_04_28_165712_add_password_reset_tokens_table.php @@ -14,9 +14,9 @@ return new class extends Migration public function up(): void { Schema::create('user_password_reset_tokens', function (Blueprint $table): void { - $table->string('email')->primary(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); + $table->string('email')->primary()->comment('Email of the user.'); + $table->string('token')->comment('Token of the password reset.'); + $table->timestamp('created_at')->nullable()->comment('Date the reset password was created.'); }); } diff --git a/lang/fr/auth.php b/lang/fr/auth.php index c00a51d..26f21b8 100644 --- a/lang/fr/auth.php +++ b/lang/fr/auth.php @@ -3,25 +3,25 @@ declare(strict_types=1); return [ - 'failed' => 'Ces identifiants ne correspondent pas à nos enregistrements.', - 'password' => 'Le mot de passe fourni est incorrect.', - 'throttle' => 'Tentatives de connexion trop nombreuses. Veuillez réessayer dans :seconds secondes.', - "login" => "Se connecter", - "remember" => "Se souvenir de moi", - "forgot_password" => "Mot de passe oublié", - "forgot_password_desc" => "Renseignez votre email pour recevoir un lien de réinitialisation.", - "description" => "Connectez-vous afin d'accéder à notre outil :appName !", - "connected" => "Connecté !", - "connected_desc" => "Vous êtes à présent authentifié au Support UWIL.", - "send_link" => "Envoyer le lien", - "mail_sent" => "Mail envoyé !", - "mail_sent_desc" => "Si un compte est associé à l'adresse :email, un e-mail de réinitialisation du mot de passe + 'failed' => 'Ces identifiants ne correspondent pas à nos enregistrements.', + 'password' => 'Le mot de passe fourni est incorrect.', + 'throttle' => 'Tentatives de connexion trop nombreuses. Veuillez réessayer dans :seconds secondes.', + "login" => "Se connecter", + "remember" => "Se souvenir de moi", + "forgot_password" => "Mot de passe oublié", + "forgot_password_desc" => "Renseignez votre email pour recevoir un lien de réinitialisation.", + "description" => "Connectez-vous afin d'accéder à notre outil :appName !", + "connected" => "Connecté !", + "connected_desc" => "Vous êtes à présent authentifié au Support UWIL.", + "send_link" => "Envoyer le lien", + "mail_sent" => "Mail envoyé !", + "mail_sent_desc" => "Si un compte est associé à l'adresse :email, un e-mail de réinitialisation du mot de passe vous sera envoyé dans quelques instants.", - "reset_password" => "Réinitialisation du mot de passe", - "reset_password_desc" => "Choisissez un nouveau mot de passe pour votre compte.", - "reset_your_password" => "Réinitialiser votre mot de passe", - "reset_sent" => "Réinitialisation du mot de passe effectué !", - "reset_sent_desc" => "Mot de passe mis à jour avec succès. Vous pouvez dès à présent vous connecter + "reset_password" => "Réinitialisation du mot de passe", + "reset_password_desc" => "Choisissez un nouveau mot de passe pour votre compte.", + "reset_your_password" => "Réinitialiser votre mot de passe", + "reset_sent" => "Réinitialisation du mot de passe effectué !", + "reset_sent_desc" => "Mot de passe mis à jour avec succès. Vous pouvez dès à présent vous connecter avec vos nouveaux identifiants.", 'email_hello' => 'Bonjour !', 'email_get_reset_password' => 'Vous recevez cet e-mail parce que nous avons reçu une demande de réinitialisation diff --git a/resources/ts/back/Components/Inputs/MultiSelect.tsx b/resources/ts/back/Components/Inputs/MultiSelect.tsx index 9af188c..54e5abc 100644 --- a/resources/ts/back/Components/Inputs/MultiSelect.tsx +++ b/resources/ts/back/Components/Inputs/MultiSelect.tsx @@ -982,7 +982,7 @@ export const MultiSelect = forwardRef( }, [minSelection, maxSelection, multiple]); return ( -
+
{politeMessage} @@ -1054,143 +1054,159 @@ export const MultiSelect = forwardRef( responsiveSettings.compactMode && "gap-0.5", )} > - {selectedValues - .slice(0, responsiveSettings.maxCount) - .map((value) => { - const option = getOptionByValue(value); - const IconComponent = option?.icon; - const customStyle = option?.style; - if (!option) { - return null; - } - const badgeStyle: CSSProperties = { - animationDuration: `${animation}s`, - ...(customStyle?.badgeColor && { - backgroundColor: customStyle.badgeColor, - }), - ...(customStyle?.gradient && { - background: customStyle.gradient, - color: "white", - }), - }; - return ( - svg]:pointer-events-auto", - )} - style={{ - ...badgeStyle, - animationDuration: `${ - animationConfig?.duration || animation - }s`, - animationDelay: `${animationConfig?.delay || 0}s`, - }} - > - {IconComponent && !responsiveSettings.hideIcons && ( - { + const option = getOptionByValue(value); + const IconComponent = option?.icon; + const customStyle = option?.style; + if (!option) { + return null; + } + const badgeStyle: CSSProperties = { + animationDuration: `${animation}s`, + ...(customStyle?.badgeColor && { + backgroundColor: customStyle.badgeColor, + }), + ...(customStyle?.gradient && { + background: customStyle.gradient, + color: "white", + }), + }; + return ( + svg]:pointer-events-auto", )} - // eslint-disable-next-line react/jsx-props-no-spreading - {...(customStyle?.iconColor && { - style: { - color: customStyle.iconColor, - }, - })} - /> - )} - - {option.label} - -
{ - event.stopPropagation(); - toggleOption(value); - }} - onKeyDown={(event) => { - if ( - event.key === "Enter" || - event.key === " " - ) { - event.preventDefault(); - event.stopPropagation(); - toggleOption(value); - } - }} - aria-label={`Remove ${option.label} from selection`} - className="ml-2 h-4 w-4 cursor-pointer hover:bg-white/20 rounded-sm -m-0.5 focus:outline-none focus:ring-1 focus:ring-white/50" - > - -
-
- ); - }) - .filter(Boolean)} - {selectedValues.length > responsiveSettings.maxCount && ( - svg]:pointer-events-auto", - )} - style={{ - animationDuration: `${animationConfig?.duration || animation}s`, - animationDelay: `${animationConfig?.delay || 0}s`, - }} - > - {`+ ${ - selectedValues.length - responsiveSettings.maxCount - } ${transMore}`} - + {IconComponent && + !responsiveSettings.hideIcons && ( + + )} + + {option.label} + +
{ + event.stopPropagation(); + toggleOption(value); + }} + onKeyDown={(event) => { + if ( + event.key === "Enter" || + event.key === " " + ) { + event.preventDefault(); + event.stopPropagation(); + toggleOption(value); + } + }} + aria-label={`Remove ${option.label} from selection`} + className="ml-2 h-4 w-4 cursor-pointer hover:bg-white/20 rounded-sm -m-0.5 focus:outline-none focus:ring-1 focus:ring-white/50" + > + +
+
+ ); + }) + .filter(Boolean) + : selectedValues + .slice(0, responsiveSettings.maxCount) + .map((value) => { + const option = getOptionByValue(value); + if (!option) { + return null; + } + return {option.label}; + })} + {multiple && + selectedValues.length > responsiveSettings.maxCount && ( + svg]:pointer-events-auto", )} - onClick={(event) => { - event.stopPropagation(); - clearExtraOptions(); + style={{ + animationDuration: `${animationConfig?.duration || animation}s`, + animationDelay: `${animationConfig?.delay || 0}s`, }} - /> - - )} + > + {`+ ${ + selectedValues.length - responsiveSettings.maxCount + } ${transMore}`} + { + event.stopPropagation(); + clearExtraOptions(); + }} + /> +
+ )}
) : (
-

+

{placeholder}

diff --git a/resources/ts/back/Components/Layout/Sidebar/AppSidebar.tsx b/resources/ts/back/Components/Layout/Sidebar/AppSidebar.tsx index 86ade70..3e9c4e1 100644 --- a/resources/ts/back/Components/Layout/Sidebar/AppSidebar.tsx +++ b/resources/ts/back/Components/Layout/Sidebar/AppSidebar.tsx @@ -5,7 +5,6 @@ import { ChevronDownIcon, MoreHorizontalIcon, HomeIcon, - SquareArrowOutUpRightIcon, TelescopeIcon, } from "lucide-react"; import { route } from "ziggy-js"; @@ -134,7 +133,6 @@ export default function AppSidebar() { // Translations. const transPages = useTrans("uwil-backend::back.pages"); const transDashboard = useTrans("uwil-backend::back.dashboard"); - const transWebsite = useTrans("uwil-backend::back.your_website"); const transModules = useTrans("uwil-backend::back.modules"); const transAdmin = useTrans("uwil-backend::enums.user-role.admin"); const transTelescope = useTrans("uwil-backend::back.telescope"); @@ -150,12 +148,6 @@ export default function AppSidebar() { show: true, icon: HomeIcon, }, - { - title: transWebsite, - link: "/", - show: true, - icon: SquareArrowOutUpRightIcon, - }, ...SidebarRegistry.getAll(auth, "pages"), ], }, diff --git a/resources/ts/back/types/global.d.ts b/resources/ts/back/types/global.d.ts index 133ec52..bb6ff30 100644 --- a/resources/ts/back/types/global.d.ts +++ b/resources/ts/back/types/global.d.ts @@ -16,20 +16,17 @@ type DefaultModel = { id: number; created_at: Date; updated_at: Date; + deleted_at: Date; }; // User type, with policies. -type UserModel = { - policies: ModelPolicy; - id: number; +type UserModel = DefaultModel & { first_name: string; last_name: string; email: string; role: { value: number; label: string; name: string }; published: boolean; published_at: Date; - created_at: Date; - updated_at: Date; }; // Pagination-related types. diff --git a/resources/ts/hooks/use-translations.tsx b/resources/ts/hooks/use-translations.tsx index 921bf73..0f81d32 100644 --- a/resources/ts/hooks/use-translations.tsx +++ b/resources/ts/hooks/use-translations.tsx @@ -75,7 +75,7 @@ const useTrans = (key: string, options: UseTransOptions = {}): string => { const parts = keyword.split("|"); if (parts.length !== 2) { throw new Error( - "The input string must contain exactly one '|' character.", + `The input string '${keyword}' must contain exactly one '|' character.`, ); } keyword = choice === 1 ? parts[0].trim() : parts[1].trim(); diff --git a/resources/ts/lib/mapPivotOptions.tsx b/resources/ts/lib/mapPivotOptions.tsx index de1bbdc..d0bd1af 100644 --- a/resources/ts/lib/mapPivotOptions.tsx +++ b/resources/ts/lib/mapPivotOptions.tsx @@ -1,11 +1,11 @@ // * Other -import { Model } from "@/back/types/global"; +import { DefaultModel } from "@/back/types/global"; /** * Extract ids from model relation pivot and format options * for a multi select component. */ -export function mapPivotOptions( +export function mapPivotOptions( model: T[], data?: D[], valueKey?: keyof T, @@ -32,7 +32,7 @@ export function mapPivotOptions( return { options, defaultValue }; } -export function extractIdsFromDatabasePivotRelation( +export function extractIdsFromDatabasePivotRelation( data?: D[], ): number[] { return data ? data.map((item) => item.id) : []; diff --git a/routes/auth.php b/routes/auth.php index 5541b5a..2ea8496 100644 --- a/routes/auth.php +++ b/routes/auth.php @@ -12,12 +12,12 @@ Route::prefix(config('uwil-backend.routes.prefix')) ->name('login'); Route::post('login', [AuthenticatedSessionController::class, 'postLogin']) ->name('login.post'); - + Route::get('forgot-password', [AuthenticatedSessionController::class, 'forgotPassword']) ->name('forgot-password'); Route::post('forgot-password', [AuthenticatedSessionController::class, 'postForgotPassword']) ->name('forgot-password.post'); - + Route::get('reset-password/{token}', [AuthenticatedSessionController::class, 'resetPassword']) ->name('reset-password'); Route::post('reset-password', [AuthenticatedSessionController::class, 'postResetPassword']) diff --git a/routes/back/web-back.php b/routes/back/web-back.php deleted file mode 100644 index 28bec97..0000000 --- a/routes/back/web-back.php +++ /dev/null @@ -1,4 +0,0 @@ -parent('back.invoice-companies.index'); $trail->push( - Str::ucfirst(trans_choice('models.classes.invoice-companies', 1)), - route('back.invoice-companies.create') + Str::ucfirst(trans('uwil-backend::crud.actions.create')), + route('back.invoice-companies.create'), ); }); Breadcrumbs::for('back.invoice-companies.edit', function (Generator $trail) { $trail->parent('back.invoice-companies.index'); - $trail->push(Str::ucfirst(trans('uwil-backend::crud.actions.edit')), route('back.invoice-companies.edit', [ - 'invoice_company' => request()->invoice_company - ])); + $trail->push( + Str::ucfirst(trans('uwil-backend::crud.actions.edit')), + route('back.invoice-companies.edit', [ + 'invoice_company' => request()->invoice_company, + ]), + ); }); Breadcrumbs::for('back.invoice-companies.duplicate', function (Generator $trail) { $trail->parent('back.invoice-companies.index'); @@ -29,9 +32,12 @@ Breadcrumbs::for('back.invoice-companies.duplicate', function (Generator $trail) }); Breadcrumbs::for('back.invoice-companies.show', function (Generator $trail) { $trail->parent('back.invoice-companies.index'); - $trail->push(Str::ucfirst(trans('uwil-backend::crud.actions.visualize')), route('back.invoice-companies.show', [ - 'invoice_company' => request()->invoice_company - ])); + $trail->push( + Str::ucfirst(trans('uwil-backend::crud.actions.visualize')), + route('back.invoice-companies.show', [ + 'invoice_company' => request()->invoice_company, + ]), + ); }); Breadcrumbs::for('back.invoice-companies.trash', function (Generator $trail) { $trail->parent('back.invoice-companies.index'); diff --git a/routes/breadcrumbs/invoice-packages.php b/routes/breadcrumbs/invoice-packages.php index 09dc243..9e02917 100644 --- a/routes/breadcrumbs/invoice-packages.php +++ b/routes/breadcrumbs/invoice-packages.php @@ -13,15 +13,18 @@ Breadcrumbs::for('back.invoice-packages.index', function (Generator $trail) { Breadcrumbs::for('back.invoice-packages.create', function (Generator $trail) { $trail->parent('back.invoice-packages.index'); $trail->push( - Str::ucfirst(trans_choice('models.classes.invoice-packages', 1)), - route('back.invoice-packages.create') + Str::ucfirst(trans('uwil-backend::crud.actions.create')), + route('back.invoice-packages.create'), ); }); Breadcrumbs::for('back.invoice-packages.edit', function (Generator $trail) { $trail->parent('back.invoice-packages.index'); - $trail->push(Str::ucfirst(trans('uwil-backend::crud.actions.edit')), route('back.invoice-packages.edit', [ - 'invoice_package' => request()->invoice_package - ])); + $trail->push( + Str::ucfirst(trans('uwil-backend::crud.actions.edit')), + route('back.invoice-packages.edit', [ + 'invoice_package' => request()->invoice_package, + ]), + ); }); Breadcrumbs::for('back.invoice-packages.duplicate', function (Generator $trail) { $trail->parent('back.invoice-packages.index'); @@ -29,9 +32,12 @@ Breadcrumbs::for('back.invoice-packages.duplicate', function (Generator $trail) }); Breadcrumbs::for('back.invoice-packages.show', function (Generator $trail) { $trail->parent('back.invoice-packages.index'); - $trail->push(Str::ucfirst(trans('uwil-backend::crud.actions.visualize')), route('back.invoice-packages.show', [ - 'invoice_package' => request()->invoice_package - ])); + $trail->push( + Str::ucfirst(trans('uwil-backend::crud.actions.visualize')), + route('back.invoice-packages.show', [ + 'invoice_package' => request()->invoice_package, + ]) + ); }); Breadcrumbs::for('back.invoice-packages.trash', function (Generator $trail) { $trail->parent('back.invoice-packages.index'); diff --git a/routes/breadcrumbs/notices.php b/routes/breadcrumbs/notices.php index 36d2693..19a158c 100644 --- a/routes/breadcrumbs/notices.php +++ b/routes/breadcrumbs/notices.php @@ -13,15 +13,18 @@ Breadcrumbs::for('back.notices.index', function (Generator $trail) { Breadcrumbs::for('back.notices.create', function (Generator $trail) { $trail->parent('back.notices.index'); $trail->push( - Str::ucfirst(trans_choice('models.classes.notices', 1)), - route('back.notices.create') + Str::ucfirst(trans('uwil-backend::crud.actions.create')), + route('back.notices.create'), ); }); Breadcrumbs::for('back.notices.edit', function (Generator $trail) { $trail->parent('back.notices.index'); - $trail->push(Str::ucfirst(trans('uwil-backend::crud.actions.edit')), route('back.notices.edit', [ - 'notice' => request()->notice - ])); + $trail->push( + Str::ucfirst(trans('uwil-backend::crud.actions.edit')), + route('back.notices.edit', [ + 'notice' => request()->notice, + ]), + ); }); Breadcrumbs::for('back.notices.duplicate', function (Generator $trail) { $trail->parent('back.notices.index'); @@ -29,9 +32,12 @@ Breadcrumbs::for('back.notices.duplicate', function (Generator $trail) { }); Breadcrumbs::for('back.notices.show', function (Generator $trail) { $trail->parent('back.notices.index'); - $trail->push(Str::ucfirst(trans('uwil-backend::crud.actions.visualize')), route('back.notices.show', [ - 'notice' => request()->notice - ])); + $trail->push( + Str::ucfirst(trans('uwil-backend::crud.actions.visualize')), + route('back.notices.show', [ + 'notice' => request()->notice, + ]), + ); }); Breadcrumbs::for('back.notices.trash', function (Generator $trail) { $trail->parent('back.notices.index');