Compare commits
10 Commits
1ee784e70d
...
4c56279c23
| 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 EditFaq from "./Pages/EditFAQ";
|
||||||
import EditFeedback from "./Pages/EditFeedback";
|
import EditFeedback from "./Pages/EditFeedback";
|
||||||
import EditLowongan from "./Pages/EditLowongan";
|
import EditLowongan from "./Pages/EditLowongan";
|
||||||
import HomeInternPage from "./Pages/Internify/intern/HomeInternPage";
|
import HomeInternPage from "./Pages/internify/intern/HomeInternPage";
|
||||||
import { InternLayout, MentorLayout } from "./Pages/Internify/layout";
|
import { InternLayout, MentorLayout } from "./Pages/internify/layout";
|
||||||
import ProjectsPage from "./Pages/Internify/intern/ProjectsPage";
|
import ProjectsPage from "./Pages/internify/intern/ProjectsPage";
|
||||||
import ProjectDetailPage from "./Pages/Internify/intern/ProjectDetailPage";
|
import ProjectDetailPage from "./Pages/internify/intern/ProjectDetailPage";
|
||||||
import HomeMentorPage from "./Pages/Internify/mentor/HomeMentorPage";
|
import HomeMentorPage from "./Pages/internify/mentor/HomeMentorPage";
|
||||||
import MentorProjectsPage from "./Pages/Internify/mentor/BaseProjectsPage";
|
import MentorProjectsPage from "./Pages/internify/mentor/BaseProjectsPage";
|
||||||
import MentorCertificatePage from "./Pages/Internify/mentor/CertificateListPage";
|
import MentorCertificatePage from "./Pages/internify/mentor/CertificateListPage";
|
||||||
import MentorInternPage from "./Pages/Internify/mentor/InternsPage";
|
import MentorInternPage from "./Pages/internify/mentor/InternsPage";
|
||||||
import MentorDetailProject from "./Pages/Internify/mentor/ProjectsPage";
|
import MentorDetailProject from "./Pages/internify/mentor/ProjectsPage";
|
||||||
import InternifyLogin from "./Pages/Internify/LoginInternify"
|
import InternifyLogin from "./Pages/internify/LoginInternify"
|
||||||
import FAQPage from "./Pages/Internify/FAQpage";
|
import FAQPage from "./Pages/internify/FAQpage";
|
||||||
import NotificationList from "./Pages/Internify/NotificationList";
|
import NotificationList from "./Pages/internify/NotificationList";
|
||||||
import SettingsPage from "./Pages/Internify/SettingsPage";
|
import SettingsPage from "./Pages/internify/SettingsPage";
|
||||||
import TaskSubmission from "./Pages/Internify/intern/TaskSubmission";
|
import TaskSubmission from "./Pages/internify/intern/TaskSubmission";
|
||||||
import SertificateList from "./Pages/Internify/intern/InternCertList";
|
import SertificateList from "./Pages/internify/intern/InternCertList";
|
||||||
import MentorProjectsDetailPage from "./Pages/Internify/mentor/MentorProjectDetailPage";
|
import MentorProjectsDetailPage from "./Pages/internify/mentor/MentorProjectDetailPage";
|
||||||
import ViewInternSubmission from "./Pages/Internify/mentor/ViewInternSubmission";
|
import ViewInternSubmission from "./Pages/internify/mentor/ViewInternSubmission";
|
||||||
import ProtectedRoutes from "./Pages/utils/ProtectedRoute";
|
import ProtectedRoutes from "./Pages/utils/ProtectedRoute";
|
||||||
import AdminMentorPage from "./Pages/MentorPage";
|
import AdminMentorPage from "./Pages/MentorPage";
|
||||||
import CreateMentorForm from "./Pages/CreateMentorForm";
|
import CreateMentorForm from "./Pages/CreateMentorForm";
|
||||||
import EditMentorForm from "./Pages/EditMentorForm";
|
import EditMentorForm from "./Pages/EditMentorForm";
|
||||||
import NotFoundPage from "./Pages/NotFoundPage";
|
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 InternCertificatePage = lazy(() => import("./Pages/internify/intern/InternCertDetail"));
|
||||||
const MentorCertForm = lazy(() => import("./Pages/Internify/mentor/CertificateForm"));
|
const MentorCertForm = lazy(() => import("./Pages/internify/mentor/CertificateForm"));
|
||||||
const MentorCertResult = lazy(() => import("./Pages/Internify/mentor/CertificateResult"));
|
const MentorCertResult = lazy(() => import("./Pages/internify/mentor/CertificateResult"));
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
@@ -109,7 +109,7 @@ function App() {
|
|||||||
|
|
||||||
{/* Intern only */}
|
{/* Intern only */}
|
||||||
<Route element={<ProtectedRoutes allowedRoles={["intern"]} />}>
|
<Route element={<ProtectedRoutes allowedRoles={["intern"]} />}>
|
||||||
<Route path="/intern" element={<InternLayout />}>
|
<Route path="/internship" element={<InternLayout />}>
|
||||||
<Route index element={<HomeInternPage />} />
|
<Route index element={<HomeInternPage />} />
|
||||||
<Route path="projects" element={<ProjectsPage />} />
|
<Route path="projects" element={<ProjectsPage />} />
|
||||||
<Route path="certificates" element={<SertificateList />} />
|
<Route path="certificates" element={<SertificateList />} />
|
||||||
|
|||||||
@@ -1,25 +1,23 @@
|
|||||||
import { Link } from 'react-router-dom';
|
|
||||||
import { FaInstagram, FaLinkedin, FaRegEnvelope } from "react-icons/fa";
|
import { FaInstagram, FaLinkedin, FaRegEnvelope } from "react-icons/fa";
|
||||||
import logoHumic from "../assets/logo.png";
|
import logoHumic from "../assets/logo.png";
|
||||||
|
|
||||||
const internshipLinks = [
|
const internshipLinks = [
|
||||||
{ label: "Beranda", path: "/" },
|
{ label: "Beranda", path: "/" },
|
||||||
{ label: "Tentang", path: "/about-us" },
|
{ label: "Tentang", path: "/about-us" },
|
||||||
{ label: "Life At Humic", path: "" },
|
{ label: "Life At Humic", path: "/internships" },
|
||||||
{ label: "Our Developer", path: "/our-developer" }
|
{ label: "Our Developer", path: "/our-developer" }
|
||||||
];
|
];
|
||||||
|
|
||||||
const externalLinks = [
|
const externalLinks = [
|
||||||
{ label: "Humic Website", href: "https://humic.telkomuniversity.ac.id/" },
|
{ label: "Humic Website", href: "https://humic.telkomuniversity.ac.id/" },
|
||||||
{ label: "Our Activity", href: "https://humic.telkomuniversity.ac.id/humicinmedia/" },
|
{ label: "Our Activity", href: "https://humic.telkomuniversity.ac.id/humicinmedia/" },
|
||||||
{ label: "Life At Humic", href: "" },
|
{ label: "Life At Humic", href: "https://humic.telkomuniversity.ac.id/" },
|
||||||
// { label: "Our Developer", href: "#" },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const socials = [
|
const socials = [
|
||||||
{ label: "Instagram", icon: FaInstagram, href: "https://www.instagram.com/humicengineering/" },
|
{ label: "Instagram", icon: FaInstagram, href: "https://www.instagram.com/humicengineering/" },
|
||||||
{ label: "LinkedIn", icon: FaLinkedin, href: "https://www.linkedin.com/company/humic-engineering/" },
|
{ 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() {
|
export function FooterIntern() {
|
||||||
@@ -45,7 +43,7 @@ export function FooterIntern() {
|
|||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
aria-label={label}
|
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" />
|
<Icon className="w-4 h-4" />
|
||||||
</a>
|
</a>
|
||||||
@@ -60,12 +58,14 @@ export function FooterIntern() {
|
|||||||
<ul className="flex flex-col gap-0.5 font-semibold">
|
<ul className="flex flex-col gap-0.5 font-semibold">
|
||||||
{internshipLinks.map(({ label, path }) => (
|
{internshipLinks.map(({ label, path }) => (
|
||||||
<li key={label}>
|
<li key={label}>
|
||||||
<Link
|
<a
|
||||||
to={path}
|
href={path}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
className="text-[12.5px] text-gray-600 hover:text-red-800 transition-colors"
|
className="text-[12.5px] text-gray-600 hover:text-red-800 transition-colors"
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
</Link>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export default function Header({ toggleSidebar }: { toggleSidebar: () => void })
|
|||||||
const nav = useNavigate();
|
const nav = useNavigate();
|
||||||
const { user } = useCurrentUser();
|
const { user } = useCurrentUser();
|
||||||
const [imageError, setImageError] = useState(false);
|
const [imageError, setImageError] = useState(false);
|
||||||
const { unreadCount } = useNotifications();
|
const { hasUnreadNotifications } = useNotifications();
|
||||||
const photoUrl = resolveFileUrl(user?.profile_picture);
|
const photoUrl = resolveFileUrl(user?.profile_picture);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -42,7 +42,7 @@ export default function Header({ toggleSidebar }: { toggleSidebar: () => void })
|
|||||||
<div className="flex flex-row gap-6 items-center">
|
<div className="flex flex-row gap-6 items-center">
|
||||||
<button onClick={() => nav("notifications")} className="relative">
|
<button onClick={() => nav("notifications")} className="relative">
|
||||||
<Bell className="w-5 h-5 hover:text-red-800"/>
|
<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" />
|
<span className="absolute -top-1 -right-0.5 w-2.5 h-2.5 bg-red-600 rounded-full border-2 border-white" />
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -59,19 +59,19 @@ const Navbar = () => {
|
|||||||
<div className="hidden md:flex items-center gap-8 text-[18px] font-semibold">
|
<div className="hidden md:flex items-center gap-8 text-[18px] font-semibold">
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate("/about-us")}
|
onClick={() => navigate("/about-us")}
|
||||||
className="hover:text-gray-600 transition cursor-pointer"
|
className="hover:text-blue-600 transition cursor-pointer"
|
||||||
>
|
>
|
||||||
About Us
|
About Us
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={handleContactClick}
|
onClick={handleContactClick}
|
||||||
className="hover:text-gray-600 transition cursor-pointer"
|
className="hover:text-blue-600 transition cursor-pointer"
|
||||||
>
|
>
|
||||||
Contact Us
|
Contact Us
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate("/internships")}
|
onClick={() => navigate("/internships")}
|
||||||
className="hover:text-gray-600 transition cursor-pointer"
|
className="hover:text-grblueay-600 transition cursor-pointer"
|
||||||
>
|
>
|
||||||
Internship
|
Internship
|
||||||
</button>
|
</button>
|
||||||
@@ -80,7 +80,7 @@ const Navbar = () => {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigate("/login-internify");
|
navigate("/login-internify");
|
||||||
}}
|
}}
|
||||||
className="hover:text-red-600 transition cursor-pointer"
|
className="hover:text-blue-600 transition cursor-pointer"
|
||||||
>
|
>
|
||||||
Portal LMS
|
Portal LMS
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -58,12 +58,6 @@ const Landing = () => {
|
|||||||
return feedbacks[displayIndex];
|
return feedbacks[displayIndex];
|
||||||
}, [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(() => {
|
useEffect(() => {
|
||||||
// Fetch internships
|
// Fetch internships
|
||||||
fetch(`${import.meta.env.VITE_API_BASE_URL}/lowongan-magang-api/get`)
|
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/",
|
link: "https://www.linkedin.com/in/reihanramadhana/",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Ayu",
|
name: "Nomi",
|
||||||
role: "Web Designer",
|
role: "Web Designer",
|
||||||
img: ayu,
|
img: ayu,
|
||||||
link: "https://www.linkedin.com/in/anom-ayu-radhaswasti/",
|
link: "https://www.linkedin.com/in/anom-ayu-radhaswasti/",
|
||||||
|
|||||||
@@ -42,15 +42,15 @@ const NameInternBreadcrumb = ({ match }: BreadcrumbMatch) => {
|
|||||||
|
|
||||||
const breadcrumbRoutes = [
|
const breadcrumbRoutes = [
|
||||||
// --- AREA INTERN ---
|
// --- AREA INTERN ---
|
||||||
{ path: '/intern', breadcrumb: 'Home' },
|
{ path: '/internship', breadcrumb: 'Home' },
|
||||||
{ path: '/intern/projects', breadcrumb: 'Projects' },
|
{ path: '/internship/projects', breadcrumb: 'Projects' },
|
||||||
{ path: '/intern/projects/:slug', breadcrumb: ProjectBreadcrumb },
|
{ path: '/internship/projects/:slug', breadcrumb: ProjectBreadcrumb },
|
||||||
{ path: '/intern/projects/:slug/:taskSlug', breadcrumb: TaskBreadcrumb },
|
{ path: '/internship/projects/:slug/:taskSlug', breadcrumb: TaskBreadcrumb },
|
||||||
{ path: '/intern/certificates', breadcrumb: 'Certificates' },
|
{ path: '/internship/certificates', breadcrumb: 'Certificates' },
|
||||||
{ path: '/intern/certificates/:slug', breadcrumb: CertBreadcrumb },
|
{ path: '/internship/certificates/:slug', breadcrumb: CertBreadcrumb },
|
||||||
{ path: '/intern/faq', breadcrumb: 'FAQ' },
|
{ path: '/internship/faq', breadcrumb: 'FAQ' },
|
||||||
{ path: '/intern/notifications', breadcrumb: 'Notifications' },
|
{ path: '/internship/notifications', breadcrumb: 'Notifications' },
|
||||||
{ path: '/intern/settings', breadcrumb: 'Settings' },
|
{ path: '/internship/settings', breadcrumb: 'Settings' },
|
||||||
|
|
||||||
// --- AREA MENTOR / ADMIN ---
|
// --- AREA MENTOR / ADMIN ---
|
||||||
{ path: '/mentor', breadcrumb: 'Home' },
|
{ path: '/mentor', breadcrumb: 'Home' },
|
||||||
@@ -71,7 +71,7 @@ export default function Breadcrumbs(){
|
|||||||
const breadcrumbs = useBreadcrumbs(breadcrumbRoutes);
|
const breadcrumbs = useBreadcrumbs(breadcrumbRoutes);
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
const rootPaths = ['/intern', '/mentor'];
|
const rootPaths = ['/internship', '/mentor'];
|
||||||
const isOnRootPath = rootPaths.includes(location.pathname);
|
const isOnRootPath = rootPaths.includes(location.pathname);
|
||||||
const fixbreadcumbs = breadcrumbs.filter(({ match }) => {
|
const fixbreadcumbs = breadcrumbs.filter(({ match }) => {
|
||||||
if (match.pathname === '/') return false;
|
if (match.pathname === '/') return false;
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ export default function HomeCalendar() {
|
|||||||
return (
|
return (
|
||||||
<div className="px-13 py-5 bg-gray-100 animate-pulse rounded-2xl">
|
<div className="px-13 py-5 bg-gray-100 animate-pulse rounded-2xl">
|
||||||
<div className="h-[260px] rounded-xl flex items-center justify-center animate-pulse">
|
<div className="h-[260px] rounded-xl flex items-center justify-center animate-pulse">
|
||||||
<Loader2 className='w-5 h-5 animate-spin'/>
|
<Loader2 className='w-5 h-5 animate-spin' />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -103,11 +103,13 @@ export default function HomeCalendar() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="box">
|
<div className="box">
|
||||||
|
<div className="flex flex-col py-4">
|
||||||
{/* Header */}
|
{/* 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">
|
<h2 className="font-bold text-font">
|
||||||
{MONTH_NAMES[currentMonth]} {currentYear}
|
{MONTH_NAMES[currentMonth]} {currentYear}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<button
|
<button
|
||||||
onClick={prevMonth}
|
onClick={prevMonth}
|
||||||
@@ -116,6 +118,7 @@ export default function HomeCalendar() {
|
|||||||
>
|
>
|
||||||
<ChevronLeft className="w-4 h-4 text-gray-500" />
|
<ChevronLeft className="w-4 h-4 text-gray-500" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={nextMonth}
|
onClick={nextMonth}
|
||||||
className="p-1 rounded hover:bg-gray-100 transition-colors"
|
className="p-1 rounded hover:bg-gray-100 transition-colors"
|
||||||
@@ -126,70 +129,90 @@ export default function HomeCalendar() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-7 mb-1 px-5">
|
<div className="grid grid-cols-7 mb-1 px-10 md:px-0">
|
||||||
{DAY_LABELS.map(day => (
|
{DAY_LABELS.map((day) => (
|
||||||
<div key={day} className="text-center text-xs text-gray-400 font-medium py-1">
|
<div
|
||||||
|
key={day}
|
||||||
|
className="text-center text-xs text-gray-400 font-medium py-1"
|
||||||
|
>
|
||||||
{day}
|
{day}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-7 px-5">
|
<div className="grid grid-cols-7 px-10 md:px-0">
|
||||||
{/* Trailing days from prev month */}
|
{/* Trailing days from previous month */}
|
||||||
{trailingDays.map(day => (
|
{trailingDays.map((day) => (
|
||||||
<div key={`prev-${day}`} className="text-center py-2">
|
<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>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{currentDays.map(day => (
|
{currentDays.map((day) => (
|
||||||
<div key={day} className="flex justify-center items-center py-0.5">
|
<div
|
||||||
|
key={day}
|
||||||
|
className="flex justify-center items-center py-1"
|
||||||
|
>
|
||||||
|
<div className="w-7 flex items-center justify-center">
|
||||||
{isToday(day) ? (
|
{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}
|
{day}
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
<span
|
<span
|
||||||
className={`w-full h-7 flex items-center justify-center text-xs
|
className={`w-full h-7 flex items-center justify-center text-xs
|
||||||
${isBold(day) ? 'font-bold text-gray-800' : 'text-gray-700'}
|
${isBold(day)
|
||||||
${hasDeadline(day) ? 'bg-red text-white' : ''}
|
? "font-bold text-gray-800"
|
||||||
|
: "text-gray-700"
|
||||||
|
}
|
||||||
|
${hasDeadline(day)
|
||||||
|
? "bg-red text-white rounded-full"
|
||||||
|
: ""
|
||||||
|
}
|
||||||
transition-colors`}
|
transition-colors`}
|
||||||
>
|
>
|
||||||
{day}
|
{day}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{/* Leading days from next month */}
|
{/* Leading days from next month */}
|
||||||
{leadingDays.map(day => (
|
{leadingDays.map((day) => (
|
||||||
<div key={`next-${day}`} className="text-center py-2">
|
<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>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Divider */}
|
{/* Divider */}
|
||||||
<hr className="my-3 border-box-border" />
|
<hr className="my-1.5 border-box-border" />
|
||||||
|
|
||||||
{/* Upcoming Deadlines */}
|
{/* 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">
|
<p className="text-[10px] font-semibold text-font uppercase tracking-widest mb-2">
|
||||||
Upcoming Deadlines
|
Upcoming Deadlines
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{upcomingDeadlines.length > 0 ? (
|
{upcomingDeadlines.length > 0 ? (
|
||||||
<ul className="flex flex-col gap-1">
|
<ul className="flex flex-col gap-1">
|
||||||
{upcomingDeadlines.map((d, i) => (
|
{upcomingDeadlines.map((d, i) => (
|
||||||
<li key={i} className="flex items-center gap-2">
|
<li key={i} className="flex items-center gap-2">
|
||||||
<span className="w-2 h-2 rounded-full bg-red flex-shrink-0" />
|
<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>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</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>
|
</div>
|
||||||
)
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@@ -5,16 +5,7 @@ import { Mail, Lock, Eye, EyeOff } from 'lucide-react';
|
|||||||
import { useLogin } from "../../hooks/useUser";
|
import { useLogin } from "../../hooks/useUser";
|
||||||
import { customToast } from "../utils/showToast";
|
import { customToast } from "../utils/showToast";
|
||||||
import { CircleQuestionMark } from 'lucide-react';
|
import { CircleQuestionMark } from 'lucide-react';
|
||||||
|
import { decodeJWT } from "../utils/decodeJWT";
|
||||||
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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function InternifyLogin() {
|
export default function InternifyLogin() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -48,7 +39,7 @@ export default function InternifyLogin() {
|
|||||||
const decoded = decodeJWT(token);
|
const decoded = decodeJWT(token);
|
||||||
const role = decoded?.role;
|
const role = decoded?.role;
|
||||||
if (role === "intern") {
|
if (role === "intern") {
|
||||||
navigate("/intern");
|
navigate("/internship");
|
||||||
} else if (role === "mentor" || role === "admin") {
|
} else if (role === "mentor" || role === "admin") {
|
||||||
navigate("/mentor");
|
navigate("/mentor");
|
||||||
} else {
|
} else {
|
||||||
@@ -61,7 +52,13 @@ export default function InternifyLogin() {
|
|||||||
<div className="w-full flex flex-col items-center mb-8">
|
<div className="w-full flex flex-col items-center mb-8">
|
||||||
<div className="text-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">
|
<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" />
|
<img src={logo} alt="Logo" />
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-[10px] tracking-widest text-yellow-950 font-semibold mt-1 uppercase">
|
<p className="text-[10px] tracking-widest text-yellow-950 font-semibold mt-1 uppercase">
|
||||||
HUMIC LMS PORTAL
|
HUMIC LMS PORTAL
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export default function UpdateProfileDialog({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{/* Header */}
|
{/* 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 className="flex items-center gap-3">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-base font-bold text-foreground">Simpan Perubahan</h2>
|
<h2 className="text-base font-bold text-foreground">Simpan Perubahan</h2>
|
||||||
@@ -101,7 +101,7 @@ export default function UpdateProfileDialog({
|
|||||||
disabled={loading}
|
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"
|
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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</dialog>
|
</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>
|
<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]">
|
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -38,20 +38,20 @@ export default function VerificationCert() {
|
|||||||
className="[240px] h-[240x] object-cover mb-14"
|
className="[240px] h-[240x] object-cover mb-14"
|
||||||
/>
|
/>
|
||||||
<h1 className="text-2xl font-bold text-green-600 mb-6 text-center">
|
<h1 className="text-2xl font-bold text-green-600 mb-6 text-center">
|
||||||
Sertifikat Valid
|
Validasi Berhasil!
|
||||||
</h1>
|
</h1>
|
||||||
<div className="space-y-3 text-sm">
|
<div className="space-y-6 text-sm p-12 bg-card shadow-xl rounded-2xl w-1/3">
|
||||||
<div>
|
<div className="flex justify-between items-start gap-4">
|
||||||
<span className="text-font">Nama Intern</span>
|
<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>
|
||||||
<div>
|
<div className="flex justify-between items-start gap-4">
|
||||||
<span className="text-font">Proyek</span>
|
<span className="text-font">Atas Proyek Humic</span>
|
||||||
<p className="font-semibold">{verification.project_name}</p>
|
<p className="font-semibold text-right">{verification.project.project_name}</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className="flex justify-between items-start gap-4">
|
||||||
<span className="text-font">Tanggal Terbit</span>
|
<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", {
|
{new Date(verification.created_at).toLocaleDateString("id-ID", {
|
||||||
day: "numeric",
|
day: "numeric",
|
||||||
month: "long",
|
month: "long",
|
||||||
@@ -59,9 +59,19 @@ export default function VerificationCert() {
|
|||||||
})}
|
})}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</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>
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -32,7 +32,12 @@ export default function InternCertificateDetail() {
|
|||||||
};
|
};
|
||||||
}, [projectDetail, projectFromList]);
|
}, [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 =
|
const progress =
|
||||||
project && project.total_tasks > 0
|
project && project.total_tasks > 0
|
||||||
@@ -50,10 +55,8 @@ export default function InternCertificateDetail() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col lg:flex-row gap-6 items-stretch animate-pulse">
|
<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" />
|
<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 className="w-full lg:w-3/8 flex-shrink-0 h-[420px] bg-gray-200 rounded-xl" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -68,9 +71,9 @@ export default function InternCertificateDetail() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col lg:flex-row gap-6 items-stretch">
|
<div className="flex flex-col lg:flex-row gap-6 items-stretch">
|
||||||
<div className="w-full lg:w-5/8 flex flex-col">
|
<div className="w-full lg:w-5/8 flex flex-col">
|
||||||
{myCertificateForProject ? (
|
{myCertificateForProject && (project?.total_tasks ?? 0) > 0 ? (
|
||||||
<CertificateAvailable
|
<CertificateAvailable
|
||||||
project={project}
|
project={project!}
|
||||||
certificate={myCertificateForProject}
|
certificate={myCertificateForProject}
|
||||||
templateUrl={project?.certificate_template ?? ""}
|
templateUrl={project?.certificate_template ?? ""}
|
||||||
/>
|
/>
|
||||||
@@ -79,6 +82,7 @@ export default function InternCertificateDetail() {
|
|||||||
progress={progress}
|
progress={progress}
|
||||||
remainingTasks={remainingTasks}
|
remainingTasks={remainingTasks}
|
||||||
allTasksDone={allTasksDone}
|
allTasksDone={allTasksDone}
|
||||||
|
noTasks={(project?.total_tasks ?? 0) === 0}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export default function SertificateList() {
|
|||||||
<div
|
<div
|
||||||
key={item.id}
|
key={item.id}
|
||||||
className="bg-white border border-card-outline rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-shadow cursor-pointer group"
|
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 */}
|
{/* Thumbnail */}
|
||||||
<div className="p-6 pb-0">
|
<div className="p-6 pb-0">
|
||||||
@@ -79,7 +79,7 @@ export default function SertificateList() {
|
|||||||
{new Date(item.start_date).toLocaleDateString("id-ID", {
|
{new Date(item.start_date).toLocaleDateString("id-ID", {
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
month: "long",
|
month: "long",
|
||||||
})} until {new Date(item.end_date).toLocaleDateString("id-ID", {
|
})} - {new Date(item.end_date).toLocaleDateString("id-ID", {
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
month: "long",
|
month: "long",
|
||||||
})}
|
})}
|
||||||
@@ -88,7 +88,7 @@ export default function SertificateList() {
|
|||||||
{item.project_name}
|
{item.project_name}
|
||||||
</p>
|
</p>
|
||||||
<p className="text-xs text-font mt-1">
|
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ export default function ProjectsPage() {
|
|||||||
|
|
||||||
if (projects.length === 0) {
|
if (projects.length === 0) {
|
||||||
return (
|
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="" />
|
<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>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
|||||||
|
|
||||||
const duration = formatDateRange(project?.start_date, project?.end_date)
|
const duration = formatDateRange(project?.start_date, project?.end_date)
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!templateUrl) return;
|
if (!templateUrl) return;
|
||||||
const verifyUrl = `${window.location.origin}/verify-certificate/${certificate.uuid}`;
|
const verifyUrl = `${window.location.origin}/verify-certificate/${certificate.uuid}`;
|
||||||
@@ -42,7 +41,7 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
|||||||
generateCertificate(
|
generateCertificate(
|
||||||
resolveFileUrl(templateUrl),
|
resolveFileUrl(templateUrl),
|
||||||
certificate.user.full_name,
|
certificate.user.full_name,
|
||||||
certificate.project.project_name,
|
certificate.intern_position,
|
||||||
certificate.certificate_no,
|
certificate.certificate_no,
|
||||||
duration,
|
duration,
|
||||||
verifyUrl,
|
verifyUrl,
|
||||||
@@ -82,12 +81,17 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleShareLinkedIn = () => {
|
const handleShareLinkedIn = () => {
|
||||||
|
|
||||||
|
const issueDate = new Date(certificate.issued_at.replace(" ", "T"));
|
||||||
const verifyUrl = `${window.location.origin}/verify-certificate/${certificate.uuid}`;
|
const verifyUrl = `${window.location.origin}/verify-certificate/${certificate.uuid}`;
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
startTask: "CERTIFICATION_NAME",
|
startTask: "CERTIFICATION_NAME",
|
||||||
name: certificate.project.project_name,
|
name: "Penyelesaian Kerja Magang Instansi CoE HUMIC Engineering Proyek: " + certificate.project.project_name,
|
||||||
organizationName: "Internify",
|
issueYear: String(issueDate.getFullYear()),
|
||||||
|
issueMonth: String(issueDate.getMonth() + 1),
|
||||||
|
organizationName: "CoE Humic Engineering",
|
||||||
certUrl: verifyUrl,
|
certUrl: verifyUrl,
|
||||||
|
|
||||||
certId: certificate.certificate_no,
|
certId: certificate.certificate_no,
|
||||||
});
|
});
|
||||||
window.open(
|
window.open(
|
||||||
@@ -100,7 +104,7 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
{/* Certificate Card */}
|
{/* 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 ? (
|
{loadingPreview ? (
|
||||||
<div className="w-[550px] h-[350px] flex items-center justify-center text-gray-400 text-sm">
|
<div className="w-[550px] h-[350px] flex items-center justify-center text-gray-400 text-sm">
|
||||||
Memuat sertifikat...
|
Memuat sertifikat...
|
||||||
@@ -109,7 +113,7 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
|||||||
<img
|
<img
|
||||||
src={previewUrl}
|
src={previewUrl}
|
||||||
alt="Certificate"
|
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">
|
<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>
|
</div>
|
||||||
|
|
||||||
{/* Program Summary */}
|
{/* Program Summary */}
|
||||||
<div className="grid grid-cols-2 gap-5">
|
<div className="grid md:grid-cols-2 gap-5">
|
||||||
<div className="bg-white rounded-2xl border border-card-outline shadow-sm p-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">
|
<div className="flex items-center gap-2 mb-4">
|
||||||
<h3 className="font-semibold text-gray-800 text-sm">Ringkasan Program</h3>
|
<h3 className="font-semibold text-gray-800 text-sm">Ringkasan Program</h3>
|
||||||
</div>
|
</div>
|
||||||
@@ -128,26 +132,26 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
|||||||
{[
|
{[
|
||||||
{ label: "Nama Program", value: project?.project_name ?? "-" },
|
{ label: "Nama Program", value: project?.project_name ?? "-" },
|
||||||
{ label: "Durasi", value: duration },
|
{ label: "Durasi", value: duration },
|
||||||
{ label: "No. Sertifikat", value: certificate.certificate_no ?? "-" },
|
{ label: "No. Sertifikat", value: certificate.certificate_no ? certificate.certificate_no : "-" },
|
||||||
].map((row) => (
|
].map((row) => (
|
||||||
<div
|
<div
|
||||||
key={row.label}
|
key={row.label}
|
||||||
className="flex justify-between items-center text-sm border-b border-card-outline pb-2 last:border-0"
|
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 text-start text-xs md:text-sm">{row.label}</span>
|
||||||
<span className="text-font-shade font-bold">{row.value}</span>
|
<span className="text-font-shade font-bold text-end text-xs md:text-sm">{row.value}</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{/* End Program Summary */}
|
||||||
<div className="bg-white rounded-2xl border border-card-outline shadow-sm p-5">
|
<div className="bg-box-primary rounded-2xl border border-box-border shadow-sm p-5">
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
{/* Unduh Sertifikat */}
|
{/* Unduh Sertifikat */}
|
||||||
<button
|
<button
|
||||||
onClick={handleDownloadPdf}
|
onClick={handleDownloadPdf}
|
||||||
disabled={downloadingPdf}
|
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" />
|
<Download className="w-4 h-4" />
|
||||||
{downloadingPdf ? "Memproses" : "Unduh Sertifikat"}
|
{downloadingPdf ? "Memproses" : "Unduh Sertifikat"}
|
||||||
@@ -156,11 +160,11 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
|||||||
{/* Bagikan ke LinkedIn */}
|
{/* Bagikan ke LinkedIn */}
|
||||||
<button
|
<button
|
||||||
onClick={handleShareLinkedIn}
|
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 */}
|
{/* LinkedIn icon */}
|
||||||
<svg className="w-4 h-4 fill-white" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
<svg className="w-4 h-4 fill-white" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/>
|
<path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z" />
|
||||||
</svg>
|
</svg>
|
||||||
Tambah ke Profil LinkedIn
|
Tambah ke Profil LinkedIn
|
||||||
</button>
|
</button>
|
||||||
@@ -170,20 +174,20 @@ export default function CertificateAvailable({ project, certificate, templateUrl
|
|||||||
<button
|
<button
|
||||||
onClick={handleDownloadImage}
|
onClick={handleDownloadImage}
|
||||||
disabled={downloadingImg}
|
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">
|
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-5 h-5" />
|
>
|
||||||
{downloadingImg ? "Memproses" : "Cetak"}
|
<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>
|
||||||
<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-1 md:py-3.5 rounded-xl text-sm hover:cursor-pointer"
|
||||||
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"
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigator.clipboard.writeText(`${window.location.origin}/verify-certificate/${certificate.uuid}`);
|
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" />
|
<Link className="w-4 h-4 md:w-5 md:h-5" />
|
||||||
Salin Link
|
<span className="text-xs md:text-sm">Salin Link</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { useMyCertificates } from "../../../../hooks/useCertificates";
|
|||||||
export default function SertificateHistory() {
|
export default function SertificateHistory() {
|
||||||
const { certificates, loading, error } = useMyCertificates();
|
const { certificates, loading, error } = useMyCertificates();
|
||||||
const displayed = certificates.slice(0, 3);
|
const displayed = certificates.slice(0, 3);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-box-primary rounded-2xl border border-box-border shadow-sm p-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">
|
<div className="flex items-center gap-2 mb-4">
|
||||||
@@ -36,11 +35,12 @@ export default function SertificateHistory() {
|
|||||||
{displayed.map((item: Certificate) => (
|
{displayed.map((item: Certificate) => (
|
||||||
<div
|
<div
|
||||||
key={item.id}
|
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">
|
<div className="w-full">
|
||||||
<p className="text-xs text-gray-400">
|
<p className="text-xs text-gray-400">
|
||||||
{new Date(item.issued_at).toLocaleDateString("id-ID", {
|
{new Date(item.issued_at).toLocaleDateString("id-ID", {
|
||||||
|
day: "numeric",
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
month: "long",
|
month: "long",
|
||||||
})}
|
})}
|
||||||
@@ -48,7 +48,7 @@ export default function SertificateHistory() {
|
|||||||
<p className="text-sm font-semibold text-gray-800 leading-tight">
|
<p className="text-sm font-semibold text-gray-800 leading-tight">
|
||||||
{item.project.project_name}
|
{item.project.project_name}
|
||||||
</p>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
// CertificateNotAvailable.tsx
|
import { Clock, Lock } from "lucide-react";
|
||||||
import { Clock, Lock, Award } from "lucide-react";
|
import { FaAward } from "react-icons/fa";
|
||||||
|
import { ListTodo } from "lucide-react";
|
||||||
|
|
||||||
interface CertificateNotAvailableProps {
|
interface CertificateNotAvailableProps {
|
||||||
progress: number;
|
progress: number;
|
||||||
remainingTasks: number;
|
remainingTasks: number;
|
||||||
allTasksDone?: boolean;
|
allTasksDone?: boolean;
|
||||||
|
noTasks?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function CertificateNotAvailable({
|
export default function CertificateNotAvailable({
|
||||||
progress,
|
progress,
|
||||||
remainingTasks,
|
remainingTasks,
|
||||||
allTasksDone = false,
|
allTasksDone = false,
|
||||||
|
noTasks = false,
|
||||||
}: CertificateNotAvailableProps) {
|
}: CertificateNotAvailableProps) {
|
||||||
return (
|
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">
|
<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="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-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">
|
<div className="w-26 h-26 flex items-center rounded-lg justify-center bg-gray-300">
|
||||||
{allTasksDone ? (
|
{noTasks ? (
|
||||||
<Award className="w-12 h-12 text-green-600" />
|
<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>
|
||||||
<div className="absolute -bottom-2 -right-2 w-7 h-7 bg-amber-500 rounded- flex items-center justify-center shadow-md">
|
<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>
|
||||||
</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>
|
<h2 className="text-[37px] font-bold text-gray-900 mb-3">Selamat!</h2>
|
||||||
<p className="text-gray-500 text-[17px] mb-6 text-center">
|
<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>;
|
if (error) return <p className="text-red-500 text-sm">{error}</p>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className=''>
|
<div>
|
||||||
<h2 className="text-lg font-semibold text-font-shade mb-5">Projects</h2>
|
<h2 className="text-lg font-semibold text-font-shade mb-5">Projects</h2>
|
||||||
|
|
||||||
{projects.length === 0 ? (
|
{projects.length === 0 ? (
|
||||||
@@ -33,7 +33,7 @@ const HomeProjectList = () => {
|
|||||||
{projects.map((project) => (
|
{projects.map((project) => (
|
||||||
<div
|
<div
|
||||||
key={project.id}
|
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"
|
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
|
<div
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export default function TaskCard({ task }: { task: InternTaskItem }) {
|
|||||||
return (
|
return (
|
||||||
<div
|
<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"
|
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="flex-1 min-w-0">
|
||||||
<div className="md:hidden mb-[8px]">
|
<div className="md:hidden mb-[8px]">
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ export default function ProjectTimeline({ tasks }: { tasks: InternTaskItem[] })
|
|||||||
active ? 'bg-red' : 'bg-gray-400'
|
active ? 'bg-red' : 'bg-gray-400'
|
||||||
} ${isToday ? 'shadow-md' : ''}`}
|
} ${isToday ? 'shadow-md' : ''}`}
|
||||||
/>
|
/>
|
||||||
<div className={`text-[11px] font-semibold ${isToday ? 'text-red' : 'text-font'}`}>
|
<div className={`text-[14px] font-semibold ${isToday ? 'text-red' : 'text-font'}`}>
|
||||||
{isToday ? 'Hari ini' : formatDate(task.deadline_at)}
|
{task.title}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs text-font mt-px leading-[1.3]">
|
<div className="text-xs text-font mt-px leading-[1.3]">
|
||||||
{task.title}
|
{isToday ? 'Hari ini' : formatDate(task.deadline_at)}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const ProjectCard = (project: Project) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<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"
|
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 */}
|
{/* Thumbnail */}
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ import { MdOutlineAssignment, MdLogout } from "react-icons/md";
|
|||||||
import { HiUser } from "react-icons/hi2";
|
import { HiUser } from "react-icons/hi2";
|
||||||
|
|
||||||
const navItems = [
|
const navItems = [
|
||||||
{ label: "Home", icon: GrHomeRounded, path: "/intern" },
|
{ label: "Home", icon: GrHomeRounded, path: "/internship" },
|
||||||
{ label: "List Projects", icon: MdOutlineAssignment, path: "/intern/projects" },
|
{ label: "List Projects", icon: MdOutlineAssignment, path: "/internship/projects" },
|
||||||
{ label: "Certificates", icon: Award, path: "/intern/certificates" },
|
{ label: "Certificates", icon: Award, path: "/internship/certificates" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const prefItems = [
|
const prefItems = [
|
||||||
{ label: "Settings", icon: Settings, path: "/intern/settings" },
|
{ label: "Settings", icon: Settings, path: "/internship/settings" },
|
||||||
{ label: "FAQ", icon: HelpCircle, path: "/intern/faq" },
|
{ label: "FAQ", icon: HelpCircle, path: "/internship/faq" },
|
||||||
{ label: "Logout", icon: MdLogout, path: "/login-internify", danger: true, isLogout: true },
|
{ label: "Logout", icon: MdLogout, path: "/login-internify", danger: true, isLogout: true },
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ export default function SidebarIntern({ isOpen, closeSidebar }: SidebarProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
document.cookie = "token=; path=/; max-age=86400; SameSite=Strict";
|
document.cookie = "token=; Max-Age=0; path=/; SameSite=Strict";
|
||||||
|
|
||||||
closeSidebar();
|
closeSidebar();
|
||||||
navigate("/login-internify", { replace: true });
|
navigate("/login-internify", { replace: true });
|
||||||
|
|||||||
@@ -15,13 +15,31 @@ interface SubmitStatusTableProps {
|
|||||||
|
|
||||||
function getTimeEarly(submittedAt: Date, deadline: Date): string {
|
function getTimeEarly(submittedAt: Date, deadline: Date): string {
|
||||||
const diffMs = deadline.getTime() - submittedAt.getTime();
|
const diffMs = deadline.getTime() - submittedAt.getTime();
|
||||||
if (diffMs <= 0) return "Submitted after deadline";
|
|
||||||
const diffHours = Math.floor(diffMs / (1000 * 60 * 60));
|
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 days = Math.floor(diffHours / 24);
|
||||||
const hours = diffHours % 24;
|
const hours = diffHours % 24;
|
||||||
const parts = [];
|
|
||||||
if (days > 0) parts.push(`${days} day${days > 1 ? "s" : ""}`);
|
if (days > 0) parts.push(`${days} day${days > 1 ? "s" : ""}`);
|
||||||
if (hours > 0) parts.push(`${hours} hour${hours > 1 ? "s" : ""}`);
|
if (hours > 0) parts.push(`${hours} hour${hours > 1 ? "s" : ""}`);
|
||||||
|
|
||||||
return `Assignment was submitted ${parts.join(" ")} early`;
|
return `Assignment was submitted ${parts.join(" ")} early`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,14 @@ export default function TaskFormFile({ taskId, projectId, deadline, initialSubmi
|
|||||||
selectedFiles.forEach((file) => {
|
selectedFiles.forEach((file) => {
|
||||||
const ext = file.name.split(".").pop()?.toLowerCase();
|
const ext = file.name.split(".").pop()?.toLowerCase();
|
||||||
if (ext && allowedExtensions.includes(ext)) {
|
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]);
|
if (validFiles.length > 0) setFiles((prev) => [...prev, ...validFiles]);
|
||||||
|
|||||||
@@ -34,18 +34,14 @@ export default function TaskFormLink({
|
|||||||
loading: isEditing ? "Memperbarui Link..." : "Mengirim Link...",
|
loading: isEditing ? "Memperbarui Link..." : "Mengirim Link...",
|
||||||
success: (res) => ({
|
success: (res) => ({
|
||||||
title: isEditing ? "Link diperbaharui" : "Link berhasil dikirim",
|
title: isEditing ? "Link diperbaharui" : "Link berhasil dikirim",
|
||||||
description:
|
description: res?.message
|
||||||
res?.message ??
|
// ?? (isEditing ? "Perubahan submission Anda telah disimpan." : "Link berhasil dikirim."),
|
||||||
(isEditing
|
|
||||||
? "Perubahan submission Anda telah disimpan."
|
|
||||||
: "Link berhasil dikirim."),
|
|
||||||
}),
|
}),
|
||||||
error: (err) => ({
|
error: (err) => ({
|
||||||
title: isEditing ? "Gagal memperbarui link!" : "Gagal mengirim link!",
|
title: isEditing ? "Gagal memperbarui link!" : "Gagal mengirim link!",
|
||||||
description:
|
description:
|
||||||
err?.response?.data?.message ||
|
err?.response?.data?.message || err?.message
|
||||||
err?.message ||
|
// || "Link yang anda submit gagal dikirim",
|
||||||
"Link yang anda submit gagal dikirim",
|
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,13 +5,6 @@ import CreateProjectModal from './components/CreateProjectDialog';
|
|||||||
import { useProjectsByRole } from '../../../hooks/useListProjects';
|
import { useProjectsByRole } from '../../../hooks/useListProjects';
|
||||||
import TeamPana from '../../../assets/Team-pana.svg';
|
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() {
|
export default function MentorProjectsPage() {
|
||||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||||
const { projects, loading, error, refetch } = useProjectsByRole();
|
const { projects, loading, error, refetch } = useProjectsByRole();
|
||||||
@@ -34,8 +27,9 @@ export default function MentorProjectsPage() {
|
|||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-row gap-3 w-full">
|
<div className="flex flex-row gap-3 w-full">
|
||||||
{[...Array(4)].map((_) => (
|
{[...Array(4)].map((_, index) => (
|
||||||
<MentorProjectCardSkeleton />
|
<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>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const HomeMentorPage = () => {
|
|||||||
<HomeHeader />
|
<HomeHeader />
|
||||||
<div className="flex flex-col gap-5">
|
<div className="flex flex-col gap-5">
|
||||||
<div className="">
|
<div className="">
|
||||||
<div className="bg-white border border-box-border rounded-xl p-6">
|
<div>
|
||||||
<HomeMentorProject />
|
<HomeMentorProject />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useParams, useLocation } from "react-router-dom";
|
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 { useTaskSubmissions } from "../../../hooks/useTasks";
|
||||||
import type { DisplayStatus } from "../../../types/task.types";
|
import type { DisplayStatus } from "../../../types/task.types";
|
||||||
import { StatusTable } from "./components/StatusSubmissionTable";
|
import { StatusTable } from "./components/StatusSubmissionTable";
|
||||||
@@ -50,8 +50,8 @@ export default function ViewInternSubmission() {
|
|||||||
{task.title}
|
{task.title}
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-sm text-gray-500 flex items-center gap-1.5">
|
<p className="text-sm text-gray-500 flex items-center gap-1.5">
|
||||||
<Clock className="w-3.5 h-3.5" />
|
<User2 className="w-3.5 h-3.5" />
|
||||||
{internSubmission.full_name} — {internSubmission.email}
|
{internSubmission.full_name}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ export default function AddInternsModal({ isOpen, onClose, userId }: AddInternsM
|
|||||||
const { projects, loading: loadingProjects } = useProjects("active");
|
const { projects, loading: loadingProjects } = useProjects("active");
|
||||||
const { interns, loading: loadingInterns } = useAssignableInterns();
|
const { interns, loading: loadingInterns } = useAssignableInterns();
|
||||||
|
|
||||||
console.log(projects)
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const dialog = dialogRef.current;
|
const dialog = dialogRef.current;
|
||||||
if (!dialog) return;
|
if (!dialog) return;
|
||||||
|
|||||||
@@ -132,13 +132,6 @@ export default function CertResultTable({ certificates, templateUrl }: Certifica
|
|||||||
: <Download className="w-4 h-4" />
|
: <Download className="w-4 h-4" />
|
||||||
}
|
}
|
||||||
</button>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export default function CreateProjectModal({ isOpen, onClose, onSuccess }: Creat
|
|||||||
icon: PROJECT_ICON_MAP[id],
|
icon: PROJECT_ICON_MAP[id],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
//open/close doalog komponen
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const dialog = dialogRef.current;
|
const dialog = dialogRef.current;
|
||||||
if (!dialog) return;
|
if (!dialog) return;
|
||||||
@@ -54,8 +55,22 @@ export default function CreateProjectModal({ isOpen, onClose, onSuccess }: Creat
|
|||||||
};
|
};
|
||||||
}, [isOpen, onClose]);
|
}, [isOpen, onClose]);
|
||||||
|
|
||||||
const handleAddEmail = (emailToAdd?: string) => {
|
// tutup dropdown email di luar kotak
|
||||||
const email = (emailToAdd ?? emailInput).trim();
|
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)) {
|
if (email && !invitedEmails.includes(email)) {
|
||||||
setInvitedEmails([...invitedEmails, email]);
|
setInvitedEmails([...invitedEmails, email]);
|
||||||
setEmailInput("");
|
setEmailInput("");
|
||||||
@@ -182,34 +197,23 @@ export default function CreateProjectModal({ isOpen, onClose, onSuccess }: Creat
|
|||||||
<label className="text-xs font-bold text-gray-700 tracking-wide">
|
<label className="text-xs font-bold text-gray-700 tracking-wide">
|
||||||
Invite via Gmail
|
Invite via Gmail
|
||||||
</label>
|
</label>
|
||||||
{/* Input email + dropdown sugesti intern */}
|
{/* filterisasi email */}
|
||||||
<div ref={emailSectionRef} className="relative">
|
<div ref={emailSectionRef} className="relative">
|
||||||
<div className="relative flex items-center">
|
<div className="relative flex items-center">
|
||||||
<span className="absolute left-3.5 text-gray-400">
|
<span className="absolute left-3.5 text-gray-400">
|
||||||
<LuMail className="w-4 h-4 stroke-[2.5]" />
|
<LuMail className="w-4 h-4 stroke-[2.5]" />
|
||||||
</span>
|
</span>
|
||||||
<input
|
<input
|
||||||
type="email"
|
type="text"
|
||||||
placeholder="intern.name@gmail.com"
|
placeholder="cari intern berdasarkan nama/email"
|
||||||
value={emailInput}
|
value={emailInput}
|
||||||
onChange={(e) => { setEmailInput(e.target.value); setShowDropdown(true); }}
|
onChange={(e) => { setEmailInput(e.target.value); setShowDropdown(true); }}
|
||||||
onFocus={() => setShowDropdown(true)}
|
onFocus={() => setShowDropdown(true)}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Escape') setShowDropdown(false)
|
||||||
e.preventDefault();
|
|
||||||
handleAddEmail();
|
|
||||||
}
|
|
||||||
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"
|
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>
|
</div>
|
||||||
|
|
||||||
{/* Dropdown daftar intern */}
|
{/* Dropdown daftar intern */}
|
||||||
@@ -231,12 +235,16 @@ export default function CreateProjectModal({ isOpen, onClose, onSuccess }: Creat
|
|||||||
<button
|
<button
|
||||||
key={intern.id}
|
key={intern.id}
|
||||||
type="button"
|
type="button"
|
||||||
onMouseDown={(e) => { e.preventDefault(); handleAddEmail(intern.email); }}
|
onMouseDown={(e) => {
|
||||||
className="w-full flex items-center gap-3 px-6 py-2.5 hover:bg-gray-50 transition-colors text-left"
|
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">
|
<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-[10px] font-semibold text-gray-800 truncate">{intern.full_name}</span>
|
||||||
<span className="text-[11px] text-gray-400 truncate">{intern.email}</span>
|
<span className="text-[8px] text-gray-400 truncate">{intern.email}</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ export default function EditSubmissionModal({
|
|||||||
}: EditTaskModalProps) {
|
}: EditTaskModalProps) {
|
||||||
const dialogRef = useRef<HTMLDialogElement>(null);
|
const dialogRef = useRef<HTMLDialogElement>(null);
|
||||||
const { update, loading, error } = useUpdateTask();
|
const { update, loading, error } = useUpdateTask();
|
||||||
|
|
||||||
// Form States — diinisialisasi dari props task
|
|
||||||
const [taskTitle, setTaskTitle] = useState(task.title);
|
const [taskTitle, setTaskTitle] = useState(task.title);
|
||||||
const [description, setDescription] = useState(task.description);
|
const [description, setDescription] = useState(task.description);
|
||||||
const [deadlineDate, setDeadlineDate] = useState(
|
const [deadlineDate, setDeadlineDate] = useState(
|
||||||
@@ -32,7 +30,9 @@ export default function EditSubmissionModal({
|
|||||||
);
|
);
|
||||||
const [submissionType, setSubmissionType] = useState<SubmissionType>(task.submission_type);
|
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(() => {
|
useEffect(() => {
|
||||||
setTaskTitle(task.title);
|
setTaskTitle(task.title);
|
||||||
setDescription(task.description);
|
setDescription(task.description);
|
||||||
@@ -108,7 +108,7 @@ export default function EditSubmissionModal({
|
|||||||
|
|
||||||
{/* Error Message */}
|
{/* Error Message */}
|
||||||
{error && (
|
{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}
|
{error}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -148,9 +148,18 @@ export default function EditSubmissionModal({
|
|||||||
required
|
required
|
||||||
value={deadlineDate}
|
value={deadlineDate}
|
||||||
onChange={(e) => setDeadlineDate(e.target.value)}
|
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>
|
</div>
|
||||||
|
{isDeadlinePast && (
|
||||||
|
<p className="text-xs text-red-500 font-medium mt-1">
|
||||||
|
Tenggat waktu tidak boleh sebelum hari ini.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-1.5">
|
||||||
@@ -200,7 +209,7 @@ export default function EditSubmissionModal({
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="submit"
|
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"
|
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]" />
|
<LuSave className="w-4 h-4 stroke-[2.5]" />
|
||||||
|
|||||||
@@ -15,14 +15,12 @@ interface EditTaskModalProps {
|
|||||||
export default function EditTaskModal({ isOpen, onClose, task, onSuccess }: EditTaskModalProps) {
|
export default function EditTaskModal({ isOpen, onClose, task, onSuccess }: EditTaskModalProps) {
|
||||||
const dialogRef = useRef<HTMLDialogElement>(null);
|
const dialogRef = useRef<HTMLDialogElement>(null);
|
||||||
const { update, loading } = useUpdateTask();
|
const { update, loading } = useUpdateTask();
|
||||||
|
|
||||||
const [taskTitle, setTaskTitle] = useState(task.title);
|
const [taskTitle, setTaskTitle] = useState(task.title);
|
||||||
const [description, setDescription] = useState(task.description);
|
const [description, setDescription] = useState(task.description);
|
||||||
const [deadlineDate, setDeadlineDate] = useState(task.deadline_at.split("T")[0]);
|
const [deadlineDate, setDeadlineDate] = useState(task.deadline_at.split("T")[0]);
|
||||||
const [specificTime, setSpecificTime] = useState(task.deadline_at.split("T")[1]?.slice(0, 5) ?? "");
|
const [specificTime, setSpecificTime] = useState(task.deadline_at.split("T")[1]?.slice(0, 5) ?? "");
|
||||||
const [submissionType, setSubmissionType] = useState<SubmissionType>(task.submission_type);
|
const [submissionType, setSubmissionType] = useState<SubmissionType>(task.submission_type);
|
||||||
|
|
||||||
// Reset tiap task berubah
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTaskTitle(task.title);
|
setTaskTitle(task.title);
|
||||||
setDescription(task.description);
|
setDescription(task.description);
|
||||||
|
|||||||
@@ -118,12 +118,14 @@ export default function EligibleInternTable({
|
|||||||
id: intern.id_user,
|
id: intern.id_user,
|
||||||
id_project: project.id,
|
id_project: project.id,
|
||||||
id_user: intern.id_user,
|
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),
|
issued_at: new Date().toISOString().slice(0, 10),
|
||||||
uuid: "HANYA SEBATAS PREVIEW",
|
uuid: "HANYA SEBATAS PREVIEW",
|
||||||
|
intern_position: "[Posisi Intern]",
|
||||||
user: {
|
user: {
|
||||||
id: intern.id_user,
|
id: intern.id_user,
|
||||||
full_name: intern.full_name,
|
full_name: intern.full_name,
|
||||||
|
intern_position: "[Posisi Intern]",
|
||||||
email: intern.email,
|
email: intern.email,
|
||||||
},
|
},
|
||||||
project: {
|
project: {
|
||||||
@@ -185,12 +187,12 @@ export default function EligibleInternTable({
|
|||||||
const blob = await generateCertificate(
|
const blob = await generateCertificate(
|
||||||
templateUrl,
|
templateUrl,
|
||||||
cert.user.full_name,
|
cert.user.full_name,
|
||||||
cert.project.project_name,
|
cert.intern_position,
|
||||||
cert.certificate_no,
|
cert.certificate_no,
|
||||||
duration,
|
duration,
|
||||||
cert.uuid,
|
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 (
|
return (
|
||||||
<div className='flex flex-col'>
|
<div className='flex flex-col box'>
|
||||||
<div className='flex flex-row justify-between mb-3 items-center'>
|
<div className='flex flex-row justify-between mb-5 items-center'>
|
||||||
<h2 className="text-lg font-semibold text-gray-800">Projects</h2>
|
<h2 className="text-lg font-semibold text-gray-800">Projects</h2>
|
||||||
<button
|
<button
|
||||||
className='bg-card p-1.5 rounded-lg font-bold hover:bg-card-hover border border-card-outline'
|
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"
|
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)}
|
{intern.name.charAt(0)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ export default function MentorTaskCard({ task }: {task: InternTaskItem}) {
|
|||||||
navigate(`/mentor/projects/${slug}/${task.slug}?type=${task.submission_type}`)
|
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 (
|
return (
|
||||||
<div
|
<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"
|
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}
|
{task.title}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-[13px] text-[#666]">
|
<div className="text-[13px] text-[#666]">
|
||||||
{task.description}
|
{truncateText(task.description)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export default function SidebarMentor({ isOpen, closeSidebar }: SidebarProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
document.cookie = "token=; path=/; max-age=86400; SameSite=Strict";
|
document.cookie = "token=; Max-Age=0; path=/; SameSite=Strict";
|
||||||
|
|
||||||
closeSidebar();
|
closeSidebar();
|
||||||
navigate("/login-internify", { replace: true });
|
navigate("/login-internify", { replace: true });
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export const previewCertificate = async (
|
|||||||
const blob = await generateCertificate(
|
const blob = await generateCertificate(
|
||||||
resolveFileUrl(templateUrl),
|
resolveFileUrl(templateUrl),
|
||||||
cert.user.full_name,
|
cert.user.full_name,
|
||||||
cert.project.project_name,
|
cert.intern_position,
|
||||||
cert.certificate_no,
|
cert.certificate_no,
|
||||||
formatDateRange(cert.project.start_date, cert.project.end_date),
|
formatDateRange(cert.project.start_date, cert.project.end_date),
|
||||||
cert.uuid,
|
cert.uuid,
|
||||||
@@ -85,11 +85,11 @@ export const downloadCertificatePdf = async (
|
|||||||
cert: Certificate,
|
cert: Certificate,
|
||||||
templateUrl: string,
|
templateUrl: string,
|
||||||
): Promise<void> => {
|
): 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(
|
const blob = await generateCertificate(
|
||||||
resolveFileUrl(templateUrl),
|
resolveFileUrl(templateUrl),
|
||||||
cert.user.full_name,
|
cert.user.full_name,
|
||||||
cert.project.project_name,
|
cert.intern_position,
|
||||||
cert.certificate_no,
|
cert.certificate_no,
|
||||||
formatDateRange(cert.project.start_date, cert.project.end_date),
|
formatDateRange(cert.project.start_date, cert.project.end_date),
|
||||||
cert.uuid,
|
cert.uuid,
|
||||||
@@ -125,11 +125,11 @@ export const downloadCertificateImage = async (
|
|||||||
templateUrl: string,
|
templateUrl: string,
|
||||||
format: "png" | "jpg" = "png",
|
format: "png" | "jpg" = "png",
|
||||||
): Promise<void> => {
|
): 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(
|
const blob = await generateCertificate(
|
||||||
resolveFileUrl(templateUrl),
|
resolveFileUrl(templateUrl),
|
||||||
cert.user.full_name,
|
cert.user.full_name,
|
||||||
cert.project.project_name,
|
cert.intern_position,
|
||||||
cert.certificate_no,
|
cert.certificate_no,
|
||||||
formatDateRange(cert.project.start_date, cert.project.end_date),
|
formatDateRange(cert.project.start_date, cert.project.end_date),
|
||||||
cert.uuid,
|
cert.uuid,
|
||||||
@@ -192,12 +192,12 @@ export const downloadAllCertificatesZip = async (
|
|||||||
const blob = await generateCertificate(
|
const blob = await generateCertificate(
|
||||||
resolveFileUrl(templateUrl),
|
resolveFileUrl(templateUrl),
|
||||||
cert.user.full_name,
|
cert.user.full_name,
|
||||||
cert.project.project_name,
|
cert.intern_position,
|
||||||
cert.certificate_no,
|
cert.certificate_no,
|
||||||
formatDateRange(cert.project.start_date, cert.project.end_date),
|
formatDateRange(cert.project.start_date, cert.project.end_date),
|
||||||
cert.uuid,
|
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);
|
onProgress?.(i + 1, total);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@@ -205,7 +205,7 @@ export const downloadAllCertificatesZip = async (
|
|||||||
const zipBlob = await zip.generateAsync({ type: "blob" });
|
const zipBlob = await zip.generateAsync({ type: "blob" });
|
||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
a.href = URL.createObjectURL(zipBlob);
|
a.href = URL.createObjectURL(zipBlob);
|
||||||
a.download = `Sertifikat - ${projectName}.zip`;
|
a.download = `Sertifikat_${projectName}_${new Date().toISOString().slice(0, 10)}.zip`;
|
||||||
a.click();
|
a.click();
|
||||||
URL.revokeObjectURL(a.href);
|
URL.revokeObjectURL(a.href);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const PrivateRoute = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
navigate("/humic-20242025-2");
|
navigate("/login-admin");
|
||||||
}
|
}
|
||||||
}, [navigate, token]);
|
}, [navigate, token]);
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,10 @@
|
|||||||
import { Outlet, Navigate } from "react-router-dom";
|
import { Outlet, Navigate } from "react-router-dom";
|
||||||
|
import { decodeJWT } from "../utils/decodeJWT";
|
||||||
|
|
||||||
interface PrivateRouteProps {
|
interface PrivateRouteProps {
|
||||||
allowedRoles?: ("intern" | "admin" | "mentor")[];
|
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 ProtectedRoutes = ({ allowedRoles }: PrivateRouteProps) => {
|
||||||
const token = document.cookie
|
const token = document.cookie
|
||||||
.split("; ")
|
.split("; ")
|
||||||
@@ -40,7 +24,7 @@ const ProtectedRoutes = ({ allowedRoles }: PrivateRouteProps) => {
|
|||||||
|
|
||||||
if (allowedRoles && !allowedRoles.includes(userRole)) {
|
if (allowedRoles && !allowedRoles.includes(userRole)) {
|
||||||
if (userRole === "admin" || userRole === "mentor") return <Navigate to="/mentor" replace />;
|
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 />;
|
return <Outlet />;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { resolveFileUrl } from "./resolveFileFromUrl";
|
import { resolveFileUrl } from "./resolveFileFromUrl";
|
||||||
import QRCode from "qrcode";
|
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) => {
|
return new Promise((resolve, reject) => {
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
if (!src.startsWith("data:")) img.crossOrigin = "anonymous";
|
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([
|
await Promise.all([
|
||||||
document.fonts.load('105px "Great Vibes"'),
|
document.fonts.load('105px "Great Vibes"'),
|
||||||
document.fonts.load('54px "Grenze"'),
|
document.fonts.load('54px "Grenze"'),
|
||||||
@@ -19,20 +21,34 @@ export async function ensureFontsLoaded(): Promise<void> {
|
|||||||
await document.fonts.ready;
|
await document.fonts.ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LAYOUT DEFAULT SERTIFIKAT YANG AKAN DIGENERATE
|
||||||
const LAYOUT = {
|
const LAYOUT = {
|
||||||
internName: { x: 0.57, y: 0.48, size: 140, font: "Great Vibes", color: "#800000" },
|
internName: { x: 0.56, y: 0.47, size: 130, font: "Great Vibes", color: "#800000" },
|
||||||
internNameSmall: { x: 0.82, y: 0.889, size: 47, font: "Great Vibes", color: "#090909" },
|
internNameSmall: { x: 0.82, y: 0.88, size: 42, font: "Great Vibes", color: "#090909" },
|
||||||
projectName: { x: 0.815, y: 0.598, size: 46, font: "Grenze", color: "#800000" },
|
userposition: { x: 0.85, y: 0.557, size: 46, font: "Grenze", color: "#800000" },
|
||||||
duration: { x: 0.7, y: 0.645, size: 48, font: "Grenze", color: "#090909" },
|
duration: { x: 0.7, y: 0.615, size: 48, font: "Grenze", color: "#090909" },
|
||||||
certNo: { x: 0.597, y: 0.305, size: 50, font: "Grenze", color: "#090909" },
|
certNo: { x: 0.56, y: 0.305, size: 50, font: "Grenze", color: "#090909" },
|
||||||
certNoSmall: { x: 0.827, y: 0.92, size: 32, font: "Grenze", color: "#090909"},
|
certNoSmall: { x: 0.827, y: 0.905, size: 30, font: "Grenze", color: "#090909"},
|
||||||
qr: { x: 0.77, y: 0.715, size: 0.103 },
|
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(
|
export async function generateCertificate(
|
||||||
templateUrl: string,
|
templateUrl: string,
|
||||||
internName: string,
|
internName: string,
|
||||||
projectName: string,
|
userposition: string,
|
||||||
certificateNo: string,
|
certificateNo: string,
|
||||||
ProjectDuration: string,
|
ProjectDuration: string,
|
||||||
verifyUrl: string,
|
verifyUrl: string,
|
||||||
@@ -52,19 +68,19 @@ export async function generateCertificate(
|
|||||||
cfg: { x: number; y: number; size: number; font: string; color: string },
|
cfg: { x: number; y: number; size: number; font: string; color: string },
|
||||||
value: 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.fillStyle = cfg.color;
|
||||||
ctx.fillText(value, canvas.width * cfg.x, canvas.height * cfg.y);
|
ctx.fillText(value, canvas.width * cfg.x, canvas.height * cfg.y);
|
||||||
};
|
};
|
||||||
|
|
||||||
text(LAYOUT.internName, internName);
|
text(LAYOUT.internName, internName);
|
||||||
text(LAYOUT.internNameSmall, internName);
|
text(LAYOUT.internNameSmall, internName.trim().toLowerCase());
|
||||||
text(LAYOUT.projectName, projectName);
|
text(LAYOUT.userposition, userposition);
|
||||||
text(LAYOUT.duration, ProjectDuration);
|
text(LAYOUT.duration, ProjectDuration);
|
||||||
text(LAYOUT.certNo, certificateNo);
|
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 qrSize = Math.round(canvas.width * LAYOUT.qr.size);
|
||||||
const qrDataUrl = await QRCode.toDataURL(
|
const qrDataUrl = await QRCode.toDataURL(
|
||||||
`${window.location.origin}/verify-certificate/${verifyUrl}`,
|
`${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 { FaCheck } from "react-icons/fa";
|
||||||
import { IoAlertCircleOutline } from "react-icons/io5";
|
import { IoAlertCircleOutline } from "react-icons/io5";
|
||||||
|
|
||||||
|
// Komponen Toast Card dengan Tailwind untuk pesan sukses dan pesan error
|
||||||
function ToastCard({ t, type, title, description }: {
|
function ToastCard({ t, type, title, description }: {
|
||||||
t: Toast;
|
t: Toast;
|
||||||
type: 'success' | 'error';
|
type: 'success' | 'error';
|
||||||
@@ -27,13 +28,15 @@ function ToastCard({ t, type, title, description }: {
|
|||||||
</p>
|
</p>
|
||||||
{description && <p className="text-[13px] text-gray-700 mt-0.5">{description}</p>}
|
{description && <p className="text-[13px] text-gray-700 mt-0.5">{description}</p>}
|
||||||
</div>
|
</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} />
|
<FiX size={16} />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// pemanggilan function ToastCard dengan params
|
||||||
export const customToast = {
|
export const customToast = {
|
||||||
success: (title: string, description?: string) =>
|
success: (title: string, description?: string) =>
|
||||||
toast.custom((t) => <ToastCard t={t} type="success" title={title} description={description} />),
|
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;
|
const isHookFailure = typeof data === 'object' && data !== null && 'success' in data && (data as { success?: boolean }).success === false;
|
||||||
|
|
||||||
if (isHookFailure) {
|
if (isHookFailure) {
|
||||||
toast.dismiss(loadingId);
|
toast.remove(loadingId);
|
||||||
const result = data as { success: boolean; message?: string };
|
const result = data as { success: boolean; message?: string };
|
||||||
const { title, description } = messages.error(result);
|
const { title, description } = messages.error(result);
|
||||||
customToast.error(title, description ?? result.message);
|
customToast.error(title, description ?? result.message);
|
||||||
throw new Error(result.message ?? 'Operasi gagal.');
|
throw new Error(result.message ?? 'Operasi gagal.');
|
||||||
}
|
}
|
||||||
|
|
||||||
toast.dismiss(loadingId);
|
toast.remove(loadingId);
|
||||||
const { title, description } = messages.success(data);
|
const { title, description } = messages.success(data);
|
||||||
customToast.success(title, description);
|
customToast.success(title, description);
|
||||||
return data;
|
return data;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast.dismiss(loadingId);
|
toast.remove(loadingId);
|
||||||
const { title, description } = messages.error(err);
|
const { title, description } = messages.error(err);
|
||||||
customToast.error(title, description ?? (err as Error)?.message);
|
customToast.error(title, description ?? (err as Error)?.message);
|
||||||
throw err;
|
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));
|
.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 () => {
|
const markAllRead = async () => {
|
||||||
try {
|
try {
|
||||||
const { message } = await markAllAsRead();
|
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) {
|
} 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);
|
setError(msg);
|
||||||
return { success: false as const, message: msg };
|
|
||||||
|
return {
|
||||||
|
success: false as const,
|
||||||
|
message: msg,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const markOneRead = async (id: number) => {
|
const markOneRead = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
const { message } = await markAsRead(id);
|
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) {
|
} catch (err: any) {
|
||||||
const msg = err?.response?.data?.message ?? "Gagal menandai notifikasi.";
|
const msg = err?.response?.data?.message ?? "Gagal menandai notifikasi.";
|
||||||
|
|
||||||
setError(msg);
|
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,
|
||||||
return { notifications, unreadCount, loading, error, refetch, markAllRead, markOneRead };
|
unreadCount,
|
||||||
|
hasUnreadNotifications,
|
||||||
|
loading,
|
||||||
|
error,
|
||||||
|
refetch,
|
||||||
|
markAllRead,
|
||||||
|
markOneRead,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
+82
-20
@@ -1,11 +1,12 @@
|
|||||||
import { useState, useEffect, useCallback, useMemo } from "react";
|
import { useState, useEffect, useCallback, useMemo } from "react";
|
||||||
import type {
|
import type {
|
||||||
ProjectTask,
|
|
||||||
ProjectTaskDetail,
|
ProjectTaskDetail,
|
||||||
CreateTaskPayload,
|
CreateTaskPayload,
|
||||||
UpdateTaskPayload,
|
UpdateTaskPayload,
|
||||||
TaskSubmissionData,
|
TaskSubmissionData,
|
||||||
AdminTaskDetail,
|
AdminTaskDetail,
|
||||||
|
MentorTaskItem,
|
||||||
|
ProjectTask,
|
||||||
} from "../types/task.types";
|
} from "../types/task.types";
|
||||||
import {
|
import {
|
||||||
getProjectTasks,
|
getProjectTasks,
|
||||||
@@ -21,10 +22,10 @@ import {
|
|||||||
getAllMentorTasks,
|
getAllMentorTasks,
|
||||||
getTaskSubmissions,
|
getTaskSubmissions,
|
||||||
} from "../services/TaskService";
|
} from "../services/TaskService";
|
||||||
import type { MentorTaskItem } from "../types/task.types";
|
|
||||||
import { useCurrentUser } from "./useUser";
|
import { useCurrentUser } from "./useUser";
|
||||||
import { useMyTasks } from "./useProjects";
|
import { useMyTasks } from "./useProjects";
|
||||||
import type { InternTaskItem } from "../types/project.types";
|
import type { InternTaskItem } from "../types/project.types";
|
||||||
|
import { getProjects, getProjectById } from "../services/ProjectService";
|
||||||
|
|
||||||
// GET /task-api/projects/{id_project}/tasks
|
// GET /task-api/projects/{id_project}/tasks
|
||||||
export const useProjectTasks = (projectId: number) => {
|
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) => {
|
export const useAllMentorTasks = (enabled: boolean) => {
|
||||||
const [tasks, setTasks] = useState<MentorTaskItem[]>([]);
|
const [tasks, setTasks] = useState<MentorTaskItem[]>([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
@@ -291,36 +292,97 @@ export interface Deadline {
|
|||||||
label: string;
|
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 = () => {
|
export const useDeadlines = () => {
|
||||||
const { user, loading: userLoading, error: userError } = useCurrentUser();
|
const { user, loading: userLoading, error: userError } = useCurrentUser();
|
||||||
|
|
||||||
const isIntern = user?.role === "intern";
|
const isIntern = user?.role === "intern";
|
||||||
|
const isMentor = user?.role === "mentor";
|
||||||
|
const isAdmin = user?.role === "admin";
|
||||||
|
|
||||||
const {
|
const { tasks: internTasks, loading: internLoading, error: internError } = useMyTasks();
|
||||||
tasks: internTasks,
|
const { tasks: mentorTasks, loading: mentorLoading, error: mentorError } = useAllMentorTasks(isMentor);
|
||||||
loading: internLoading,
|
const { tasks: allTasks, loading: allTasksLoading, error: allTasksError } = useRetrieveAllTasks(isAdmin);
|
||||||
error: internError,
|
|
||||||
} = useMyTasks();
|
|
||||||
const {
|
|
||||||
tasks: mentorTasks,
|
|
||||||
loading: mentorLoading,
|
|
||||||
error: mentorError,
|
|
||||||
} = useAllMentorTasks(!isIntern && user !== null);
|
|
||||||
|
|
||||||
const deadlines: Deadline[] = useMemo(() => {
|
const deadlines: Deadline[] = useMemo(() => {
|
||||||
if (!user) return [];
|
if (!user) return [];
|
||||||
return isIntern
|
|
||||||
? internTasks.map((task) => ({
|
if (isIntern) {
|
||||||
|
return internTasks.map((task) => ({
|
||||||
date: new Date(task.deadline_at),
|
date: new Date(task.deadline_at),
|
||||||
label: task.title,
|
label: task.title,
|
||||||
}))
|
}));
|
||||||
: mentorTasks.map((task) => ({
|
}
|
||||||
|
|
||||||
|
if (isMentor) {
|
||||||
|
return mentorTasks.map((task) => ({
|
||||||
date: new Date(task.deadline_at),
|
date: new Date(task.deadline_at),
|
||||||
label: `[${task.project_name}] ${task.title}`,
|
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 };
|
return { deadlines, loading, error, isIntern };
|
||||||
};
|
};
|
||||||
|
|||||||
+4
-1
@@ -57,7 +57,7 @@
|
|||||||
background-color: var(--color-box-primary);
|
background-color: var(--color-box-primary);
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
border: 1px solid var(--color-border);
|
border: 1px solid var(--color-border);
|
||||||
padding: 32px;
|
padding:12px;
|
||||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
|
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
|
||||||
0 2px 4px -2px 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;
|
padding-bottom: 1.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.box {
|
||||||
|
padding: 32px;
|
||||||
|
}
|
||||||
.main-content {
|
.main-content {
|
||||||
padding-block: calc(var(--spacing) * 10);
|
padding-block: calc(var(--spacing) * 10);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,17 @@ export const getProjectById = async (
|
|||||||
position: m.user?.position,
|
position: m.user?.position,
|
||||||
kelompok_peminatan: m.user?.kelompok_peminatan,
|
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,
|
template_sertificate: raw.template_sertificate,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ export interface CertificateUser {
|
|||||||
id: number;
|
id: number;
|
||||||
full_name: string;
|
full_name: string;
|
||||||
email: string;
|
email: string;
|
||||||
|
intern_position: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CertificateProject {
|
export interface CertificateProject {
|
||||||
@@ -19,6 +20,7 @@ export interface Certificate {
|
|||||||
id_user: number;
|
id_user: number;
|
||||||
certificate_no: string;
|
certificate_no: string;
|
||||||
issued_at: string;
|
issued_at: string;
|
||||||
|
intern_position: string;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
user: CertificateUser;
|
user: CertificateUser;
|
||||||
project: CertificateProject;
|
project: CertificateProject;
|
||||||
@@ -28,6 +30,7 @@ export interface Certificate {
|
|||||||
export interface CertificateVerification {
|
export interface CertificateVerification {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
intern_name: string;
|
intern_name: string;
|
||||||
|
intern_position: string;
|
||||||
project_name: string;
|
project_name: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
}
|
}
|
||||||
@@ -37,9 +40,18 @@ export interface CertificateTemplate {
|
|||||||
certificate_template: string;
|
certificate_template: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface projectbysertif {
|
||||||
|
project_id: number
|
||||||
|
project_name: string;
|
||||||
|
end_date: string;
|
||||||
|
description: string;
|
||||||
|
certificate_template: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface CertificateVerifyResult {
|
export interface CertificateVerifyResult {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
intern_name: string;
|
intern_name: string;
|
||||||
project_name: string;
|
project: projectbysertif;
|
||||||
|
intern_position: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
|
||||||
/* Bundler mode */
|
/* Bundler mode */
|
||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
|
|||||||
Reference in New Issue
Block a user