Skip to content

Commit

Permalink
Merge pull request #55 from incubyte/feature-LP-70-add-project-team
Browse files Browse the repository at this point in the history
Feature lp 70 add project team
  • Loading branch information
amanramoliya committed Aug 24, 2023
2 parents cf61ee9 + e294923 commit 17417fc
Show file tree
Hide file tree
Showing 20 changed files with 204 additions and 48 deletions.
13 changes: 13 additions & 0 deletions admin/src/components/user/AddSingleUserForm.test.tsx
Expand Up @@ -67,6 +67,19 @@ describe("Display Add User Page", () => {
getByPlaceholderText("Enter client team");
expect(clientTeamInputPlaceholder).toBeInTheDocument();
});
test("renders client team input", () => {
const { getByTestId, getByPlaceholderText } = render(
<BrowserRouter>
<AddSingleUserForm />
</BrowserRouter>
);
const projectTeamInput = getByTestId("projectTeamInput");
expect(projectTeamInput).toBeInTheDocument();

const projectTeamInputPlaceholder =
getByPlaceholderText("Enter project team");
expect(projectTeamInputPlaceholder).toBeInTheDocument();
});

test("renders roles selection", () => {
const { getByTestId } = render(
Expand Down
16 changes: 15 additions & 1 deletion admin/src/components/user/AddSingleUserForm.tsx
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { ToastContainer, toast } from "react-toastify";
import "../../css/user/addSingleUserForm.css";
Expand All @@ -8,6 +8,7 @@ const AddSingleUserForm = () => {
const [employeeId, setEmployeeId] = useState("");
const [designation, setDesignation] = useState("");
const [clientTeam, setclientTeam] = useState("");
const [projectTeam, setprojectTeam] = useState("");
const [role, setRole] = useState("Employee");
const navigator = useNavigate();
const handleCreateUser = async () => {
Expand All @@ -27,6 +28,7 @@ const AddSingleUserForm = () => {
eId: employeeId,
role: designation,
clientTeam: clientTeam,
projectTeam: projectTeam,
email: email,
roles: role,
},
Expand Down Expand Up @@ -128,6 +130,18 @@ const AddSingleUserForm = () => {
onChange={(e) => setclientTeam(e.target.value)}
/>
</div>
<div className="FormGroup">
<label className="AddUserTextLabel">Project Team</label>
<input
className="AddUserTextInput"
type="text"
data-testid="projectTeamInput"
placeholder="Enter project team"
required
value={projectTeam}
onChange={(e) => setprojectTeam(e.target.value)}
/>
</div>
<div className="FormGroup">
<label className="AddUserTextLabel">Role</label>
<div>
Expand Down
11 changes: 11 additions & 0 deletions admin/src/components/user/UserDetail.test.tsx
Expand Up @@ -18,6 +18,7 @@ const mockUser = {
eId: "E0001",
role: "BQA",
clientTeam: "abc",
projectTeam: "abc",
Role: "Employee",
};
beforeEach(() => {
Expand Down Expand Up @@ -173,6 +174,11 @@ describe("UserDetail Component", () => {
"UserDetailClientTeamLabel"
);
expect(userDetailClientTeamLabel).toBeInTheDocument();

const userDetailProjectTeamLabel = screen.getByTestId(
"UserDetailProjectTeamLabel"
);
expect(userDetailProjectTeamLabel).toBeInTheDocument();
});
});
});
Expand Down Expand Up @@ -203,6 +209,11 @@ describe("UserDetail Component", () => {
"UserDetailClientTeamInput"
);
expect(userDetailClientTeamInput).toBeInTheDocument();

const userDetailProjectTeamInput = screen.getByTestId(
"UserDetailProjectTeamInput"
);
expect(userDetailProjectTeamInput).toBeInTheDocument();
});
});
});
Expand Down
42 changes: 41 additions & 1 deletion admin/src/components/user/UserDetail.tsx
Expand Up @@ -4,16 +4,17 @@ import { useNavigate, useParams } from "react-router-dom";
import { ToastContainer, toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import "../../css/user/userDetails.css";
import LoadingScreen from "../utilities/LoadingScreen";
import Navbar from "../utilities/Navbar";
import { imageUpload } from "./ImageUpload";
import { userType } from "./user";
import LoadingScreen from "../utilities/LoadingScreen";

const UserDetail = () => {
const [user, setUser] = useState<userType>({
email: "",
eId: "",
clientTeam: "",
projectTeam: "",
role: "",
roles: "",
profilePhoto: "",
Expand Down Expand Up @@ -85,6 +86,7 @@ const UserDetail = () => {
role: user.role,
roles: user.roles,
clientTeam: user.clientTeam,
projectTeam: user.projectTeam,
}),
}
);
Expand Down Expand Up @@ -121,6 +123,7 @@ const UserDetail = () => {
email: user.email,
eId: user.eId,
clientTeam: user.clientTeam,
projectTeam: user.projectTeam,
role: user.role,
roles: user.roles,
profilePhoto: media[0].url,
Expand Down Expand Up @@ -284,6 +287,7 @@ const UserDetail = () => {
email: e.target.value,
eId: user.eId,
clientTeam: user.clientTeam,
projectTeam: user.projectTeam,
role: user.role,
roles: user.roles,
profilePhoto: user.profilePhoto,
Expand Down Expand Up @@ -314,6 +318,7 @@ const UserDetail = () => {
clientTeam: user.clientTeam,
role: user.role,
roles: user.roles,
projectTeam: user.projectTeam,
profilePhoto: user.profilePhoto,
updatedAt: user.updatedAt,
id: user.id,
Expand Down Expand Up @@ -343,6 +348,7 @@ const UserDetail = () => {
role: e.target.value,
roles: user.roles,
profilePhoto: user.profilePhoto,
projectTeam: user.projectTeam,
updatedAt: user.updatedAt,
id: user.id,
createdAt: user.createdAt,
Expand Down Expand Up @@ -375,6 +381,39 @@ const UserDetail = () => {
roles: user.roles,
profilePhoto: user.profilePhoto,
updatedAt: user.updatedAt,
projectTeam: user.projectTeam,
id: user.id,
createdAt: user.createdAt,
});
}}
></input>
</div>

<div className="UserDetailsGridContent">
<label
data-testid="UserDetailProjectTeamLabel"
className="UserDetailsLabel"
>
Project Team
</label>
<input
data-testid="UserDetailProjectTeamInput"
defaultValue={
user.projectTeam !== null ? user.projectTeam : "-"
}
className="UserDetailsInput"
onChange={(e) => {
e.target.style.borderColor = "green";
setIsUpdated(true);
setUser({
email: user.email,
eId: user.eId,
clientTeam: user.clientTeam,
role: user.role,
roles: user.roles,
profilePhoto: user.profilePhoto,
updatedAt: user.updatedAt,
projectTeam: e.target.value,
id: user.id,
createdAt: user.createdAt,
});
Expand Down Expand Up @@ -406,6 +445,7 @@ const UserDetail = () => {
clientTeam: user.clientTeam,
role: user.role,
roles: e.target.checked === true ? "Admin" : "Employee",
projectTeam: user.projectTeam,
profilePhoto: user.profilePhoto,
updatedAt: user.updatedAt,
id: user.id,
Expand Down
1 change: 1 addition & 0 deletions admin/src/components/user/user.tsx
Expand Up @@ -3,6 +3,7 @@ export interface userType {
eId: string;
role: string;
clientTeam: string;
projectTeam: string;
email: string;
profilePhoto: string;
createdAt: string;
Expand Down
8 changes: 7 additions & 1 deletion admin/src/test/AddUserFormIntegration.test.tsx
@@ -1,4 +1,3 @@
import { BrowserRouter } from "react-router-dom";
import {
act,
cleanup,
Expand All @@ -7,6 +6,7 @@ import {
screen,
waitFor,
} from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";
import AddSingleUserForm from "../components/user/AddSingleUserForm";

afterEach(() => {
Expand Down Expand Up @@ -66,6 +66,12 @@ describe("test add user", () => {
await act(() => {
fireEvent.change(clientTeamInput, { target: { value: "Team1" } });
});
const projectTeamInput = screen.getByTestId(
"projectTeamInput"
) as HTMLInputElement;
await act(() => {
fireEvent.change(projectTeamInput, { target: { value: "Team1" } });
});

const roleSelect = screen.getByTestId("roleSelect") as HTMLInputElement;
await act(() => {
Expand Down
50 changes: 25 additions & 25 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/package.json
Expand Up @@ -66,9 +66,9 @@
"eslint-plugin-prettier": "^4.0.0",
"jest": "29.3.1",
"prettier": "^2.3.2",
"prisma": "^4.12.0",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"prisma": "^4.12.0",
"ts-jest": "29.0.3",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
Expand Down
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "User" ADD COLUMN "projectTeam" TEXT;
1 change: 1 addition & 0 deletions backend/prisma/schema.prisma
Expand Up @@ -17,6 +17,7 @@ model User {
eId String? @unique
role String?
clientTeam String?
projectTeam String?
email String @unique
password String
profilePhoto String
Expand Down

0 comments on commit 17417fc

Please sign in to comment.