Expand user form display for both Add and Edit of Users
This commit is contained in:
@@ -22,15 +22,15 @@ interface AddUserDialogProps {
|
|||||||
const AddUserDialog = ({ isOpen, setIsOpen, form, onSubmit, isSubmitting }: AddUserDialogProps) => {
|
const AddUserDialog = ({ isOpen, setIsOpen, form, onSubmit, isSubmitting }: AddUserDialogProps) => {
|
||||||
return (
|
return (
|
||||||
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
||||||
<DialogContent className="sm:max-w-[700px] w-[95vw]">
|
<DialogContent className="sm:max-w-[700px] w-[95vw] max-h-[95vh] flex flex-col">
|
||||||
<DialogHeader>
|
<DialogHeader className="flex-shrink-0">
|
||||||
<DialogTitle>Add New User</DialogTitle>
|
<DialogTitle>Add New User</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Create a new user account
|
Create a new user account
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<ScrollArea className="h-[60vh]">
|
<ScrollArea className="flex-1 overflow-auto">
|
||||||
<div className="p-4">
|
<div className="p-1">
|
||||||
<AddUserForm
|
<AddUserForm
|
||||||
form={form}
|
form={form}
|
||||||
onSubmit={onSubmit}
|
onSubmit={onSubmit}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { Alert, AlertDescription } from "@/components/ui/alert";
|
|||||||
import UserTextField from "./form-fields/UserTextField";
|
import UserTextField from "./form-fields/UserTextField";
|
||||||
import UserToggleField from "./form-fields/UserToggleField";
|
import UserToggleField from "./form-fields/UserToggleField";
|
||||||
import UserProfilePictureField from "./form-fields/UserProfilePictureField";
|
import UserProfilePictureField from "./form-fields/UserProfilePictureField";
|
||||||
|
import UserRoleField from "./form-fields/UserRoleField";
|
||||||
|
|
||||||
interface EditUserDialogProps {
|
interface EditUserDialogProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@@ -42,15 +43,16 @@ const EditUserDialog = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
||||||
<DialogContent className="sm:max-w-[700px] w-[95vw]">
|
<DialogContent className="sm:max-w-[700px] w-[95vw] max-h-[95vh] flex flex-col">
|
||||||
<DialogHeader>
|
<DialogHeader className="flex-shrink-0">
|
||||||
<DialogTitle>Edit User</DialogTitle>
|
<DialogTitle>Edit User</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Update user information
|
Update user information
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<ScrollArea className="h-[60vh]">
|
|
||||||
<div className="p-4">
|
<ScrollArea className="flex-1 overflow-auto">
|
||||||
|
<div className="p-1">
|
||||||
{error && (
|
{error && (
|
||||||
<Alert variant="destructive" className="mb-4">
|
<Alert variant="destructive" className="mb-4">
|
||||||
<AlertCircle className="h-4 w-4" />
|
<AlertCircle className="h-4 w-4" />
|
||||||
@@ -85,11 +87,10 @@ const EditUserDialog = ({
|
|||||||
placeholder="Enter username"
|
placeholder="Enter username"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<UserTextField
|
<UserRoleField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="role"
|
name="role"
|
||||||
label="Role"
|
label="Role"
|
||||||
placeholder="Enter role (e.g. admin, user)"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -99,23 +100,34 @@ const EditUserDialog = ({
|
|||||||
label="Active Status"
|
label="Active Status"
|
||||||
description="User will be able to access the system"
|
description="User will be able to access the system"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DialogFooter className="pt-4">
|
|
||||||
<Button type="submit" disabled={isSubmitting}>
|
|
||||||
{isSubmitting ? (
|
|
||||||
<>
|
|
||||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
|
||||||
Updating...
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
"Update User"
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</DialogFooter>
|
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
|
|
||||||
|
<DialogFooter className="flex-shrink-0 pt-4 border-t">
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
onClick={() => setIsOpen(false)}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={form.handleSubmit(onSubmit)}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
|
{isSubmitting ? (
|
||||||
|
<>
|
||||||
|
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||||
|
Updating...
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
"Update User"
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user