@@ -49,7 +49,8 @@ export default function TasksPage() {
4949 router . push ( "/login" ) ; //redirect to login if unauthorised
5050 return ;
5151 }
52- const auth = await fetch ( "http://localhost:8000/api/planner/protected/" ,
52+ const auth = await fetch (
53+ "http://localhost:8000/api/planner/protected/" ,
5354 {
5455 headers : {
5556 Authorization : `Bearer ${ token } ` ,
@@ -102,13 +103,16 @@ export default function TasksPage() {
102103 const task = items . find ( ( t ) => t . id === id ) ;
103104 if ( ! task ) return ;
104105
106+ const token = localStorage . getItem ( "access" ) ;
107+
105108 try {
106109 const response = await fetch (
107110 `http://localhost:8000/api/planner/tasks/${ id } /toggle_complete/` ,
108111 {
109112 method : "PATCH" ,
110113 headers : {
111114 "Content-Type" : "application/json" ,
115+ Authorization : `Bearer ${ token } ` ,
112116 } ,
113117 body : JSON . stringify ( { completed : ! task . completed } ) ,
114118 } ,
@@ -135,10 +139,17 @@ export default function TasksPage() {
135139 async function handleTaskDeleted ( id : number ) {
136140 if ( ! window . confirm ( "Delete this task?" ) ) return ;
137141
142+ const token = localStorage . getItem ( "access" ) ;
143+
138144 try {
139145 const response = await fetch (
140146 `http://localhost:8000/api/planner/tasks/${ id } /` ,
141- { method : "DELETE" } ,
147+ {
148+ method : "DELETE" ,
149+ headers : {
150+ Authorization : `Bearer ${ token } ` ,
151+ } ,
152+ } ,
142153 ) ;
143154
144155 if ( ! response . ok ) {
@@ -152,7 +163,7 @@ export default function TasksPage() {
152163 }
153164
154165 return (
155- < div className = "content-container min-w-screen min-h-screen relative flex flex-row items-center justify-center bg-slate-500" >
166+ < div className = "content-container min-w-screen relative flex min-h-screen flex-row items-center justify-center bg-slate-500" >
156167 < div className = "task-list-container h-full w-full" >
157168 < div className = "task-list-content flex h-full w-full flex-col items-center justify-center rounded-lg p-3 text-slate-200" >
158169 < div className = "task-list-top mb-3 hidden h-[10%] w-full rounded-t-lg" >
@@ -163,10 +174,10 @@ export default function TasksPage() {
163174 < div className = "task-list-bottom flex w-full flex-row justify-center gap-6" >
164175 < div
165176 className = "task-list-wrapper flex w-fit flex-row justify-center"
166- style = { {
167- scrollbarWidth : "thin" ,
177+ style = { {
178+ scrollbarWidth : "thin" ,
168179 scrollbarColor : "grey white" ,
169- display : ! ( showAddTask && items . length === 0 ) ? "flex" : "none"
180+ display : ! ( showAddTask && items . length === 0 ) ? "flex" : "none" ,
170181 } }
171182 >
172183 < TaskList
0 commit comments