Skip to content

Commit

Permalink
add cyperss
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseCSG committed Jun 3, 2024
1 parent f04fb85 commit 3b6fad0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ jobs:

- name: Run Tests
run: npm run test:ci
run: npm run test:e2e
11 changes: 8 additions & 3 deletions app/(base)/projects/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import {
Text,
} from "@mantine/core";
import { Employee } from "@/types/types";
import toast from "react-hot-toast";

const CreateProject = () => {
const router = useRouter();

const [isLoading, setIsLoading] = useState<boolean>(false);
const employeesQuery = useQuery({
queryKey: ["employees"],
queryFn: () => getAllEmployees(),
Expand All @@ -28,6 +29,7 @@ const CreateProject = () => {
const createProjectMutation = useMutation({
mutationFn: createProject,
onSuccess: () => {
toast.success("Project created successfully.");
router.replace("/projects");
router.refresh();
},
Expand All @@ -39,6 +41,8 @@ const CreateProject = () => {
]);

const handleForm = (formData: FormData) => {
setIsLoading(true);

const startDate = rangeDates[0];
const endDate = rangeDates[1];
const name = formData.get("name")?.toString();
Expand All @@ -57,7 +61,6 @@ const CreateProject = () => {
) {
throw new Error("User should fill all fields");
}

createProjectMutation.mutate({
newProject: {
name,
Expand All @@ -68,6 +71,7 @@ const CreateProject = () => {
},
members: memberIds,
});
setIsLoading(false);
};

const [selectedMembers, setSelectedMembers] = useState<Employee[]>([]);
Expand Down Expand Up @@ -294,11 +298,12 @@ const CreateProject = () => {
Cancel
</button>
<button
className="h-fit w-fit self-end rounded-xl bg-primary px-10 py-2 text-xl font-medium text-white drop-shadow-lg"
className={`${isLoading ? "bg-red-600" : "bg-primary"} h-fit w-fit self-end rounded-xl px-10 py-2 text-xl font-medium text-white drop-shadow-lg`}
type="submit"
onClick={() => {
console.log(selectedMembers);
}}
disabled={isLoading}
>
Create
</button>
Expand Down

0 comments on commit 3b6fad0

Please sign in to comment.