Skip to content

Commit

Permalink
Fixed: Prisma errors in all editor section
Browse files Browse the repository at this point in the history
  • Loading branch information
Peco1503 committed Jun 11, 2024
1 parent fcc5ae7 commit 2d00421
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions app/(cv)/editor/(sections)/Education.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { useSession } from "next-auth/react";
import { getProfessionalByEmail } from "@/services/sessionService";
import { MdOutlineModeEdit } from "react-icons/md";
import { MdOutlineDeleteOutline } from "react-icons/md";
import prisma from "@/lib/prisma";
import { Prisma } from "@prisma/client";

interface Education {
education_id: string;
school: string;
Expand Down Expand Up @@ -74,9 +77,9 @@ const EducationComponent: React.FC<EducationProps> = ({ educations, setEducation
setEducations((prevEducations) =>
prevEducations.filter((_, idx) => idx !== index)
);
}catch (error) {
}catch (error:any) {
console.error('Error deleting education:', error);
if (error instanceof prisma.PrismaClientKnownRequestError && error.code === 'P2025') {
if (error instanceof Prisma.PrismaClientKnownRequestError && error.code === 'P2025') {
// Optionally remove the record from the state if it does not exist in the database
setEducations((prevEducations) =>
prevEducations.filter((education) => education.education_id !== educationID)
Expand Down
3 changes: 2 additions & 1 deletion app/(cv)/editor/(sections)/Projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useSession } from "next-auth/react";
import { getProfessionalByEmail } from "@/services/sessionService";
import { MdOutlineModeEdit } from "react-icons/md";
import { MdOutlineDeleteOutline } from "react-icons/md";
import { Prisma } from "@prisma/client";

interface Project {
project_id: string;
Expand Down Expand Up @@ -73,7 +74,7 @@ const Projects: React.FC<ProjectProps> = ({projectsList, setProjects, profession
);
}catch (error) {
console.error('Error deleting project:', error);
if (error instanceof prisma.PrismaClientKnownRequestError && error.code === 'P2025') {
if (error instanceof Prisma.PrismaClientKnownRequestError && error.code === 'P2025') {
setProjects((prevProjects) =>
prevProjects.filter((project) => project.project_id !== projectID)
);
Expand Down
3 changes: 2 additions & 1 deletion app/(cv)/editor/(sections)/Skills.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { update } from "cypress/types/lodash";
import { useSession } from "next-auth/react";
import { getProfessionalByEmail } from "@/services/sessionService";
import { MdOutlineModeEdit, MdOutlineDeleteOutline } from "react-icons/md";
import { Prisma } from "@prisma/client";

interface Skill {
skill_id: string;
Expand Down Expand Up @@ -68,7 +69,7 @@ const Skills: React.FC<SkillProps> = ({ skillList, setSkills, professionalID })
);
} catch (error) {
console.error('Error deleting skill:', error);
if (error instanceof prisma.PrismaClientKnownRequestError && error.code === 'P2025') {
if (error instanceof Prisma.PrismaClientKnownRequestError && error.code === 'P2025') {
setSkills((prevSkills) =>
prevSkills.filter((skill) => skill.skill_id !== skillID)
);
Expand Down
3 changes: 2 additions & 1 deletion app/(cv)/editor/(sections)/WorkExperience.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useSession } from "next-auth/react";
import { getProfessionalByEmail } from "@/services/sessionService";
import { MdOutlineModeEdit } from "react-icons/md";
import { MdOutlineDeleteOutline } from "react-icons/md";
import { Prisma } from "@prisma/client";

interface Work {
work_experience_id : string;
Expand Down Expand Up @@ -75,7 +76,7 @@ const WorkExperience: React.FC<WorkProps> = ({works, setWorks, professionalID})
);
}catch (error) {
console.error('Error deleting work:', error);
if (error instanceof prisma.PrismaClientKnownRequestError && error.code === 'P2025') {
if (error instanceof Prisma.PrismaClientKnownRequestError && error.code === 'P2025') {
setWorks((prevWorks) =>
prevWorks.filter((work) => work.work_experience_id !== workID)
);
Expand Down

0 comments on commit 2d00421

Please sign in to comment.