Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c56279c23 | |||
| aee5124a2d | |||
| 60061e5c34 | |||
| 753012732d | |||
| 5dbb21bf5a | |||
| 252671a2cc | |||
| de7e96370c | |||
| 3c00a7c366 | |||
| 41349e5303 | |||
| 09ddb21159 |
@@ -0,0 +1,19 @@
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
.git
|
||||
.gitignore
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
*.log
|
||||
logs
|
||||
*.local
|
||||
.vscode
|
||||
.idea
|
||||
.DS_Store
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
docker-compose*.yml
|
||||
README.md
|
||||
vercel.json
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
# ---------- deps: install once, cached until package.json changes ----------
|
||||
FROM node:22.12-alpine3.20 AS deps
|
||||
WORKDIR /app
|
||||
# package-lock.json* is optional: this repo gitignores it. Commit it to get
|
||||
# reproducible installs (npm install honours a lockfile when present).
|
||||
COPY package.json package-lock.json* ./
|
||||
RUN npm install --no-audit --no-fund
|
||||
|
||||
# ---------- build: tsc -b && vite build ----------
|
||||
FROM node:22.12-alpine3.20 AS build
|
||||
WORKDIR /app
|
||||
|
||||
# Vite inlines import.meta.env.VITE_* at build time, so these are build args,
|
||||
# NOT runtime env. Changing them requires a rebuild.
|
||||
ARG VITE_API_BASE_URL
|
||||
ARG VITE_RECAPTCHA_SITE_KEY
|
||||
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL} \
|
||||
VITE_RECAPTCHA_SITE_KEY=${VITE_RECAPTCHA_SITE_KEY} \
|
||||
NODE_ENV=production
|
||||
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
RUN test -n "$VITE_API_BASE_URL" || (echo "VITE_API_BASE_URL build arg is required" >&2; exit 1) \
|
||||
&& npm run build
|
||||
|
||||
# ---------- runtime: static files only, no node, non-root ----------
|
||||
FROM nginxinc/nginx-unprivileged:1.29-alpine AS runtime
|
||||
|
||||
# Config baked into the image; no bind mounts.
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=build --chown=nginx:nginx /app/dist /usr/share/nginx/html
|
||||
|
||||
# Image already runs as uid 101 (nginx); stated explicitly.
|
||||
USER nginx
|
||||
EXPOSE 8080
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD wget -qO- http://127.0.0.1:8080/healthz || exit 1
|
||||
@@ -0,0 +1,39 @@
|
||||
services:
|
||||
web:
|
||||
build:
|
||||
context: .
|
||||
target: runtime
|
||||
args:
|
||||
# Build-time only: Vite bakes these into the bundle.
|
||||
VITE_API_BASE_URL: ${VITE_API_BASE_URL}
|
||||
VITE_RECAPTCHA_SITE_KEY: ${VITE_RECAPTCHA_SITE_KEY}
|
||||
restart: unless-stopped
|
||||
# Coolify's proxy reaches this over the internal network; no host ports.
|
||||
expose:
|
||||
- "8080"
|
||||
environment:
|
||||
# Consumed by Coolify to route the domain at the right container port.
|
||||
SERVICE_URL_WEB: ${SERVICE_URL_WEB:-}
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
read_only: true
|
||||
tmpfs:
|
||||
- /tmp
|
||||
- /var/cache/nginx
|
||||
cap_drop:
|
||||
- ALL
|
||||
cap_add:
|
||||
- CHOWN
|
||||
- SETGID
|
||||
- SETUID
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8080/healthz"]
|
||||
interval: 30s
|
||||
timeout: 3s
|
||||
start_period: 5s
|
||||
retries: 3
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# Coolify/Traefik terminates TLS upstream; trust its forwarded scheme only.
|
||||
absolute_redirect off;
|
||||
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied any;
|
||||
gzip_types text/plain text/css application/javascript application/json
|
||||
image/svg+xml font/woff2 application/wasm;
|
||||
|
||||
location = /healthz {
|
||||
access_log off;
|
||||
add_header Content-Type text/plain;
|
||||
return 200 "ok\n";
|
||||
}
|
||||
|
||||
# Vite emits content-hashed filenames here -> cache hard.
|
||||
location /assets/ {
|
||||
try_files $uri =404;
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
}
|
||||
|
||||
location /fonts/ {
|
||||
try_files $uri =404;
|
||||
add_header Cache-Control "public, max-age=2592000";
|
||||
}
|
||||
|
||||
# Never cache the shell: it points at the hashed bundles.
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-store";
|
||||
}
|
||||
|
||||
# SPA fallback, mirrors vercel.json rewrites.
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
+22
-22
@@ -30,33 +30,33 @@ import Dashboard from "./Pages/Dashboard";
|
||||
import EditFaq from "./Pages/EditFAQ";
|
||||
import EditFeedback from "./Pages/EditFeedback";
|
||||
import EditLowongan from "./Pages/EditLowongan";
|
||||
import HomeInternPage from "./Pages/Internify/intern/HomeInternPage";
|
||||
import { InternLayout, MentorLayout } from "./Pages/Internify/layout";
|
||||
import ProjectsPage from "./Pages/Internify/intern/ProjectsPage";
|
||||
import ProjectDetailPage from "./Pages/Internify/intern/ProjectDetailPage";
|
||||
import HomeMentorPage from "./Pages/Internify/mentor/HomeMentorPage";
|
||||
import MentorProjectsPage from "./Pages/Internify/mentor/BaseProjectsPage";
|
||||
import MentorCertificatePage from "./Pages/Internify/mentor/CertificateListPage";
|
||||
import MentorInternPage from "./Pages/Internify/mentor/InternsPage";
|
||||
import MentorDetailProject from "./Pages/Internify/mentor/ProjectsPage";
|
||||
import InternifyLogin from "./Pages/Internify/LoginInternify"
|
||||
import FAQPage from "./Pages/Internify/FAQpage";
|
||||
import NotificationList from "./Pages/Internify/NotificationList";
|
||||
import SettingsPage from "./Pages/Internify/SettingsPage";
|
||||
import TaskSubmission from "./Pages/Internify/intern/TaskSubmission";
|
||||
import SertificateList from "./Pages/Internify/intern/InternCertList";
|
||||
import MentorProjectsDetailPage from "./Pages/Internify/mentor/MentorProjectDetailPage";
|
||||
import ViewInternSubmission from "./Pages/Internify/mentor/ViewInternSubmission";
|
||||
import HomeInternPage from "./Pages/internify/intern/HomeInternPage";
|
||||
import { InternLayout, MentorLayout } from "./Pages/internify/layout";
|
||||
import ProjectsPage from "./Pages/internify/intern/ProjectsPage";
|
||||
import ProjectDetailPage from "./Pages/internify/intern/ProjectDetailPage";
|
||||
import HomeMentorPage from "./Pages/internify/mentor/HomeMentorPage";
|
||||
import MentorProjectsPage from "./Pages/internify/mentor/BaseProjectsPage";
|
||||
import MentorCertificatePage from "./Pages/internify/mentor/CertificateListPage";
|
||||
import MentorInternPage from "./Pages/internify/mentor/InternsPage";
|
||||
import MentorDetailProject from "./Pages/internify/mentor/ProjectsPage";
|
||||
import InternifyLogin from "./Pages/internify/LoginInternify"
|
||||
import FAQPage from "./Pages/internify/FAQpage";
|
||||
import NotificationList from "./Pages/internify/NotificationList";
|
||||
import SettingsPage from "./Pages/internify/SettingsPage";
|
||||
import TaskSubmission from "./Pages/internify/intern/TaskSubmission";
|
||||
import SertificateList from "./Pages/internify/intern/InternCertList";
|
||||
import MentorProjectsDetailPage from "./Pages/internify/mentor/MentorProjectDetailPage";
|
||||
import ViewInternSubmission from "./Pages/internify/mentor/ViewInternSubmission";
|
||||
import ProtectedRoutes from "./Pages/utils/ProtectedRoute";
|
||||
import AdminMentorPage from "./Pages/MentorPage";
|
||||
import CreateMentorForm from "./Pages/CreateMentorForm";
|
||||
import EditMentorForm from "./Pages/EditMentorForm";
|
||||
import NotFoundPage from "./Pages/NotFoundPage";
|
||||
import VerificationCert from "./Pages/Internify/VerificationCert";
|
||||
import VerificationCert from "./Pages/internify/VerificationCert";
|
||||
|
||||
const InternCertificatePage = lazy(() => import("./Pages/Internify/intern/InternCertDetail"));
|
||||
const MentorCertForm = lazy(() => import("./Pages/Internify/mentor/CertificateForm"));
|
||||
const MentorCertResult = lazy(() => import("./Pages/Internify/mentor/CertificateResult"));
|
||||
const InternCertificatePage = lazy(() => import("./Pages/internify/intern/InternCertDetail"));
|
||||
const MentorCertForm = lazy(() => import("./Pages/internify/mentor/CertificateForm"));
|
||||
const MentorCertResult = lazy(() => import("./Pages/internify/mentor/CertificateResult"));
|
||||
|
||||
function App() {
|
||||
return (
|
||||
@@ -109,7 +109,7 @@ function App() {
|
||||
|
||||
{/* Intern only */}
|
||||
<Route element={<ProtectedRoutes allowedRoles={["intern"]} />}>
|
||||
<Route path="/intern" element={<InternLayout />}>
|
||||
<Route path="/internship" element={<InternLayout />}>
|
||||
<Route index element={<HomeInternPage />} />
|
||||
<Route path="projects" element={<ProjectsPage />} />
|
||||
<Route path="certificates" element={<SertificateList />} />
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
import { FaInstagram, FaLinkedin, FaRegEnvelope } from "react-icons/fa";
|
||||
import logoHumic from "../assets/logo.png";
|
||||
|
||||
const internshipLinks = [
|
||||
{ label: "Beranda", path: "/" },
|
||||
{ label: "Tentang", path: "/about-us" },
|
||||
{ label: "Life At Humic", path: "" },
|
||||
{ label: "Life At Humic", path: "/internships" },
|
||||
{ label: "Our Developer", path: "/our-developer" }
|
||||
];
|
||||
|
||||
const externalLinks = [
|
||||
{ label: "Humic Website", href: "https://humic.telkomuniversity.ac.id/" },
|
||||
{ label: "Our Activity", href: "https://humic.telkomuniversity.ac.id/humicinmedia/" },
|
||||
{ label: "Life At Humic", href: "" },
|
||||
// { label: "Our Developer", href: "#" },
|
||||
{ label: "Life At Humic", href: "https://humic.telkomuniversity.ac.id/" },
|
||||
];
|
||||
|
||||
const socials = [
|
||||
{ label: "Instagram", icon: FaInstagram, href: "https://www.instagram.com/humicengineering/" },
|
||||
{ label: "LinkedIn", icon: FaLinkedin, href: "https://www.linkedin.com/company/humic-engineering/" },
|
||||
{ label: "Email", icon: FaRegEnvelope, href: "" },
|
||||
{ label: "Email", icon: FaRegEnvelope, href: "mailto:humic@telkomuniversity.ac.id" },
|
||||
];
|
||||
|
||||
export function FooterIntern() {
|
||||
@@ -45,7 +43,7 @@ export function FooterIntern() {
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
aria-label={label}
|
||||
className="w-10 h-10 border rounded-full bg-gray-100 flex items-center justify-center text-gray-600 hover:bg-red-50 hover:text-red-600 transition-colors"
|
||||
className="w-10 h-10 border rounded-full bg-gray-100 flex items-center justify-center text-gray-600 hover:bg-red-50 hover:text-red-800 transition-colors"
|
||||
>
|
||||
<Icon className="w-4 h-4" />
|
||||
</a>
|
||||
@@ -60,12 +58,14 @@ export function FooterIntern() {
|
||||
<ul className="flex flex-col gap-0.5 font-semibold">
|
||||
{internshipLinks.map(({ label, path }) => (
|
||||
<li key={label}>
|
||||
<Link
|
||||
to={path}
|
||||
<a
|
||||
href={path}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-[12.5px] text-gray-600 hover:text-red-800 transition-colors"
|
||||
>
|
||||
{label}
|
||||
</Link>
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
@@ -10,7 +10,7 @@ export default function Header({ toggleSidebar }: { toggleSidebar: () => void })
|
||||
const nav = useNavigate();
|
||||
const { user } = useCurrentUser();
|
||||
const [imageError, setImageError] = useState(false);
|
||||
const { unreadCount } = useNotifications();
|
||||
const { hasUnreadNotifications } = useNotifications();
|
||||
const photoUrl = resolveFileUrl(user?.profile_picture);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -42,7 +42,7 @@ export default function Header({ toggleSidebar }: { toggleSidebar: () => void })
|
||||
<div className="flex flex-row gap-6 items-center">
|
||||
<button onClick={() => nav("notifications")} className="relative">
|
||||
<Bell className="w-5 h-5 hover:text-red-800"/>
|
||||
{unreadCount > 0 && (
|
||||
{hasUnreadNotifications && (
|
||||
<span className="absolute -top-1 -right-0.5 w-2.5 h-2.5 bg-red-600 rounded-full border-2 border-white" />
|
||||
)}
|
||||
</button>
|
||||
|
||||
@@ -59,19 +59,19 @@ const Navbar = () => {
|
||||
<div className="hidden md:flex items-center gap-8 text-[18px] font-semibold">
|
||||
<button
|
||||
onClick={() => navigate("/about-us")}
|
||||
className="hover:text-gray-600 transition cursor-pointer"
|
||||
className="hover:text-blue-600 transition cursor-pointer"
|
||||
>
|
||||
About Us
|
||||
</button>
|
||||
<button
|
||||
onClick={handleContactClick}
|
||||
className="hover:text-gray-600 transition cursor-pointer"
|
||||
className="hover:text-blue-600 transition cursor-pointer"
|
||||
>
|
||||
Contact Us
|
||||
</button>
|
||||
<button
|
||||
onClick={() => navigate("/internships")}
|
||||
className="hover:text-gray-600 transition cursor-pointer"
|
||||
className="hover:text-grblueay-600 transition cursor-pointer"
|
||||
>
|
||||
Internship
|
||||
</button>
|
||||
@@ -80,7 +80,7 @@ const Navbar = () => {
|
||||
onClick={() => {
|
||||
navigate("/login-internify");
|
||||
}}
|
||||
className="hover:text-red-600 transition cursor-pointer"
|
||||
className="hover:text-blue-600 transition cursor-pointer"
|
||||
>
|
||||
Portal LMS
|
||||
</button>
|
||||
|
||||
@@ -58,12 +58,6 @@ const Landing = () => {
|
||||
return feedbacks[displayIndex];
|
||||
}, [feedbacks, displayIndex]);
|
||||
|
||||
// Gambar statis: selalu pakai foto dari feedback pertama
|
||||
const staticImgUrl = useMemo(() => {
|
||||
if (feedbacks.length === 0) return "";
|
||||
return getFeedbackImageUrl(feedbacks[0].image_path);
|
||||
}, [feedbacks]);
|
||||
|
||||
useEffect(() => {
|
||||
// Fetch internships
|
||||
fetch(`${import.meta.env.VITE_API_BASE_URL}/lowongan-magang-api/get`)
|
||||
|
||||
@@ -74,7 +74,7 @@ const OurDeveloper = () => {
|
||||
link: "https://www.linkedin.com/in/reihanramadhana/",
|
||||
},
|
||||
{
|
||||
name: "Ayu",
|
||||
name: "Nomi",
|
||||
role: "Web Designer",
|
||||
img: ayu,
|
||||
link: "https://www.linkedin.com/in/anom-ayu-radhaswasti/",
|
||||
|
||||
@@ -42,15 +42,15 @@ const NameInternBreadcrumb = ({ match }: BreadcrumbMatch) => {
|
||||
|
||||
const breadcrumbRoutes = [
|
||||
// --- AREA INTERN ---
|
||||
{ path: '/intern', breadcrumb: 'Home' },
|
||||
{ path: '/intern/projects', breadcrumb: 'Projects' },
|
||||
{ path: '/intern/projects/:slug', breadcrumb: ProjectBreadcrumb },
|
||||
{ path: '/intern/projects/:slug/:taskSlug', breadcrumb: TaskBreadcrumb },
|
||||
{ path: '/intern/certificates', breadcrumb: 'Certificates' },
|
||||
{ path: '/intern/certificates/:slug', breadcrumb: CertBreadcrumb },
|
||||
{ path: '/intern/faq', breadcrumb: 'FAQ' },
|
||||
{ path: '/intern/notifications', breadcrumb: 'Notifications' },
|
||||
{ path: '/intern/settings', breadcrumb: 'Settings' },
|
||||
{ path: '/internship', breadcrumb: 'Home' },
|
||||
{ path: '/internship/projects', breadcrumb: 'Projects' },
|
||||
{ path: '/internship/projects/:slug', breadcrumb: ProjectBreadcrumb },
|
||||
{ path: '/internship/projects/:slug/:taskSlug', breadcrumb: TaskBreadcrumb },
|
||||
{ path: '/internship/certificates', breadcrumb: 'Certificates' },
|
||||
{ path: '/internship/certificates/:slug', breadcrumb: CertBreadcrumb },
|
||||
{ path: '/internship/faq', breadcrumb: 'FAQ' },
|
||||
{ path: '/internship/notifications', breadcrumb: 'Notifications' },
|
||||
{ path: '/internship/settings', breadcrumb: 'Settings' },
|
||||
|
||||
// --- AREA MENTOR / ADMIN ---
|
||||
{ path: '/mentor', breadcrumb: 'Home' },
|
||||
@@ -71,7 +71,7 @@ export default function Breadcrumbs(){
|
||||
const breadcrumbs = useBreadcrumbs(breadcrumbRoutes);
|
||||
const location = useLocation();
|
||||
|
||||
const rootPaths = ['/intern', '/mentor'];
|
||||
const rootPaths = ['/internship', '/mentor'];
|
||||
const isOnRootPath = rootPaths.includes(location.pathname);
|
||||
const fixbreadcumbs = breadcrumbs.filter(({ match }) => {
|
||||
if (match.pathname === '/') return false;
|
||||
|
||||
@@ -103,11 +103,13 @@ export default function HomeCalendar() {
|
||||
|
||||
return (
|
||||
<div className="box">
|
||||
<div className="flex flex-col py-4">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between mb-4 px-6">
|
||||
<div className="flex items-center justify-between mb-4 px-13">
|
||||
<h2 className="font-bold text-font">
|
||||
{MONTH_NAMES[currentMonth]} {currentYear}
|
||||
</h2>
|
||||
|
||||
<div className="flex items-center">
|
||||
<button
|
||||
onClick={prevMonth}
|
||||
@@ -116,6 +118,7 @@ export default function HomeCalendar() {
|
||||
>
|
||||
<ChevronLeft className="w-4 h-4 text-gray-500" />
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={nextMonth}
|
||||
className="p-1 rounded hover:bg-gray-100 transition-colors"
|
||||
@@ -126,70 +129,90 @@ export default function HomeCalendar() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-7 mb-1 px-5">
|
||||
{DAY_LABELS.map(day => (
|
||||
<div key={day} className="text-center text-xs text-gray-400 font-medium py-1">
|
||||
<div className="grid grid-cols-7 mb-1 px-10 md:px-0">
|
||||
{DAY_LABELS.map((day) => (
|
||||
<div
|
||||
key={day}
|
||||
className="text-center text-xs text-gray-400 font-medium py-1"
|
||||
>
|
||||
{day}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-7 px-5">
|
||||
{/* Trailing days from prev month */}
|
||||
{trailingDays.map(day => (
|
||||
<div className="grid grid-cols-7 px-10 md:px-0">
|
||||
{/* Trailing days from previous month */}
|
||||
{trailingDays.map((day) => (
|
||||
<div key={`prev-${day}`} className="text-center py-2">
|
||||
<span className="text-xs text-gray-300">{day}</span>
|
||||
<span className="text-xs text-gray-400">{day}</span>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{currentDays.map(day => (
|
||||
<div key={day} className="flex justify-center items-center py-0.5">
|
||||
{currentDays.map((day) => (
|
||||
<div
|
||||
key={day}
|
||||
className="flex justify-center items-center py-1"
|
||||
>
|
||||
<div className="w-7 flex items-center justify-center">
|
||||
{isToday(day) ? (
|
||||
<span className="w-8 h-7 flex items-center justify-center border-b-2 border-red- text-xs font-semibold">
|
||||
<span className="w-8 h-7 flex items-center justify-center text-red border-b-2 border-red text-xs font-semibold">
|
||||
{day}
|
||||
</span>
|
||||
) : (
|
||||
<span
|
||||
className={`w-full h-7 flex items-center justify-center text-xs
|
||||
${isBold(day) ? 'font-bold text-gray-800' : 'text-gray-700'}
|
||||
${hasDeadline(day) ? 'bg-red text-white' : ''}
|
||||
${isBold(day)
|
||||
? "font-bold text-gray-800"
|
||||
: "text-gray-700"
|
||||
}
|
||||
${hasDeadline(day)
|
||||
? "bg-red text-white rounded-full"
|
||||
: ""
|
||||
}
|
||||
transition-colors`}
|
||||
>
|
||||
{day}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{/* Leading days from next month */}
|
||||
{leadingDays.map(day => (
|
||||
{leadingDays.map((day) => (
|
||||
<div key={`next-${day}`} className="text-center py-2">
|
||||
<span className="text-xs text-gray-300">{day}</span>
|
||||
<span className="text-xs text-gray-400">{day}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Divider */}
|
||||
<hr className="my-3 border-box-border" />
|
||||
<hr className="my-1.5 border-box-border" />
|
||||
|
||||
{/* Upcoming Deadlines */}
|
||||
<div className='px-5 mt-2'>
|
||||
<div className="px-8 mt-2">
|
||||
<p className="text-[10px] font-semibold text-font uppercase tracking-widest mb-2">
|
||||
Upcoming Deadlines
|
||||
</p>
|
||||
|
||||
{upcomingDeadlines.length > 0 ? (
|
||||
<ul className="flex flex-col gap-1">
|
||||
{upcomingDeadlines.map((d, i) => (
|
||||
<li key={i} className="flex items-center gap-2">
|
||||
<span className="w-2 h-2 rounded-full bg-red flex-shrink-0" />
|
||||
<span className="text-xs text-font-shade">{formatDate(d.date)} - {d.label}</span>
|
||||
<span className="text-xs text-font-shade">
|
||||
{formatDate(d.date)} - {d.label}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p className="text-[11px] text-font-shade">No upcoming deadlines this month.</p>
|
||||
<p className="text-[11px] text-font-shade">
|
||||
No upcoming deadlines this month.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -5,16 +5,7 @@ import { Mail, Lock, Eye, EyeOff } from 'lucide-react';
|
||||
import { useLogin } from "../../hooks/useUser";
|
||||
import { customToast } from "../utils/showToast";
|
||||
import { CircleQuestionMark } from 'lucide-react';
|
||||
|
||||
const decodeJWT = (token: string) => {
|
||||
try {
|
||||
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;
|
||||
}
|
||||
};
|
||||
import { decodeJWT } from "../utils/decodeJWT";
|
||||
|
||||
export default function InternifyLogin() {
|
||||
const navigate = useNavigate();
|
||||
@@ -48,7 +39,7 @@ export default function InternifyLogin() {
|
||||
const decoded = decodeJWT(token);
|
||||
const role = decoded?.role;
|
||||
if (role === "intern") {
|
||||
navigate("/intern");
|
||||
navigate("/internship");
|
||||
} else if (role === "mentor" || role === "admin") {
|
||||
navigate("/mentor");
|
||||
} else {
|
||||
@@ -61,7 +52,13 @@ export default function InternifyLogin() {
|
||||
<div className="w-full flex flex-col items-center mb-8">
|
||||
<div className="text-center mb-8">
|
||||
<div className="flex items-center justify-center gap-2 font-bold text-2xl tracking-tight text-black">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => navigate("/")}
|
||||
className="flex items-center gap-2 hover:cursor-pointer w-[160px] md:w-full"
|
||||
>
|
||||
<img src={logo} alt="Logo" />
|
||||
</button>
|
||||
</div>
|
||||
<p className="text-[10px] tracking-widest text-yellow-950 font-semibold mt-1 uppercase">
|
||||
HUMIC LMS PORTAL
|
||||
|
||||
@@ -45,7 +45,7 @@ export default function UpdateProfileDialog({
|
||||
}}
|
||||
>
|
||||
{/* Header */}
|
||||
<div className="flex items-start justify-between gap-4 p-5 border-b border-box-border">
|
||||
<div className="flex items-start justify-between gap-4 p-3 border-b border-box-border">
|
||||
<div className="flex items-center gap-3">
|
||||
<div>
|
||||
<h2 className="text-base font-bold text-foreground">Simpan Perubahan</h2>
|
||||
@@ -101,7 +101,7 @@ export default function UpdateProfileDialog({
|
||||
disabled={loading}
|
||||
className="px-5 py-2 bg-[#B30000] hover:bg-[#990000] text-white text-xs font-bold rounded-lg shadow-sm transition-colors uppercase tracking-wider disabled:opacity-60"
|
||||
>
|
||||
{loading ? "Menyimpan..." : "Ya, Simpan"}
|
||||
{loading ? "Menyimpan..." : "Simpan"}
|
||||
</button>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
@@ -24,7 +24,7 @@ export default function VerificationCert() {
|
||||
/>
|
||||
<h1 className="text-2xl font-bold text-red mb-2 animate-pulse">Maaf, ID Sertifikat anda masukkan tidak valid</h1>
|
||||
<p className="text-gray-500 text-[16px]">
|
||||
Sertifikat dengan UUID ini tidak dapat ditemukan atau sudah tidak berlaku.
|
||||
Sertifikat dengan UUID ini tidak dapat ditemukan
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
@@ -38,20 +38,20 @@ export default function VerificationCert() {
|
||||
className="[240px] h-[240x] object-cover mb-14"
|
||||
/>
|
||||
<h1 className="text-2xl font-bold text-green-600 mb-6 text-center">
|
||||
Sertifikat Valid
|
||||
Validasi Berhasil!
|
||||
</h1>
|
||||
<div className="space-y-3 text-sm">
|
||||
<div>
|
||||
<div className="space-y-6 text-sm p-12 bg-card shadow-xl rounded-2xl w-1/3">
|
||||
<div className="flex justify-between items-start gap-4">
|
||||
<span className="text-font">Nama Intern</span>
|
||||
<p className="font-semibold">{verification.intern_name}</p>
|
||||
<p className="font-semibold text-right">{verification.intern_name}</p>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-font">Proyek</span>
|
||||
<p className="font-semibold">{verification.project_name}</p>
|
||||
<div className="flex justify-between items-start gap-4">
|
||||
<span className="text-font">Atas Proyek Humic</span>
|
||||
<p className="font-semibold text-right">{verification.project.project_name}</p>
|
||||
</div>
|
||||
<div>
|
||||
<div className="flex justify-between items-start gap-4">
|
||||
<span className="text-font">Tanggal Terbit</span>
|
||||
<p className="font-semibold">
|
||||
<p className="font-semibold text-right">
|
||||
{new Date(verification.created_at).toLocaleDateString("id-ID", {
|
||||
day: "numeric",
|
||||
month: "long",
|
||||
@@ -59,9 +59,19 @@ export default function VerificationCert() {
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<div className="flex justify-between items-start gap-4">
|
||||
<span className="text-font">Projek Selesai</span>
|
||||
<p className="font-semibold text-right">
|
||||
{new Date(verification.project.end_date).toLocaleDateString("id-ID", {
|
||||
day: "numeric",
|
||||
month: "long",
|
||||
year: "numeric",
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex justify-between items-start gap-4">
|
||||
<span className="text-font">UUID</span>
|
||||
<p className="font-mono text-xs break-all">{verification.uuid}</p>
|
||||
<p className="font-mono text-xs break-all text-right">{verification.uuid}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -32,7 +32,12 @@ export default function InternCertificateDetail() {
|
||||
};
|
||||
}, [projectDetail, projectFromList]);
|
||||
|
||||
const allTasksDone = !projectLoading && !!project && project.task_done >= project.total_tasks;
|
||||
|
||||
const allTasksDone =
|
||||
!projectLoading &&
|
||||
!!project &&
|
||||
(project.total_tasks ?? 0) > 0 &&
|
||||
project.task_done >= project.total_tasks;
|
||||
|
||||
const progress =
|
||||
project && project.total_tasks > 0
|
||||
@@ -50,10 +55,8 @@ export default function InternCertificateDetail() {
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col lg:flex-row gap-6 items-stretch animate-pulse">
|
||||
{/* Kolom kiri: certificate box */}
|
||||
<div className="w-full lg:w-5/8 h-[420px] bg-gray-200 rounded-xl" />
|
||||
|
||||
{/* Kolom kanan: history box */}
|
||||
<div className="w-full lg:w-3/8 flex-shrink-0 h-[420px] bg-gray-200 rounded-xl" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -68,9 +71,9 @@ export default function InternCertificateDetail() {
|
||||
</div>
|
||||
<div className="flex flex-col lg:flex-row gap-6 items-stretch">
|
||||
<div className="w-full lg:w-5/8 flex flex-col">
|
||||
{myCertificateForProject ? (
|
||||
{myCertificateForProject && (project?.total_tasks ?? 0) > 0 ? (
|
||||
<CertificateAvailable
|
||||
project={project}
|
||||
project={project!}
|
||||
certificate={myCertificateForProject}
|
||||
templateUrl={project?.certificate_template ?? ""}
|
||||
/>
|
||||
@@ -79,6 +82,7 @@ export default function InternCertificateDetail() {
|
||||
progress={progress}
|
||||
remainingTasks={remainingTasks}
|
||||
allTasksDone={allTasksDone}
|
||||
noTasks={(project?.total_tasks ?? 0) === 0}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -56,7 +56,7 @@ export default function SertificateList() {
|
||||
<div
|
||||
key={item.id}
|
||||
className="bg-white border border-card-outline rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-shadow cursor-pointer group"
|
||||
onClick={() => navigate(`/intern/certificates/${item.slug}`, { state: { project: item } })}
|
||||
onClick={() => navigate(`/internship/certificates/${item.slug}`, { state: { project: item } })}
|
||||
>
|
||||
{/* Thumbnail */}
|
||||
<div className="p-6 pb-0">
|
||||
@@ -79,7 +79,7 @@ export default function SertificateList() {
|
||||
{new Date(item.start_date).toLocaleDateString("id-ID", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
})} until {new Date(item.end_date).toLocaleDateString("id-ID", {
|
||||
})} - {new Date(item.end_date).toLocaleDateString("id-ID", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
})}
|
||||
@@ -88,7 +88,7 @@ export default function SertificateList() {
|
||||
{item.project_name}
|
||||
</p>
|
||||
<p className="text-xs text-font mt-1">
|
||||
Status Projek: <span className="font-bold text-red-600">{item.status}</span>
|
||||
Status: <span className="font-bold text-red-600">{item.status}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -22,9 +22,9 @@ export default function ProjectsPage() {
|
||||
|
||||
if (projects.length === 0) {
|
||||
return (
|
||||
<div className="col-span-full flex flex-col items-center justify-center py-2 gap-3 mt-19">
|
||||
<div className="flex w-full flex-col items-center justify-center py-2 gap-3 mt-19">
|
||||
<img className="w-[440px]" src={TeamPana} alt="" />
|
||||
<p className="text-[18px] text-font-shade">Kamu belum tergabung ke projek apapun</p>
|
||||
<p className="text-[13px] text-font-shade">Kamu belum tergabung ke projek apapun</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
||||
|
||||
const duration = formatDateRange(project?.start_date, project?.end_date)
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (!templateUrl) return;
|
||||
const verifyUrl = `${window.location.origin}/verify-certificate/${certificate.uuid}`;
|
||||
@@ -42,7 +41,7 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
||||
generateCertificate(
|
||||
resolveFileUrl(templateUrl),
|
||||
certificate.user.full_name,
|
||||
certificate.project.project_name,
|
||||
certificate.intern_position,
|
||||
certificate.certificate_no,
|
||||
duration,
|
||||
verifyUrl,
|
||||
@@ -82,12 +81,17 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
||||
};
|
||||
|
||||
const handleShareLinkedIn = () => {
|
||||
|
||||
const issueDate = new Date(certificate.issued_at.replace(" ", "T"));
|
||||
const verifyUrl = `${window.location.origin}/verify-certificate/${certificate.uuid}`;
|
||||
const params = new URLSearchParams({
|
||||
startTask: "CERTIFICATION_NAME",
|
||||
name: certificate.project.project_name,
|
||||
organizationName: "Internify",
|
||||
name: "Penyelesaian Kerja Magang Instansi CoE HUMIC Engineering Proyek: " + certificate.project.project_name,
|
||||
issueYear: String(issueDate.getFullYear()),
|
||||
issueMonth: String(issueDate.getMonth() + 1),
|
||||
organizationName: "CoE Humic Engineering",
|
||||
certUrl: verifyUrl,
|
||||
|
||||
certId: certificate.certificate_no,
|
||||
});
|
||||
window.open(
|
||||
@@ -100,7 +104,7 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
{/* Certificate Card */}
|
||||
<div className="flex rounded-xl p-5 mb-1 border bg-box-primary border-box-border shadow-md items-center justify-center">
|
||||
<div className="flex rounded-xl p-2 mb-1 border bg-box-primary border-box-border shadow-md items-center justify-center">
|
||||
{loadingPreview ? (
|
||||
<div className="w-[550px] h-[350px] flex items-center justify-center text-gray-400 text-sm">
|
||||
Memuat sertifikat...
|
||||
@@ -109,7 +113,7 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
||||
<img
|
||||
src={previewUrl}
|
||||
alt="Certificate"
|
||||
className="rounded-xl object-contain border-2"
|
||||
className="object-contain border shadow-md h-[400px]"
|
||||
/>
|
||||
) : (
|
||||
<div className="w-[550px] h-[350px] flex items-center justify-center text-gray-400 text-sm">
|
||||
@@ -119,8 +123,8 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
||||
</div>
|
||||
|
||||
{/* Program Summary */}
|
||||
<div className="grid grid-cols-2 gap-5">
|
||||
<div className="bg-white rounded-2xl border border-card-outline shadow-sm p-5">
|
||||
<div className="grid md:grid-cols-2 gap-5">
|
||||
<div className="bg-box-primary rounded-2xl border border-box-border shadow-sm p-5">
|
||||
<div className="flex items-center gap-2 mb-4">
|
||||
<h3 className="font-semibold text-gray-800 text-sm">Ringkasan Program</h3>
|
||||
</div>
|
||||
@@ -128,26 +132,26 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
||||
{[
|
||||
{ label: "Nama Program", value: project?.project_name ?? "-" },
|
||||
{ label: "Durasi", value: duration },
|
||||
{ label: "No. Sertifikat", value: certificate.certificate_no ?? "-" },
|
||||
{ label: "No. Sertifikat", value: certificate.certificate_no ? certificate.certificate_no : "-" },
|
||||
].map((row) => (
|
||||
<div
|
||||
key={row.label}
|
||||
className="flex justify-between items-center text-sm border-b border-card-outline pb-2 last:border-0"
|
||||
>
|
||||
<span className="text-font">{row.label}</span>
|
||||
<span className="text-font-shade font-bold">{row.value}</span>
|
||||
<span className="text-font text-start text-xs md:text-sm">{row.label}</span>
|
||||
<span className="text-font-shade font-bold text-end text-xs md:text-sm">{row.value}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-white rounded-2xl border border-card-outline shadow-sm p-5">
|
||||
{/* End Program Summary */}
|
||||
<div className="bg-box-primary rounded-2xl border border-box-border shadow-sm p-5">
|
||||
<div className="flex flex-col gap-3">
|
||||
{/* Unduh Sertifikat */}
|
||||
<button
|
||||
onClick={handleDownloadPdf}
|
||||
disabled={downloadingPdf}
|
||||
className="flex items-center justify-center gap-2 w-full bg-red-700 hover:bg-red-800 active:scale-95 transition-all text-white font-semibold py-2 rounded-xl text-sm"
|
||||
className="flex items-center justify-center gap-2 w-full bg-red-700 hover:bg-red-800 active:scale-95 transition-all text-white font-semibold py-2 rounded-xl text-sm hover:cursor-pointer"
|
||||
>
|
||||
<Download className="w-4 h-4" />
|
||||
{downloadingPdf ? "Memproses" : "Unduh Sertifikat"}
|
||||
@@ -156,7 +160,7 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
||||
{/* Bagikan ke LinkedIn */}
|
||||
<button
|
||||
onClick={handleShareLinkedIn}
|
||||
className="flex items-center justify-center gap-2 w-full bg-[#0A66C2] hover:bg-[#004182] active:scale-95 transition-all text-white font-semibold py-2 rounded-xl text-sm"
|
||||
className="flex items-center justify-center gap-2 w-full bg-[#0A66C2] hover:bg-[#004182] active:scale-95 transition-all text-white font-semibold py-2 rounded-xl text-sm hover:cursor-pointer"
|
||||
>
|
||||
{/* LinkedIn icon */}
|
||||
<svg className="w-4 h-4 fill-white" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
@@ -170,20 +174,20 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
||||
<button
|
||||
onClick={handleDownloadImage}
|
||||
disabled={downloadingImg}
|
||||
className="flex flex-col items-center justify-center gap-1.5 border border-card-outline hover:bg-gray-50 active:scale-95 transition-all text-red-700 font-medium py-3.5 rounded-xl text-sm">
|
||||
<Printer className="w-5 h-5" />
|
||||
{downloadingImg ? "Memproses" : "Cetak"}
|
||||
className="flex flex-col items-center justify-center gap-1.5 border border-card-outline hover:bg-gray-50 active:scale-95 transition-all text-red-700 font-medium py-1 md:py-3.5 rounded-xl text-sm hover:cursor-pointer"
|
||||
>
|
||||
<Printer className="w-4 h-4 md:w-5 md:h-5" />
|
||||
<span className="text-xs md:text-sm">{downloadingImg ? "Memproses" : "Cetak"}</span>
|
||||
</button>
|
||||
<button
|
||||
// onClick={handleCopyLink}
|
||||
className="flex flex-col items-center justify-center gap-1.5 border border-card-outline hover:bg-gray-50 active:scale-95 transition-all text-red-700 font-medium py-3.5 rounded-xl text-sm"
|
||||
className="flex flex-col items-center justify-center gap-1.5 border border-card-outline hover:bg-gray-50 active:scale-95 transition-all text-red-700 font-medium py-1 md:py-3.5 rounded-xl text-sm hover:cursor-pointer"
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(`${window.location.origin}/verify-certificate/${certificate.uuid}`);
|
||||
customToast.success("Link berhasil disalin!");
|
||||
customToast.success("Link berhasil disalin!", "Link sudah disalin ke clipboard");
|
||||
}}
|
||||
>
|
||||
<Link className="w-5 h-5" />
|
||||
Salin Link
|
||||
<Link className="w-4 h-4 md:w-5 md:h-5" />
|
||||
<span className="text-xs md:text-sm">Salin Link</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,6 @@ import { useMyCertificates } from "../../../../hooks/useCertificates";
|
||||
export default function SertificateHistory() {
|
||||
const { certificates, loading, error } = useMyCertificates();
|
||||
const displayed = certificates.slice(0, 3);
|
||||
|
||||
return (
|
||||
<div className="bg-box-primary rounded-2xl border border-box-border shadow-sm p-5">
|
||||
<div className="flex items-center gap-2 mb-4">
|
||||
@@ -36,11 +35,12 @@ export default function SertificateHistory() {
|
||||
{displayed.map((item: Certificate) => (
|
||||
<div
|
||||
key={item.id}
|
||||
className="flex flex-col gap-3 p-3 bg-white border border-gray-200 shadow-sm rounded-xl hover:bg-gray-50 transition-colors cursor-pointer"
|
||||
className="flex flex-col gap-3 p-3 bg-box-primary border border-box-border shadow-sm rounded-xl transition-colors"
|
||||
>
|
||||
<div className="w-full">
|
||||
<p className="text-xs text-gray-400">
|
||||
{new Date(item.issued_at).toLocaleDateString("id-ID", {
|
||||
day: "numeric",
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
})}
|
||||
@@ -48,7 +48,7 @@ export default function SertificateHistory() {
|
||||
<p className="text-sm font-semibold text-gray-800 leading-tight">
|
||||
{item.project.project_name}
|
||||
</p>
|
||||
<p className="text-sm text-gray-500">No: {item.certificate_no}</p>
|
||||
<p className="text-sm text-font-shade">{item.certificate_no}</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
// CertificateNotAvailable.tsx
|
||||
import { Clock, Lock, Award } from "lucide-react";
|
||||
import { Clock, Lock } from "lucide-react";
|
||||
import { FaAward } from "react-icons/fa";
|
||||
import { ListTodo } from "lucide-react";
|
||||
|
||||
interface CertificateNotAvailableProps {
|
||||
progress: number;
|
||||
remainingTasks: number;
|
||||
allTasksDone?: boolean;
|
||||
noTasks?: boolean;
|
||||
}
|
||||
|
||||
export default function CertificateNotAvailable({
|
||||
progress,
|
||||
remainingTasks,
|
||||
allTasksDone = false,
|
||||
noTasks = false,
|
||||
}: CertificateNotAvailableProps) {
|
||||
return (
|
||||
<div className="bg-box-primary w-full h-full rounded-2xl border border-box-border shadow-sm px-24 py-12 flex flex-col items-center justify-center">
|
||||
@@ -18,10 +21,12 @@ export default function CertificateNotAvailable({
|
||||
<div className="relative mb-6">
|
||||
<div className="w-34 h-34 border-2 border-dashed border-gray-600 rounded-xl flex justify-center items-center">
|
||||
<div className="w-26 h-26 flex items-center rounded-lg justify-center bg-gray-300">
|
||||
{allTasksDone ? (
|
||||
<Award className="w-12 h-12 text-green-600" />
|
||||
{noTasks ? (
|
||||
<ListTodo className="w-12 h-12 text-gray-400" />
|
||||
) : allTasksDone ? (
|
||||
<FaAward className="w-12 h-12 text-green-400" />
|
||||
) : (
|
||||
<Lock className="w-12 h-12 text-red-700" />
|
||||
<Lock className="w-12 h-12 text-red-500" />
|
||||
)}
|
||||
</div>
|
||||
<div className="absolute -bottom-2 -right-2 w-7 h-7 bg-amber-500 rounded- flex items-center justify-center shadow-md">
|
||||
@@ -30,7 +35,15 @@ export default function CertificateNotAvailable({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{allTasksDone ? (
|
||||
{noTasks ? (
|
||||
<>
|
||||
<h2 className="text-[28px] font-bold text-gray-900 mb-3">Sertifikat Belum Tersedia</h2>
|
||||
<p className="text-gray-500 text-[15px] mb-6 text-center">
|
||||
Proyek ini belum memiliki tugas yang ditetapkan.
|
||||
Sertifikat akan tersedia setelah semua tugas proyek diselesaikan.
|
||||
</p>
|
||||
</>
|
||||
) : allTasksDone ? (
|
||||
<>
|
||||
<h2 className="text-[37px] font-bold text-gray-900 mb-3">Selamat!</h2>
|
||||
<p className="text-gray-500 text-[17px] mb-6 text-center">
|
||||
|
||||
@@ -20,7 +20,7 @@ const HomeProjectList = () => {
|
||||
if (error) return <p className="text-red-500 text-sm">{error}</p>;
|
||||
|
||||
return (
|
||||
<div className=''>
|
||||
<div>
|
||||
<h2 className="text-lg font-semibold text-font-shade mb-5">Projects</h2>
|
||||
|
||||
{projects.length === 0 ? (
|
||||
@@ -33,7 +33,7 @@ const HomeProjectList = () => {
|
||||
{projects.map((project) => (
|
||||
<div
|
||||
key={project.id}
|
||||
onClick={() => navigate(`/intern/projects/${toSlug(project.slug)}`)}
|
||||
onClick={() => navigate(`/internship/projects/${toSlug(project.slug)}`)}
|
||||
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
|
||||
|
||||
@@ -31,7 +31,7 @@ export default function TaskCard({ task }: { task: InternTaskItem }) {
|
||||
return (
|
||||
<div
|
||||
className="border border-card-outline rounded-xl px-6 py-4 mb-3 bg-box-primary flex items-start justify-between gap-3 cursor-pointer hover:bg-gray-50 transition-colors"
|
||||
onClick={() => navigate(`/intern/projects/${task.project_slug}/${task.slug}?type=${task.submission_type}`)}
|
||||
onClick={() => navigate(`/internship/projects/${task.project_slug}/${task.slug}?type=${task.submission_type}`)}
|
||||
>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="md:hidden mb-[8px]">
|
||||
|
||||
@@ -29,11 +29,11 @@ export default function ProjectTimeline({ tasks }: { tasks: InternTaskItem[] })
|
||||
active ? 'bg-red' : 'bg-gray-400'
|
||||
} ${isToday ? 'shadow-md' : ''}`}
|
||||
/>
|
||||
<div className={`text-[11px] font-semibold ${isToday ? 'text-red' : 'text-font'}`}>
|
||||
{isToday ? 'Hari ini' : formatDate(task.deadline_at)}
|
||||
<div className={`text-[14px] font-semibold ${isToday ? 'text-red' : 'text-font'}`}>
|
||||
{task.title}
|
||||
</div>
|
||||
<div className="text-xs text-font mt-px leading-[1.3]">
|
||||
{task.title}
|
||||
{isToday ? 'Hari ini' : formatDate(task.deadline_at)}
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
|
||||
@@ -12,7 +12,7 @@ const ProjectCard = (project: Project) => {
|
||||
|
||||
return (
|
||||
<div
|
||||
onClick={() => navigate(`/intern/projects/${project.slug}`)}
|
||||
onClick={() => navigate(`/internship/projects/${project.slug}`)}
|
||||
className="w-[220px] min-h-[320px] flex flex-col bg-white rounded-xl overflow-hidden shadow-sm border border-gray-100 cursor-pointer hover:shadow-md transition-shadow duration-200"
|
||||
>
|
||||
{/* Thumbnail */}
|
||||
|
||||
@@ -5,14 +5,14 @@ import { MdOutlineAssignment, MdLogout } from "react-icons/md";
|
||||
import { HiUser } from "react-icons/hi2";
|
||||
|
||||
const navItems = [
|
||||
{ label: "Home", icon: GrHomeRounded, path: "/intern" },
|
||||
{ label: "List Projects", icon: MdOutlineAssignment, path: "/intern/projects" },
|
||||
{ label: "Certificates", icon: Award, path: "/intern/certificates" },
|
||||
{ label: "Home", icon: GrHomeRounded, path: "/internship" },
|
||||
{ label: "List Projects", icon: MdOutlineAssignment, path: "/internship/projects" },
|
||||
{ label: "Certificates", icon: Award, path: "/internship/certificates" },
|
||||
];
|
||||
|
||||
const prefItems = [
|
||||
{ label: "Settings", icon: Settings, path: "/intern/settings" },
|
||||
{ label: "FAQ", icon: HelpCircle, path: "/intern/faq" },
|
||||
{ label: "Settings", icon: Settings, path: "/internship/settings" },
|
||||
{ label: "FAQ", icon: HelpCircle, path: "/internship/faq" },
|
||||
{ label: "Logout", icon: MdLogout, path: "/login-internify", danger: true, isLogout: true },
|
||||
];
|
||||
|
||||
@@ -31,7 +31,7 @@ export default function SidebarIntern({ isOpen, closeSidebar }: SidebarProps) {
|
||||
};
|
||||
|
||||
const handleLogout = () => {
|
||||
document.cookie = "token=; path=/; max-age=86400; SameSite=Strict";
|
||||
document.cookie = "token=; Max-Age=0; path=/; SameSite=Strict";
|
||||
|
||||
closeSidebar();
|
||||
navigate("/login-internify", { replace: true });
|
||||
|
||||
@@ -15,13 +15,31 @@ interface SubmitStatusTableProps {
|
||||
|
||||
function getTimeEarly(submittedAt: Date, deadline: Date): string {
|
||||
const diffMs = deadline.getTime() - submittedAt.getTime();
|
||||
if (diffMs <= 0) return "Submitted after deadline";
|
||||
const diffHours = Math.floor(diffMs / (1000 * 60 * 60));
|
||||
|
||||
if (diffMs <= 0) {
|
||||
const absHours = Math.abs(diffHours);
|
||||
const days = Math.floor(absHours / 24);
|
||||
const hours = absHours % 24;
|
||||
const overdueParts = [] as string[];
|
||||
|
||||
if (days > 0) overdueParts.push(`${days} day${days > 1 ? "s" : ""}`);
|
||||
if (hours > 0) overdueParts.push(`${hours} hour${hours > 1 ? "s" : ""}`);
|
||||
|
||||
if (overdueParts.length === 0) {
|
||||
return "Submitted after deadline (0 hours late)";
|
||||
}
|
||||
|
||||
return `Submitted after deadline (${overdueParts.join(" ")} late)`;
|
||||
}
|
||||
|
||||
const parts = [] as string[];
|
||||
const days = Math.floor(diffHours / 24);
|
||||
const hours = diffHours % 24;
|
||||
const parts = [];
|
||||
|
||||
if (days > 0) parts.push(`${days} day${days > 1 ? "s" : ""}`);
|
||||
if (hours > 0) parts.push(`${hours} hour${hours > 1 ? "s" : ""}`);
|
||||
|
||||
return `Assignment was submitted ${parts.join(" ")} early`;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,14 @@ export default function TaskFormFile({ taskId, projectId, deadline, initialSubmi
|
||||
selectedFiles.forEach((file) => {
|
||||
const ext = file.name.split(".").pop()?.toLowerCase();
|
||||
if (ext && allowedExtensions.includes(ext)) {
|
||||
if (file.size <= 5 * 1024 * 1024) validFiles.push(file);
|
||||
if (file.size <= 5 * 1024 * 1024) {
|
||||
validFiles.push(file);
|
||||
} else {
|
||||
customToast.error(
|
||||
"File terlalu besar!",
|
||||
`File ${file.name} melebihi batas ukuran 5MB.`
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (validFiles.length > 0) setFiles((prev) => [...prev, ...validFiles]);
|
||||
|
||||
@@ -34,18 +34,14 @@ export default function TaskFormLink({
|
||||
loading: isEditing ? "Memperbarui Link..." : "Mengirim Link...",
|
||||
success: (res) => ({
|
||||
title: isEditing ? "Link diperbaharui" : "Link berhasil dikirim",
|
||||
description:
|
||||
res?.message ??
|
||||
(isEditing
|
||||
? "Perubahan submission Anda telah disimpan."
|
||||
: "Link berhasil dikirim."),
|
||||
description: res?.message
|
||||
// ?? (isEditing ? "Perubahan submission Anda telah disimpan." : "Link berhasil dikirim."),
|
||||
}),
|
||||
error: (err) => ({
|
||||
title: isEditing ? "Gagal memperbarui link!" : "Gagal mengirim link!",
|
||||
description:
|
||||
err?.response?.data?.message ||
|
||||
err?.message ||
|
||||
"Link yang anda submit gagal dikirim",
|
||||
err?.response?.data?.message || err?.message
|
||||
// || "Link yang anda submit gagal dikirim",
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
@@ -5,13 +5,6 @@ import CreateProjectModal from './components/CreateProjectDialog';
|
||||
import { useProjectsByRole } from '../../../hooks/useListProjects';
|
||||
import TeamPana from '../../../assets/Team-pana.svg';
|
||||
|
||||
function MentorProjectCardSkeleton() {
|
||||
return (
|
||||
<div className="flex flex-row bg-gray-300 rounded-xl overflow-hidden shadow-sm w-[180px] min-h-[270px] animate-pulse">
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default function MentorProjectsPage() {
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
const { projects, loading, error, refetch } = useProjectsByRole();
|
||||
@@ -34,8 +27,9 @@ export default function MentorProjectsPage() {
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="flex flex-row gap-3 w-full">
|
||||
{[...Array(4)].map((_) => (
|
||||
<MentorProjectCardSkeleton />
|
||||
{[...Array(4)].map((_, index) => (
|
||||
<div key={index} className="flex flex-row bg-gray-300 rounded-xl overflow-hidden shadow-sm w-[180px] min-h-[270px] animate-pulse">
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@ const HomeMentorPage = () => {
|
||||
<HomeHeader />
|
||||
<div className="flex flex-col gap-5">
|
||||
<div className="">
|
||||
<div className="bg-white border border-box-border rounded-xl p-6">
|
||||
<div>
|
||||
<HomeMentorProject />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useParams, useLocation } from "react-router-dom";
|
||||
import { Download, Clock, AlertCircle } from "lucide-react";
|
||||
import { Download, AlertCircle, User2 } from "lucide-react";
|
||||
import { useTaskSubmissions } from "../../../hooks/useTasks";
|
||||
import type { DisplayStatus } from "../../../types/task.types";
|
||||
import { StatusTable } from "./components/StatusSubmissionTable";
|
||||
@@ -50,8 +50,8 @@ export default function ViewInternSubmission() {
|
||||
{task.title}
|
||||
</h1>
|
||||
<p className="text-sm text-gray-500 flex items-center gap-1.5">
|
||||
<Clock className="w-3.5 h-3.5" />
|
||||
{internSubmission.full_name} — {internSubmission.email}
|
||||
<User2 className="w-3.5 h-3.5" />
|
||||
{internSubmission.full_name}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -19,8 +19,6 @@ export default function AddInternsModal({ isOpen, onClose, userId }: AddInternsM
|
||||
const { projects, loading: loadingProjects } = useProjects("active");
|
||||
const { interns, loading: loadingInterns } = useAssignableInterns();
|
||||
|
||||
console.log(projects)
|
||||
|
||||
useEffect(() => {
|
||||
const dialog = dialogRef.current;
|
||||
if (!dialog) return;
|
||||
|
||||
@@ -132,13 +132,6 @@ export default function CertResultTable({ certificates, templateUrl }: Certifica
|
||||
: <Download className="w-4 h-4" />
|
||||
}
|
||||
</button>
|
||||
{/*
|
||||
<button
|
||||
className="p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-md transition-colors"
|
||||
title="Share"
|
||||
>
|
||||
<Share2 className="w-4 h-4" />
|
||||
</button> */}
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
|
||||
@@ -33,6 +33,7 @@ export default function CreateProjectModal({ isOpen, onClose, onSuccess }: Creat
|
||||
icon: PROJECT_ICON_MAP[id],
|
||||
}));
|
||||
|
||||
//open/close doalog komponen
|
||||
useEffect(() => {
|
||||
const dialog = dialogRef.current;
|
||||
if (!dialog) return;
|
||||
@@ -54,8 +55,22 @@ export default function CreateProjectModal({ isOpen, onClose, onSuccess }: Creat
|
||||
};
|
||||
}, [isOpen, onClose]);
|
||||
|
||||
const handleAddEmail = (emailToAdd?: string) => {
|
||||
const email = (emailToAdd ?? emailInput).trim();
|
||||
// tutup dropdown email di luar kotak
|
||||
useEffect(() => {
|
||||
if (!showDropdown) return;
|
||||
|
||||
const handleClickOutside = (e: MouseEvent) => {
|
||||
if (emailSectionRef.current && !emailSectionRef.current.contains(e.target as Node)) {
|
||||
setShowDropdown(false);
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener("mousedown", handleClickOutside);
|
||||
return () => document.removeEventListener("mousedown", handleClickOutside);
|
||||
}, [showDropdown]);
|
||||
|
||||
|
||||
const handleAddEmail = (email: string) => {
|
||||
if (email && !invitedEmails.includes(email)) {
|
||||
setInvitedEmails([...invitedEmails, email]);
|
||||
setEmailInput("");
|
||||
@@ -182,34 +197,23 @@ export default function CreateProjectModal({ isOpen, onClose, onSuccess }: Creat
|
||||
<label className="text-xs font-bold text-gray-700 tracking-wide">
|
||||
Invite via Gmail
|
||||
</label>
|
||||
{/* Input email + dropdown sugesti intern */}
|
||||
{/* filterisasi email */}
|
||||
<div ref={emailSectionRef} className="relative">
|
||||
<div className="relative flex items-center">
|
||||
<span className="absolute left-3.5 text-gray-400">
|
||||
<LuMail className="w-4 h-4 stroke-[2.5]" />
|
||||
</span>
|
||||
<input
|
||||
type="email"
|
||||
placeholder="intern.name@gmail.com"
|
||||
type="text"
|
||||
placeholder="cari intern berdasarkan nama/email"
|
||||
value={emailInput}
|
||||
onChange={(e) => { setEmailInput(e.target.value); setShowDropdown(true); }}
|
||||
onFocus={() => setShowDropdown(true)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
handleAddEmail();
|
||||
}
|
||||
if (e.key === 'Escape') setShowDropdown(false);
|
||||
if (e.key === 'Escape') setShowDropdown(false)
|
||||
}}
|
||||
className="w-full pl-10 pr-20 py-2.5 bg-white border border-card-outline rounded-lg text-sm placeholder-gray-400 text-gray-800 focus:outline-none focus:border-red-600 focus:ring-1 focus:ring-red-600 font-medium"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleAddEmail()}
|
||||
className="absolute right-2 px-3 py-1 bg-card hover:bg-card-hover border border-card-outline text-font-shade text-[11px] font-bold rounded-md transition-colors tracking-wider uppercase"
|
||||
>
|
||||
ADD
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Dropdown daftar intern */}
|
||||
@@ -231,12 +235,16 @@ export default function CreateProjectModal({ isOpen, onClose, onSuccess }: Creat
|
||||
<button
|
||||
key={intern.id}
|
||||
type="button"
|
||||
onMouseDown={(e) => { e.preventDefault(); handleAddEmail(intern.email); }}
|
||||
className="w-full flex items-center gap-3 px-6 py-2.5 hover:bg-gray-50 transition-colors text-left"
|
||||
onMouseDown={(e) => {
|
||||
e.preventDefault();
|
||||
handleAddEmail(intern.email);
|
||||
}}
|
||||
|
||||
className="w-full flex items-center gap-3 px-6 py-1.5 hover:bg-gray-50 transition-colors text-left"
|
||||
>
|
||||
<div className="flex flex-col min-w-0">
|
||||
<span className="text-[13px] font-semibold text-gray-800 truncate">{intern.full_name}</span>
|
||||
<span className="text-[11px] text-gray-400 truncate">{intern.email}</span>
|
||||
<span className="text-[10px] font-semibold text-gray-800 truncate">{intern.full_name}</span>
|
||||
<span className="text-[8px] text-gray-400 truncate">{intern.email}</span>
|
||||
</div>
|
||||
</button>
|
||||
))
|
||||
|
||||
@@ -20,8 +20,6 @@ export default function EditSubmissionModal({
|
||||
}: EditTaskModalProps) {
|
||||
const dialogRef = useRef<HTMLDialogElement>(null);
|
||||
const { update, loading, error } = useUpdateTask();
|
||||
|
||||
// Form States — diinisialisasi dari props task
|
||||
const [taskTitle, setTaskTitle] = useState(task.title);
|
||||
const [description, setDescription] = useState(task.description);
|
||||
const [deadlineDate, setDeadlineDate] = useState(
|
||||
@@ -32,7 +30,9 @@ export default function EditSubmissionModal({
|
||||
);
|
||||
const [submissionType, setSubmissionType] = useState<SubmissionType>(task.submission_type);
|
||||
|
||||
// Sync form ketika task berubah (misal modal dibuka untuk task berbeda)
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
const isDeadlinePast = !!deadlineDate && deadlineDate < today;
|
||||
|
||||
useEffect(() => {
|
||||
setTaskTitle(task.title);
|
||||
setDescription(task.description);
|
||||
@@ -108,7 +108,7 @@ export default function EditSubmissionModal({
|
||||
|
||||
{/* Error Message */}
|
||||
{error && (
|
||||
<div className="px-3 py-2 bg-red-50 border border-red-200 rounded-lg text-xs text-red-600 font-medium">
|
||||
<div className="px-3 py-2 border border-red-200 rounded-lg text-xs text-red font-medium">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
@@ -148,9 +148,18 @@ export default function EditSubmissionModal({
|
||||
required
|
||||
value={deadlineDate}
|
||||
onChange={(e) => setDeadlineDate(e.target.value)}
|
||||
className="w-full p-3 py-2.5 bg-white border border-gray-200 rounded-lg text-sm font-medium text-gray-800 focus:outline-none focus:border-[#B30000] focus:ring-1 focus:ring-[#B30000] appearance-none"
|
||||
className={`w-full p-3 py-2.5 bg-white border rounded-lg text-sm font-medium text-gray-800 focus:outline-none appearance-none ${
|
||||
isDeadlinePast
|
||||
? "border-red-400 focus:border-red-500 focus:ring-1 focus:ring-red-400"
|
||||
: "border-gray-200 focus:border-[#B30000] focus:ring-1 focus:ring-[#B30000]"
|
||||
}`}
|
||||
/>
|
||||
</div>
|
||||
{isDeadlinePast && (
|
||||
<p className="text-xs text-red-500 font-medium mt-1">
|
||||
Tenggat waktu tidak boleh sebelum hari ini.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
@@ -200,7 +209,7 @@ export default function EditSubmissionModal({
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
disabled={loading || isDeadlinePast}
|
||||
className="px-5 py-2.5 bg-[#B30000] hover:bg-[#990000] text-white text-sm font-bold rounded-xl transition-colors shadow-md flex items-center gap-2 disabled:opacity-60 disabled:cursor-not-allowed"
|
||||
>
|
||||
<LuSave className="w-4 h-4 stroke-[2.5]" />
|
||||
|
||||
@@ -15,14 +15,12 @@ interface EditTaskModalProps {
|
||||
export default function EditTaskModal({ isOpen, onClose, task, onSuccess }: EditTaskModalProps) {
|
||||
const dialogRef = useRef<HTMLDialogElement>(null);
|
||||
const { update, loading } = useUpdateTask();
|
||||
|
||||
const [taskTitle, setTaskTitle] = useState(task.title);
|
||||
const [description, setDescription] = useState(task.description);
|
||||
const [deadlineDate, setDeadlineDate] = useState(task.deadline_at.split("T")[0]);
|
||||
const [specificTime, setSpecificTime] = useState(task.deadline_at.split("T")[1]?.slice(0, 5) ?? "");
|
||||
const [submissionType, setSubmissionType] = useState<SubmissionType>(task.submission_type);
|
||||
|
||||
// Reset tiap task berubah
|
||||
useEffect(() => {
|
||||
setTaskTitle(task.title);
|
||||
setDescription(task.description);
|
||||
|
||||
@@ -118,12 +118,14 @@ export default function EligibleInternTable({
|
||||
id: intern.id_user,
|
||||
id_project: project.id,
|
||||
id_user: intern.id_user,
|
||||
certificate_no: "CERT/yyddmm/X",
|
||||
certificate_no: "No.2025/SPI3/CERT/MMDDYY/XXX",
|
||||
issued_at: new Date().toISOString().slice(0, 10),
|
||||
uuid: "HANYA SEBATAS PREVIEW",
|
||||
intern_position: "[Posisi Intern]",
|
||||
user: {
|
||||
id: intern.id_user,
|
||||
full_name: intern.full_name,
|
||||
intern_position: "[Posisi Intern]",
|
||||
email: intern.email,
|
||||
},
|
||||
project: {
|
||||
@@ -185,12 +187,12 @@ export default function EligibleInternTable({
|
||||
const blob = await generateCertificate(
|
||||
templateUrl,
|
||||
cert.user.full_name,
|
||||
cert.project.project_name,
|
||||
cert.intern_position,
|
||||
cert.certificate_no,
|
||||
duration,
|
||||
cert.uuid,
|
||||
);
|
||||
zip.file(`Sertifikat - ${cert.user.full_name}.png`, blob);
|
||||
zip.file(`${cert.certificate_no}_${cert.user.full_name}_${cert.project.project_name}.png`, blob);
|
||||
})
|
||||
);
|
||||
})(),
|
||||
|
||||
@@ -28,8 +28,8 @@ const HomeMentorProject = () => {
|
||||
|
||||
|
||||
return (
|
||||
<div className='flex flex-col'>
|
||||
<div className='flex flex-row justify-between mb-3 items-center'>
|
||||
<div className='flex flex-col box'>
|
||||
<div className='flex flex-row justify-between mb-5 items-center'>
|
||||
<h2 className="text-lg font-semibold text-gray-800">Projects</h2>
|
||||
<button
|
||||
className='bg-card p-1.5 rounded-lg font-bold hover:bg-card-hover border border-card-outline'
|
||||
|
||||
@@ -80,7 +80,7 @@ export default function InternsTable({
|
||||
className="w-10 h-10 rounded-full object-cover border border-gray-100 shadow-sm hidden md:block"
|
||||
/>
|
||||
) : (
|
||||
<div className=" w-10 h-10 rounded-full bg-gradient-to-br from-teal-400 to-emerald-500 items-center justify-center border border-gray-100 shadow-sm text-white text-xs font-bold hidden md:flex">
|
||||
<div className=" w-8 h-8 rounded-full bg-gray-300 items-center justify-center shadow-sm text-font-shade text-xs font-bold hidden md:flex">
|
||||
{intern.name.charAt(0)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -15,6 +15,11 @@ export default function MentorTaskCard({ task }: {task: InternTaskItem}) {
|
||||
navigate(`/mentor/projects/${slug}/${task.slug}?type=${task.submission_type}`)
|
||||
};
|
||||
|
||||
function truncateText(text: string) {
|
||||
if (text.length <= 230) return text;
|
||||
return text.slice(0, 230) + "...";
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className="border border-card-outline rounded-[10px] px-5 py-4 mb-3 bg-card shadow-lg flex items-start justify-between gap-3 cursor-pointer hover:border-card-outline/50 transition-colors"
|
||||
@@ -28,7 +33,7 @@ export default function MentorTaskCard({ task }: {task: InternTaskItem}) {
|
||||
{task.title}
|
||||
</div>
|
||||
<div className="text-[13px] text-[#666]">
|
||||
{task.description}
|
||||
{truncateText(task.description)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -30,7 +30,7 @@ export default function SidebarMentor({ isOpen, closeSidebar }: SidebarProps) {
|
||||
};
|
||||
|
||||
const handleLogout = () => {
|
||||
document.cookie = "token=; path=/; max-age=86400; SameSite=Strict";
|
||||
document.cookie = "token=; Max-Age=0; path=/; SameSite=Strict";
|
||||
|
||||
closeSidebar();
|
||||
navigate("/login-internify", { replace: true });
|
||||
|
||||
@@ -25,7 +25,7 @@ export const previewCertificate = async (
|
||||
const blob = await generateCertificate(
|
||||
resolveFileUrl(templateUrl),
|
||||
cert.user.full_name,
|
||||
cert.project.project_name,
|
||||
cert.intern_position,
|
||||
cert.certificate_no,
|
||||
formatDateRange(cert.project.start_date, cert.project.end_date),
|
||||
cert.uuid,
|
||||
@@ -85,11 +85,11 @@ export const downloadCertificatePdf = async (
|
||||
cert: Certificate,
|
||||
templateUrl: string,
|
||||
): Promise<void> => {
|
||||
const fileName = `Sertifikat - ${cert.user.full_name} - ${cert.certificate_no}`;
|
||||
const fileName = `${cert.certificate_no}_${cert.user.full_name}_${cert.project.project_name}`;
|
||||
const blob = await generateCertificate(
|
||||
resolveFileUrl(templateUrl),
|
||||
cert.user.full_name,
|
||||
cert.project.project_name,
|
||||
cert.intern_position,
|
||||
cert.certificate_no,
|
||||
formatDateRange(cert.project.start_date, cert.project.end_date),
|
||||
cert.uuid,
|
||||
@@ -125,11 +125,11 @@ export const downloadCertificateImage = async (
|
||||
templateUrl: string,
|
||||
format: "png" | "jpg" = "png",
|
||||
): Promise<void> => {
|
||||
const fileName = `Sertifikat - ${cert.user.full_name} - ${cert.certificate_no}`;
|
||||
const fileName = `${cert.certificate_no}_${cert.user.full_name}_${cert.project.project_name}`;
|
||||
const blob = await generateCertificate(
|
||||
resolveFileUrl(templateUrl),
|
||||
cert.user.full_name,
|
||||
cert.project.project_name,
|
||||
cert.intern_position,
|
||||
cert.certificate_no,
|
||||
formatDateRange(cert.project.start_date, cert.project.end_date),
|
||||
cert.uuid,
|
||||
@@ -192,12 +192,12 @@ export const downloadAllCertificatesZip = async (
|
||||
const blob = await generateCertificate(
|
||||
resolveFileUrl(templateUrl),
|
||||
cert.user.full_name,
|
||||
cert.project.project_name,
|
||||
cert.intern_position,
|
||||
cert.certificate_no,
|
||||
formatDateRange(cert.project.start_date, cert.project.end_date),
|
||||
cert.uuid,
|
||||
);
|
||||
zip.file(`Sertifikat - ${cert.user.full_name}.png`, blob);
|
||||
zip.file(`${cert.certificate_no}_${projectName}_${cert.user.full_name}.png`, blob);
|
||||
onProgress?.(i + 1, total);
|
||||
}),
|
||||
);
|
||||
@@ -205,7 +205,7 @@ export const downloadAllCertificatesZip = async (
|
||||
const zipBlob = await zip.generateAsync({ type: "blob" });
|
||||
const a = document.createElement("a");
|
||||
a.href = URL.createObjectURL(zipBlob);
|
||||
a.download = `Sertifikat - ${projectName}.zip`;
|
||||
a.download = `Sertifikat_${projectName}_${new Date().toISOString().slice(0, 10)}.zip`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(a.href);
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ const PrivateRoute = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (!token) {
|
||||
navigate("/humic-20242025-2");
|
||||
navigate("/login-admin");
|
||||
}
|
||||
}, [navigate, token]);
|
||||
|
||||
|
||||
@@ -1,26 +1,10 @@
|
||||
import { Outlet, Navigate } from "react-router-dom";
|
||||
import { decodeJWT } from "../utils/decodeJWT";
|
||||
|
||||
interface PrivateRouteProps {
|
||||
allowedRoles?: ("intern" | "admin" | "mentor")[];
|
||||
}
|
||||
|
||||
const decodeJWT = (token: string) => {
|
||||
try {
|
||||
const base64Url = token.split(".")[1];
|
||||
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
||||
const jsonPayload = decodeURIComponent(
|
||||
window
|
||||
.atob(base64)
|
||||
.split("")
|
||||
.map((c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2))
|
||||
.join("")
|
||||
);
|
||||
return JSON.parse(jsonPayload);
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const ProtectedRoutes = ({ allowedRoles }: PrivateRouteProps) => {
|
||||
const token = document.cookie
|
||||
.split("; ")
|
||||
@@ -40,7 +24,7 @@ const ProtectedRoutes = ({ allowedRoles }: PrivateRouteProps) => {
|
||||
|
||||
if (allowedRoles && !allowedRoles.includes(userRole)) {
|
||||
if (userRole === "admin" || userRole === "mentor") return <Navigate to="/mentor" replace />;
|
||||
if (userRole === "intern") return <Navigate to="/intern" replace />;
|
||||
if (userRole === "intern") return <Navigate to="/internship" replace />;
|
||||
}
|
||||
|
||||
return <Outlet />;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { resolveFileUrl } from "./resolveFileFromUrl";
|
||||
import QRCode from "qrcode";
|
||||
|
||||
export function loadImage(src: string): Promise<HTMLImageElement> {
|
||||
//LOAD IMAGE TEMPLATE
|
||||
function loadImage(src: string): Promise<HTMLImageElement> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const img = new Image();
|
||||
if (!src.startsWith("data:")) img.crossOrigin = "anonymous";
|
||||
@@ -11,7 +12,8 @@ export function loadImage(src: string): Promise<HTMLImageElement> {
|
||||
});
|
||||
}
|
||||
|
||||
export async function ensureFontsLoaded(): Promise<void> {
|
||||
//LOAD FONT UNTUK MENCEGAH FONT TERGANTI
|
||||
async function ensureFontsLoaded(): Promise<void> {
|
||||
await Promise.all([
|
||||
document.fonts.load('105px "Great Vibes"'),
|
||||
document.fonts.load('54px "Grenze"'),
|
||||
@@ -19,20 +21,34 @@ export async function ensureFontsLoaded(): Promise<void> {
|
||||
await document.fonts.ready;
|
||||
}
|
||||
|
||||
// LAYOUT DEFAULT SERTIFIKAT YANG AKAN DIGENERATE
|
||||
const LAYOUT = {
|
||||
internName: { x: 0.57, y: 0.48, size: 140, font: "Great Vibes", color: "#800000" },
|
||||
internNameSmall: { x: 0.82, y: 0.889, size: 47, font: "Great Vibes", color: "#090909" },
|
||||
projectName: { x: 0.815, y: 0.598, size: 46, font: "Grenze", color: "#800000" },
|
||||
duration: { x: 0.7, y: 0.645, size: 48, font: "Grenze", color: "#090909" },
|
||||
certNo: { x: 0.597, y: 0.305, size: 50, font: "Grenze", color: "#090909" },
|
||||
certNoSmall: { x: 0.827, y: 0.92, size: 32, font: "Grenze", color: "#090909"},
|
||||
qr: { x: 0.77, y: 0.715, size: 0.103 },
|
||||
internName: { x: 0.56, y: 0.47, size: 130, font: "Great Vibes", color: "#800000" },
|
||||
internNameSmall: { x: 0.82, y: 0.88, size: 42, font: "Great Vibes", color: "#090909" },
|
||||
userposition: { x: 0.85, y: 0.557, size: 46, font: "Grenze", color: "#800000" },
|
||||
duration: { x: 0.7, y: 0.615, size: 48, font: "Grenze", color: "#090909" },
|
||||
certNo: { x: 0.56, y: 0.305, size: 50, font: "Grenze", color: "#090909" },
|
||||
certNoSmall: { x: 0.827, y: 0.905, size: 30, font: "Grenze", color: "#090909"},
|
||||
qr: { x: 0.771, y: 0.715, size: 0.103 },
|
||||
};
|
||||
|
||||
// HELPER: kurangi ukuran font 25% jika nama melebihi 22 karakter (termasuk spasi)
|
||||
function fitNameText(name: string, baseSize: number): number {
|
||||
const SAFE_LENGTH = 24;
|
||||
const REDUCTION_PER_CHAR = 0.032;
|
||||
const MIN_SCALE = 0.75;
|
||||
|
||||
const length = name.length;
|
||||
if (length <= SAFE_LENGTH) return baseSize;
|
||||
const scale = Math.max(1 - (length - SAFE_LENGTH) * REDUCTION_PER_CHAR, MIN_SCALE);
|
||||
return baseSize * scale;
|
||||
}
|
||||
|
||||
//MAIN FUNCTION: generasi sertifikat intern formatted
|
||||
export async function generateCertificate(
|
||||
templateUrl: string,
|
||||
internName: string,
|
||||
projectName: string,
|
||||
userposition: string,
|
||||
certificateNo: string,
|
||||
ProjectDuration: string,
|
||||
verifyUrl: string,
|
||||
@@ -52,19 +68,19 @@ export async function generateCertificate(
|
||||
cfg: { x: number; y: number; size: number; font: string; color: string },
|
||||
value: string,
|
||||
) => {
|
||||
ctx.font = `400 ${cfg.size}px "${cfg.font}", serif`;
|
||||
const size = cfg === LAYOUT.internName ? fitNameText(value, cfg.size) : cfg.size;
|
||||
ctx.font = `400 ${size}px "${cfg.font}", serif`;
|
||||
ctx.fillStyle = cfg.color;
|
||||
ctx.fillText(value, canvas.width * cfg.x, canvas.height * cfg.y);
|
||||
};
|
||||
|
||||
text(LAYOUT.internName, internName);
|
||||
text(LAYOUT.internNameSmall, internName);
|
||||
text(LAYOUT.projectName, projectName);
|
||||
text(LAYOUT.internNameSmall, internName.trim().toLowerCase());
|
||||
text(LAYOUT.userposition, userposition);
|
||||
text(LAYOUT.duration, ProjectDuration);
|
||||
text(LAYOUT.certNo, certificateNo);
|
||||
text(LAYOUT.certNoSmall, "No.2026/SPI3/" + certificateNo);
|
||||
text(LAYOUT.certNoSmall, certificateNo);
|
||||
|
||||
// QR code — nanti akan diganti ke alamat domain
|
||||
const qrSize = Math.round(canvas.width * LAYOUT.qr.size);
|
||||
const qrDataUrl = await QRCode.toDataURL(
|
||||
`${window.location.origin}/verify-certificate/${verifyUrl}`,
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
export const decodeJWT = <T = any>(token: string): T | null => {
|
||||
try {
|
||||
const payload = token.split(".")[1];
|
||||
if (!payload) return null;
|
||||
|
||||
const base64 = payload
|
||||
.replace(/-/g, "+")
|
||||
.replace(/_/g, "/");
|
||||
|
||||
const padded = base64.padEnd(
|
||||
base64.length + ((4 - (base64.length % 4)) % 4),
|
||||
"="
|
||||
);
|
||||
|
||||
return JSON.parse(window.atob(padded));
|
||||
} catch (error) {
|
||||
console.error("Gagal decode JWT:", error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@@ -3,6 +3,7 @@ import { FiX } from 'react-icons/fi';
|
||||
import { FaCheck } from "react-icons/fa";
|
||||
import { IoAlertCircleOutline } from "react-icons/io5";
|
||||
|
||||
// Komponen Toast Card dengan Tailwind untuk pesan sukses dan pesan error
|
||||
function ToastCard({ t, type, title, description }: {
|
||||
t: Toast;
|
||||
type: 'success' | 'error';
|
||||
@@ -27,13 +28,15 @@ function ToastCard({ t, type, title, description }: {
|
||||
</p>
|
||||
{description && <p className="text-[13px] text-gray-700 mt-0.5">{description}</p>}
|
||||
</div>
|
||||
<button onClick={() => toast.dismiss(t.id)} className="text-gray-500 hover:text-gray-800 mt-0.5 shrink-0">
|
||||
<button onClick={() => toast.remove(t.id)} className="text-gray-500 hover:text-gray-800 mt-0.5 shrink-0">
|
||||
<FiX size={16} />
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// pemanggilan function ToastCard dengan params
|
||||
export const customToast = {
|
||||
success: (title: string, description?: string) =>
|
||||
toast.custom((t) => <ToastCard t={t} type="success" title={title} description={description} />),
|
||||
@@ -55,19 +58,19 @@ export const customToast = {
|
||||
const isHookFailure = typeof data === 'object' && data !== null && 'success' in data && (data as { success?: boolean }).success === false;
|
||||
|
||||
if (isHookFailure) {
|
||||
toast.dismiss(loadingId);
|
||||
toast.remove(loadingId);
|
||||
const result = data as { success: boolean; message?: string };
|
||||
const { title, description } = messages.error(result);
|
||||
customToast.error(title, description ?? result.message);
|
||||
throw new Error(result.message ?? 'Operasi gagal.');
|
||||
}
|
||||
|
||||
toast.dismiss(loadingId);
|
||||
toast.remove(loadingId);
|
||||
const { title, description } = messages.success(data);
|
||||
customToast.success(title, description);
|
||||
return data;
|
||||
} catch (err) {
|
||||
toast.dismiss(loadingId);
|
||||
toast.remove(loadingId);
|
||||
const { title, description } = messages.error(err);
|
||||
customToast.error(title, description ?? (err as Error)?.message);
|
||||
throw err;
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Great+Vibes&family=Grenze:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="preview" style="max-width: 100%;"></canvas>
|
||||
|
||||
<script>
|
||||
const TEMPLATE_PATH = "../../assets/template.png";
|
||||
|
||||
// LAYOUT
|
||||
const LAYOUT = {
|
||||
internName: { x: 0.57, y: 0.48, size: 140, font: "Great Vibes", color: "#800000" },
|
||||
internNameSmall: { x: 0.82, y: 0.889, size: 33, font: "Great Vibes", color: "#800000" },
|
||||
projectName: { x: 0.815, y: 0.598, size: 46, font: "Grenze", color: "#090909" },
|
||||
duration: { x: 0.692, y: 0.645, size: 48, font: "Grenze", color: "#090909" },
|
||||
certNo: { x: 0.6, y: 0.305, size: 50, font: "Grenze", color: "#090909" },
|
||||
certNoSmall: { x: 0.825, y: 0.91, size: 22, font: "Grenze", color: "#800000" },
|
||||
qr: { x: 0.77, y: 0.715, size: 0.103 },
|
||||
};
|
||||
|
||||
const DATA = {
|
||||
internName: "Jonathan Kristina",
|
||||
projectName: "Internify Proyek Humic",
|
||||
duration: "20 April 2026 - 20 Juni 2026",
|
||||
certNo: "CERT/XXXXXX/1",
|
||||
verifyUrl: "dummy-uuid-preview",
|
||||
};
|
||||
|
||||
function loadImage(src) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const img = new Image();
|
||||
img.onload = () => resolve(img);
|
||||
img.onerror = () => reject(new Error("Gagal load gambar: " + src));
|
||||
img.src = src;
|
||||
});
|
||||
}
|
||||
|
||||
async function ensureFontsLoaded() {
|
||||
await Promise.all([
|
||||
document.fonts.load('400 105px "Great Vibes"'),
|
||||
document.fonts.load('400 54px "Grenze"'),
|
||||
]);
|
||||
await document.fonts.ready;
|
||||
}
|
||||
|
||||
async function draw() {
|
||||
await ensureFontsLoaded();
|
||||
|
||||
const templateImg = await loadImage(TEMPLATE_PATH);
|
||||
|
||||
const canvas = document.getElementById("preview");
|
||||
canvas.width = templateImg.naturalWidth;
|
||||
canvas.height = templateImg.naturalHeight;
|
||||
const ctx = canvas.getContext("2d");
|
||||
|
||||
ctx.drawImage(templateImg, 0, 0);
|
||||
ctx.textAlign = "center";
|
||||
ctx.textBaseline = "middle";
|
||||
|
||||
const text = (cfg, value) => {
|
||||
ctx.font = `400 ${cfg.size}px "${cfg.font}", serif`;
|
||||
ctx.fillStyle = cfg.color;
|
||||
ctx.fillText(value, canvas.width * cfg.x, canvas.height * cfg.y);
|
||||
};
|
||||
|
||||
text(LAYOUT.internName, DATA.internName);
|
||||
text(LAYOUT.internNameSmall, DATA.internName);
|
||||
text(LAYOUT.projectName, DATA.projectName);
|
||||
text(LAYOUT.duration, DATA.duration);
|
||||
text(LAYOUT.certNo, DATA.certNo);
|
||||
text(LAYOUT.certNoSmall, DATA.certNo);
|
||||
|
||||
// QR
|
||||
const qrSize = Math.round(canvas.width * LAYOUT.qr.size);
|
||||
ctx.fillStyle = "#000";
|
||||
ctx.fillRect(canvas.width * LAYOUT.qr.x, canvas.height * LAYOUT.qr.y, qrSize, qrSize);
|
||||
}
|
||||
|
||||
draw().catch((err) => {
|
||||
document.body.insertAdjacentHTML("beforeend", `<pre style="color:red">${err.message}</pre>`);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 224 KiB |
@@ -19,35 +19,97 @@ export const useNotifications = () => {
|
||||
.finally(() => setLoading(false));
|
||||
}, []);
|
||||
|
||||
useEffect(() => { refetch(); }, [refetch]);
|
||||
useEffect(() => {
|
||||
refetch();
|
||||
|
||||
const handleNotificationUpdate = () => {
|
||||
refetch();
|
||||
};
|
||||
|
||||
window.addEventListener("notifications-updated", handleNotificationUpdate);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener(
|
||||
"notifications-updated",
|
||||
handleNotificationUpdate,
|
||||
);
|
||||
};
|
||||
}, [refetch]);
|
||||
|
||||
const markAllRead = async () => {
|
||||
try {
|
||||
const { message } = await markAllAsRead();
|
||||
setNotifications(prev => prev.map(n => ({ ...n, is_read: true })));
|
||||
return { success: true as const, message };
|
||||
|
||||
setNotifications((prev) =>
|
||||
prev.map((notification) => ({
|
||||
...notification,
|
||||
is_read: true,
|
||||
})),
|
||||
);
|
||||
|
||||
window.dispatchEvent(new Event("notifications-updated"));
|
||||
|
||||
return {
|
||||
success: true as const,
|
||||
message,
|
||||
};
|
||||
} catch (err: any) {
|
||||
const msg = err?.response?.data?.message ?? "Gagal menandai semua notifikasi.";
|
||||
const msg =
|
||||
err?.response?.data?.message ?? "Gagal menandai semua notifikasi.";
|
||||
|
||||
setError(msg);
|
||||
return { success: false as const, message: msg };
|
||||
|
||||
return {
|
||||
success: false as const,
|
||||
message: msg,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const markOneRead = async (id: number) => {
|
||||
try {
|
||||
const { message } = await markAsRead(id);
|
||||
setNotifications(prev =>
|
||||
prev.map(n => n.id === id ? { ...n, is_read: true } : n)
|
||||
|
||||
setNotifications((prev) =>
|
||||
prev.map((notification) =>
|
||||
notification.id === id
|
||||
? { ...notification, is_read: true }
|
||||
: notification,
|
||||
),
|
||||
);
|
||||
return { success: true as const, message };
|
||||
|
||||
window.dispatchEvent(new Event("notifications-updated"));
|
||||
|
||||
return {
|
||||
success: true as const,
|
||||
message,
|
||||
};
|
||||
} catch (err: any) {
|
||||
const msg = err?.response?.data?.message ?? "Gagal menandai notifikasi.";
|
||||
|
||||
setError(msg);
|
||||
return { success: false as const, message: msg };
|
||||
|
||||
return {
|
||||
success: false as const,
|
||||
message: msg,
|
||||
};
|
||||
}
|
||||
};
|
||||
//notifikasi di header, jika ada notifikasi yang belum dibaca maka akan muncul titik merah di icon bell
|
||||
const hasUnreadNotifications = notifications.some(
|
||||
(notification) => !notification.is_read,
|
||||
);
|
||||
//jumlah notifikasi yang belum dibaca
|
||||
const unreadCount = notifications.filter((n) => !n.is_read).length;
|
||||
|
||||
const unreadCount = notifications.filter(n => !n.is_read).length;
|
||||
|
||||
return { notifications, unreadCount, loading, error, refetch, markAllRead, markOneRead };
|
||||
return {
|
||||
notifications,
|
||||
unreadCount,
|
||||
hasUnreadNotifications,
|
||||
loading,
|
||||
error,
|
||||
refetch,
|
||||
markAllRead,
|
||||
markOneRead,
|
||||
};
|
||||
};
|
||||
+82
-20
@@ -1,11 +1,12 @@
|
||||
import { useState, useEffect, useCallback, useMemo } from "react";
|
||||
import type {
|
||||
ProjectTask,
|
||||
ProjectTaskDetail,
|
||||
CreateTaskPayload,
|
||||
UpdateTaskPayload,
|
||||
TaskSubmissionData,
|
||||
AdminTaskDetail,
|
||||
MentorTaskItem,
|
||||
ProjectTask,
|
||||
} from "../types/task.types";
|
||||
import {
|
||||
getProjectTasks,
|
||||
@@ -21,10 +22,10 @@ import {
|
||||
getAllMentorTasks,
|
||||
getTaskSubmissions,
|
||||
} from "../services/TaskService";
|
||||
import type { MentorTaskItem } from "../types/task.types";
|
||||
import { useCurrentUser } from "./useUser";
|
||||
import { useMyTasks } from "./useProjects";
|
||||
import type { InternTaskItem } from "../types/project.types";
|
||||
import { getProjects, getProjectById } from "../services/ProjectService";
|
||||
|
||||
// GET /task-api/projects/{id_project}/tasks
|
||||
export const useProjectTasks = (projectId: number) => {
|
||||
@@ -268,7 +269,7 @@ export const useSubmission = (
|
||||
};
|
||||
};
|
||||
|
||||
// hooks/useAllMentorTasks.ts
|
||||
// hooks/useAllMentorTasks.ts - Ambil semua tasks untuk mentor (tanpa filter project)/hanya ambil tasks yang dibuat pengguna tersebut (mentor) untuk semua project yang dia ikuti. Ini digunakan untuk menampilkan semua tasks mentor di halaman dashboard mentor.
|
||||
export const useAllMentorTasks = (enabled: boolean) => {
|
||||
const [tasks, setTasks] = useState<MentorTaskItem[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -291,36 +292,97 @@ export interface Deadline {
|
||||
label: string;
|
||||
}
|
||||
|
||||
// hooks.useRetrieveAllTasks.ts - Ambil semua tasks untuk admin tanpa adanya batasan dari pembuat task (mentor), bertujuan agar admin bisa melihat semua task yang ada di dalam database
|
||||
interface AdminTask extends ProjectTask {
|
||||
project_name: string;
|
||||
}
|
||||
export const useRetrieveAllTasks = (enabled = true) => {
|
||||
const [tasks, setTasks] = useState<AdminTask[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!enabled) return;
|
||||
|
||||
let isMounted = true;
|
||||
|
||||
const fetchAllTasks = async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const projects = await getProjects();
|
||||
const projectDetails = await Promise.all(
|
||||
projects.map((project) => getProjectById(project.id)),
|
||||
);
|
||||
|
||||
if (!isMounted) return;
|
||||
|
||||
const allTasks = projectDetails.flatMap((project) =>
|
||||
project.tasks.map((task) => ({
|
||||
...task,
|
||||
project_name: project.project_name,
|
||||
})),
|
||||
);
|
||||
setTasks(allTasks);
|
||||
} catch (err) {
|
||||
if (!isMounted) return;
|
||||
setError("Gagal memuat semua tasks.");
|
||||
} finally {
|
||||
if (!isMounted) return;
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchAllTasks();
|
||||
return () => {
|
||||
isMounted = false;
|
||||
};
|
||||
}, [enabled]);
|
||||
|
||||
return { tasks, loading, error };
|
||||
}
|
||||
|
||||
export const useDeadlines = () => {
|
||||
const { user, loading: userLoading, error: userError } = useCurrentUser();
|
||||
|
||||
const isIntern = user?.role === "intern";
|
||||
const isMentor = user?.role === "mentor";
|
||||
const isAdmin = user?.role === "admin";
|
||||
|
||||
const {
|
||||
tasks: internTasks,
|
||||
loading: internLoading,
|
||||
error: internError,
|
||||
} = useMyTasks();
|
||||
const {
|
||||
tasks: mentorTasks,
|
||||
loading: mentorLoading,
|
||||
error: mentorError,
|
||||
} = useAllMentorTasks(!isIntern && user !== null);
|
||||
const { tasks: internTasks, loading: internLoading, error: internError } = useMyTasks();
|
||||
const { tasks: mentorTasks, loading: mentorLoading, error: mentorError } = useAllMentorTasks(isMentor);
|
||||
const { tasks: allTasks, loading: allTasksLoading, error: allTasksError } = useRetrieveAllTasks(isAdmin);
|
||||
|
||||
const deadlines: Deadline[] = useMemo(() => {
|
||||
if (!user) return [];
|
||||
return isIntern
|
||||
? internTasks.map((task) => ({
|
||||
|
||||
if (isIntern) {
|
||||
return internTasks.map((task) => ({
|
||||
date: new Date(task.deadline_at),
|
||||
label: task.title,
|
||||
}))
|
||||
: mentorTasks.map((task) => ({
|
||||
}));
|
||||
}
|
||||
|
||||
if (isMentor) {
|
||||
return mentorTasks.map((task) => ({
|
||||
date: new Date(task.deadline_at),
|
||||
label: `[${task.project_name}] ${task.title}`,
|
||||
}));
|
||||
}, [isIntern, internTasks, mentorTasks, user]);
|
||||
const loading = userLoading || (isIntern ? internLoading : mentorLoading);
|
||||
const error = userError || (isIntern ? internError : mentorError);
|
||||
}
|
||||
|
||||
if (isAdmin) {
|
||||
return allTasks.map((task) => ({
|
||||
date: new Date(task.deadline_at),
|
||||
label: `[${task.project_name}] ${task.title}`,
|
||||
}));
|
||||
}
|
||||
|
||||
return [];
|
||||
}, [isAdmin, isIntern, isMentor, allTasks, internTasks, mentorTasks, user]);
|
||||
|
||||
const loading = userLoading || (isIntern ? internLoading : isMentor ? mentorLoading : allTasksLoading);
|
||||
const error = userError || (isIntern ? internError : isMentor ? mentorError : allTasksError);
|
||||
|
||||
return { deadlines, loading, error, isIntern };
|
||||
};
|
||||
|
||||
+4
-1
@@ -57,7 +57,7 @@
|
||||
background-color: var(--color-box-primary);
|
||||
border-radius: 20px;
|
||||
border: 1px solid var(--color-border);
|
||||
padding: 32px;
|
||||
padding:12px;
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
|
||||
0 2px 4px -2px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
@@ -135,6 +135,9 @@ dialog.custom-dialog::backdrop {
|
||||
padding-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
.box {
|
||||
padding: 32px;
|
||||
}
|
||||
.main-content {
|
||||
padding-block: calc(var(--spacing) * 10);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,17 @@ export const getProjectById = async (
|
||||
position: m.user?.position,
|
||||
kelompok_peminatan: m.user?.kelompok_peminatan,
|
||||
})),
|
||||
tasks: raw.tasks.map((t: any) => ({
|
||||
id: t.id,
|
||||
id_project: raw.id,
|
||||
slug: t.slug,
|
||||
title: t.title,
|
||||
description: t.description,
|
||||
deadline_at: t.deadline_at,
|
||||
submission_type: t.submission_type,
|
||||
created_at: t.created_at,
|
||||
updated_at: t.updated_at,
|
||||
})),
|
||||
template_sertificate: raw.template_sertificate,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@ export interface CertificateUser {
|
||||
id: number;
|
||||
full_name: string;
|
||||
email: string;
|
||||
intern_position: string;
|
||||
}
|
||||
|
||||
export interface CertificateProject {
|
||||
@@ -19,6 +20,7 @@ export interface Certificate {
|
||||
id_user: number;
|
||||
certificate_no: string;
|
||||
issued_at: string;
|
||||
intern_position: string;
|
||||
uuid: string;
|
||||
user: CertificateUser;
|
||||
project: CertificateProject;
|
||||
@@ -28,6 +30,7 @@ export interface Certificate {
|
||||
export interface CertificateVerification {
|
||||
uuid: string;
|
||||
intern_name: string;
|
||||
intern_position: string;
|
||||
project_name: string;
|
||||
created_at: string;
|
||||
}
|
||||
@@ -37,9 +40,18 @@ export interface CertificateTemplate {
|
||||
certificate_template: string;
|
||||
}
|
||||
|
||||
interface projectbysertif {
|
||||
project_id: number
|
||||
project_name: string;
|
||||
end_date: string;
|
||||
description: string;
|
||||
certificate_template: string
|
||||
}
|
||||
|
||||
export interface CertificateVerifyResult {
|
||||
uuid: string;
|
||||
intern_name: string;
|
||||
project_name: string;
|
||||
project: projectbysertif;
|
||||
intern_position: string;
|
||||
created_at: string;
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
|
||||
Reference in New Issue
Block a user