39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
// * Packages
|
|
import { usePage } from "@inertiajs/react";
|
|
import { route } from "ziggy-js";
|
|
// * Other
|
|
import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout";
|
|
import ModelActions from "@/back/Components/ModelActions";
|
|
import Form from "@/back/Pages/Users/Form";
|
|
import useTrans from "@/hooks/use-translations";
|
|
import { Actions, Methods } from "@/lib/enums";
|
|
import { Views } from "@/lib/utils";
|
|
import { AuthProp, SingleResource, UserModel } from "@/back/types/global";
|
|
|
|
export default function Edit({ data }: { data: SingleResource }) {
|
|
const { viewAny } = (usePage().props.auth as AuthProp).policies.users;
|
|
const userModel = data.data as UserModel;
|
|
const actionModels = [Views.SHOW, Views.DUPLICATION, Views.DELETION];
|
|
return (
|
|
<AuthenticatedLayout
|
|
title={useTrans("crud.helpers.edition_model", {
|
|
model: useTrans("models.classes.user"),
|
|
})}
|
|
linkBefore={viewAny ? route("back.users.index") : undefined}
|
|
>
|
|
<ModelActions
|
|
actions={actionModels}
|
|
modelName="users"
|
|
model={userModel}
|
|
modelUpdatedAt={userModel.updated_at.toString()}
|
|
/>
|
|
<Form
|
|
model={userModel}
|
|
modelName="user"
|
|
modelRoute="users"
|
|
action={Actions.UPDATE}
|
|
method={Methods.PATCH}
|
|
/>
|
|
</AuthenticatedLayout>
|
|
);
|
|
}
|