Certification.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import React, { useState } from "react";
  2. import CertificateModal from "@/components/CertificateModal";
  3. type Category = {
  4. id: string;
  5. label: string;
  6. };
  7. type Certificate = {
  8. id: number;
  9. category: string;
  10. title: string;
  11. imageUrl: string;
  12. };
  13. const categories: Category[] = [
  14. { id: "all", label: "전체" },
  15. { id: "eval", label: "시공능력 확인서, 평가액" },
  16. { id: "design", label: "상표 디자인" },
  17. { id: "patent", label: "특허" },
  18. { id: "award", label: "상장" },
  19. { id: "iso", label: "ISO 인증서" },
  20. ];
  21. // FIXME : public/image 하위에 cert 폴더 만들고, 인증서 쭈셔넣으면 됨
  22. const certificates: Certificate[] = [
  23. {
  24. id: 1,
  25. category: "eval",
  26. title: "시공능력 확인서 2024",
  27. imageUrl: "https://placehold.co/564x788?text=Eval+1",
  28. },
  29. {
  30. id: 2,
  31. category: "design",
  32. title: "상표등록증",
  33. imageUrl: "https://placehold.co/564x788?text=Design+1",
  34. },
  35. ];
  36. const Certification: React.FC = () => {
  37. const [activeTab, setActiveTab] = useState<string>("all");
  38. const [selectedCert, setSelectedCert] = useState<Certificate | null>(null);
  39. const filteredCerts =
  40. activeTab === "all"
  41. ? certificates
  42. : certificates.filter((cert) => cert.category === activeTab);
  43. return (
  44. <div className="max-w-7xl mx-auto px-4 py-10">
  45. {/* 탭 */}
  46. <div className="flex w-full mb-8 border border-gray-200 rounded overflow-hidden">
  47. {categories.map((category) => (
  48. <div
  49. key={category.id}
  50. onClick={() => setActiveTab(category.id)}
  51. className={`w-1/6 h-11 flex items-center justify-center cursor-pointer transition-colors ${
  52. activeTab === category.id
  53. ? "bg-blue-900 text-white font-bold text-base"
  54. : "border-l border-zinc-300/75 text-black/70 text-xs font-thin"
  55. }`}
  56. >
  57. {category.label}
  58. </div>
  59. ))}
  60. </div>
  61. {/* 인증서 그리드 */}
  62. <div className="grid grid-cols-4 gap-6">
  63. {filteredCerts.map((cert) => (
  64. <div
  65. key={cert.id}
  66. className="flex flex-col items-center w-72 h-96 cursor-pointer"
  67. onClick={() => setSelectedCert(cert)}
  68. >
  69. <img
  70. src={cert.imageUrl}
  71. alt={cert.title}
  72. className="w-60 h-80 rounded-[5px] object-cover"
  73. />
  74. <div className="w-80 text-center mt-2 text-black text-base font-light font-['Inter'] leading-tight">
  75. {cert.title}
  76. </div>
  77. </div>
  78. ))}
  79. </div>
  80. {/* 모달 */}
  81. {selectedCert && (
  82. <CertificateModal
  83. title={selectedCert.title}
  84. imageUrl={selectedCert.imageUrl}
  85. onClose={() => setSelectedCert(null)}
  86. />
  87. )}
  88. </div>
  89. );
  90. };
  91. export default Certification;