Skip to content

Commit 169c222

Browse files
committed
fixed permissions issues
1 parent 144cf28 commit 169c222

5 files changed

Lines changed: 37 additions & 2 deletions

File tree

client/package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"next": "15.4.7",
2828
"react": "19.1.0",
2929
"react-dom": "19.1.0",
30+
"react-icons": "^5.5.0",
3031
"tailwind-merge": "^3.3.1",
3132
"tailwindcss-animate": "^1.0.7"
3233
},

client/src/components/task_form.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ export function TaskForm({ userId, onTaskCreated }: TaskFormProps) {
5151

5252
const handleSubmit = async (e: React.FormEvent) => {
5353
e.preventDefault();
54+
55+
const token = localStorage.getItem("access");
56+
if (!token) {
57+
console.error("No access token");
58+
return;
59+
}
60+
5461
try {
5562
const existing_topic_ids = topics
5663
.filter((t) => t.type === "existing")
@@ -63,6 +70,7 @@ export function TaskForm({ userId, onTaskCreated }: TaskFormProps) {
6370
method: "POST",
6471
headers: {
6572
"Content-Type": "application/json",
73+
Authorization: `Bearer ${token}`,
6674
},
6775
body: JSON.stringify({
6876
name: taskName,

client/src/components/task_item.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ export function TaskItem({
7878

7979
async function saveEdit() {
8080
setSaving(true);
81+
82+
const token = localStorage.getItem("access");
83+
8184
try {
8285
const existing_topic_ids = draftTopics
8386
.filter((t) => t.type === "existing")
@@ -94,7 +97,10 @@ export function TaskItem({
9497
`http://localhost:8000/api/planner/tasks/${item.id}/`,
9598
{
9699
method: "PUT",
97-
headers: { "Content-Type": "application/json" },
100+
headers: {
101+
"Content-Type": "application/json",
102+
Authorization: `Bearer ${token}`,
103+
},
98104
body: JSON.stringify({
99105
name: draftName,
100106
description: draftDescription,

client/src/pages/tasks.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,16 @@ export default function TasksPage() {
9696
const task = items.find((t) => t.id === id);
9797
if (!task) return;
9898

99+
const token = localStorage.getItem("access");
100+
99101
try {
100102
const response = await fetch(
101103
`http://localhost:8000/api/planner/tasks/${id}/toggle_complete/`,
102104
{
103105
method: "PATCH",
104106
headers: {
105107
"Content-Type": "application/json",
108+
Authorization: `Bearer ${token}`,
106109
},
107110
body: JSON.stringify({ completed: !task.completed }),
108111
},
@@ -129,10 +132,17 @@ export default function TasksPage() {
129132
async function handleTaskDeleted(id: number) {
130133
if (!window.confirm("Delete this task?")) return;
131134

135+
const token = localStorage.getItem("access");
136+
132137
try {
133138
const response = await fetch(
134139
`http://localhost:8000/api/planner/tasks/${id}/`,
135-
{ method: "DELETE" },
140+
{
141+
method: "DELETE",
142+
headers: {
143+
Authorization: `Bearer ${token}`,
144+
},
145+
},
136146
);
137147

138148
if (!response.ok) {

0 commit comments

Comments
 (0)