Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/components/PageSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ function PageSection() {
// Store variables
const categories = useSelector((state: RootState) => state.categories.categories);
const currentCategory = useSelector((state: RootState) => state.categories.currentCategory);
const tasks = useSelector((state: RootState) => state.tasks.tasks.filter(item => item.categoryID === currentCategory));
const tasks = useSelector((state: RootState) => state.tasks.tasks.filter((item: Task) => item.categoryID === currentCategory));

// Current category
const category = categories.find(item => item.id === currentCategory) as Category;
const category = categories.find((item: Category) => item.id === currentCategory) as Category;

// Toggle table creation modal
const toggleCreateTableModal = () => {
Expand All @@ -35,7 +35,7 @@ function PageSection() {
setTaskModal(val as any);
}

if(currentCategory !== 'none') {
if (currentCategory !== 'none') {
return (
<div className="w-full h-full overflow-x-auto flex flex-col text-stone-700">
{/* Add new task button */}
Expand All @@ -57,8 +57,8 @@ function PageSection() {
{/* Main section */}
<div className="w-full h-full py-4 flex flex-col md:flex-row md:divide-x">
{/* Category tables */}
{category.tables.map(table => {
return <TasksTable table={table} key={table.id} toogleTaskModal={toogleTaskModal} tasks={tasks.filter(item => item.tableID === table.id && item.categoryID === currentCategory)}></TasksTable>
{category.tables.map((table) => {
return <TasksTable table={table} key={table.id} toogleTaskModal={toogleTaskModal} tasks={tasks.filter((item: Task) => item.tableID === table.id && item.categoryID === currentCategory)}></TasksTable>
})}

{/* Create new table button */}
Expand Down
27 changes: 21 additions & 6 deletions src/components/modal/NewTaskModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useDispatch, useSelector } from "react-redux";
import { RootState } from "../../store/store";
import { addTask } from "../../store/tasksSlice";


function NewTableModal({ toggleCreateTaskModal }: any) {
// Store variables
const categories = useSelector((state: RootState) => state.categories.categories);
Expand All @@ -13,7 +14,9 @@ function NewTableModal({ toggleCreateTaskModal }: any) {
const [name, setName] = useState('');
const [description, setDescription] = useState('');
const [tableID, setTableID] = useState(categories.find(item => item.id === currentCategory)?.tables[0].id);
const [subtasks, setSubtasks] = useState(Array<{id: string, value: string, done: boolean}>())
const [subtasks, setSubtasks] = useState(Array<{id: string, value: string, done: boolean}>());
const [requestedBy, setRequestedBy] = useState('');
const [timeToComplete, setTimeToComplete] = useState('');

// Refs
const subtaskName = useRef(null);
Expand All @@ -27,10 +30,12 @@ function NewTableModal({ toggleCreateTaskModal }: any) {
tableID: tableID,
name: name,
description: description,
subtasks: subtasks
} as Task));
}

subtasks: subtasks,
requestedBy: requestedBy,
timeToComplete: timeToComplete // Ensure timeToComplete is a number
// timeToComplete: Number(timeToComplete) // Ensure timeToComplete is a number
} as unknown as Task)); // Convert to unknown first to bypass type error
}
// Create new subtask
const addSubtask = () => {
if(subtaskName.current) {
Expand Down Expand Up @@ -87,6 +92,16 @@ function NewTableModal({ toggleCreateTaskModal }: any) {
<textarea rows={3} value={description} onChange={(e) => setDescription(e.target.value)} className='w-full bg-stone-200 p-2 rounded-xl placeholder-stone-400' placeholder="Description"></textarea>
</div>

{/* Requested by */}
<div className="w-full">
<input type="text" className='w-full bg-stone-200 p-2 rounded-xl placeholder-stone-400' placeholder='Requested by' value={requestedBy} onChange={(e) => setRequestedBy(e.target.value)} />
</div>

{/* Time to complete */}
<div className="w-full">
<input type="text" className='w-full bg-stone-200 p-2 rounded-xl placeholder-stone-400' placeholder='Time to complete' value={timeToComplete} onChange={(e) => setTimeToComplete(e.target.value)} />
</div>

{/* Subtasks */}
<div className="flex flex-col gap-2">
<p className='text-xs uppercase font-semibold text-stone-400'>Sub tasks</p>
Expand Down Expand Up @@ -136,4 +151,4 @@ function NewTableModal({ toggleCreateTaskModal }: any) {

}

export default NewTableModal;
export default NewTableModal;
Loading