headplane/app/routes/users/dialogs/rename.tsx

38 lines
1,014 B
TypeScript
Raw Normal View History

import { Pencil } from 'lucide-react';
2024-12-31 10:30:14 +05:30
import { useState } from 'react';
import Dialog from '~/components/Dialog';
import Input from '~/components/Input';
2024-05-15 21:52:19 -04:00
interface Props {
2024-12-31 10:30:14 +05:30
username: string;
2024-05-15 21:52:19 -04:00
}
// TODO: Server side validation before submitting
export default function Rename({ username }: Props) {
2024-12-31 10:30:14 +05:30
const [newName, setNewName] = useState(username);
2024-05-15 21:52:19 -04:00
return (
<Dialog>
<Dialog.IconButton label={`Rename ${username}`}>
<Pencil className="p-1" />
</Dialog.IconButton>
<Dialog.Panel>
<Dialog.Title>Rename {username}?</Dialog.Title>
<Dialog.Text className="mb-8">
Enter a new username for {username}. Changing a username will not
update any ACL policies that may refer to this user by their old
username.
</Dialog.Text>
<input type="hidden" name="_method" value="rename" />
<input type="hidden" name="old" value={username} />
<Input
isRequired
name="new"
label="Username"
placeholder="my-new-name"
/>
</Dialog.Panel>
</Dialog>
2024-12-31 10:30:14 +05:30
);
2024-05-15 21:52:19 -04:00
}