diff --git a/src/App.jsx b/src/App.jsx index 816bb66..2e608d9 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -18,7 +18,6 @@ const adminAtom = atomWithStorage("admin-id", ""); const pickmeModeAtom = atomWithStorage("pickmeMode", false); const EditorPage = lazy(() => import("./pages/editor")); -const TestPage = lazy(() => import("./pages/test")); const AdminProfilePage = lazy(() => import("./pages/AdminProfile")); const ClassProfilePage = lazy(() => import("./pages/ClassProfile")); @@ -62,7 +61,6 @@ const pages = { "/app": , "/exit": , "/editor": , - "/test": , "/adminprofile": , "/classprofile": , }; diff --git a/src/pages/ClassProfile.jsx b/src/pages/ClassProfile.jsx index fc9bf54..e3cf93c 100644 --- a/src/pages/ClassProfile.jsx +++ b/src/pages/ClassProfile.jsx @@ -1,7 +1,6 @@ import { useAtom } from "jotai"; import { AnimatePresence, motion } from "motion/react"; import { - BiCheck, BiCheckCircle, BiCopy, BiLeftArrowAlt, @@ -10,11 +9,9 @@ import { BiPlusCircle, BiTrash, BiX, - BiXCircle, } from "react-icons/bi"; import Logo from "../assets/logo.svg"; import { - AdminReq, AdminUpdateRequest, ClassUpdateRequest, getClassProfile, diff --git a/src/pages/test.jsx b/src/pages/test.jsx deleted file mode 100644 index 225c602..0000000 --- a/src/pages/test.jsx +++ /dev/null @@ -1,11 +0,0 @@ -import { TextPreloader } from "../trash/trash-components"; - -export default function TestPage() { - return ( - <> -
- -
- - ); -} diff --git a/src/pages/test_arch0.jsx b/src/pages/test_arch0.jsx deleted file mode 100644 index 052ff1c..0000000 --- a/src/pages/test_arch0.jsx +++ /dev/null @@ -1,212 +0,0 @@ -import React, { useState } from 'react'; -import { DndContext, closestCenter, PointerSensor, TouchSensor, useSensor, useSensors } from '@dnd-kit/core'; -import { arrayMove, SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable'; -import { CSS } from '@dnd-kit/utilities'; - -// Configuration -const COLUMNS = [ - { key: 'position', label: 'Pos', width: 'w-16', placeholder: '#' }, - { key: 'subject', label: 'Subject', width: 'flex-1', placeholder: 'Enter subject' }, - { key: 'time', label: 'Time', width: 'w-24', placeholder: '00:00' }, - { key: 'room', label: 'Room', width: 'w-20', placeholder: 'A-1' }, -]; - -const INITIAL_DATA = [ - { id: '1', position: '1', subject: 'Mathematics', time: '09:00', room: 'A-1' }, - { id: '2', position: '2', subject: 'Physics', time: '10:00', room: 'B-2' }, - { id: '3', position: '3', subject: 'Chemistry', time: '11:00', room: 'A-3' }, - { id: '4', position: '4', subject: 'Biology', time: '13:00', room: 'C-1' }, -]; - -function SortableRow({ item, columns, onUpdate, onDelete }) { - const { - attributes, - listeners, - setNodeRef, - transform, - transition, - isDragging, - } = useSortable({ id: item.id }); - - const style = { - transform: CSS.Transform.toString(transform), - transition, - opacity: isDragging ? 0.5 : 1, - }; - return ( -
-
- {columns.map((col) => ( - onUpdate(item.id, col.key, e.target.value)} - className={`${col.width} px-3 py-3 bg-transparent text-white border-r border-gray-700 last:border-r-0 focus:outline-none focus:bg-gray-700/50 placeholder-gray-500`} - placeholder={col.placeholder} - /> - ))} -
- ⋮ -
- -
-
- ); -} - -export default function ScheduleEditor({ - initialData = INITIAL_DATA, - columns = COLUMNS, - onChange, -}) { - const [items, setItems] = useState(initialData); - - const sensors = useSensors( - useSensor(PointerSensor, { - activationConstraint: { - distance: 8, - }, - }), - useSensor(TouchSensor, { - activationConstraint: { - delay: 200, - tolerance: 8, - }, - }) - ); - - const updateItems = (newItems) => { - setItems(newItems); - onChange?.(newItems); - }; - - const handleDragEnd = (event) => { - const { active, over } = event; - - if (over && active.id !== over.id) { - const oldIndex = items.findIndex((item) => item.id === active.id); - const newIndex = items.findIndex((item) => item.id === over.id); - - const newItems = arrayMove(items, oldIndex, newIndex); - - // Update positions based on new order - const positions = newItems.map(item => item.position); - const reorderedItems = newItems.map((item, idx) => ({ - ...item, - position: positions[idx] - })); - - updateItems(reorderedItems); - } - }; - - const handleUpdate = (id, field, value) => { - const newItems = items.map(item => - item.id === id ? { ...item, [field]: value } : item - ); - updateItems(newItems); - }; - - const handleDelete = (id) => { - const newItems = items.filter(item => item.id !== id); - updateItems(newItems); - }; - - const handleAddRow = () => { - const newId = String(Date.now()); - const lastPosition = items.length > 0 - ? String(parseInt(items[items.length - 1].position || '0') + 1) - : '1'; - - const newItem = { id: newId, position: lastPosition }; - columns.forEach(col => { - if (col.key !== 'position') { - newItem[col.key] = ''; - } - }); - - updateItems([...items, newItem]); - }; - - const handleClear = () => { - updateItems([]); - }; - - return ( -
-
-

- Schedule Editor -

- - - item.id)} - strategy={verticalListSortingStrategy} - > -
- {items.map((item) => ( - - ))} -
-
-
- - {items.length === 0 && ( -
- No items. Add a row to get started. -
- )} - -
- - -
- -
-

Instructions:

-
    -
  • • Drag rows by the handle (⋮) on the right to reorder
  • -
  • • Positions move with their rows when dragged
  • -
  • • Click any field to edit
  • -
  • • Click × to delete a row
  • -
-
-
-
- ); -} \ No newline at end of file