mirror of
https://github.com/projectsend/projectsend.git
synced 2026-10-03 01:01:23 +00:00
6e47d76ba6
Client file sharing, rebuilt from the ground up: a private area per client, resumable uploads, folders, groups and categories, sharing with expiry dates and download limits, comments, file versions, an activity log, a REST API, and sixteen languages. This repository begins here. ProjectSend 2 was developed privately, and that development history is not published — the previous generation remains available, with its own history, at projectsend/legacy. Free software under the GNU General Public License v2, or (at your option) any later version.
79 lines
2.5 KiB
TypeScript
79 lines
2.5 KiB
TypeScript
import { type BreadcrumbItem } from '@/types';
|
|
import { Head, useForm } from '@inertiajs/react';
|
|
import { FormEventHandler } from 'react';
|
|
|
|
import Heading from '@/components/heading';
|
|
import { Button } from '@/components/ui/button';
|
|
import { AssignableRole, ClientOption, UserForm } from '@/components/user-form';
|
|
import { useTranslation } from '@/hooks/use-translation';
|
|
import AppLayout from '@/layouts/app-layout';
|
|
|
|
interface UsersCreateProps {
|
|
roles: AssignableRole[];
|
|
clients: ClientOption[];
|
|
}
|
|
|
|
interface UserFormData {
|
|
[key: string]: string | number[];
|
|
name: string;
|
|
email: string;
|
|
role_id: string;
|
|
password: string;
|
|
password_confirmation: string;
|
|
assigned_clients: number[];
|
|
}
|
|
|
|
export default function UsersCreate({ roles, clients }: UsersCreateProps) {
|
|
const { t } = useTranslation();
|
|
|
|
const breadcrumbs: BreadcrumbItem[] = [
|
|
{ title: t('System users'), href: '/users' },
|
|
{ title: t('New user'), href: '/users/create' },
|
|
];
|
|
|
|
const { data, setData, post, processing, errors } = useForm<UserFormData>({
|
|
name: '',
|
|
email: '',
|
|
role_id: '',
|
|
password: '',
|
|
password_confirmation: '',
|
|
assigned_clients: [],
|
|
});
|
|
|
|
const submit: FormEventHandler = (e) => {
|
|
e.preventDefault();
|
|
post(route('users.store'));
|
|
};
|
|
|
|
return (
|
|
<AppLayout breadcrumbs={breadcrumbs}>
|
|
<Head title={t('New user')} />
|
|
|
|
<div className="px-4 py-6">
|
|
<Heading title={t('New user')} description={t('Create a staff account for this installation')} />
|
|
|
|
<form onSubmit={submit} className="space-y-6">
|
|
<UserForm
|
|
name={data.name}
|
|
email={data.email}
|
|
roleId={data.role_id}
|
|
password={data.password}
|
|
passwordConfirmation={data.password_confirmation}
|
|
onChange={(field, value) => setData(field, value)}
|
|
roles={roles}
|
|
clients={clients}
|
|
assignedClients={data.assigned_clients}
|
|
onAssignedClientsChange={(ids) => setData('assigned_clients', ids)}
|
|
passwordOptional={false}
|
|
errors={errors}
|
|
/>
|
|
|
|
<Button type="submit" disabled={processing}>
|
|
{t('Create user')}
|
|
</Button>
|
|
</form>
|
|
</div>
|
|
</AppLayout>
|
|
);
|
|
}
|