base UI for Hackathon backoffice

TODO:
- Organize table schema for users, teams, and submissions management
- Create API Contract for additional back-end endpoint
This commit is contained in:
Hafid Nur
2025-11-30 17:22:47 +07:00
parent a20f5eff85
commit 5faba43728
6 changed files with 275 additions and 64 deletions
@@ -1,18 +1,31 @@
import { BackofficeWrapper } from '@imphnen-frontend-service/ui/organisms';
import { FC, ReactElement } from 'react'; import { FC, ReactElement } from 'react';
export const HackathonDashboardPage: FC = (): ReactElement => { export const HackathonDashboardPage: FC = (): ReactElement => {
return ( return (
<main className="w-full px-12 py-10 flex flex-col gap-8"> <BackofficeWrapper title="IMPHNEN x Kolosal.ai Hackathon 2025">
<header className="bg-white py-4 px-8 rounded-lg shadow p-4"> <h1 className="mb-8 text-p1 font-semibold text-neutral-700">Dashboard</h1>
<h1 className="text-p2 font-semibold">Hackathon Dashboard</h1>
</header>
<section className="bg-white rounded-lg shadow p-8"> <section className="grid grid-cols-5 gap-5">
<p className="text-label1 text-neutral-600"> {/* Participant */}
Boilerplate page for hackathon dashboard. Add KPIs and actions here. <div className="bg-white px-6 py-4 rounded-md shadow">
</p> <h3 className="text-primary-500 text-p2 font-semibold mb-2.5">
1261
</h3>
<p className="text-neutral-400 text-p3">Total Participants</p>
</div>
{/* Team */}
<div className="bg-white px-6 py-4 rounded-md shadow">
<h3 className="text-primary-500 text-p2 font-semibold mb-2.5">206</h3>
<p className="text-neutral-400 text-p3">Total Teams</p>
</div>
{/* Project Submitted */}
<div className="bg-white px-6 py-4 rounded-md shadow">
<h3 className="text-primary-500 text-p2 font-semibold mb-2.5">0</h3>
<p className="text-neutral-400 text-p3">Total Project Submitted</p>
</div>
</section> </section>
</main> </BackofficeWrapper>
); );
}; };
@@ -1,17 +1,194 @@
import { FC, ReactElement } from 'react'; import { FC, ReactElement, useState } from 'react';
import ModalUserDetail from '../../../components/modal-user-detail';
import ModalSuspendOrBan from '../../../components/modal-suspend-or-ban';
import ModalDeleteUser from '../../../components/modal-delete-user';
import {
BackofficeWrapper,
DataTable,
} from '@imphnen-frontend-service/ui/organisms';
import {
ColumnDef,
getCoreRowModel,
getPaginationRowModel,
PaginationState,
RowSelectionState,
useReactTable,
} from '@tanstack/react-table';
import { Button } from '@imphnen-frontend-service/ui/atoms';
import { cn } from '@imphnen-frontend-service/utils';
import { SearchOutlined } from '@ant-design/icons';
export const HackathonUsersPage: FC = (): ReactElement => {
const [showDeleteModal, setShowDeleteModal] = useState(false);
const [showDetailModal, setShowDetailModal] = useState(false);
const [showSuspendModal, setShowSuspendModal] = useState(false);
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
const [pagination, setPagination] = useState<PaginationState>({
pageIndex: 0,
pageSize: 9,
});
const mockData: any[] = Array.from({ length: 90 }, (_, i) => ({
id: i + 1,
name: i % 3 === 0 ? 'Ahmad Wijuana' : 'Sofia Wijuana',
email: 'fullname23@gmail.com',
rating: 4.5,
status: i % 2 === 0 ? 'active' : 'inactive',
}));
type UserStatus = 'active' | 'inactive';
interface UserType {
id: number;
name: string;
email: string;
rating: number;
status: UserStatus;
}
const columns: ColumnDef<UserType>[] = [
{
id: 'select',
meta: { cellClassName: cn('w-20') },
header: ({ table }) => (
<input
type="checkbox"
className="rounded"
checked={table.getIsAllRowsSelected()}
onChange={table.getToggleAllRowsSelectedHandler()}
/>
),
cell: ({ row }) => (
<input
type="checkbox"
className="rounded"
checked={row.getIsSelected()}
onChange={row.getToggleSelectedHandler()}
/>
),
},
{
id: 'name',
header: 'Name',
accessorKey: 'name',
},
{
id: 'email',
header: 'Email',
accessorKey: 'email',
},
{
id: 'rating',
header: 'Rating',
accessorKey: 'rating',
},
{
id: 'status',
header: 'Status',
accessorKey: 'status',
cell: ({ row }) => {
const status = row.original.status;
const statusColors: Record<UserStatus, string> = {
active: 'bg-success-200 text-success-500',
inactive: 'bg-danger-200 text-danger-500',
};
const statusText: Record<UserStatus, string> = {
active: 'Active',
inactive: 'Inactive',
};
return (
<div
className={`py-2 px-4 rounded-md text-center ${statusColors[status]}`}
>
{statusText[status]}
</div>
);
},
},
{
header: 'Action',
meta: { cellClassName: cn('w-72') },
cell: ({ row }) => (
<Button
variant="primary"
size="sm"
onClick={
(e) => {}
// {
// e.stopPropagation();
// setSelectedUserId(row.original.id);
// setShowDetail(true);
// }
}
className="flex items-center gap-2 w-max"
>
<SearchOutlined className="text-[16px]" /> Lihat Detail & Action
</Button>
),
},
];
const table = useReactTable({
data: mockData,
columns,
state: {
pagination,
rowSelection,
},
enableRowSelection: true,
onRowSelectionChange: setRowSelection,
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
onPaginationChange: setPagination,
pageCount: Math.ceil(mockData.length / pagination.pageSize),
manualPagination: false,
});
export const HackathonSubmissionsPage: FC = (): ReactElement => {
return ( return (
<main className="w-full px-12 py-10 flex flex-col gap-8"> <BackofficeWrapper title="IMPHNEN x Kolosal.ai Hackathon 2025">
<header className="bg-white py-4 px-8 rounded-lg shadow p-4"> <h1 className="mb-8 text-p1 font-semibold text-neutral-700">
<h1 className="text-p2 font-semibold">Hackathon Submissions</h1> Project Submission
</header> </h1>
{/* Filters and actions */}
<section className="bg-white rounded-md shadow p-8 flex flex-col gap-6">
<div className="flex flex-wrap gap-3 items-center">
<input
type="text"
className="border border-neutral-200 rounded-md px-3 py-2 text-label1 w-full sm:w-64"
placeholder="Search name or email"
/>
<select className="border border-neutral-200 rounded-md px-3 py-2 text-label1 w-full sm:w-40">
<option value="all">All Status</option>
<option value="active">Active</option>
<option value="suspended">Suspended</option>
</select>
<select className="border border-neutral-200 rounded-md px-3 py-2 text-label1 w-full sm:w-40">
<option value="all">All City</option>
<option value="jakarta">Jakarta</option>
<option value="bandung">Bandung</option>
</select>
</div>
<section className="bg-white rounded-lg shadow-sm p-8 border border-neutral-100"> {/* Table */}
<p className="text-label1 text-neutral-600">Boilerplate page for managing submissions. Add table, filters, and review workspace here.</p> <DataTable data={mockData} columns={columns} table={table} />
</section> </section>
</main>
{/* Modals extracted into shared backoffice components */}
<ModalUserDetail
isOpen={showDetailModal}
onClose={() => setShowDetailModal(false)}
/>
<ModalSuspendOrBan
isOpen={showSuspendModal}
onClose={() => setShowSuspendModal(false)}
/>
<ModalDeleteUser
isOpen={showDeleteModal}
onClose={() => setShowDeleteModal(false)}
/>
</BackofficeWrapper>
); );
}; };
export default HackathonSubmissionsPage; export default HackathonUsersPage;
@@ -2,7 +2,10 @@ import { FC, ReactElement, useState } from 'react';
import ModalUserDetail from '../../../components/modal-user-detail'; import ModalUserDetail from '../../../components/modal-user-detail';
import ModalSuspendOrBan from '../../../components/modal-suspend-or-ban'; import ModalSuspendOrBan from '../../../components/modal-suspend-or-ban';
import ModalDeleteUser from '../../../components/modal-delete-user'; import ModalDeleteUser from '../../../components/modal-delete-user';
import { DataTable } from '@imphnen-frontend-service/ui/organisms'; import {
BackofficeWrapper,
DataTable,
} from '@imphnen-frontend-service/ui/organisms';
import { import {
ColumnDef, ColumnDef,
getCoreRowModel, getCoreRowModel,
@@ -219,13 +222,12 @@ export const HackathonTeamsPage: FC = (): ReactElement => {
}); });
return ( return (
<main className="w-full px-12 py-10 flex flex-col gap-8"> <BackofficeWrapper title="IMPHNEN x Kolosal.ai Hackathon 2025">
<header className="bg-white py-4 px-8 rounded-lg shadow p-4"> <h1 className="mb-8 text-p1 font-semibold text-neutral-700">
<h1 className="text-p2 font-semibold">Hackathon Teams</h1> Team Management
</header> </h1>
{/* Filters and actions */} {/* Filters and actions */}
<section className="bg-white rounded-lg shadow p-8 flex flex-col gap-6"> <section className="bg-white rounded-md shadow p-8 flex flex-col gap-6">
<div className="flex flex-wrap gap-3 items-center"> <div className="flex flex-wrap gap-3 items-center">
<input <input
type="text" type="text"
@@ -243,11 +245,9 @@ export const HackathonTeamsPage: FC = (): ReactElement => {
<option value="bandung">Bandung</option> <option value="bandung">Bandung</option>
</select> </select>
</div> </div>
{/* Table */} {/* Table */}
<DataTable data={mockData} columns={columns} table={table} /> <DataTable data={mockData} columns={columns} table={table} />
</section> </section>
{/* Modals extracted into shared backoffice components */} {/* Modals extracted into shared backoffice components */}
<ModalUserDetail <ModalUserDetail
isOpen={showDetailModal} isOpen={showDetailModal}
@@ -261,7 +261,7 @@ export const HackathonTeamsPage: FC = (): ReactElement => {
isOpen={showDeleteModal} isOpen={showDeleteModal}
onClose={() => setShowDeleteModal(false)} onClose={() => setShowDeleteModal(false)}
/> />
</main> </BackofficeWrapper>
); );
}; };
@@ -2,7 +2,10 @@ import { FC, ReactElement, useState } from 'react';
import ModalUserDetail from '../../../components/modal-user-detail'; import ModalUserDetail from '../../../components/modal-user-detail';
import ModalSuspendOrBan from '../../../components/modal-suspend-or-ban'; import ModalSuspendOrBan from '../../../components/modal-suspend-or-ban';
import ModalDeleteUser from '../../../components/modal-delete-user'; import ModalDeleteUser from '../../../components/modal-delete-user';
import { DataTable } from '@imphnen-frontend-service/ui/organisms'; import {
BackofficeWrapper,
DataTable,
} from '@imphnen-frontend-service/ui/organisms';
import { import {
ColumnDef, ColumnDef,
getCoreRowModel, getCoreRowModel,
@@ -143,13 +146,12 @@ export const HackathonUsersPage: FC = (): ReactElement => {
}); });
return ( return (
<main className="w-full px-12 py-10 flex flex-col gap-8"> <BackofficeWrapper title="IMPHNEN x Kolosal.ai Hackathon 2025">
<header className="bg-white py-4 px-8 rounded-lg shadow p-4"> <h1 className="mb-8 text-p1 font-semibold text-neutral-700">
<h1 className="text-p2 font-semibold">Hackathon Users</h1> User Management
</header> </h1>
{/* Filters and actions */} {/* Filters and actions */}
<section className="bg-white rounded-lg shadow-sm p-8 border border-neutral-100 flex flex-col gap-6"> <section className="bg-white rounded-md shadow p-8 flex flex-col gap-6">
<div className="flex flex-wrap gap-3 items-center"> <div className="flex flex-wrap gap-3 items-center">
<input <input
type="text" type="text"
@@ -185,7 +187,7 @@ export const HackathonUsersPage: FC = (): ReactElement => {
isOpen={showDeleteModal} isOpen={showDeleteModal}
onClose={() => setShowDeleteModal(false)} onClose={() => setShowDeleteModal(false)}
/> />
</main> </BackofficeWrapper>
); );
}; };
@@ -1,19 +1,29 @@
import { SearchOutlined } from "@ant-design/icons"; import { SearchOutlined } from '@ant-design/icons';
import { Button, Input, Select } from "@imphnen-frontend-service/ui/atoms"; import { Button, Input, Select } from '@imphnen-frontend-service/ui/atoms';
import { BackofficeWrapper, DataTable } from "@imphnen-frontend-service/ui/organisms"; import {
import { cn, For } from "@imphnen-frontend-service/utils"; BackofficeWrapper,
import { ColumnDef, getCoreRowModel, getPaginationRowModel, PaginationState, RowSelectionState, useReactTable } from "@tanstack/react-table"; DataTable,
import { ReactElement, useState } from "react"; } from '@imphnen-frontend-service/ui/organisms';
import { ModalDetailUser } from "./_components/modal/detail"; import { cn, For } from '@imphnen-frontend-service/utils';
import {
ColumnDef,
getCoreRowModel,
getPaginationRowModel,
PaginationState,
RowSelectionState,
useReactTable,
} from '@tanstack/react-table';
import { ReactElement, useState } from 'react';
import { ModalDetailUser } from './_components/modal/detail';
type UserStatus = 'active' | 'inactive'; type UserStatus = 'active' | 'inactive';
interface UserType { interface UserType {
id: number id: number;
name: string name: string;
email: string email: string;
rating: number rating: number;
status: UserStatus status: UserStatus;
} }
const mockData: UserType[] = Array.from({ length: 90 }, (_, i) => ({ const mockData: UserType[] = Array.from({ length: 90 }, (_, i) => ({
@@ -22,15 +32,15 @@ const mockData: UserType[] = Array.from({ length: 90 }, (_, i) => ({
email: 'fullname23@gmail.com', email: 'fullname23@gmail.com',
rating: 4.5, rating: 4.5,
status: i % 2 === 0 ? 'active' : 'inactive', status: i % 2 === 0 ? 'active' : 'inactive',
})) }));
export default function Components(): ReactElement { export default function Components(): ReactElement {
const TABS = ['mentor', 'mentee'] as const const TABS = ['mentor', 'mentee'] as const;
const [activeTab, setActiveTab] = useState<'mentor' | 'mentee'>('mentor') const [activeTab, setActiveTab] = useState<'mentor' | 'mentee'>('mentor');
const [showDetail, setShowDetail] = useState(false) const [showDetail, setShowDetail] = useState(false);
const [selectedUserId, setSelectedUserId] = useState<number | null>(null) const [selectedUserId, setSelectedUserId] = useState<number | null>(null);
const [rowSelection, setRowSelection] = useState<RowSelectionState>({}) const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
const [pagination, setPagination] = useState<PaginationState>({ const [pagination, setPagination] = useState<PaginationState>({
pageIndex: 0, pageIndex: 0,
pageSize: 9, pageSize: 9,
@@ -39,7 +49,7 @@ export default function Components(): ReactElement {
const columns: ColumnDef<UserType>[] = [ const columns: ColumnDef<UserType>[] = [
{ {
id: 'select', id: 'select',
meta: { cellClassName: cn("w-20") }, meta: { cellClassName: cn('w-20') },
header: ({ table }) => ( header: ({ table }) => (
<input <input
type="checkbox" type="checkbox"
@@ -97,7 +107,7 @@ export default function Components(): ReactElement {
}, },
{ {
header: 'Action', header: 'Action',
meta: { cellClassName: cn("w-72") }, meta: { cellClassName: cn('w-72') },
cell: ({ row }) => ( cell: ({ row }) => (
<Button <Button
variant="primary" variant="primary"
@@ -113,7 +123,7 @@ export default function Components(): ReactElement {
</Button> </Button>
), ),
}, },
] ];
const table = useReactTable({ const table = useReactTable({
data: mockData, data: mockData,
@@ -134,14 +144,19 @@ export default function Components(): ReactElement {
return ( return (
<BackofficeWrapper title="Dimentorin.dev"> <BackofficeWrapper title="Dimentorin.dev">
<div className="mb-8 flex justify-between items-center"> <div className="mb-8 flex justify-between items-center">
<h1 className="text-p1 font-semibold text-neutral-700">User Management</h1> <h1 className="text-p1 font-semibold text-neutral-700 mb-8">
User Management
</h1>
<div className="flex gap-2 bg-primary-100 p-1.5 rounded-md"> <div className="flex gap-2 bg-primary-100 p-1.5 rounded-md">
<For data={TABS}> <For data={TABS}>
{(tab) => ( {(tab) => (
<Button <Button
key={tab} key={tab}
variant="text" variant="text"
className={cn("px-3 py-2 capitalize", activeTab === tab && "bg-white")} className={cn(
'px-3 py-2 capitalize',
activeTab === tab && 'bg-white'
)}
onClick={() => setActiveTab(tab)} onClick={() => setActiveTab(tab)}
> >
{tab} {tab}
@@ -163,12 +178,16 @@ export default function Components(): ReactElement {
</div> </div>
</div> </div>
<Select> <Select>
<option selected disabled>Rating</option> <option selected disabled>
Rating
</option>
<option value="4.5">4.5</option> <option value="4.5">4.5</option>
<option value="5">5</option> <option value="5">5</option>
</Select> </Select>
<Select> <Select>
<option selected disabled>Status</option> <option selected disabled>
Status
</option>
<option value="active">Active</option> <option value="active">Active</option>
<option value="inactive">Inactive</option> <option value="inactive">Inactive</option>
</Select> </Select>
@@ -199,7 +199,7 @@ export const BackofficeSidebar: FC<SidebarProps> = ({
className={cn( className={cn(
'flex items-center justify-between w-full gap-3 px-2 py-2.5 rounded-md cursor-pointer', 'flex items-center justify-between w-full gap-3 px-2 py-2.5 rounded-md cursor-pointer',
openGroups[menu.label] openGroups[menu.label]
? 'bg-primary-500 text-white' ? 'bg-primary-400 hover:bg-primary-500 text-white'
: 'text-gray-700 hover:bg-gray-100' : 'text-gray-700 hover:bg-gray-100'
)} )}
> >
@@ -225,7 +225,7 @@ export const BackofficeSidebar: FC<SidebarProps> = ({
className={cn( className={cn(
'flex items-center gap-3 px-2 py-2.5 rounded-md', 'flex items-center gap-3 px-2 py-2.5 rounded-md',
isActive(child.href) isActive(child.href)
? 'bg-primary-100 text-primary-700' ? 'bg-primary-100 text-primary-700 hover:bg-primary-200'
: 'text-gray-700 hover:bg-gray-100' : 'text-gray-700 hover:bg-gray-100'
)} )}
> >