Merge pull request #1 from internship-humic/implement-backend
Implement backend
This commit is contained in:
+9
-2
@@ -33,7 +33,7 @@ import { InternLayout, MentorLayout } from "./Pages/Internify/layout";
|
|||||||
import ProjectsPage from "./Pages/Internify/intern/ProjectsPage";
|
import ProjectsPage from "./Pages/Internify/intern/ProjectsPage";
|
||||||
import SertificatePage from "./Pages/Internify/intern/SertificatePage";
|
import SertificatePage from "./Pages/Internify/intern/SertificatePage";
|
||||||
import ProjectDetailPage from "./Pages/Internify/intern/ProjectDetailPage";
|
import ProjectDetailPage from "./Pages/Internify/intern/ProjectDetailPage";
|
||||||
import HomeMentorPage from "./Pages/Internify/mentor/HomePage";
|
import HomeMentorPage from "./Pages/Internify/mentor/HomeMentorPage";
|
||||||
import MentorProjectsPage from "./Pages/Internify/mentor/BaseProjectsPage";
|
import MentorProjectsPage from "./Pages/Internify/mentor/BaseProjectsPage";
|
||||||
import MentorCertificatePage from "./Pages/Internify/mentor/CertificatePage";
|
import MentorCertificatePage from "./Pages/Internify/mentor/CertificatePage";
|
||||||
import MentorInternPage from "./Pages/Internify/mentor/InternsPage";
|
import MentorInternPage from "./Pages/Internify/mentor/InternsPage";
|
||||||
@@ -88,18 +88,23 @@ function App() {
|
|||||||
|
|
||||||
<Route path="/login-internify" element={<InternifyLogin />} />
|
<Route path="/login-internify" element={<InternifyLogin />} />
|
||||||
|
|
||||||
|
{/* Intern only */}
|
||||||
|
<Route element={<ProtectedRoutes allowedRoles={["intern"]} />}>
|
||||||
<Route path="/intern" element={<InternLayout />}>
|
<Route path="/intern" element={<InternLayout />}>
|
||||||
<Route index element={<HomeInternPage />} />
|
<Route index element={<HomeInternPage />} />
|
||||||
<Route path="projects" element={<ProjectsPage />} />
|
<Route path="projects" element={<ProjectsPage />} />
|
||||||
<Route path="certificates" element={<SertificatePage />} />
|
<Route path="certificates" element={<SertificatePage />} />
|
||||||
<Route path="certificates/all" element={<SertificateList />} />
|
<Route path="certificates/all" element={<SertificateList />} />
|
||||||
<Route path="projects/:slug" element={<ProjectDetailPage />} />
|
<Route path="projects/:slug" element={<ProjectDetailPage />} />
|
||||||
<Route path="projects/:slug/:TaskSlug" element={<TaskSubmission />} />
|
<Route path="projects/:slug/:taskSlug" element={<TaskSubmission />} />
|
||||||
<Route path="faq" element={<FAQPage />} />
|
<Route path="faq" element={<FAQPage />} />
|
||||||
<Route path="notifications" element={<NotificationList />} />
|
<Route path="notifications" element={<NotificationList />} />
|
||||||
<Route path="settings" element={<SettingsContent />} />
|
<Route path="settings" element={<SettingsContent />} />
|
||||||
</Route>
|
</Route>
|
||||||
|
</Route>
|
||||||
|
|
||||||
|
{/* Mentor only */}
|
||||||
|
<Route element={<ProtectedRoutes allowedRoles={["admin"]} />}>
|
||||||
<Route path="/mentor" element={<MentorLayout />}>
|
<Route path="/mentor" element={<MentorLayout />}>
|
||||||
<Route index element={<HomeMentorPage />} />
|
<Route index element={<HomeMentorPage />} />
|
||||||
<Route path="projects" element={<MentorProjectsPage />} />
|
<Route path="projects" element={<MentorProjectsPage />} />
|
||||||
@@ -112,6 +117,8 @@ function App() {
|
|||||||
<Route path="notifications" element={<NotificationList />} />
|
<Route path="notifications" element={<NotificationList />} />
|
||||||
<Route path="settings" element={<SettingsPage />} />
|
<Route path="settings" element={<SettingsPage />} />
|
||||||
</Route>
|
</Route>
|
||||||
|
</Route>
|
||||||
|
|
||||||
</Routes>
|
</Routes>
|
||||||
</Router>
|
</Router>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export default function Header({ toggleSidebar }: { toggleSidebar: () => void })
|
|||||||
<div className='flex items-center gap-3'>
|
<div className='flex items-center gap-3'>
|
||||||
<button
|
<button
|
||||||
onClick={toggleSidebar}
|
onClick={toggleSidebar}
|
||||||
className="p-1 text-gray-600 hover:bg-gray-100 rounded-md md:hidden"
|
className="p-1 text-gray-600 hover:bg-gray-100 rounded-md lg:hidden"
|
||||||
>
|
>
|
||||||
<Menu className="w-6 h-6" />
|
<Menu className="w-6 h-6" />
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ const Landing = () => {
|
|||||||
loading="eager"
|
loading="eager"
|
||||||
decoding="async"
|
decoding="async"
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
fetchPriority="high"
|
fetchpriority="high"
|
||||||
className="w-full h-full object-contain rounded-lg"
|
className="w-full h-full object-contain rounded-lg"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export default function Breadcrumbs(){
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<nav className="text-[12px] mb-3">
|
<nav className="text-[15px] mb-3">
|
||||||
{fixbreadcumbs.map(({ match, breadcrumb }) => {
|
{fixbreadcumbs.map(({ match, breadcrumb }) => {
|
||||||
const isLast = match.pathname === location.pathname;
|
const isLast = match.pathname === location.pathname;
|
||||||
|
|
||||||
@@ -63,13 +63,13 @@ export default function Breadcrumbs(){
|
|||||||
{isLast ? (
|
{isLast ? (
|
||||||
<span className="font-bold text-red-800">
|
<span className="font-bold text-red-800">
|
||||||
{breadcrumb}
|
{breadcrumb}
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Link to={match.pathname} className="text-gray-800">
|
<Link to={match.pathname} className="text-gray-800">
|
||||||
{breadcrumb}
|
{breadcrumb}
|
||||||
</Link>
|
</Link>
|
||||||
{/* Karakter pemisah antar breadcrumb */}
|
|
||||||
<ChevronRight className="w-4 h-4 mx-1.5"/>
|
<ChevronRight className="w-4 h-4 mx-1.5"/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,25 +1,33 @@
|
|||||||
const mockFAQData = [
|
import api from "../../lib/api";
|
||||||
{
|
import { useEffect, useState } from "react";
|
||||||
id: 1,
|
|
||||||
question: "How do I generate internship certificates?",
|
interface FAQ {
|
||||||
answer: "Once an intern has completed all required project milestones and their final evaluation is approved by a manager, go to the 'Manage Certificates' tab. Select the intern's name, click 'Generate Certificate', and the system will automatically populate the official Internify template with their specific details."
|
id: number;
|
||||||
},
|
pertanyaan: string;
|
||||||
{
|
jawaban: string;
|
||||||
id: 2,
|
created_at: string;
|
||||||
question: "What are the technical requirements for interns?",
|
|
||||||
answer: "Internify is a web-based LMS. Interns simply need a modern web browser (Chrome, Firefox, or Safari) and a stable internet connection. Some engineering modules may require local development environments, which are detailed in the specific project onboarding documentation."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
question: "How often is the project dashboard updated?",
|
|
||||||
answer: "The dashboard updates in real-time as interns submit tasks or participate in the forum. Weekly progress reports are automatically generated every Friday at 5:00 PM EST and can be exported as PDF files from the Dashboard view."
|
|
||||||
}
|
}
|
||||||
];
|
|
||||||
|
|
||||||
export default function FAQPage() {
|
export default function FAQPage() {
|
||||||
|
const [faq, setFaq] = useState<FAQ[]>([]);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setLoading(true);
|
||||||
|
api.get("/faq-api/get")
|
||||||
|
.then((res) => {
|
||||||
|
setFaq(res.data.data); // ambil array dari field "data"
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error("Gagal fetch FAQ:", err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{/* Header Title */}
|
|
||||||
<div className="mb-10">
|
<div className="mb-10">
|
||||||
<h1 className="page-title">FAQ</h1>
|
<h1 className="page-title">FAQ</h1>
|
||||||
<p className="page-title-desc">
|
<p className="page-title-desc">
|
||||||
@@ -28,22 +36,25 @@ export default function FAQPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* FAQ Lists */}
|
{/* FAQ Lists */}
|
||||||
|
{loading ? (
|
||||||
|
<p className="text-gray-500">Memuat FAQ...</p>
|
||||||
|
) : (
|
||||||
<div className="space-y-8 max-w-auto">
|
<div className="space-y-8 max-w-auto">
|
||||||
{mockFAQData.map((faq) => (
|
{faq.map((item) => (
|
||||||
<div key={faq.id} className="relative shadow-md group py-5 px-10 rounded-md bg-white">
|
<div key={item.id} className="relative shadow-md group py-5 px-10 rounded-md bg-white">
|
||||||
|
|
||||||
{/* Item Question */}
|
{/* Item Question */}
|
||||||
<h2 className="text-[17px] font-bold text-[#8A0000] tracking-tight leading-snug mb-2 border-l-4 border-[#8A0000] pl-3">
|
<h2 className="text-[17px] font-bold text-[#8A0000] tracking-tight leading-snug mb-2 border-l-4 border-[#8A0000] pl-3">
|
||||||
{faq.question}
|
{item.pertanyaan}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
{/* Item Answer */}
|
|
||||||
<p className="text-[14px] pl-8 text-[#8A0000] font-light leading-relaxed tracking-normal">
|
<p className="text-[14px] pl-8 text-[#8A0000] font-light leading-relaxed tracking-normal">
|
||||||
{faq.answer}
|
{item.jawaban}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -2,11 +2,17 @@ import { useState } from "react";
|
|||||||
import logo from "../../assets/logo.png";
|
import logo from "../../assets/logo.png";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { Mail, Lock, Eye, EyeOff } from 'lucide-react';
|
import { Mail, Lock, Eye, EyeOff } from 'lucide-react';
|
||||||
|
import api from "../../lib/api";
|
||||||
|
|
||||||
const DataUsers = [
|
const decodeJWT = (token: string) => {
|
||||||
{ "Email": "intern@email.com", "Password": "password123", "role": "intern" },
|
try {
|
||||||
{ "Email": "mentor@email.com", "Password": "password123", "role": "mentor" },
|
const base64 = token.split(".")[1].replace(/-/g, "+").replace(/_/g, "/");
|
||||||
];
|
const padded = base64.padEnd(base64.length + (4 - base64.length % 4) % 4, "=");
|
||||||
|
return JSON.parse(atob(padded));
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export default function InternifyLogin() {
|
export default function InternifyLogin() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -14,8 +20,9 @@ export default function InternifyLogin() {
|
|||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const [showPassword, setShowPassword] = useState(false);
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const handleSignIn = (e: React.FormEvent) => {
|
const handleSignIn = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setError("");
|
setError("");
|
||||||
|
|
||||||
@@ -24,20 +31,30 @@ export default function InternifyLogin() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = DataUsers.find(
|
try {
|
||||||
(u) => u.Email.toLowerCase() === email.toLowerCase() && u.Password === password
|
setLoading(true);
|
||||||
);
|
const response = await api.post("/auth-api/login", { email, password });
|
||||||
|
|
||||||
if (user) {
|
const { token } = response.data.data;
|
||||||
if (user.role === "intern") {
|
document.cookie = `token=${token}; path=/; SameSite=Strict`;
|
||||||
|
|
||||||
|
const decoded = decodeJWT(token);
|
||||||
|
const role = decoded?.role;
|
||||||
|
if (role === "intern") {
|
||||||
navigate("/intern");
|
navigate("/intern");
|
||||||
} else if (user.role === "mentor") {
|
} else if (role === "admin") {
|
||||||
navigate("/mentor");
|
navigate("/mentor");
|
||||||
} else {
|
} else {
|
||||||
setError("Role user tidak dikenali.");
|
setError("Role user tidak dikenali.");
|
||||||
}
|
}
|
||||||
} else {
|
} catch (err: any) {
|
||||||
|
if (err.response?.status === 401 || err.response?.status === 400) {
|
||||||
setError("Email atau password salah.");
|
setError("Email atau password salah.");
|
||||||
|
} else {
|
||||||
|
setError("Terjadi kesalahan. Coba beberapa saat lagi.");
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,7 +65,7 @@ export default function InternifyLogin() {
|
|||||||
<div className="w-full max-w-[440px] flex flex-col items-center">
|
<div className="w-full max-w-[440px] flex flex-col items-center">
|
||||||
<div className="text-center mb-6">
|
<div className="text-center mb-6">
|
||||||
<div className="flex items-center justify-center gap-2 font-bold text-2xl tracking-tight text-black">
|
<div className="flex items-center justify-center gap-2 font-bold text-2xl tracking-tight text-black">
|
||||||
<img src={logo} alt="Logo" className="w-32 h-20" />
|
<img src={logo} alt="Logo" />
|
||||||
</div>
|
</div>
|
||||||
<p className="text-[10px] tracking-widest text-yellow-950 font-semibold mt-1 uppercase">
|
<p className="text-[10px] tracking-widest text-yellow-950 font-semibold mt-1 uppercase">
|
||||||
HUMIC LMS PORTAL
|
HUMIC LMS PORTAL
|
||||||
@@ -112,6 +129,7 @@ export default function InternifyLogin() {
|
|||||||
|
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
|
disabled={loading}
|
||||||
className="w-full bg-[#B30000] hover:bg-[#990000] text-white font-medium text-sm py-2.5 rounded-lg transition-colors shadow-sm mt-2"
|
className="w-full bg-[#B30000] hover:bg-[#990000] text-white font-medium text-sm py-2.5 rounded-lg transition-colors shadow-sm mt-2"
|
||||||
>
|
>
|
||||||
Sign In
|
Sign In
|
||||||
|
|||||||
@@ -1,30 +1,72 @@
|
|||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
|
import api from "../../lib/api";
|
||||||
// Mock Data Profile awal
|
|
||||||
const mockProfileData = {
|
|
||||||
fullName: "JonathanKristina",
|
|
||||||
email: "JonathanKristina@gmail.com",
|
|
||||||
bio: "UIUX holic"
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function SettingsContent() {
|
export default function SettingsContent() {
|
||||||
const [formData, setFormData] = useState(mockProfileData);
|
const [formData, setFormData] = useState({
|
||||||
|
fullName: "",
|
||||||
|
email: "",
|
||||||
|
bio: ""
|
||||||
|
});
|
||||||
|
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
|
const [successMsg, setSuccessMsg] = useState("");
|
||||||
|
const [errorMsg, setErrorMsg] = useState("");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await api.patch("/auth-api/update-profile");
|
||||||
|
const data = response.data.data;
|
||||||
|
setFormData({
|
||||||
|
fullName: data.full_name || "",
|
||||||
|
email: data.email || "",
|
||||||
|
bio: data.professional_bio || "",
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to fetch profile:", err)
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fetchData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
||||||
const { name, value } = e.target;
|
const { name, value } = e.target;
|
||||||
setFormData((prev) => ({ ...prev, [name]: value }));
|
setFormData((prev) => ({ ...prev, [name]: value }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSaveChanges = (e: React.FormEvent) => {
|
const handleSaveChanges = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// Simulasi penyimpanan data sukses
|
setSuccessMsg("");
|
||||||
alert("Changes saved successfully!");
|
setErrorMsg("");
|
||||||
console.log("Saved Data:", formData);
|
setSaving(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await api.patch("/auth-api/update-profile", {
|
||||||
|
full_name: formData.fullName,
|
||||||
|
email: formData.email,
|
||||||
|
professional_bio: formData.bio,
|
||||||
|
});
|
||||||
|
setSuccessMsg("Profile updated successfully!");
|
||||||
|
} catch (err: any) {
|
||||||
|
setErrorMsg(err?.response?.data?.message || "Failed to save changes.");
|
||||||
|
} finally {
|
||||||
|
setSaving(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Mendapatkan inisial huruf pertama untuk avatar profile gambar
|
|
||||||
const initialLetter = formData.fullName ? formData.fullName.charAt(1).toUpperCase() : "U";
|
const initialLetter = formData.fullName ? formData.fullName.charAt(1).toUpperCase() : "U";
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center justify-center h-40 text-sm text-gray-400">
|
||||||
|
Loading profile...
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="">
|
<div className="">
|
||||||
|
|
||||||
@@ -114,13 +156,25 @@ export default function SettingsContent() {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{successMsg && (
|
||||||
|
<p className="text-xs text-green-600 bg-green-50 p-2 rounded-md font-medium">
|
||||||
|
{successMsg}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{errorMsg && (
|
||||||
|
<p className="text-xs text-red-600 bg-red-50 p-2 rounded-md font-medium">
|
||||||
|
{errorMsg}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Form Action Footer Row */}
|
{/* Form Action Footer Row */}
|
||||||
<div className="flex justify-end pt-2">
|
<div className="flex justify-end pt-2">
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
|
disabled={saving}
|
||||||
className="px-6 py-2 bg-[#B30000] hover:bg-[#990000] text-white font-bold text-xs rounded-lg shadow-sm transition-colors uppercase tracking-wider"
|
className="px-6 py-2 bg-[#B30000] hover:bg-[#990000] text-white font-bold text-xs rounded-lg shadow-sm transition-colors uppercase tracking-wider"
|
||||||
>
|
>
|
||||||
Save Changes
|
{saving ? "Saving..." : "Save Changes"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,43 @@
|
|||||||
import type { Project } from '../../../lib/mockProjects';
|
import { useParams } from 'react-router-dom';
|
||||||
import ProjectTimeline from './components/ProjectTimeline';
|
import ProjectTimeline from './components/ProjectTimeline';
|
||||||
import TaskCard from './components/ProjectTaskCard';
|
import TaskCard from './components/ProjectTaskCard';
|
||||||
import HeroProject from './components/Hero-project';
|
import HeroProject from './components/Hero-project';
|
||||||
|
import { useProjectTasks } from '../../../hooks/useTasks';
|
||||||
|
import type { Project } from '../../../types/project.types';
|
||||||
|
|
||||||
export default function ForumTab({ project }: { project: Project }) {
|
export default function ForumTab({ project }: { project: Project }) {
|
||||||
|
const { slug } = useParams<{ slug: string }>();
|
||||||
|
const { tasks, loading, error } = useProjectTasks(slug ?? "");
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{/* Hero banner */}
|
{/* Hero banner */}
|
||||||
<HeroProject title={project.name} description={project.description} />
|
<HeroProject title={project.project_name} description={project.description} />
|
||||||
|
|
||||||
|
{/* Loading */}
|
||||||
|
{loading && (
|
||||||
|
<div className="flex flex-col gap-3 mt-5">
|
||||||
|
{[...Array(3)].map((_, i) => (
|
||||||
|
<div key={i} className="h-24 bg-gray-100 rounded-xl animate-pulse" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Error */}
|
||||||
|
{error && <p className="text-red-500 text-sm mt-5">{error}</p>}
|
||||||
|
|
||||||
{/* Timeline + Task list */}
|
{/* Timeline + Task list */}
|
||||||
<div className="flex gap-7 items-start">
|
<div className="flex flex-col gap-7 md:flex-row md:items-start">
|
||||||
<div className="w-1/5 bg-white rounded-xl p-5 shadow-md shrink-0">
|
<div className="w-full md:w-1/5 bg-white rounded-xl p-5 border border-box-border shrink-0">
|
||||||
<ProjectTimeline tasks={project.tasks} />
|
<ProjectTimeline tasks={tasks} />
|
||||||
</div>
|
</div>
|
||||||
|
<div className="w-full border-t border-box-border md:border-t-0 pt-4 md:pt-0 md:w-4/5">
|
||||||
<div className="w-4/5">
|
{tasks.length === 0 ? (
|
||||||
{project.tasks.map((task, idx) => (
|
<p className="text-sm text-gray-400">Belum ada task.</p>
|
||||||
<TaskCard key={idx} task={task} projectName={project.name} />
|
) : (
|
||||||
))}
|
tasks.map((task) => (
|
||||||
|
<TaskCard key={task.id} task={task} />
|
||||||
|
))
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ export default function HomeInternPage() {
|
|||||||
<HomeHeader />
|
<HomeHeader />
|
||||||
<div className="flex flex-col gap-5">
|
<div className="flex flex-col gap-5">
|
||||||
<div className="grid grid-cols-2 gap-5">
|
<div className="grid grid-cols-2 gap-5">
|
||||||
<div className="bg-white border border-gray-200 rounded-xl p-6">
|
<div className="bg-box-primary border border-box-border rounded-xl p-6">
|
||||||
<HomeProjectList />
|
<HomeProjectList />
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-white border border-gray-200 rounded-xl p-6">
|
<div className="bg-box-primary border border-box-border rounded-xl p-6">
|
||||||
<TaskTimeline />
|
<TaskTimeline />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-white rounded-xl">
|
<div className="bg-box-primary rounded-xl">
|
||||||
<HomeCalendar />
|
<HomeCalendar />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,44 +1,75 @@
|
|||||||
import type { Project, Intern } from '../../../lib/mockData';
|
import { useParams } from 'react-router-dom';
|
||||||
|
import { } from '../../../hooks/useProjects';
|
||||||
|
import type { Project } from '../../../types/project.types';
|
||||||
|
|
||||||
export default function ParticipantsTab({ project }: { project: Project }) {
|
export default function ParticipantsTab({ project }: { project: Project }) {
|
||||||
|
const { slug } = useParams<{ slug: string }>();
|
||||||
|
const { interns, loading, error } = useProjectInterns(slug ?? "");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{/* Mentor */}
|
{/* Mentor */}
|
||||||
<div className="mb-8">
|
<div className="mb-8">
|
||||||
<h3 className=" font-bold text-base text-[#1a1a1a] mb-3.5">
|
<h3 className="font-bold text-font-shade mb-3.5">Mentor</h3>
|
||||||
Mentor
|
<div className="border-b border-box-border pb-4">
|
||||||
</h3>
|
|
||||||
<div className="border-b border-[#eee] pb-4">
|
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<span className=" text-sm text-[#333]">
|
{project.admin.profile_picture ? (
|
||||||
{project.mentor}
|
<img
|
||||||
</span>
|
src={project.admin.profile_picture}
|
||||||
|
alt={project.admin.full_name}
|
||||||
|
className="w-8 h-8 rounded-full object-cover"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="w-8 h-8 rounded-full bg-gray-200" />
|
||||||
|
)}
|
||||||
|
<span className="text-md text-font">{project.admin.full_name}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Members */}
|
{/* Members */}
|
||||||
<div>
|
<div>
|
||||||
<h3 className="font-bold text-base text-[#1a1a1a] mb-3.5">
|
<h3 className="font-bold text-font-shade mb-3.5">Members</h3>
|
||||||
Members
|
|
||||||
</h3>
|
{loading && (
|
||||||
{project.interns.map((intern: Intern, idx: number) => (
|
<div className="flex flex-col gap-3">
|
||||||
|
{[...Array(3)].map((_, i) => (
|
||||||
|
<div key={i} className="h-10 bg-gray-100 rounded animate-pulse" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{error && <p className="text-red-500 text-sm">{error}</p>}
|
||||||
|
|
||||||
|
{!loading && !error && interns.map((intern, idx) => (
|
||||||
<div
|
<div
|
||||||
key={idx}
|
key={intern.id}
|
||||||
className={`flex items-center justify-between py-3 ${
|
className={`flex items-center justify-between py-3 ${
|
||||||
idx < project.interns.length - 1 ? 'border-b border-[#f0f0f0]' : ''
|
idx < interns.length - 1 ? 'border-b border-box-border' : ''
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<span className=" text-sm text-[#333]">
|
{intern.avatar ? (
|
||||||
{intern.name}
|
<img
|
||||||
</span>
|
src={intern.avatar}
|
||||||
|
alt={intern.full_name}
|
||||||
|
className="w-7 h-7 rounded-full object-cover"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="w-7 h-7 rounded-full bg-gray-200 flex-shrink-0" />
|
||||||
|
)}
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<span className="text-sm text-[#333]">{intern.full_name}</span>
|
||||||
|
<span className="text-[11px] text-gray-400">{intern.email}</span>
|
||||||
</div>
|
</div>
|
||||||
<span className=" text-[13px] text-[#555] font-semibold">
|
</div>
|
||||||
{intern.role}
|
<span className="text-[13px] text-[#555] font-semibold">{intern.kelompok_peminatan}</span>
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
{!loading && !error && interns.length === 0 && (
|
||||||
|
<p className="text-sm text-gray-400">Belum ada members.</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,24 +1,19 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { mockProjects } from '../../../lib/mockProjects';
|
// import { useProjectDetail } from '../../../hooks/useProjectDetail';
|
||||||
|
import { useProjectDetail } from '../../../hooks/useProjects';
|
||||||
import ForumTab from './ForumTab';
|
import ForumTab from './ForumTab';
|
||||||
import ParticipantsTab from './ParticipantTab';
|
import ParticipantsTab from './ParticipantTab';
|
||||||
|
|
||||||
const toSlug = (name: string) => name.toLowerCase().replace(/\s+/g, '-');
|
|
||||||
|
|
||||||
export default function ProjectDetailPage() {
|
export default function ProjectDetailPage() {
|
||||||
const { slug } = useParams<{ slug: string }>();
|
const { slug } = useParams<{ slug: string }>();
|
||||||
|
const { project, loading, error } = useProjectDetail(slug ?? "");
|
||||||
const [activeTab, setActiveTab] = useState<'forum' | 'participants'>('forum');
|
const [activeTab, setActiveTab] = useState<'forum' | 'participants'>('forum');
|
||||||
|
|
||||||
const project = mockProjects.find((p) => toSlug(p.name) === slug);
|
// Fallback sederhana
|
||||||
|
if (loading) return <p className="p-10 text-gray-400">Memuat project...</p>;
|
||||||
if (!project) {
|
if (error) return <p className="p-10 text-red-500">{error}</p>;
|
||||||
return (
|
if (!project) return <p className="p-10 text-gray-400">Project tidak ditemukan.</p>;
|
||||||
<div className="p-10 text-[#888]">
|
|
||||||
Project tidak ditemukan.
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const tabClass = (tab: string) =>
|
const tabClass = (tab: string) =>
|
||||||
`pr-0 py-2.5 mr-7 text-sm bg-transparent border-0 cursor-pointer transition-colors duration-150 border-b-2 ${activeTab === tab
|
`pr-0 py-2.5 mr-7 text-sm bg-transparent border-0 cursor-pointer transition-colors duration-150 border-b-2 ${activeTab === tab
|
||||||
@@ -30,7 +25,7 @@ export default function ProjectDetailPage() {
|
|||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
{/* Tabs */}
|
{/* Tabs */}
|
||||||
<div className="flex mb-4">
|
<div className="flex mb-4 border-b border-card-outline">
|
||||||
<button className={tabClass('forum')} onClick={() => setActiveTab('forum')}>
|
<button className={tabClass('forum')} onClick={() => setActiveTab('forum')}>
|
||||||
Forum
|
Forum
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,7 +1,19 @@
|
|||||||
import ProjectCard from './components/ProjectsCard'
|
import ProjectCard from './components/ProjectsCard'
|
||||||
import { mockProjects } from '../../../lib/mockData'
|
import { useMyProjects } from '../../../hooks/useProjects';
|
||||||
|
|
||||||
export default function ProjectsPage() {
|
export default function ProjectsPage() {
|
||||||
|
const { projects, loading, error } = useMyProjects();
|
||||||
|
|
||||||
|
if (loading) return (
|
||||||
|
<div className="flex flex-col gap-3">
|
||||||
|
{[...Array(3)].map((_, i) => (
|
||||||
|
<div key={i} className="h-16 bg-gray-100 rounded-lg animate-pulse" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (error) return <p className="text-danger text-md">{error}</p>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="flex flex-col gap-1 mb-6">
|
<div className="flex flex-col gap-1 mb-6">
|
||||||
@@ -10,8 +22,8 @@ export default function ProjectsPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Grid card */}
|
{/* Grid card */}
|
||||||
<div className="grid grid-cols-1 gap-6 md:gap-4 md:grid-cols-3 lg:grid-cols-4">
|
<div className="grid grid-cols-1 gap-4 md:gap-3 md:grid-cols-3 lg:grid-cols-5">
|
||||||
{mockProjects.map(project => (
|
{projects.map(project => (
|
||||||
<ProjectCard key={project.id} {...project} />
|
<ProjectCard key={project.id} {...project} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,71 +2,68 @@ import { useParams, useSearchParams } from "react-router-dom";
|
|||||||
import { FileText, Info } from "lucide-react";
|
import { FileText, Info } from "lucide-react";
|
||||||
import TaskFormFile from "./components/TaskForm-file";
|
import TaskFormFile from "./components/TaskForm-file";
|
||||||
import TaskFormLink from "./components/TaskForm-link";
|
import TaskFormLink from "./components/TaskForm-link";
|
||||||
import { mockProjects } from "../../../lib/mockProjects";
|
import { useTaskDetail } from "../../../hooks/useTasks";
|
||||||
|
|
||||||
const toSlug = (name: string) => name.toLowerCase().replace(/\s+/g, '-');
|
|
||||||
|
|
||||||
export default function TaskSubmission() {
|
export default function TaskSubmission() {
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const { slug, TaskSlug } = useParams<{ slug: string; TaskSlug: string }>();
|
const { slug, taskSlug } = useParams<{ slug: string; taskSlug: string }>();
|
||||||
|
const submissionType = (searchParams.get("type") ?? "file") as "file_upload" | "url_link";
|
||||||
|
const { task, loading, error } = useTaskDetail(taskSlug!, slug);
|
||||||
|
|
||||||
const submissionType = (searchParams.get("type") ?? "file") as "file" | "link";
|
const formatDeadline = (dateStr: string) =>
|
||||||
|
new Date(dateStr).toLocaleDateString("id-ID", { day: "numeric", month: "long", year: "numeric" });
|
||||||
|
const formatTime = (dateStr: string) =>
|
||||||
|
new Date(dateStr).toLocaleTimeString("id-ID", { hour: "2-digit", minute: "2-digit" });
|
||||||
|
|
||||||
const project = mockProjects.find((p) => toSlug(p.name) === slug);
|
if (loading) return (
|
||||||
const task = project?.tasks.find((t) => toSlug(t.title) === TaskSlug);
|
<div className="space-y-4">
|
||||||
const handleFileSubmit = (files: File[]) => {
|
{[...Array(3)].map((_, i) => (
|
||||||
const fileNames = files.map(f => f.name).join(', ');
|
<div key={i} className="h-32 bg-box-secondary rounded-2xl animate-pulse" />
|
||||||
console.log(`Submitting Files for Project ${slug}:`, fileNames);
|
))}
|
||||||
alert(`File ${fileNames} berhasil dikirim!`);
|
</div>
|
||||||
};
|
);
|
||||||
|
if (error) return <p className="text-red-500 text-sm">{error}</p>;
|
||||||
const handleLinkSubmit = (link: string) => {
|
if (!task) return null;
|
||||||
console.log(`Submitting Link for Project ${slug}:`, link);
|
|
||||||
alert(`Link berhasil dikirim!`);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4 mt-7">
|
||||||
{/* Header Card */}
|
|
||||||
<div className="w-full bg-box-secondary rounded-2xl border border-box-border p-6">
|
<div className="w-full bg-box-secondary rounded-2xl border border-box-border p-6">
|
||||||
<div className="flex justify-between items-start">
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<h1 className="text-2xl font-bold text-gray-900 tracking-tight">
|
<h1 className="text-2xl font-bold text-gray-900 tracking-tight">{task.title}</h1>
|
||||||
{task?.title}
|
|
||||||
</h1>
|
|
||||||
<span className="text-sm font-bold text-gray-600">
|
<span className="text-sm font-bold text-gray-600">
|
||||||
Due {task?.deadline.label} at {task?.deadline.time}
|
Due {formatDeadline(task.deadline_at)} at {formatTime(task.deadline_at)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Task Description Card */}
|
|
||||||
<div className="w-full bg-box-secondary rounded-2xl border border-box-border p-6 space-y-3">
|
<div className="w-full bg-box-secondary rounded-2xl border border-box-border p-6 space-y-3">
|
||||||
<h2 className="text-xl text-gray-800 tracking-tight">Task Description</h2>
|
<h2 className="text-xl text-gray-800 tracking-tight">Task Description</h2>
|
||||||
<p className="text-sm text-foreground font-light leading-relaxed">
|
<p className="text-sm text-foreground font-light leading-relaxed">{task.description}</p>
|
||||||
{task?.description}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Submit Area Card */}
|
|
||||||
<div className="w-full bg-box-secondary rounded-2xl border border-box-border p-6 space-y-5">
|
<div className="w-full bg-box-secondary rounded-2xl border border-box-border p-6 space-y-5">
|
||||||
<div className="flex items-center gap-2 pb-2">
|
<div className="flex items-center gap-2 pb-2">
|
||||||
<FileText className="w-4 h-4 text-[#B30000] stroke-[2.5]" />
|
<FileText className="w-4 h-4 text-primary stroke-[2.5]" />
|
||||||
<h2 className="text-base font-bold text-secondary tracking-tight">Save Changes</h2>
|
<h2 className="text-font-shade font-bold text-secondary tracking-tight">Submit Task</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Render form sesuai tipe dari query param */}
|
{submissionType === "file_upload" ? (
|
||||||
{submissionType === "file" ? (
|
<TaskFormFile
|
||||||
<TaskFormFile onSubmitSuccess={handleFileSubmit} deadline={task?.deadline.date}/>
|
taskId={taskSlug!}
|
||||||
|
deadline={new Date(task.deadline_at)}
|
||||||
|
initialSubmission={task.my_submission}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<TaskFormLink onSubmitSuccess={handleLinkSubmit} deadline={task?.deadline.date}/>
|
<TaskFormLink
|
||||||
|
taskId={taskSlug!}
|
||||||
|
deadline={new Date(task.deadline_at)}
|
||||||
|
initialSubmission={task.my_submission}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Info Box */}
|
|
||||||
<div className="w-full border border-box-border rounded-lg p-3 flex items-start gap-2.5">
|
<div className="w-full border border-box-border rounded-lg p-3 flex items-start gap-2.5">
|
||||||
<Info className="w-4 h-4 text-gray-400 mt-0.5 flex-shrink-0" />
|
<Info className="w-4 h-4 text-font mt-0.5 flex-shrink-0" />
|
||||||
<p className="text-[11px] text-gray-400 font-medium leading-relaxed">
|
<p className="text-[11px] text-font font-medium leading-relaxed">
|
||||||
Once submitted, your work will be locked for mentor review. You can request a re-submission if needed.
|
Once submitted, your work will be locked for mentor review. You can request a re-submission if needed.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -34,19 +34,11 @@ export default function CertificateAvailable({ data }: { data: CertificateData }
|
|||||||
{[
|
{[
|
||||||
{ label: "Nama Program", value: certificate.programName },
|
{ label: "Nama Program", value: certificate.programName },
|
||||||
{ label: "Durasi", value: certificate.duration },
|
{ label: "Durasi", value: certificate.duration },
|
||||||
{
|
|
||||||
label: "Nilai Akhir",
|
|
||||||
value: (
|
|
||||||
<span className="text-red-600 font-bold">
|
|
||||||
{certificate.finalScore}/100 ({certificate.grade})
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: "Status",
|
label: "Status",
|
||||||
value: (
|
value: (
|
||||||
<span className="bg-green-100 text-green-700 text-xs font-bold px-2 py-0.5 rounded-full">
|
<span className="bg-green-100 text-green-700 text-xs font-bold px-2 py-0.5 rounded-full">
|
||||||
{certificate.status}
|
VERIFIED
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { ChevronLeft, ChevronRight } from 'lucide-react'
|
import { ChevronLeft, ChevronRight } from 'lucide-react'
|
||||||
import { DEADLINES } from '../../../../lib/mockDeadline'
|
import { useMyTasks } from '../../../../hooks/useProjects';
|
||||||
|
|
||||||
|
|
||||||
const DAY_LABELS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']
|
const DAY_LABELS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']
|
||||||
const MONTH_NAMES = [
|
const MONTH_NAMES = [
|
||||||
@@ -18,7 +17,13 @@ function getFirstDayOfMonth(year: number, month: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const HomeCalendar = () => {
|
const HomeCalendar = () => {
|
||||||
const [today, setToday] = useState(new Date())
|
const [today, setToday] = useState(new Date());
|
||||||
|
const { tasks } = useMyTasks();
|
||||||
|
|
||||||
|
const DEADLINES = tasks.map(task => ({
|
||||||
|
date: new Date(task.deadline_at),
|
||||||
|
label: task.title,
|
||||||
|
}));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
@@ -89,13 +94,13 @@ const HomeCalendar = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className=" px-13 py-5 border border-gray-200 rounded-2xl">
|
<div className=" px-13 py-5 border border-card-outline rounded-2xl">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="flex items-center justify-between mb-4">
|
<div className="flex items-center justify-between mb-4">
|
||||||
<h2 className="text-base font-semibold text-gray-800">
|
<h2 className="font-bold text-font">
|
||||||
{MONTH_NAMES[currentMonth]} {currentYear}
|
{MONTH_NAMES[currentMonth]} {currentYear}
|
||||||
</h2>
|
</h2>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center">
|
||||||
<button
|
<button
|
||||||
onClick={prevMonth}
|
onClick={prevMonth}
|
||||||
className="p-1 rounded hover:bg-gray-100 transition-colors"
|
className="p-1 rounded hover:bg-gray-100 transition-colors"
|
||||||
@@ -160,11 +165,11 @@ const HomeCalendar = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Divider */}
|
{/* Divider */}
|
||||||
<hr className="my-3 border-gray-100" />
|
<hr className="my-3 border-gray-400" />
|
||||||
|
|
||||||
{/* Upcoming Deadlines */}
|
{/* Upcoming Deadlines */}
|
||||||
<div>
|
<div>
|
||||||
<p className="text-[10px] font-semibold text-gray-400 uppercase tracking-widest mb-2">
|
<p className="text-[10px] font-semibold text-font uppercase tracking-widest mb-2">
|
||||||
Upcoming Deadlines
|
Upcoming Deadlines
|
||||||
</p>
|
</p>
|
||||||
{upcomingDeadlines.length > 0 ? (
|
{upcomingDeadlines.length > 0 ? (
|
||||||
@@ -172,12 +177,12 @@ const HomeCalendar = () => {
|
|||||||
{upcomingDeadlines.map((d, i) => (
|
{upcomingDeadlines.map((d, i) => (
|
||||||
<li key={i} className="flex items-center gap-2">
|
<li key={i} className="flex items-center gap-2">
|
||||||
<span className="w-2 h-2 rounded-full bg-red-600 flex-shrink-0" />
|
<span className="w-2 h-2 rounded-full bg-red-600 flex-shrink-0" />
|
||||||
<span className="text-xs text-gray-600">{d.label}</span>
|
<span className="text-xs text-font-shade">{d.label}</span>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
) : (
|
) : (
|
||||||
<p className="text-[11px] text-gray-400">No upcoming deadlines this month.</p>
|
<p className="text-[11px] text-font-shade">No upcoming deadlines this month.</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,12 +1,26 @@
|
|||||||
|
import { useState, useEffect } from "react";
|
||||||
|
import api from "../../../../lib/api";
|
||||||
|
|
||||||
const HomeHeader = () => {
|
const HomeHeader = () => {
|
||||||
const name = "Karina";
|
const [name, setName] = useState("");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
api.get("/auth-api/me")
|
||||||
|
.then((res) => {
|
||||||
|
setName(res.data.data.full_name || res.data.data.nama_depan);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error("Failed to fetch user:", err);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="flex items-start px-0 mb-5">
|
<div className="flex items-start px-0 mb-5">
|
||||||
<h1 className="page-title">Hi, {name}!</h1>
|
<h1 className="page-title">Hi, {name || "..."}!</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default HomeHeader
|
export default HomeHeader;
|
||||||
@@ -1,31 +1,42 @@
|
|||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { mockProjects } from '../../../../lib/mockProjects'
|
import { useProjects } from '../../../../hooks/useProjects';
|
||||||
|
|
||||||
const toSlug = (name: string) => name.toLowerCase().replace(/\s+/g, '-');
|
const toSlug = (name: string) => name.toLowerCase().replace(/\s+/g, '-');
|
||||||
|
|
||||||
const HomeProjectList = () => {
|
const HomeProjectList = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
return (
|
const { projects, loading, error } = useProjects();
|
||||||
<div>
|
|
||||||
<h2 className="text-lg font-semibold text-gray-800 mb-4">Projects</h2>
|
|
||||||
<div className="flex flex-col gap-3">
|
|
||||||
{mockProjects.map((project, index) => {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={index}
|
|
||||||
onClick={() => navigate(`/intern/projects/${toSlug(project.name)}`)}
|
|
||||||
className="flex items-center gap-4 border border-gray-200 rounded-lg px-4 py-3 hover:bg-gray-50 cursor-pointer transition-colors duration-150"
|
|
||||||
>
|
|
||||||
<div className={`w-10 h-10 rounded-lg flex items-center justify-center flex-shrink-0 bg-gray-300`}/>
|
|
||||||
<div>
|
|
||||||
<p className="text-sm font-semibold text-gray-800">{project.name}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default HomeProjectList
|
if (loading) return (
|
||||||
|
<div className="flex flex-col gap-3">
|
||||||
|
{[...Array(3)].map((_, i) => (
|
||||||
|
<div key={i} className="h-16 bg-gray-100 rounded-lg animate-pulse" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (error) return <p className="text-red-500 text-sm">{error}</p>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h2 className="text-lg font-semibold text-font-shade mb-8">Projects</h2>
|
||||||
|
<div className="flex flex-col gap-3">
|
||||||
|
{projects.map((project) => (
|
||||||
|
<div
|
||||||
|
key={project.id}
|
||||||
|
onClick={() => navigate(`/intern/projects/${toSlug(project.project_name)}`)}
|
||||||
|
className="flex items-center gap-4 border border-card-outline rounded-lg px-4 py-3 hover:bg-gray-50 cursor-pointer transition-colors duration-150"
|
||||||
|
>
|
||||||
|
<div className="w-10 h-10 rounded-lg flex items-center justify-center flex-shrink-0 bg-red-600" />
|
||||||
|
<div>
|
||||||
|
<p className="text-sm font-semibold text-font-shade">{project.project_name}</p>
|
||||||
|
<p className="text-xs text-gray-400">{project.status}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default HomeProjectList;
|
||||||
@@ -1,41 +1,43 @@
|
|||||||
import type { Task } from "../../../../lib/mockProjects";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
import { useNavigate } from "react-router-dom";
|
import type { ProjectTask } from "../../../../types/task.types";
|
||||||
|
|
||||||
const formatDate = (date: Date) =>
|
const formatDate = (dateStr: string) =>
|
||||||
new Date(date).toLocaleDateString('id-ID', { day: 'numeric', month: 'short', year: 'numeric' });
|
new Date(dateStr).toLocaleDateString('id-ID', { day: 'numeric', month: 'short', year: 'numeric' });
|
||||||
|
|
||||||
const toSlug = (name: string) => name.toLowerCase().replace(/\s+/g, '-');
|
const formatTime = (dateStr: string) =>
|
||||||
|
new Date(dateStr).toLocaleTimeString('id-ID', { hour: '2-digit', minute: '2-digit' });
|
||||||
|
|
||||||
export default function TaskCard({ task, projectName }: { task: Task; projectName: string }) {
|
export default function TaskCard({ task }: { task: ProjectTask }) {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const toTaskSlug = (title: string) => title.toLowerCase().replace(/\s+/g, '-');
|
const { slug } = useParams<{ slug: string }>();
|
||||||
return (
|
return (
|
||||||
<div className="border border-gray-200 rounded-[10px] px-6 py-4 mb-3 bg-white flex items-start justify-between gap-3">
|
<div
|
||||||
|
className="border border-card-outline rounded-xl px-6 py-4 mb-3 bg-white flex items-start justify-between gap-3"
|
||||||
|
onClick={() => navigate(`/intern/projects/${slug}/${task.slug}?type=${task.submission_type}`)}
|
||||||
|
>
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
<div className=" text-[11px] text-[#888] mb-1">
|
<div className=" text-[11px] text-font mb-1">
|
||||||
Deadline : {formatDate(task.deadline.date)} at {task.deadline.time}
|
Deadline : {formatDate(task.deadline_at)} at {formatTime(task.deadline_at)}
|
||||||
</div>
|
</div>
|
||||||
<div className=" font-bold text-[15px] text-[#1a1a1a] mb-1">
|
<div className=" font-bold text-[15px] text-[#1a1a1a] mb-1">
|
||||||
{task.title}
|
{task.title}
|
||||||
</div>
|
</div>
|
||||||
<div className=" text-[13px] text-[#666]">
|
<div className=" text-[13px] text-font">
|
||||||
{task.description}
|
{task.description}
|
||||||
</div>
|
</div>
|
||||||
<div className=" text-[13px] text-[#666]">
|
<div className=" text-[13px] text-font">
|
||||||
Tipe Submission : {task.type === 'file' ? "File" : "Link"}
|
Tipe Submission : {task.submission_type === 'file_upload' ? "File" : "Link"}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="shrink-0">
|
<div className="block md:hidden h-[10px] bg-gray-600"/>
|
||||||
{task.isSubmitted ? (
|
|
||||||
<span className=" inline-block bg-[#27AE60] text-white font-bold text-xs px-3.5 py-[5px] rounded-md tracking-[0.5px]">
|
<div className="shrink-0 hidden md:block">
|
||||||
DONE
|
<button
|
||||||
</span>
|
className="bg-white text-font-shade border-[1.5px] border-card-outline font-semibold text-xs px-3.5 py-[5px] rounded-md cursor-pointer whitespace-nowrap transition-colors duration-150"
|
||||||
) : (
|
>
|
||||||
<button className=" bg-white text-[#1a1a1a] border-[1.5px] border-[#d0d0d0] font-semibold text-xs px-3.5 py-[5px] rounded-md cursor-pointer whitespace-nowrap transition-colors duration-150 hover:border-[#C0392B] hover:text-[#C0392B]" onClick={() => navigate(`/intern/projects/${toSlug(projectName)}/${toTaskSlug(task.title)}?type=${task.type}`)}>
|
|
||||||
Add Submission
|
Add Submission
|
||||||
</button>
|
</button>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,42 +1,35 @@
|
|||||||
import type { Task } from "../../../../lib/mockProjects";
|
import type { ProjectTask } from "../../../../types/project.types";
|
||||||
import { ArrowDownNarrowWide } from "lucide-react";
|
|
||||||
|
|
||||||
const formatDate = (date: Date) =>
|
const formatDate = (dateStr: string) =>
|
||||||
new Date(date).toLocaleDateString('id-ID', { day: 'numeric', month: 'short', year: 'numeric' });
|
new Date(dateStr).toLocaleDateString('id-ID', { day: 'numeric', month: 'short' });
|
||||||
|
|
||||||
export default function ProjectTimeline({ tasks }: { tasks: Task[] }) {
|
export default function ProjectTimeline({ tasks }: { tasks: ProjectTask[] }) {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
today.setHours(0, 0, 0, 0);
|
today.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="">
|
||||||
<div className="flex items-center gap-1.5 mb-4 justify-between">
|
<div className="flex items-center gap-1.5 mb-4 justify-between">
|
||||||
<span className="font-semibold text-md text-[#1a1a1a]">
|
<span className="font-semibold text-md text-font-shade">Timeline</span>
|
||||||
Timeline
|
|
||||||
</span>
|
|
||||||
<ArrowDownNarrowWide className="w-5 h-5 text-gray-500"/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul className="relative pl-4">
|
<ul className="relative pl-4">
|
||||||
{tasks.map((task, idx) => {
|
{tasks.map((task) => {
|
||||||
const d = new Date(task.deadline.date);
|
const d = new Date(task.deadline_at);
|
||||||
d.setHours(0, 0, 0, 0);
|
d.setHours(0, 0, 0, 0);
|
||||||
const isToday = d.getTime() === today.getTime();
|
const isToday = d.getTime() === today.getTime();
|
||||||
const isPast = d < today;
|
const isPast = d < today;
|
||||||
const active = isToday || isPast;
|
const active = isToday || isPast;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li key={idx} className="relative mb-6 list-none">
|
<li key={task.id} className="relative mb-6 list-none">
|
||||||
{/* Dot */}
|
{/* Dot */}
|
||||||
<div
|
<div
|
||||||
className={`absolute -left-5 top-0.5 w-3 h-3 rounded-full border-2 border-white ${active ? 'bg-[#C0392B]' : 'bg-[#ccc]'
|
className={`absolute -left-5 top-0.5 w-3 h-3 rounded-full border-2 border-white ${
|
||||||
|
active ? 'bg-[#C0392B]' : 'bg-[#ccc]'
|
||||||
} ${isToday ? 'shadow-md' : ''}`}
|
} ${isToday ? 'shadow-md' : ''}`}
|
||||||
/>
|
/>
|
||||||
<div
|
<div className={`text-[11px] font-semibold ${isToday ? 'text-[#C0392B]' : 'text-[#888]'}`}>
|
||||||
className={`text-[11px] font-semibold ${isToday ? 'text-[#C0392B]' : 'text-[#888]'
|
{isToday ? 'Hari ini' : formatDate(task.deadline_at)} {/* ← format ISO string */}
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{isToday ? 'Hari ini' : formatDate(task.deadline.date)}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs text-[#555] mt-px leading-[1.3]">
|
<div className="text-xs text-[#555] mt-px leading-[1.3]">
|
||||||
{task.title}
|
{task.title}
|
||||||
|
|||||||
@@ -1,53 +1,54 @@
|
|||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import * as LucideIcons from 'lucide-react';
|
||||||
|
import type { LucideProps } from 'lucide-react';
|
||||||
|
import type { Project } from '../../../../types/project.types';
|
||||||
|
|
||||||
const toSlug = (name: string) => name.toLowerCase().replace(/\s+/g, '-');
|
const getDynamicIcon = (iconName: string) => {
|
||||||
|
const formatted = iconName.charAt(0).toUpperCase() + iconName.slice(1);
|
||||||
|
const Icon = (LucideIcons as unknown as Record<string, React.ComponentType<LucideProps>>)[formatted];
|
||||||
|
return Icon ?? LucideIcons.FolderOpen;
|
||||||
|
};
|
||||||
|
|
||||||
interface ProjectCardProps {
|
const ProjectCard = (project: Project) => {
|
||||||
id: number | string
|
const navigate = useNavigate();
|
||||||
name: string
|
const Icon = getDynamicIcon(project.project_icon);
|
||||||
mentor: string
|
|
||||||
avatarUrl?: string
|
|
||||||
thumbnailUrl?: string
|
|
||||||
progress: number
|
|
||||||
tasksDone: number
|
|
||||||
tasksTotal: number
|
|
||||||
}
|
|
||||||
|
|
||||||
const ProjectCard = ({
|
|
||||||
name,
|
const tasksDone = -1;
|
||||||
mentor,
|
const tasksTotal = project.total_tasks;
|
||||||
avatarUrl,
|
|
||||||
thumbnailUrl,
|
|
||||||
progress,
|
|
||||||
tasksDone,
|
|
||||||
tasksTotal,
|
|
||||||
}: ProjectCardProps) => {
|
|
||||||
const navigate = useNavigate()
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-white rounded-xl overflow-hidden shadow-sm border border-gray-100 w-full flex flex-col">
|
<div
|
||||||
|
onClick={() => navigate(`/intern/projects/${project.slug}`)}
|
||||||
|
className=" rounded-xl overflow-hidden shadow-sm border border-gray-100 w-full flex flex-col cursor-pointer hover:shadow-md transition-shadow duration-200"
|
||||||
|
>
|
||||||
{/* Thumbnail */}
|
{/* Thumbnail */}
|
||||||
<div className="h-[150px] bg-gradient-to-tr from-red-700 to-red-800 overflow-hidden">
|
<div className="h-[150px] bg-gradient-to-tr from-red-700 to-red-800 overflow-hidden flex items-center justify-center">
|
||||||
{thumbnailUrl && (
|
<Icon className="w-12 h-12 text-white opacity-80" />
|
||||||
<img src={thumbnailUrl} alt={name} className="w-full h-full object-cover" />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Content */}
|
{/* Content */}
|
||||||
<div className="min-h-[180px] max-h-[210px] flex-1 flex flex-col justify-between py-3">
|
<div className="min-h-[180px] max-h-[200px] flex-1 flex flex-col justify-between py-3">
|
||||||
<div className="px-3 flex flex-col gap-2">
|
<div className="px-3 flex flex-col gap-2">
|
||||||
<p className="text-xs lg:text-sm font-semibold text-gray-800 leading-tight">{name}</p>
|
{/* Project Name */}
|
||||||
|
<p className="text-xs lg:text-sm font-semibold text-gray-800 leading-tight">
|
||||||
|
{project.project_name}
|
||||||
|
</p>
|
||||||
|
|
||||||
{/* Mentor */}
|
{/* Mentor */}
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<div className="w-6 h-6 rounded-full bg-gray-200 overflow-hidden flex-shrink-0">
|
<div className="w-6 h-6 rounded-full bg-gray-200 overflow-hidden flex-shrink-0">
|
||||||
{avatarUrl ? (
|
{project.admin.profile_picture ? (
|
||||||
<img src={avatarUrl} alt={mentor} className="w-full h-full object-cover" />
|
<img
|
||||||
|
src={project.admin.profile_picture}
|
||||||
|
alt={project.admin.full_name}
|
||||||
|
className="w-full h-full object-cover"
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="w-full h-full bg-gray-300" />
|
<div className="w-full h-full bg-gray-300" />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<span className="text-xs text-gray-500 truncate">{mentor}</span>
|
<span className="text-xs text-gray-500 truncate">{project.admin.email}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Progress bar */}
|
{/* Progress bar */}
|
||||||
@@ -55,18 +56,18 @@ const ProjectCard = ({
|
|||||||
<div className="w-full h-1.5 bg-gray-200 rounded-full overflow-hidden">
|
<div className="w-full h-1.5 bg-gray-200 rounded-full overflow-hidden">
|
||||||
<div
|
<div
|
||||||
className="h-full bg-red-600 rounded-full transition-all duration-300"
|
className="h-full bg-red-600 rounded-full transition-all duration-300"
|
||||||
style={{ width: `${progress}%` }}
|
style={{ width: tasksTotal > 0 ? `${(tasksDone / tasksTotal) * 100}%` : '0%' }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span className="text-[10px] text-gray-400 text-right">
|
<span className="text-font text-[12px] font-bold text-right">
|
||||||
{tasksDone}/{tasksTotal}
|
{tasksDone}/{tasksTotal}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Button */}
|
{/* Button */}
|
||||||
<div className="flex items-end justify-end px-3 pb-1">
|
<div className="flex items-end justify-end px-3 pb-1">
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate(`/intern/projects/${toSlug(name)}`)}
|
|
||||||
className="bg-red-600 hover:bg-red-700 text-white text-xs font-medium py-1.5 px-3 rounded-xl transition-colors"
|
className="bg-red-600 hover:bg-red-700 text-white text-xs font-medium py-1.5 px-3 rounded-xl transition-colors"
|
||||||
>
|
>
|
||||||
View Project
|
View Project
|
||||||
@@ -74,7 +75,7 @@ const ProjectCard = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default ProjectCard
|
export default ProjectCard;
|
||||||
@@ -1,16 +1,18 @@
|
|||||||
import { useNavigate, useLocation } from 'react-router-dom';
|
import { useNavigate, useLocation } from 'react-router-dom';
|
||||||
import { Home, FolderKanban, Award, Settings, HelpCircle, LogOut, ChevronRight, X } from 'lucide-react';
|
import { Award, Settings, HelpCircle, X } from 'lucide-react';
|
||||||
|
import { GrHomeRounded } from "react-icons/gr";
|
||||||
|
import { MdOutlineAssignment, MdLogout } from "react-icons/md";
|
||||||
|
|
||||||
const navItems = [
|
const navItems = [
|
||||||
{ label: "Home", icon: Home, path: "/intern" },
|
{ label: "Home", icon: GrHomeRounded, path: "/intern" },
|
||||||
{ label: "List Projects", icon: FolderKanban, path: "/intern/projects" },
|
{ label: "List Projects", icon: MdOutlineAssignment, path: "/intern/projects" },
|
||||||
{ label: "Certificates", icon: Award, path: "/intern/certificates" },
|
{ label: "Certificates", icon: Award, path: "/intern/certificates" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const prefItems = [
|
const prefItems = [
|
||||||
{ label: "Settings", icon: Settings, path: "/intern/settings" },
|
{ label: "Settings", icon: Settings, path: "/intern/settings" },
|
||||||
{ label: "FAQ", icon: HelpCircle, path: "/intern/faq" },
|
{ label: "FAQ", icon: HelpCircle, path: "/intern/faq" },
|
||||||
{ label: "Logout", icon: LogOut, path: "/login-internify", danger: true },
|
{ label: "Logout", icon: MdLogout, path: "/login-internify", danger: true, isLogout: true },
|
||||||
];
|
];
|
||||||
|
|
||||||
interface SidebarProps {
|
interface SidebarProps {
|
||||||
@@ -24,7 +26,14 @@ export default function SidebarIntern({ isOpen, closeSidebar }: SidebarProps) {
|
|||||||
|
|
||||||
const handleNav = (path: string) => {
|
const handleNav = (path: string) => {
|
||||||
navigate(path);
|
navigate(path);
|
||||||
closeSidebar(); // Otomatis tutup sidebar setelah klik menu di HP
|
closeSidebar();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleLogout = () => {
|
||||||
|
document.cookie = "token=; path=/; max-age=86400; SameSite=Strict";
|
||||||
|
|
||||||
|
closeSidebar();
|
||||||
|
navigate("/login-internify", { replace: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -37,7 +46,7 @@ export default function SidebarIntern({ isOpen, closeSidebar }: SidebarProps) {
|
|||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
{/* Brand & Tombol Close untuk Mobile */}
|
{/* Brand & Tombol Close untuk Mobile */}
|
||||||
<div className="flex items-center justify-between px-2 pb-4">
|
<div className="flex items-center justify-between px-2 pb-10">
|
||||||
<div className="flex items-center gap-2.5">
|
<div className="flex items-center gap-2.5">
|
||||||
<div className="w-9 h-9 rounded-[10px] bg-red-600 flex items-center justify-center flex-shrink-0"></div>
|
<div className="w-9 h-9 rounded-[10px] bg-red-600 flex items-center justify-center flex-shrink-0"></div>
|
||||||
<div>
|
<div>
|
||||||
@@ -45,8 +54,6 @@ export default function SidebarIntern({ isOpen, closeSidebar }: SidebarProps) {
|
|||||||
<p className="text-[11px] text-gray-400">LMS Portal</p>
|
<p className="text-[11px] text-gray-400">LMS Portal</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Tombol Close silang (X): Hanya muncul di HP saat sidebar terbuka */}
|
|
||||||
<button
|
<button
|
||||||
onClick={closeSidebar}
|
onClick={closeSidebar}
|
||||||
className="p-1 text-gray-500 hover:bg-gray-100 rounded-lg lg:hidden"
|
className="p-1 text-gray-500 hover:bg-gray-100 rounded-lg lg:hidden"
|
||||||
@@ -55,8 +62,6 @@ export default function SidebarIntern({ isOpen, closeSidebar }: SidebarProps) {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="h-px bg-gray-300 my-1" />
|
|
||||||
|
|
||||||
{/* Main nav */}
|
{/* Main nav */}
|
||||||
<nav className="flex flex-col gap-0.5">
|
<nav className="flex flex-col gap-0.5">
|
||||||
{navItems.map(({ label, icon: Icon, path }) => {
|
{navItems.map(({ label, icon: Icon, path }) => {
|
||||||
@@ -67,13 +72,12 @@ export default function SidebarIntern({ isOpen, closeSidebar }: SidebarProps) {
|
|||||||
onClick={() => handleNav(path)}
|
onClick={() => handleNav(path)}
|
||||||
className={`flex items-center gap-2.5 w-full px-3 py-2 rounded-lg text-[13.5px] font-medium text-left transition-colors
|
className={`flex items-center gap-2.5 w-full px-3 py-2 rounded-lg text-[13.5px] font-medium text-left transition-colors
|
||||||
${isActive
|
${isActive
|
||||||
? "bg-red-50 text-red-600 font-semibold border-l-4 border-red-600"
|
? "bg-red-foreground text-red font-semibold border-l-4 border-base"
|
||||||
: "text-gray-500 hover:bg-red-50 hover:text-red-600"
|
: "text-font hover:bg-red-foreground"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<Icon className="w-[18px] h-[18px] flex-shrink-0" />
|
<Icon className="w-[18px] h-[18px] flex-shrink-0" />
|
||||||
<span>{label}</span>
|
<span>{label}</span>
|
||||||
{isActive && <ChevronRight className="w-3.5 h-3.5 ml-auto opacity-60" />}
|
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -86,18 +90,18 @@ export default function SidebarIntern({ isOpen, closeSidebar }: SidebarProps) {
|
|||||||
PREFERENCES
|
PREFERENCES
|
||||||
</p>
|
</p>
|
||||||
<nav className="flex flex-col gap-0.5">
|
<nav className="flex flex-col gap-0.5">
|
||||||
{prefItems.map(({ label, icon: Icon, path, danger }) => {
|
{prefItems.map(({ label, icon: Icon, path, danger, isLogout }) => {
|
||||||
const isActive = location.pathname === path;
|
const isActive = location.pathname === path;
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
key={path}
|
key={path}
|
||||||
onClick={() => handleNav(path)}
|
onClick={() => isLogout ? handleLogout() : handleNav(path)}
|
||||||
className={`flex items-center gap-2.5 w-full px-3 py-2 rounded-lg text-[13.5px] font-medium text-left transition-colors
|
className={`flex items-center gap-2.5 w-full px-3 py-2 rounded-lg text-[13.5px] font-medium text-left transition-colors
|
||||||
${isActive
|
${isActive
|
||||||
? "bg-red-50 text-red-600 font-semibold"
|
? "bg-red-50 text-red-600 font-semibold"
|
||||||
: danger
|
: danger
|
||||||
? "text-gray-400 hover:bg-red-50 hover:text-red-600"
|
? "text-font hover:bg-base-foreground"
|
||||||
: "text-gray-500 hover:bg-red-50 hover:text-red-600"
|
: "text-font hover:bg-red-foreground"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<Icon className="w-[18px] h-[18px] flex-shrink-0" />
|
<Icon className="w-[18px] h-[18px] flex-shrink-0" />
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { FileText, FileUp, Link } from "lucide-react";
|
|||||||
|
|
||||||
interface SubmitStatusTableProps {
|
interface SubmitStatusTableProps {
|
||||||
type: "file" | "link";
|
type: "file" | "link";
|
||||||
files?: File[];
|
filePath?: string | null; // ganti dari files: File[]
|
||||||
link?: string;
|
link?: string;
|
||||||
submittedAt?: Date;
|
submittedAt?: Date;
|
||||||
deadline?: Date;
|
deadline?: Date;
|
||||||
@@ -25,7 +25,7 @@ function getTimeEarly(submittedAt: Date, deadline: Date): string {
|
|||||||
|
|
||||||
export default function SubmitStatusTable({
|
export default function SubmitStatusTable({
|
||||||
type,
|
type,
|
||||||
files = [],
|
filePath,
|
||||||
link = "",
|
link = "",
|
||||||
submittedAt = new Date(),
|
submittedAt = new Date(),
|
||||||
deadline,
|
deadline,
|
||||||
@@ -120,19 +120,13 @@ export default function SubmitStatusTable({
|
|||||||
</div>
|
</div>
|
||||||
<div className="px-4 py-3 flex flex-col gap-2">
|
<div className="px-4 py-3 flex flex-col gap-2">
|
||||||
{type === "file" ? (
|
{type === "file" ? (
|
||||||
files.map((f, i) => (
|
<div className="flex items-center gap-2 text-sm text-gray-800">
|
||||||
<div key={i} className="flex items-center gap-2 text-sm text-gray-800">
|
|
||||||
<FileText className="w-4 h-4 text-red-700 stroke-[2.5]" />
|
<FileText className="w-4 h-4 text-red-700 stroke-[2.5]" />
|
||||||
{f.name}
|
{filePath ? filePath.split("/").pop() : "File submitted"}
|
||||||
</div>
|
</div>
|
||||||
))
|
|
||||||
) : (
|
) : (
|
||||||
<a
|
<a href={link} target="_blank" rel="noopener noreferrer"
|
||||||
href={link}
|
className="flex items-center gap-1.5 text-sm text-blue-600 hover:underline break-all">
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="flex items-center gap-1.5 text-sm text-blue-600 hover:underline break-all"
|
|
||||||
>
|
|
||||||
<Link className="w-3.5 h-3.5 shrink-0" />
|
<Link className="w-3.5 h-3.5 shrink-0" />
|
||||||
{link}
|
{link}
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -2,103 +2,78 @@ import { useState, useRef } from "react";
|
|||||||
import { FileText, UploadCloud, X } from "lucide-react";
|
import { FileText, UploadCloud, X } from "lucide-react";
|
||||||
import { LuSendHorizontal } from "react-icons/lu";
|
import { LuSendHorizontal } from "react-icons/lu";
|
||||||
import SubmitStatusTable from "./SubmissionStatusTable";
|
import SubmitStatusTable from "./SubmissionStatusTable";
|
||||||
|
import { useSubmission } from "../../../../hooks/useTasks";
|
||||||
|
import type { TaskSubmissionData } from "../../../../types/task.types";
|
||||||
|
|
||||||
interface TaskFormFileProps {
|
interface TaskFormFileProps {
|
||||||
onSubmitSuccess: (files: File[]) => void;
|
taskId: string;
|
||||||
deadline?: Date;
|
deadline?: Date;
|
||||||
|
initialSubmission?: TaskSubmissionData | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function TaskFormFile({ onSubmitSuccess, deadline }: TaskFormFileProps) {
|
export default function TaskFormFile({ taskId, deadline, initialSubmission }: TaskFormFileProps) {
|
||||||
|
const { submission, loading, submitFile, updateFile, remove } = useSubmission(taskId, initialSubmission);
|
||||||
const [files, setFiles] = useState<File[]>([]);
|
const [files, setFiles] = useState<File[]>([]);
|
||||||
const [isDragActive, setIsDragActive] = useState(false);
|
const [isDragActive, setIsDragActive] = useState(false);
|
||||||
const [isSubmitted, setIsSubmitted] = useState(false);
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
||||||
if (e.target.files && e.target.files.length > 0) {
|
|
||||||
validateAndAddFiles(Array.from(e.target.files));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDrag = (e: React.DragEvent) => {
|
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
if (e.type === "dragenter" || e.type === "dragover") {
|
|
||||||
setIsDragActive(true);
|
|
||||||
} else if (e.type === "dragleave") {
|
|
||||||
setIsDragActive(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDrop = (e: React.DragEvent) => {
|
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
setIsDragActive(false);
|
|
||||||
|
|
||||||
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
||||||
validateAndAddFiles(Array.from(e.dataTransfer.files));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const validateAndAddFiles = (selectedFiles: File[]) => {
|
const validateAndAddFiles = (selectedFiles: File[]) => {
|
||||||
const allowedExtensions = ["pdf", "docx", "zip"];
|
const allowedExtensions = ["pdf", "docx", "zip"];
|
||||||
const validFiles: File[] = [];
|
const validFiles: File[] = [];
|
||||||
|
|
||||||
selectedFiles.forEach((file) => {
|
selectedFiles.forEach((file) => {
|
||||||
const fileExtension = file.name.split(".").pop()?.toLowerCase();
|
const ext = file.name.split(".").pop()?.toLowerCase();
|
||||||
if (fileExtension && allowedExtensions.includes(fileExtension)) {
|
if (ext && allowedExtensions.includes(ext)) {
|
||||||
if (file.size <= 10 * 1024 * 1024) {
|
if (file.size <= 10 * 1024 * 1024) validFiles.push(file);
|
||||||
validFiles.push(file);
|
else alert(`Ukuran file ${file.name} melebihi 10MB.`);
|
||||||
} else {
|
} else {
|
||||||
alert(`Ukuran file ${file.name} melebihi batas maksimal 10MB.`);
|
alert(`Format ${file.name} tidak didukung. Gunakan PDF, DOCX, atau ZIP.`);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
alert(`Format file ${file.name} tidak didukung. Harap gunakan PDF, DOCX, atau ZIP.`);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (validFiles.length > 0) setFiles((prev) => [...prev, ...validFiles]);
|
||||||
if (validFiles.length > 0) {
|
|
||||||
setFiles((prev) => [...prev, ...validFiles]);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeFile = (indexToRemove: number, e: React.MouseEvent) => {
|
const handleDrag = (e: React.DragEvent) => {
|
||||||
|
e.preventDefault(); e.stopPropagation();
|
||||||
|
setIsDragActive(e.type === "dragenter" || e.type === "dragover");
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDrop = (e: React.DragEvent) => {
|
||||||
|
e.preventDefault(); e.stopPropagation();
|
||||||
|
setIsDragActive(false);
|
||||||
|
if (e.dataTransfer.files.length > 0) validateAndAddFiles(Array.from(e.dataTransfer.files));
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeFile = (index: number, e: React.MouseEvent) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setFiles((prev) => prev.filter((_, index) => index !== indexToRemove));
|
setFiles((prev) => prev.filter((_, i) => i !== index));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = (e: React.FormEvent) => {
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (files.length === 0) {
|
if (files.length === 0) { alert("Pilih file terlebih dahulu."); return; }
|
||||||
alert("Silakan pilih atau jatuhkan berkas tugas Anda terlebih dahulu.");
|
const res = isEditing
|
||||||
return;
|
? await updateFile(submission!.id, files[0])
|
||||||
}
|
: await submitFile(files[0]);
|
||||||
// Set to local submitted mode
|
if (res) { setIsEditing(false); setFiles([]); }
|
||||||
setIsSubmitted(true);
|
|
||||||
// Call parent handler
|
|
||||||
onSubmitSuccess(files);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEditSubmission = () => {
|
const handleDelete = async () => {
|
||||||
setIsSubmitted(false);
|
if (!confirm("Yakin ingin menghapus submission ini?")) return;
|
||||||
|
const ok = await remove(submission!.id);
|
||||||
|
if (ok) { setFiles([]); setIsEditing(false); }
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteSubmission = () => {
|
// Sudah ada submission dan tidak sedang edit → tampilkan status
|
||||||
if (confirm("Are you sure you want to delete this submission?")) {
|
if (submission && !isEditing) {
|
||||||
setFiles([]);
|
|
||||||
setIsSubmitted(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ganti if (isSubmitted) { return (...) }
|
|
||||||
if (isSubmitted) {
|
|
||||||
return (
|
return (
|
||||||
<SubmitStatusTable
|
<SubmitStatusTable
|
||||||
type="file"
|
type="file"
|
||||||
files={files}
|
filePath={submission.file_path}
|
||||||
submittedAt={new Date()}
|
submittedAt={new Date(submission.submitted_at)}
|
||||||
deadline={deadline} // opsional, kirim dari parent kalau ada
|
deadline={deadline}
|
||||||
onEdit={handleEditSubmission}
|
onEdit={() => setIsEditing(true)}
|
||||||
onDelete={handleDeleteSubmission}
|
onDelete={handleDelete}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -109,16 +84,13 @@ if (isSubmitted) {
|
|||||||
type="file"
|
type="file"
|
||||||
multiple
|
multiple
|
||||||
ref={fileInputRef}
|
ref={fileInputRef}
|
||||||
onChange={handleFileChange}
|
onChange={(e) => e.target.files && validateAndAddFiles(Array.from(e.target.files))}
|
||||||
accept=".pdf,.docx,.zip"
|
accept=".pdf,.docx,.zip"
|
||||||
className="hidden"
|
className="hidden"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
onDragEnter={handleDrag}
|
onDragEnter={handleDrag} onDragOver={handleDrag}
|
||||||
onDragOver={handleDrag}
|
onDragLeave={handleDrag} onDrop={handleDrop}
|
||||||
onDragLeave={handleDrag}
|
|
||||||
onDrop={handleDrop}
|
|
||||||
onClick={() => fileInputRef.current?.click()}
|
onClick={() => fileInputRef.current?.click()}
|
||||||
className={`w-full min-h-[120px] border border-dashed rounded-xl p-4 bg-box-secondary cursor-pointer transition-all ${isDragActive ? "border-[#B30000] bg-red-50/40" : "border-foreground hover:border-gray-500"
|
className={`w-full min-h-[120px] border border-dashed rounded-xl p-4 bg-box-secondary cursor-pointer transition-all ${isDragActive ? "border-[#B30000] bg-red-50/40" : "border-foreground hover:border-gray-500"
|
||||||
}`}
|
}`}
|
||||||
@@ -126,20 +98,12 @@ if (isSubmitted) {
|
|||||||
{files.length > 0 ? (
|
{files.length > 0 ? (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{files.map((file, index) => (
|
{files.map((file, index) => (
|
||||||
<div
|
<div key={index} className="flex items-center justify-between text-sm font-medium text-gray-800" onClick={(e) => e.stopPropagation()}>
|
||||||
key={index}
|
|
||||||
className="flex items-center justify-between text-sm font-medium text-gray-800"
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<FileText className="w-4 h-4 text-red-700 stroke-[2.5]" />
|
<FileText className="w-4 h-4 text-red-700 stroke-[2.5]" />
|
||||||
{file.name}
|
{file.name}
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button type="button" onClick={(e) => removeFile(index, e)} className="p-1 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-md transition-colors">
|
||||||
type="button"
|
|
||||||
onClick={(e) => removeFile(index, e)}
|
|
||||||
className="p-1 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-md transition-colors"
|
|
||||||
>
|
|
||||||
<X className="w-4 h-4" />
|
<X className="w-4 h-4" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -148,19 +112,16 @@ if (isSubmitted) {
|
|||||||
) : (
|
) : (
|
||||||
<div className="flex flex-col items-center justify-center h-full space-y-2 pointer-events-none text-center py-6">
|
<div className="flex flex-col items-center justify-center h-full space-y-2 pointer-events-none text-center py-6">
|
||||||
<UploadCloud className="w-8 h-8 text-gray-400 mx-auto stroke-[1.5]" />
|
<UploadCloud className="w-8 h-8 text-gray-400 mx-auto stroke-[1.5]" />
|
||||||
<p className="text-sm font-bold text-gray-700">
|
<p className="text-sm font-bold text-gray-700">Click to upload <span className="font-medium text-gray-500">or drag & drop</span></p>
|
||||||
Click to upload <span className="font-medium text-gray-500">or drag & drop</span>
|
|
||||||
</p>
|
|
||||||
<p className="text-[11px] text-gray-400 font-semibold">PDF, DOCX, or ZIP (Max. 10MB)</p>
|
<p className="text-[11px] text-gray-400 font-semibold">PDF, DOCX, or ZIP (Max. 10MB)</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit" disabled={loading}
|
||||||
className="w-full bg-[#B30000] hover:bg-[#990000] text-white font-bold text-base py-3 rounded-xl transition-colors shadow-md flex items-center justify-center gap-2 tracking-wide cursor-pointer"
|
className="w-full bg-[#B30000] hover:bg-[#990000] disabled:opacity-60 text-white font-bold py-3 rounded-xl transition-colors shadow-md flex items-center justify-center gap-2 tracking-wide cursor-pointer"
|
||||||
>
|
>
|
||||||
Save Changes
|
{loading ? "Mengirim..." : isEditing ? "Update Submission" : "Save Changes"}
|
||||||
<LuSendHorizontal className="w-4 h-4 stroke-[2.5]" />
|
<LuSendHorizontal className="w-4 h-4 stroke-[2.5]" />
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,47 +1,45 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Link, FileText } from "lucide-react";
|
import { Link } from "lucide-react";
|
||||||
import { LuSendHorizontal } from "react-icons/lu";
|
import { LuSendHorizontal } from "react-icons/lu";
|
||||||
import SubmitStatusTable from "./SubmissionStatusTable";
|
import SubmitStatusTable from "./SubmissionStatusTable";
|
||||||
|
import { useSubmission } from "../../../../hooks/useTasks";
|
||||||
|
import type { TaskSubmissionData } from "../../../../types/task.types";
|
||||||
|
|
||||||
interface TaskFormLinkProps {
|
interface TaskFormLinkProps {
|
||||||
onSubmitSuccess: (link: string) => void;
|
taskId: string;
|
||||||
deadline?: Date;
|
deadline?: Date;
|
||||||
|
initialSubmission?: TaskSubmissionData | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function TaskFormLink({ onSubmitSuccess, deadline }: TaskFormLinkProps) {
|
export default function TaskFormLink({ taskId, deadline, initialSubmission }: TaskFormLinkProps) {
|
||||||
const [submissionLink, setSubmissionLink] = useState("");
|
const { submission, loading, submitLink, updateLink, remove } = useSubmission(taskId, initialSubmission);
|
||||||
const [isSubmitted, setIsSubmitted] = useState(false);
|
const [inputLink, setInputLink] = useState(initialSubmission?.url_link ?? "");
|
||||||
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
|
|
||||||
const handleSubmit = (e: React.FormEvent) => {
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!submissionLink.trim()) {
|
if (!inputLink.trim()) return;
|
||||||
// alert("Silakan masukkan link tugas Anda terlebih dahulu.");
|
const res = isEditing
|
||||||
return;
|
? await updateLink(submission!.id, inputLink)
|
||||||
}
|
: await submitLink(inputLink);
|
||||||
setIsSubmitted(true); // ini hilang
|
if (res) { setIsEditing(false); }
|
||||||
onSubmitSuccess(submissionLink);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEditSubmission = () => {
|
const handleDelete = async () => {
|
||||||
setIsSubmitted(false);
|
if (!confirm("Yakin ingin menghapus submission ini?")) return;
|
||||||
|
const ok = await remove(submission!.id);
|
||||||
|
if (ok) setInputLink("");
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteSubmission = () => {
|
if (submission && !isEditing) {
|
||||||
if (confirm("Are you sure you want to delete this submission?")) {
|
|
||||||
setSubmissionLink("");
|
|
||||||
setIsSubmitted(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (isSubmitted) {
|
|
||||||
return (
|
return (
|
||||||
<SubmitStatusTable
|
<SubmitStatusTable
|
||||||
type="link"
|
type="link"
|
||||||
link={submissionLink}
|
link={submission.url_link ?? ""}
|
||||||
submittedAt={new Date()}
|
submittedAt={new Date(submission.submitted_at)}
|
||||||
deadline={deadline}
|
deadline={deadline}
|
||||||
onEdit={handleEditSubmission}
|
onEdit={() => setIsEditing(true)}
|
||||||
onDelete={handleDeleteSubmission}
|
onDelete={handleDelete}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -49,32 +47,30 @@ export default function TaskFormLink({ onSubmitSuccess, deadline }: TaskFormLink
|
|||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit} className="space-y-5">
|
<form onSubmit={handleSubmit} className="space-y-5">
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-1.5">
|
||||||
<label className="text-[11px] font-bold text-gray-700 tracking-wide block">
|
<label className="text-[11px] font-bold text-font-shade tracking-wide block">
|
||||||
Submission Link (PDF)
|
{isEditing ? "Update Submission Link" : "Submission Link"}
|
||||||
</label>
|
</label>
|
||||||
<div className="relative flex items-center">
|
<div className="relative flex items-center">
|
||||||
<span className="absolute left-3.5 text-gray-400">
|
<span className="absolute left-3.5 text-font/70">
|
||||||
<Link className="w-4 h-4 stroke-[2]" />
|
<Link className="w-4 h-4 stroke-[2]" />
|
||||||
</span>
|
</span>
|
||||||
<input
|
<input
|
||||||
type="url"
|
type="url" required
|
||||||
required
|
|
||||||
placeholder="https://example.com/your-pdf-link"
|
placeholder="https://example.com/your-pdf-link"
|
||||||
value={submissionLink}
|
value={inputLink}
|
||||||
onChange={(e) => setSubmissionLink(e.target.value)}
|
onChange={(e) => setInputLink(e.target.value)}
|
||||||
className="w-full pl-10 pr-4 py-2.5 bg-gray-50/50 border border-gray-200 rounded-lg text-sm placeholder-gray-400 text-gray-700 focus:outline-none focus:bg-white focus:border-red-600 focus:ring-1 focus:ring-red-600 font-medium"
|
className="w-full pl-10 pr-4 py-2.5 bg-box-primary/50 border border-box-border rounded-lg text-sm placeholder-font text-font focus:outline-none focus:bg-white focus:border-red-600 focus:ring-1 focus:ring-red-600 font-medium"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-[11px] text-gray-400 font-medium pt-0.5">
|
<p className="text-[11px] text-font font-medium pt-0.5">
|
||||||
Ensure the link is accessible to the mentor (e.g., Google Drive, Dropbox).
|
Ensure the link is accessible to the mentor (e.g., Google Drive, Dropbox).
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit" disabled={loading}
|
||||||
className="w-full bg-[#B30000] hover:bg-[#990000] text-white font-bold text-base py-3 rounded-xl transition-colors shadow-md flex items-center justify-center gap-2 tracking-wide cursor-pointer"
|
className="w-full bg-[#B30000] hover:bg-[#990000] disabled:opacity-60 text-white font-bold py-3 rounded-xl transition-colors shadow-md flex items-center justify-center gap-2 tracking-wide cursor-pointer"
|
||||||
>
|
>
|
||||||
Submit Task
|
{loading ? "Mengirim..." : isEditing ? "Update Submission" : "Submit Task"}
|
||||||
<LuSendHorizontal className="w-4 h-4 stroke-[2.5]" />
|
<LuSendHorizontal className="w-4 h-4 stroke-[2.5]" />
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,36 +1,50 @@
|
|||||||
import { DEADLINES } from "../../../../lib/mockDeadline";
|
import { useMyTasks } from "../../../../hooks/useProjects";
|
||||||
import type { Deadline } from "../../../../lib/mockDeadline";
|
import type { InternTaskItem } from "../../../../types/project.types";
|
||||||
|
|
||||||
const TaskTimeline = () => {
|
const TaskTimeline = () => {
|
||||||
|
const { tasks, loading, error } = useMyTasks();
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
|
|
||||||
const isOverdue = (date: Date) => {
|
const isOverdue = (dateStr: string) => new Date(dateStr) < today;
|
||||||
return date < today;
|
|
||||||
};
|
if (loading) return (
|
||||||
|
<div className="flex flex-col gap-5">
|
||||||
|
{[...Array(3)].map((_, i) => (
|
||||||
|
<div key={i} className="h-10 bg-gray-100 rounded animate-pulse" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (error) return <p className="text-red-500 text-sm">{error}</p>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-base font-semibold text-gray-800 mb-5">Task Timeline</h2>
|
<h2 className="font-semibold text-font-shade mb-5">Task Timeline</h2>
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<div className="absolute left-1 top-2 bottom-2 w-px bg-gray-200" />
|
<div className="absolute left-1 top-2 bottom-2 w-px bg-gray-300" />
|
||||||
<ul className="flex flex-col gap-5">
|
<ul className="flex flex-col gap-5">
|
||||||
{DEADLINES.map((item: Deadline, index: number) => {
|
{tasks.map((item: InternTaskItem) => {
|
||||||
const overdue = isOverdue(item.date);
|
const overdue = isOverdue(item.deadline_at);
|
||||||
|
const deadlineDate = new Date(item.deadline_at);
|
||||||
return (
|
return (
|
||||||
<li key={index} className="flex gap-4 pl-0">
|
<li key={item.id} className="flex gap-4 pl-0">
|
||||||
<div className="relative flex-shrink-0 mt-1">
|
<div className="relative flex-shrink-0 mt-1">
|
||||||
<span
|
<span
|
||||||
className={`block w-2 h-2 rounded-full z-10 relative ${
|
className={`block w-2 h-2 rounded-full z-10 relative ${
|
||||||
overdue ? "bg-red-700" : "bg-gray-400"
|
overdue ? "bg-primary" : "bg-gray-500"
|
||||||
}`}
|
}`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col gap-0.5 min-w-0">
|
<div className="flex flex-col gap-0.5 min-w-0">
|
||||||
<p className="text-[10px] font-semibold text-gray-400 uppercase tracking-widest">
|
<p className="text-[10px] font-semibold text-gray-400 uppercase tracking-widest">
|
||||||
{item.date.toLocaleDateString("id-ID")}
|
{deadlineDate.toLocaleDateString("id-ID")} AT{" "}
|
||||||
|
{deadlineDate.toLocaleTimeString("id-ID", {
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
})}
|
||||||
</p>
|
</p>
|
||||||
<p className="text-sm font-semibold text-gray-800">{item.label}</p>
|
<p className="text-sm font-semibold text-gray-800">{item.title}</p>
|
||||||
<p className="text-xs text-gray-500">{item.time}</p>
|
<p className="text-xs text-gray-500">{item.description}</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export const InternLayout = () => {
|
|||||||
<SidebarIntern isOpen={isSidebarOpen} closeSidebar={closeSidebar} />
|
<SidebarIntern isOpen={isSidebarOpen} closeSidebar={closeSidebar} />
|
||||||
{isSidebarOpen && (
|
{isSidebarOpen && (
|
||||||
<div
|
<div
|
||||||
className="fixed inset-0 bg-black/20 z-20 md:hidden min-h-screen"
|
className="fixed inset-0 bg-black/20 z-20 lg:hidden min-h-screen"
|
||||||
onClick={closeSidebar}
|
onClick={closeSidebar}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -47,7 +47,7 @@ export const MentorLayout = () => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<main className="container">
|
<main className="container">
|
||||||
<Breadcrumbs/>
|
{/* <Breadcrumbs/> */}
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const navItems = [
|
|||||||
const prefItems = [
|
const prefItems = [
|
||||||
{ label: "Settings", icon: Settings, path: "/mentor/settings" },
|
{ label: "Settings", icon: Settings, path: "/mentor/settings" },
|
||||||
{ label: "FAQ", icon: HelpCircle, path: "/mentor/faq" },
|
{ label: "FAQ", icon: HelpCircle, path: "/mentor/faq" },
|
||||||
{ label: "Logout", icon: LogOut, path: "/login-internify", danger: true },
|
{ label: "Logout", icon: LogOut, path: "/login-internify", danger: true, isLogout: true },
|
||||||
];
|
];
|
||||||
|
|
||||||
interface SidebarProps {
|
interface SidebarProps {
|
||||||
@@ -29,6 +29,13 @@ export default function SidebarMentor({ isOpen, closeSidebar }: SidebarProps) {
|
|||||||
closeSidebar();
|
closeSidebar();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleLogout = () => {
|
||||||
|
document.cookie = "token=; path=/; max-age=86400; SameSite=Strict";
|
||||||
|
|
||||||
|
closeSidebar();
|
||||||
|
navigate("/login-internify", { replace: true });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<aside
|
<aside
|
||||||
className={`
|
className={`
|
||||||
@@ -39,7 +46,7 @@ export default function SidebarMentor({ isOpen, closeSidebar }: SidebarProps) {
|
|||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
{/* Brand & Tombol Close untuk Mobile */}
|
{/* Brand & Tombol Close untuk Mobile */}
|
||||||
<div className="flex items-center justify-between px-2 pb-4">
|
<div className="flex items-center justify-between px-2 pb-10">
|
||||||
<div className="flex items-center gap-2.5">
|
<div className="flex items-center gap-2.5">
|
||||||
<div className="w-9 h-9 rounded-[10px] bg-red-600 flex items-center justify-center flex-shrink-0"></div>
|
<div className="w-9 h-9 rounded-[10px] bg-red-600 flex items-center justify-center flex-shrink-0"></div>
|
||||||
<div>
|
<div>
|
||||||
@@ -56,8 +63,6 @@ export default function SidebarMentor({ isOpen, closeSidebar }: SidebarProps) {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="h-px bg-gray-300 my-1" />
|
|
||||||
|
|
||||||
{/* Main nav */}
|
{/* Main nav */}
|
||||||
<nav className="flex flex-col gap-0.5">
|
<nav className="flex flex-col gap-0.5">
|
||||||
{navItems.map(({ label, icon: Icon, path }) => {
|
{navItems.map(({ label, icon: Icon, path }) => {
|
||||||
@@ -68,13 +73,12 @@ export default function SidebarMentor({ isOpen, closeSidebar }: SidebarProps) {
|
|||||||
onClick={() => handleNav(path)}
|
onClick={() => handleNav(path)}
|
||||||
className={`flex items-center gap-2.5 w-full px-3 py-2 rounded-lg text-[13.5px] font-medium text-left transition-colors
|
className={`flex items-center gap-2.5 w-full px-3 py-2 rounded-lg text-[13.5px] font-medium text-left transition-colors
|
||||||
${isActive
|
${isActive
|
||||||
? "bg-red-50 text-red-600 font-semibold border-l-4 border-red-600"
|
? "bg-base-foreground text-base font-semibold border-l-4 border-base"
|
||||||
: "text-gray-500 hover:bg-red-50 hover:text-red-600"
|
: "text-font hover:bg-base-foreground hover:text-base"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<Icon className="w-[18px] h-[18px] flex-shrink-0" />
|
<Icon className="w-[18px] h-[18px] flex-shrink-0" />
|
||||||
<span>{label}</span>
|
<span>{label}</span>
|
||||||
{isActive && <ChevronRight className="w-3.5 h-3.5 ml-auto opacity-60" />}
|
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -87,18 +91,18 @@ export default function SidebarMentor({ isOpen, closeSidebar }: SidebarProps) {
|
|||||||
PREFERENCES
|
PREFERENCES
|
||||||
</p>
|
</p>
|
||||||
<nav className="flex flex-col gap-0.5">
|
<nav className="flex flex-col gap-0.5">
|
||||||
{prefItems.map(({ label, icon: Icon, path, danger }) => {
|
{prefItems.map(({ label, icon: Icon, path, danger, isLogout }) => {
|
||||||
const isActive = location.pathname === path;
|
const isActive = location.pathname === path;
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
key={path}
|
key={path}
|
||||||
onClick={() => handleNav(path)}
|
onClick={() => isLogout ? handleLogout() : handleNav(path)}
|
||||||
className={`flex items-center gap-2.5 w-full px-3 py-2 rounded-lg text-[13.5px] font-medium text-left transition-colors
|
className={`flex items-center gap-2.5 w-full px-3 py-2 rounded-lg text-[13.5px] font-medium text-left transition-colors
|
||||||
${isActive
|
${isActive
|
||||||
? "bg-red-50 text-red-600 font-semibold"
|
? "bg-red-50 text-red-600 font-semibold"
|
||||||
: danger
|
: danger
|
||||||
? "text-gray-400 hover:bg-red-50 hover:text-red-600"
|
? "text-font hover:bg-base-foreground hover:text-base"
|
||||||
: "text-gray-500 hover:bg-red-50 hover:text-red-600"
|
: "text-font hover:bg-base-foreground hover:text-base"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<Icon className="w-[18px] h-[18px] flex-shrink-0" />
|
<Icon className="w-[18px] h-[18px] flex-shrink-0" />
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
import { Outlet, Navigate } from "react-router-dom";
|
import { Outlet, Navigate } from "react-router-dom";
|
||||||
|
|
||||||
interface PrivateRouteProps {
|
interface PrivateRouteProps {
|
||||||
allowedRoles?: ("admin" | "intern" | "mentor")[];
|
allowedRoles?: ("intern" | "admin")[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function untuk decode payload JWT tanpa library external
|
|
||||||
const decodeJWT = (token: string) => {
|
const decodeJWT = (token: string) => {
|
||||||
try {
|
try {
|
||||||
const base64Url = token.split(".")[1]; // Ambil bagian payload (segmen kedua)
|
const base64Url = token.split(".")[1];
|
||||||
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
||||||
const jsonPayload = decodeURIComponent(
|
const jsonPayload = decodeURIComponent(
|
||||||
window
|
window
|
||||||
@@ -23,31 +22,25 @@ const decodeJWT = (token: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ProtectedRoutes = ({ allowedRoles }: PrivateRouteProps) => {
|
const ProtectedRoutes = ({ allowedRoles }: PrivateRouteProps) => {
|
||||||
// 1. Ambil token dari cookie
|
|
||||||
const token = document.cookie
|
const token = document.cookie
|
||||||
.split("; ")
|
.split("; ")
|
||||||
.find((row) => row.startsWith("token="))
|
.find((row) => row.startsWith("token="))
|
||||||
?.split("=")[1];
|
?.split("=")[1];
|
||||||
|
|
||||||
// Jika tidak punya token, tendang ke login admin awal
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return <Navigate to="/login-admin" replace />;
|
return <Navigate to="/login-internify" replace />;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Decode token untuk mendapatkan role asli dari Backend
|
|
||||||
const decoded = decodeJWT(token);
|
const decoded = decodeJWT(token);
|
||||||
const userRole = decoded?.role as "admin" | "intern" | "mentor" | undefined;
|
const userRole = decoded?.role as"intern" | "admin" | undefined;
|
||||||
|
|
||||||
// Jika token corrupt atau tidak bisa di-decode, hanguskan dan tendang ke login
|
|
||||||
if (!userRole) {
|
if (!userRole) {
|
||||||
return <Navigate to="/login-admin" replace />;
|
return <Navigate to="/login-internify" replace />;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Periksa hak akses role terhadap halaman yang dituju
|
|
||||||
if (allowedRoles && !allowedRoles.includes(userRole)) {
|
if (allowedRoles && !allowedRoles.includes(userRole)) {
|
||||||
// Jika role tidak diizinkan, kembalikan ke base dashboard masing-masing role
|
// Jika role tidak diizinkan, kembalikan ke base dashboard masing-masing role
|
||||||
if (userRole === "admin") return <Navigate to="/dashboard" replace />;
|
if (userRole === "admin") return <Navigate to="/mentor" replace />;
|
||||||
if (userRole === "mentor") return <Navigate to="/mentor" replace />;
|
|
||||||
if (userRole === "intern") return <Navigate to="/intern" replace />;
|
if (userRole === "intern") return <Navigate to="/intern" replace />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,230 @@
|
|||||||
|
// hooks/useProject.ts
|
||||||
|
import { useState, useEffect, useCallback } from "react";
|
||||||
|
import type {
|
||||||
|
Project,
|
||||||
|
ProjectDetail,
|
||||||
|
InternTaskItem,
|
||||||
|
InternDetail,
|
||||||
|
CreateProjectPayload,
|
||||||
|
UpdateProjectPayload,
|
||||||
|
AssignMemberPayload,
|
||||||
|
ProjectMember
|
||||||
|
} from "../types/project.types";
|
||||||
|
import {
|
||||||
|
getProjects,
|
||||||
|
getProjectById,
|
||||||
|
getMyProjects,
|
||||||
|
getMyTasks,
|
||||||
|
getMentorProjects,
|
||||||
|
getAllInterns,
|
||||||
|
createProject,
|
||||||
|
updateProject,
|
||||||
|
archiveProject,
|
||||||
|
assignMember,
|
||||||
|
getProjectMembers
|
||||||
|
} from "../services/ProjectService";
|
||||||
|
|
||||||
|
// GET /project-api/get
|
||||||
|
export const useProjects = (status?: "active" | "completed" | "archived") => {
|
||||||
|
const [projects, setProjects] = useState<Project[]>([]);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const refetch = useCallback(() => {
|
||||||
|
setLoading(true);
|
||||||
|
getProjects(status)
|
||||||
|
.then(setProjects)
|
||||||
|
.catch(() => setError("Gagal memuat projects."))
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
}, [status]);
|
||||||
|
|
||||||
|
useEffect(() => { refetch(); }, [refetch]);
|
||||||
|
|
||||||
|
return { projects, loading, error, refetch };
|
||||||
|
};
|
||||||
|
|
||||||
|
// GET /project-api/get/{id}
|
||||||
|
export const useProjectDetail = (id: string) => {
|
||||||
|
const [project, setProject] = useState<ProjectDetail | null>(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const refetch = useCallback(() => {
|
||||||
|
if (!id) return;
|
||||||
|
setLoading(true);
|
||||||
|
getProjectById(id)
|
||||||
|
.then(setProject)
|
||||||
|
.catch(() => setError("Gagal memuat detail project."))
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
useEffect(() => { refetch(); }, [refetch]);
|
||||||
|
|
||||||
|
return { project, loading, error, refetch };
|
||||||
|
};
|
||||||
|
|
||||||
|
//Khusus Ambil Intern dari Project/{id}
|
||||||
|
export const useProjectInterns = (projectId: string) => {
|
||||||
|
const [interns, setInterns] = useState<ProjectMember[]>([]);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!projectId) return;
|
||||||
|
setLoading(true);
|
||||||
|
getProjectMembers(projectId)
|
||||||
|
.then(setInterns)
|
||||||
|
.catch(() => setError("Gagal memuat participants."))
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
}, [projectId]);
|
||||||
|
|
||||||
|
return { interns, loading, error };
|
||||||
|
};
|
||||||
|
|
||||||
|
// GET /project-api/my-projects
|
||||||
|
export const useMyProjects = () => {
|
||||||
|
const [projects, setProjects] = useState<ProjectDetail[]>([]);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getMyProjects()
|
||||||
|
.then(setProjects)
|
||||||
|
.catch(() => setError("Gagal memuat my projects."))
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return { projects, loading, error };
|
||||||
|
};
|
||||||
|
|
||||||
|
// GET /project-api/my-tasks
|
||||||
|
export const useMyTasks = () => {
|
||||||
|
const [tasks, setTasks] = useState<InternTaskItem[]>([]);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getMyTasks()
|
||||||
|
.then(setTasks)
|
||||||
|
.catch(() => setError("Gagal memuat tasks."))
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return { tasks, loading, error };
|
||||||
|
};
|
||||||
|
|
||||||
|
// GET /project-api/mentor-projects
|
||||||
|
export const useMentorProjects = () => {
|
||||||
|
const [projects, setProjects] = useState<Project[]>([]);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getMentorProjects()
|
||||||
|
.then(setProjects)
|
||||||
|
.catch(() => setError("Gagal memuat mentor projects."))
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return { projects, loading, error };
|
||||||
|
};
|
||||||
|
|
||||||
|
// GET /project-api/interns
|
||||||
|
export const useAllInterns = () => {
|
||||||
|
const [interns, setInterns] = useState<InternDetail[]>([]);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getAllInterns()
|
||||||
|
.then(setInterns)
|
||||||
|
.catch(() => setError("Gagal memuat data interns."))
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return { interns, loading, error };
|
||||||
|
};
|
||||||
|
|
||||||
|
// POST /project-api/add
|
||||||
|
export const useCreateProject = () => {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const create = async (payload: CreateProjectPayload) => {
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
return await createProject(payload);
|
||||||
|
} catch {
|
||||||
|
setError("Gagal membuat project.");
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return { create, loading, error };
|
||||||
|
};
|
||||||
|
|
||||||
|
// PATCH /project-api/update/{id}
|
||||||
|
export const useUpdateProject = () => {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const update = async (id: string | number, payload: UpdateProjectPayload) => {
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
return await updateProject(id, payload);
|
||||||
|
} catch {
|
||||||
|
setError("Gagal mengupdate project.");
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return { update, loading, error };
|
||||||
|
};
|
||||||
|
|
||||||
|
// DELETE /project-api/delete/{id}
|
||||||
|
export const useArchiveProject = () => {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const archive = async (id: string | number) => {
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
return await archiveProject(id);
|
||||||
|
} catch {
|
||||||
|
setError("Gagal mengarsipkan project.");
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return { archive, loading, error };
|
||||||
|
};
|
||||||
|
|
||||||
|
// POST /project-api/assign-member
|
||||||
|
export const useAssignMember = () => {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const assign = async (payload: AssignMemberPayload) => {
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
return await assignMember(payload);
|
||||||
|
} catch {
|
||||||
|
setError("Gagal assign member.");
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return { assign, loading, error };
|
||||||
|
};
|
||||||
@@ -0,0 +1,180 @@
|
|||||||
|
// hooks/useTasks.ts
|
||||||
|
import { useState, useEffect, useCallback } from "react";
|
||||||
|
import type { ProjectTask, ProjectTaskDetail, CreateTaskPayload, UpdateTaskPayload, TaskSubmissionData } from "../types/task.types";
|
||||||
|
import {
|
||||||
|
getProjectTasks,
|
||||||
|
getTaskById,
|
||||||
|
createTask,
|
||||||
|
updateTask,
|
||||||
|
deleteTask,
|
||||||
|
submitTaskFile,
|
||||||
|
submitTaskLink,
|
||||||
|
updateSubmissionFile,
|
||||||
|
updateSubmissionLink,
|
||||||
|
deleteSubmission,
|
||||||
|
} from "../services/TaskService";
|
||||||
|
|
||||||
|
// GET /task-api/projects/{id_project}/tasks
|
||||||
|
export const useProjectTasks = (projectId: string) => {
|
||||||
|
const [tasks, setTasks] = useState<ProjectTask[]>([]);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!projectId) return;
|
||||||
|
setLoading(true);
|
||||||
|
getProjectTasks(projectId)
|
||||||
|
.then(setTasks)
|
||||||
|
.catch(() => setError("Gagal memuat task."))
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
}, [projectId]);
|
||||||
|
|
||||||
|
return { tasks, loading, error };
|
||||||
|
};
|
||||||
|
|
||||||
|
// GET /task-api/tasks/{id}
|
||||||
|
export const useTaskDetail = (taskId: string, projectId?: string) => {
|
||||||
|
const [task, setTask] = useState<ProjectTaskDetail | null>(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const refetch = useCallback(() => {
|
||||||
|
if (!taskId) return;
|
||||||
|
setLoading(true);
|
||||||
|
getTaskById(taskId, projectId)
|
||||||
|
.then(setTask)
|
||||||
|
.catch(() => setError("Gagal memuat detail task."))
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
}, [taskId, projectId]);
|
||||||
|
|
||||||
|
useEffect(() => { refetch(); }, [refetch]);
|
||||||
|
|
||||||
|
return { task, loading, error, refetch };
|
||||||
|
};
|
||||||
|
|
||||||
|
// POST /task-api/projects/{id_project}/tasks
|
||||||
|
export const useCreateTask = (projectId: string) => {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const create = async (payload: CreateTaskPayload): Promise<ProjectTask | null> => {
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
return await createTask(projectId, payload);
|
||||||
|
} catch {
|
||||||
|
setError("Gagal membuat task.");
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return { create, loading, error };
|
||||||
|
};
|
||||||
|
|
||||||
|
// PATCH /task-api/tasks/{id}
|
||||||
|
export const useUpdateTask = () => {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const update = async (
|
||||||
|
taskId: string | number,
|
||||||
|
payload: UpdateTaskPayload,
|
||||||
|
projectId?: string
|
||||||
|
) => {
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
return await updateTask(taskId, payload, projectId);
|
||||||
|
} catch {
|
||||||
|
setError("Gagal mengupdate task.");
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return { update, loading, error };
|
||||||
|
};
|
||||||
|
|
||||||
|
// DELETE /task-api/tasks/{id}
|
||||||
|
export const useDeleteTask = () => {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const remove = async (taskId: string | number, projectId?: string) => {
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
await deleteTask(taskId, projectId);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
setError("Gagal menghapus task.");
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return { remove, loading, error };
|
||||||
|
};
|
||||||
|
|
||||||
|
// POST + PATCH + DELETE submission — digabung dalam satu hook per task
|
||||||
|
export const useSubmission = (taskId: string, initialSubmission?: TaskSubmissionData | null, projectId?: string) => {
|
||||||
|
const [submission, setSubmission] = useState<TaskSubmissionData | null>(initialSubmission ?? null);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const submitFile = async (file: File) => {
|
||||||
|
setLoading(true); setError(null);
|
||||||
|
try {
|
||||||
|
const res = await submitTaskFile(taskId, file, projectId);
|
||||||
|
if (res) setSubmission(res);
|
||||||
|
return res;
|
||||||
|
} catch { setError("Gagal submit file."); return null; }
|
||||||
|
finally { setLoading(false); }
|
||||||
|
};
|
||||||
|
|
||||||
|
const submitLink = async (url: string) => {
|
||||||
|
setLoading(true); setError(null);
|
||||||
|
try {
|
||||||
|
const res = await submitTaskLink(taskId, url, projectId);
|
||||||
|
if (res) setSubmission(res);
|
||||||
|
return res;
|
||||||
|
} catch { setError("Gagal submit link."); return null; }
|
||||||
|
finally { setLoading(false); }
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateFile = async (submissionId: number, file: File) => {
|
||||||
|
setLoading(true); setError(null);
|
||||||
|
try {
|
||||||
|
const res = await updateSubmissionFile(submissionId, file);
|
||||||
|
if (res) setSubmission(res);
|
||||||
|
return res;
|
||||||
|
} catch { setError("Gagal update submission."); return null; }
|
||||||
|
finally { setLoading(false); }
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateLink = async (submissionId: number, url: string) => {
|
||||||
|
setLoading(true); setError(null);
|
||||||
|
try {
|
||||||
|
const res = await updateSubmissionLink(submissionId, url);
|
||||||
|
if (res) setSubmission(res);
|
||||||
|
return res;
|
||||||
|
} catch { setError("Gagal update submission."); return null; }
|
||||||
|
finally { setLoading(false); }
|
||||||
|
};
|
||||||
|
|
||||||
|
const remove = async (submissionId: number) => {
|
||||||
|
setLoading(true); setError(null);
|
||||||
|
try {
|
||||||
|
await deleteSubmission(submissionId);
|
||||||
|
setSubmission(null);
|
||||||
|
return true;
|
||||||
|
} catch { setError("Gagal hapus submission."); return false; }
|
||||||
|
finally { setLoading(false); }
|
||||||
|
};
|
||||||
|
|
||||||
|
return { submission, submitFile, submitLink, updateFile, updateLink, remove, loading, error };
|
||||||
|
};
|
||||||
+21
-6
@@ -16,16 +16,23 @@
|
|||||||
/* Dasar Warna Gelap */
|
/* Dasar Warna Gelap */
|
||||||
--color-background: #fdfdfd;
|
--color-background: #fdfdfd;
|
||||||
--color-foreground: #1e282c;
|
--color-foreground: #1e282c;
|
||||||
|
--color-font: #6a7282;
|
||||||
|
--color-font-shade: #393b40;
|
||||||
|
|
||||||
--color-card: #f3f3f3;
|
--color-card: #f3f3f3;
|
||||||
|
--color-card-outline: #a9afbb;
|
||||||
--color-card-hover: #d5d5d5;
|
--color-card-hover: #d5d5d5;
|
||||||
|
|
||||||
--color-box-primary: #ebebeb;
|
--color-box-primary: #FFFFFF;
|
||||||
--color-box-secondary: #f3f4f6 ;
|
--color-box-secondary: #f3f4f6 ;
|
||||||
--color-box-border: #d8d9db;
|
--color-box-border: #a9afbb;
|
||||||
|
|
||||||
--color-primary: #ad2b19;
|
--color-primary: #ad2b19;
|
||||||
--color-primary-foreground: #ffffff;
|
--color-primary-foreground: #ffffff;
|
||||||
|
--color-primary-hover: #84281c;
|
||||||
|
|
||||||
|
--color-red: #e82222;
|
||||||
|
--color-red-foreground: #fef2f2;
|
||||||
|
|
||||||
--color-border: #a8a9aa;
|
--color-border: #a8a9aa;
|
||||||
|
|
||||||
@@ -36,14 +43,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
flex: 1;
|
min-width: 0;
|
||||||
min-width: 0; /* penting! mencegah overflow */
|
|
||||||
padding-inline: calc(var(--spacing) * 14);
|
padding-inline: calc(var(--spacing) * 14);
|
||||||
padding-block: calc(var(--spacing) * 12);
|
padding-block: calc(var(--spacing) * 12);
|
||||||
background-color: var(--color-background);
|
background-color: var(--color-background);
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 13px;
|
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,6 +127,12 @@ dialog.custom-dialog::backdrop {
|
|||||||
border-bottom: 2px solid #b3b8c0; /* border-gray-100 */
|
border-bottom: 2px solid #b3b8c0; /* border-gray-100 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1024px) {
|
||||||
|
.container {
|
||||||
|
padding-inline: calc(var(--spacing) * 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Breakpoint Medium (md:) - Aktif saat lebar layar >= 768px */
|
/* Breakpoint Medium (md:) - Aktif saat lebar layar >= 768px */
|
||||||
@media (min-width: 768px) {
|
@media (min-width: 768px) {
|
||||||
.dialog-header {
|
.dialog-header {
|
||||||
@@ -132,4 +142,9 @@ dialog.custom-dialog::backdrop {
|
|||||||
padding-top: 1.25rem; /* 20px */
|
padding-top: 1.25rem; /* 20px */
|
||||||
padding-bottom: 1.25rem;/* 20px */
|
padding-bottom: 1.25rem;/* 20px */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
padding-inline: calc(var(--spacing) * 14);
|
||||||
|
padding-block: calc(var(--spacing) * 10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,6 @@ const api = axios.create({
|
|||||||
baseURL: import.meta.env.VITE_API_BASE_URL,
|
baseURL: import.meta.env.VITE_API_BASE_URL,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Otomatis tempel Token Bearer di setiap request ke BE
|
|
||||||
api.interceptors.request.use((config) => {
|
api.interceptors.request.use((config) => {
|
||||||
const token = document.cookie
|
const token = document.cookie
|
||||||
.split("; ")
|
.split("; ")
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
// services/ProjectService.ts
|
||||||
|
import api from "../lib/api";
|
||||||
|
import type {
|
||||||
|
Project,
|
||||||
|
ProjectDetail,
|
||||||
|
InternTaskItem,
|
||||||
|
InternDetail,
|
||||||
|
CreateProjectPayload,
|
||||||
|
UpdateProjectPayload,
|
||||||
|
AssignMemberPayload,
|
||||||
|
MemberAssignment,
|
||||||
|
ProjectMember
|
||||||
|
} from "../types/project.types";
|
||||||
|
|
||||||
|
// POST /project-api/add
|
||||||
|
export const createProject = async (
|
||||||
|
payload: CreateProjectPayload
|
||||||
|
): Promise<ProjectDetail> => {
|
||||||
|
const res = await api.post("/project-api/add", payload);
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// GET /project-api/get
|
||||||
|
export const getProjects = async (
|
||||||
|
status?: "active" | "completed" | "archived"
|
||||||
|
): Promise<Project[]> => {
|
||||||
|
const res = await api.get("/project-api/get", {
|
||||||
|
params: status ? { status } : undefined,
|
||||||
|
});
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// GET /project-api/get/{id} → ambil members saja
|
||||||
|
export const getProjectMembers = async (
|
||||||
|
id: string | number
|
||||||
|
): Promise<ProjectMember[]> => {
|
||||||
|
const res = await api.get(`/project-api/get/${id}`);
|
||||||
|
return res.data.data.members;
|
||||||
|
};
|
||||||
|
|
||||||
|
// GET /project-api/get/{id}
|
||||||
|
export const getProjectById = async (
|
||||||
|
id: string | number
|
||||||
|
): Promise<ProjectDetail> => {
|
||||||
|
const res = await api.get(`/project-api/get/${id}`);
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// PATCH /project-api/update/{id}
|
||||||
|
export const updateProject = async (
|
||||||
|
id: string | number,
|
||||||
|
payload: UpdateProjectPayload
|
||||||
|
): Promise<ProjectDetail> => {
|
||||||
|
const res = await api.patch(`/project-api/update/${id}`, payload);
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// DELETE /project-api/delete/{id} — soft delete (archive)
|
||||||
|
export const archiveProject = async (
|
||||||
|
id: string | number
|
||||||
|
): Promise<ProjectDetail> => {
|
||||||
|
const res = await api.delete(`/project-api/delete/${id}`);
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// GET /project-api/my-projects (intern only)
|
||||||
|
export const getMyProjects = async (): Promise<ProjectDetail[]> => {
|
||||||
|
const res = await api.get("/project-api/my-projects");
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// GET /project-api/my-tasks (intern only)
|
||||||
|
export const getMyTasks = async (): Promise<InternTaskItem[]> => {
|
||||||
|
const res = await api.get("/project-api/my-tasks");
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// GET /project-api/mentor-projects (admin/mentor only)
|
||||||
|
export const getMentorProjects = async (): Promise<Project[]> => {
|
||||||
|
const res = await api.get("/project-api/mentor-projects");
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// GET /project-api/interns (admin/mentor only)
|
||||||
|
export const getAllInterns = async (): Promise<InternDetail[]> => {
|
||||||
|
const res = await api.get("/project-api/interns");
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// POST /project-api/assign-member (admin/mentor only)
|
||||||
|
export const assignMember = async (
|
||||||
|
payload: AssignMemberPayload
|
||||||
|
): Promise<MemberAssignment> => {
|
||||||
|
const res = await api.post("/project-api/assign-member", payload);
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
// services/TaskService.ts
|
||||||
|
import api from "../lib/api";
|
||||||
|
import type {
|
||||||
|
ProjectTask,
|
||||||
|
ProjectTaskDetail,
|
||||||
|
CreateTaskPayload,
|
||||||
|
UpdateTaskPayload,
|
||||||
|
TaskSubmissionData,
|
||||||
|
} from "../types/task.types";
|
||||||
|
|
||||||
|
// ── Task ──────────────────────────────────────────────
|
||||||
|
|
||||||
|
export const createTask = async (
|
||||||
|
projectId: string | number,
|
||||||
|
payload: CreateTaskPayload
|
||||||
|
): Promise<ProjectTask> => {
|
||||||
|
const res = await api.post(`/task-api/projects/${projectId}/tasks`, payload);
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getProjectTasks = async (
|
||||||
|
projectId: string | number
|
||||||
|
): Promise<ProjectTask[]> => {
|
||||||
|
const res = await api.get(`/task-api/projects/${projectId}/tasks`);
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getTaskById = async (
|
||||||
|
taskId: string | number,
|
||||||
|
projectId?: string | number
|
||||||
|
): Promise<ProjectTaskDetail> => {
|
||||||
|
const res = await api.get(`/task-api/tasks/${taskId}`, {
|
||||||
|
params: projectId ? { project: projectId } : undefined,
|
||||||
|
});
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updateTask = async (
|
||||||
|
taskId: string | number,
|
||||||
|
payload: UpdateTaskPayload,
|
||||||
|
projectId?: string | number
|
||||||
|
): Promise<ProjectTask> => {
|
||||||
|
const res = await api.patch(`/task-api/tasks/${taskId}`, payload, {
|
||||||
|
params: projectId ? { project: projectId } : undefined,
|
||||||
|
});
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deleteTask = async (
|
||||||
|
taskId: string | number,
|
||||||
|
projectId?: string | number
|
||||||
|
): Promise<void> => {
|
||||||
|
await api.delete(`/task-api/tasks/${taskId}`, {
|
||||||
|
params: projectId ? { project: projectId } : undefined,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// ── Submission ────────────────────────────────────────
|
||||||
|
|
||||||
|
export const submitTaskFile = async (
|
||||||
|
taskId: string | number,
|
||||||
|
file: File,
|
||||||
|
projectId?: string | number
|
||||||
|
): Promise<TaskSubmissionData> => {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("submission_file", file);
|
||||||
|
const res = await api.post(`/task-api/tasks/${taskId}/submissions`, formData, {
|
||||||
|
params: projectId ? { project: projectId } : undefined,
|
||||||
|
});
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const submitTaskLink = async (
|
||||||
|
taskId: string | number,
|
||||||
|
url_link: string,
|
||||||
|
projectId?: string | number
|
||||||
|
): Promise<TaskSubmissionData> => {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("url_link", url_link);
|
||||||
|
const res = await api.post(`/task-api/tasks/${taskId}/submissions`, formData, {
|
||||||
|
params: projectId ? { project: projectId } : undefined,
|
||||||
|
});
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updateSubmissionFile = async (
|
||||||
|
submissionId: number,
|
||||||
|
file: File
|
||||||
|
): Promise<TaskSubmissionData> => {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("submission_file", file);
|
||||||
|
const res = await api.patch(`/task-api/submissions/${submissionId}`, formData);
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updateSubmissionLink = async (
|
||||||
|
submissionId: number,
|
||||||
|
url_link: string
|
||||||
|
): Promise<TaskSubmissionData> => {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("url_link", url_link);
|
||||||
|
const res = await api.patch(`/task-api/submissions/${submissionId}`, formData);
|
||||||
|
return res.data.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deleteSubmission = async (submissionId: number): Promise<void> => {
|
||||||
|
await api.delete(`/task-api/submissions/${submissionId}`);
|
||||||
|
};
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
// types/project.types.ts
|
||||||
|
|
||||||
|
export type ProjectStatus = "active" | "completed" | "archived";
|
||||||
|
export type MemberStatus = "active" | "inactive";
|
||||||
|
|
||||||
|
export interface ProjectAdmin {
|
||||||
|
id: number;
|
||||||
|
full_name: string;
|
||||||
|
email: string;
|
||||||
|
profile_picture: string | null;
|
||||||
|
professional_bio: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProjectMember {
|
||||||
|
id: number;
|
||||||
|
id_user: number;
|
||||||
|
status?: MemberStatus;
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Response GET /project-api/get dan GET /project-api/get/{id}
|
||||||
|
export interface Project {
|
||||||
|
id: number;
|
||||||
|
slug: string;
|
||||||
|
project_icon: string;
|
||||||
|
project_name: string;
|
||||||
|
description: string;
|
||||||
|
start_date: string;
|
||||||
|
end_date: string;
|
||||||
|
status: ProjectStatus;
|
||||||
|
admin: ProjectAdmin;
|
||||||
|
total_members: number;
|
||||||
|
total_tasks: number;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail project (includes members array)
|
||||||
|
export interface ProjectDetail extends Project {
|
||||||
|
members: ProjectMember[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Response GET /project-api/my-tasks
|
||||||
|
export interface InternTaskItem {
|
||||||
|
id: number;
|
||||||
|
slug: string;
|
||||||
|
id_project: number;
|
||||||
|
project_slug: string;
|
||||||
|
project_name: string;
|
||||||
|
project_icon: string;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
deadline_at: string;
|
||||||
|
submission_type: "file_upload" | "url_link";
|
||||||
|
submission_status: "pending" | "submitted" | "done" | "overdue";
|
||||||
|
submission_details: {
|
||||||
|
id: number;
|
||||||
|
file_path: string | null;
|
||||||
|
url_link: string | null;
|
||||||
|
submitted_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
} | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Response GET /project-api/interns
|
||||||
|
export interface InternDetail {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
email: string;
|
||||||
|
projectName: string;
|
||||||
|
role: string;
|
||||||
|
isAssignedByMentor: boolean;
|
||||||
|
avatar: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Payload POST /project-api/add
|
||||||
|
export interface CreateProjectPayload {
|
||||||
|
project_icon: string;
|
||||||
|
project_name: string;
|
||||||
|
description: string;
|
||||||
|
start_date: string; // "YYYY-MM-DD"
|
||||||
|
end_date: string; // "YYYY-MM-DD"
|
||||||
|
member_emails?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Payload PATCH /project-api/update/{id}
|
||||||
|
export interface UpdateProjectPayload {
|
||||||
|
project_icon?: string;
|
||||||
|
project_name?: string;
|
||||||
|
description?: string;
|
||||||
|
start_date?: string;
|
||||||
|
end_date?: string;
|
||||||
|
status?: ProjectStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Payload POST /project-api/assign-member
|
||||||
|
export interface AssignMemberPayload {
|
||||||
|
id_project: number;
|
||||||
|
id_user: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Response assign-member
|
||||||
|
export interface MemberAssignment {
|
||||||
|
id: number;
|
||||||
|
id_project: number;
|
||||||
|
id_user: number;
|
||||||
|
status: MemberStatus;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProjectMember {
|
||||||
|
id: number;
|
||||||
|
full_name: string;
|
||||||
|
email: string;
|
||||||
|
professional_bio: string | null;
|
||||||
|
position: string;
|
||||||
|
kelompok_peminatan: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// types/task.types.ts
|
||||||
|
|
||||||
|
export type SubmissionType = "file_upload" | "url_link";
|
||||||
|
export type DisplayStatus = "pending" | "submitted" | "done" | "overdue";
|
||||||
|
|
||||||
|
export interface ProjectTask {
|
||||||
|
id: number;
|
||||||
|
id_project: number;
|
||||||
|
slug: string;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
deadline_at: string;
|
||||||
|
submission_type: SubmissionType;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TaskSubmissionData {
|
||||||
|
id: number;
|
||||||
|
id_task: number;
|
||||||
|
id_user: number;
|
||||||
|
file_path: string | null;
|
||||||
|
url_link: string | null;
|
||||||
|
submitted_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProjectTaskDetail extends ProjectTask {
|
||||||
|
project: {
|
||||||
|
id: number;
|
||||||
|
project_name: string;
|
||||||
|
project_icon: string;
|
||||||
|
};
|
||||||
|
display_status: DisplayStatus;
|
||||||
|
my_submission: TaskSubmissionData | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AdminTaskDetail extends ProjectTask {
|
||||||
|
project: {
|
||||||
|
id: number;
|
||||||
|
project_name: string;
|
||||||
|
project_icon: string;
|
||||||
|
};
|
||||||
|
submission_summary: {
|
||||||
|
total_members: number;
|
||||||
|
total_submitted: number;
|
||||||
|
total_done: number;
|
||||||
|
total_pending: number;
|
||||||
|
total_overdue: number;
|
||||||
|
};
|
||||||
|
submissions: Array<{
|
||||||
|
id_user: number;
|
||||||
|
full_name: string;
|
||||||
|
file_path: string | null;
|
||||||
|
url_link: string | null;
|
||||||
|
submitted_at: string | null;
|
||||||
|
updated_at: string | null;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateTaskPayload {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
deadline_date: string; // "YYYY-MM-DD"
|
||||||
|
specific_time: string; // "HH:mm"
|
||||||
|
submission_type: SubmissionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateTaskPayload extends Partial<CreateTaskPayload> {}
|
||||||
Reference in New Issue
Block a user