refactor: move ProjectCard component and add prop types validation

This commit is contained in:
Alvalens 2025-03-18 12:37:11 +07:00
parent f1edb19b5a
commit 3aa7aedeca
3 changed files with 88 additions and 22 deletions

View file

@ -1,10 +1,10 @@
import Link from "next/link";
import { motion } from "framer-motion";
import Image from "next/image";
export default function projectCard({project, index, activeCategory}){
console.log(project.category[0], activeCategory);
console.log(project.category.includes(activeCategory));
return (
import { motion } from "framer-motion";
import PropTypes from "prop-types";
export default function ProjectCard({ project, index, activeCategory }) {
return (
<>
{project.category.includes(parseInt(activeCategory)) && (
<Link href={"projects/" + project.slug} key={index}>
@ -56,3 +56,10 @@ export default function projectCard({project, index, activeCategory}){
</>
);
}
ProjectCard.propTypes = {
project: PropTypes.object.isRequired,
index: PropTypes.number.isRequired,
activeCategory: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
.isRequired,
};