5689898f33
- Updated CertificateForm to improve loading state UI with skeletons. - Enhanced CertificateResult with better loading indicators and structure. - Refactored ProjectForumTab to include a skeleton loader and improved error handling. - Introduced ProjectTaskTab for managing project tasks with modals for creating and editing tasks. - Improved ProjectsPage with a skeleton loader during project data fetching. - Refined AddInternsToProjects, ArchiveProjectDialog, CompleteProjectDialog, CreateProjectDialog, CreateTaskDialog, and EditTaskDialog components to handle modal states more effectively. - Updated EligibleInternTable to enhance loading states and formatting of dates. - Modified StatusSubmissionTable to simplify status display. - Improved certificate generation utility functions for better date formatting and layout management. - Removed deprecated certificate assets and added a new template for certificates. - Updated types for certificates and projects to include start and end dates.
81 lines
3.4 KiB
TypeScript
81 lines
3.4 KiB
TypeScript
import { useParams, useSearchParams } from "react-router-dom";
|
|
import { FileText, Info } from "lucide-react";
|
|
import TaskFormFile from "./components/TaskForm-file";
|
|
import TaskFormLink from "./components/TaskForm-link";
|
|
import { useTaskDetail } from "../../../hooks/useTasks";
|
|
import { useProjectDetail } from "../../../hooks/useProjects";
|
|
|
|
export default function TaskSubmission() {
|
|
const [searchParams] = useSearchParams();
|
|
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 { project } = useProjectDetail(slug!);
|
|
|
|
const isProjectActive = project?.status === "active";
|
|
|
|
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" });
|
|
|
|
if (loading) return (
|
|
<div className="space-y-4">
|
|
{[...Array(3)].map((_, i) => (
|
|
<div key={i} className="h-32 bg-box-secondary rounded-2xl animate-pulse" />
|
|
))}
|
|
</div>
|
|
);
|
|
if (error) return <p className="text-red-500 text-sm">{error}</p>;
|
|
if (!task) return null;
|
|
|
|
return (
|
|
<div className="space-y-4 mt-7">
|
|
<div className="w-full bg-box-secondary rounded-2xl border border-box-border p-6">
|
|
<div className="space-y-2">
|
|
<h1 className="text-2xl font-bold text-gray-900 tracking-tight">{task.title}</h1>
|
|
<span className="text-sm font-bold text-gray-600">
|
|
Due {formatDeadline(task.deadline_at)} at {formatTime(task.deadline_at)}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<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 font-bold">Deskripsi</h2>
|
|
<p className="text-sm text-foreground font-light leading-relaxed">{task.description}</p>
|
|
</div>
|
|
|
|
<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">
|
|
<FileText className="w-4 h-4 text-primary stroke-[2.5]" />
|
|
<h2 className="text-font-shade font-bold text-secondary tracking-tight">Submit Task</h2>
|
|
</div>
|
|
|
|
{submissionType === "file_upload" ? (
|
|
<TaskFormFile
|
|
taskId={String(task.id)}
|
|
projectId={String(task.project.id)}
|
|
deadline={new Date(task.deadline_at)}
|
|
initialSubmission={task.my_submission}
|
|
isProjectActive={isProjectActive}
|
|
/>
|
|
) : (
|
|
<TaskFormLink
|
|
taskId={String(task.id)}
|
|
projectId={String(task.project.id)}
|
|
deadline={new Date(task.deadline_at)}
|
|
initialSubmission={task.my_submission}
|
|
isProjectActive={isProjectActive}
|
|
/>
|
|
)}
|
|
|
|
<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-font mt-0.5 flex-shrink-0" />
|
|
<p className="text-[11px] text-font-shade font-medium leading-relaxed">
|
|
Setelah disubmit, submission anda dapat dilihat oleh mentor. Pastikan submission yang anda masukan benar
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
} |