Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created modal component and Create role Modal Form #352

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions app/components/CreateRoleFormModal/CreateRoleForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { FC, useState } from "react";

Check failure on line 1 in app/components/CreateRoleFormModal/CreateRoleForm.tsx

View workflow job for this annotation

GitHub Actions / eslint

Replace `C,·useState·}·from·"` with `orm·}·from·"@remix-run/`
import { Form } from "@remix-run/react";

Check failure on line 2 in app/components/CreateRoleFormModal/CreateRoleForm.tsx

View workflow job for this annotation

GitHub Actions / eslint

Replace `orm·}·from·"@remix-run/react";` with `C,·useState·}·from·"react";⏎`
import CreateRoleModal from "./CreateRoleModal";

interface CreateRoleFormProperties {
isOpen: boolean;
onClose: () => void;
}

const CreateRoleForm: FC<CreateRoleFormProperties> = ({ isOpen, onClose }) => {
const [roleName, setRoleName] = useState("");
const [roleDescription, setRoleDescription] = useState("");

const handleSubmit = (event: React.FormEvent) => {
event.preventDefault();
// Handle form submission logic here
onClose();
};

return (
<CreateRoleModal isOpen={isOpen}>
<div className="p-6">
<div className="mb-4 flex items-center justify-between">
<h2 className="text-xl font-semibold">Create Role</h2>
<button
onClick={onClose}
className="text-gray-500 hover:text-gray-700"
>
<svg
className="h-6 w-6"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M6 18L18 6M6 6l12 12"
/>
</svg>
</button>
</div>
<p className="mb-4 text-sm text-gray-600">
Define customized responsibilities for collaborative success.
</p>
<Form method="post" onSubmit={handleSubmit}>
<div className="mb-4">
<label
htmlFor="roleName"
className="mb-1 block text-sm font-bold text-[#0A0A0A]"
>
Name of role
</label>
<input
type="text"
id="roleName"
name="roleName"
placeholder="e.g: IT Staff"
value={roleName}
onChange={(event) => setRoleName(event.target.value)}
className="w-[50%] rounded-md border border-border p-2 text-sm font-normal text-[#525252]"
required
/>
</div>
<div className="mb-6">
<label
htmlFor="roleDescription"
className="mb-1 block border-border text-sm font-bold text-[#0A0A0A] outline-border"
>
Role description
</label>
<textarea
id="roleDescription"
name="roleDescription"
placeholder="Describe role"
value={roleDescription}
onChange={(event) => setRoleDescription(event.target.value)}
className="h-24 w-full resize-none rounded-md border border-gray-300 p-2 text-sm font-normal text-[#525252]"
required
/>
</div>
<div className="flex justify-end space-x-2">
<button
type="button"
onClick={onClose}
className="rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50"
>
Cancel
</button>
<button
type="submit"
className="rounded-md bg-orange-500 px-4 py-2 text-sm font-medium text-white hover:bg-orange-600"
>
Create Role
</button>
</div>
</Form>
</div>
</CreateRoleModal>
);
};

export default CreateRoleForm;
23 changes: 23 additions & 0 deletions app/components/CreateRoleFormModal/CreateRoleModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { FC, ReactNode } from "react";

interface CreateRoleModalProperties {
isOpen: boolean;
children: ReactNode;
}

const CreateRoleModal: FC<CreateRoleModalProperties> = ({
isOpen,
children,
}) => {
if (!isOpen) return;

return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50">
<div className="mx-4 w-full max-w-md rounded-lg bg-white shadow-lg">
{children}
</div>
</div>
);
};

export default CreateRoleModal;
Loading