-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: delete selected activities/outputs/partners
- Loading branch information
Showing
6 changed files
with
137 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,73 @@ | ||
import { useAuthStore } from "@/stores/auth"; | ||
import { BASE_URL } from "./api"; | ||
|
||
|
||
export const getActivities = async () => { | ||
const auth = useAuthStore(); | ||
const auth = useAuthStore(); | ||
|
||
const response = await fetch(`${BASE_URL}/v1/activities`, { | ||
headers: { | ||
"Authorization": `Bearer ${auth.token}` | ||
} | ||
}); | ||
const result = await response.json(); | ||
const response = await fetch(`${BASE_URL}/v1/activities`, { | ||
headers: { | ||
Authorization: `Bearer ${auth.token}`, | ||
}, | ||
}); | ||
const result = await response.json(); | ||
|
||
if (!response.ok) { | ||
throw new Error(result.message); | ||
} | ||
|
||
return result.data; | ||
}; | ||
|
||
export const deleteActivities = async (payload: any) => { | ||
const auth = useAuthStore(); | ||
|
||
if (!response.ok) { | ||
throw new Error(result.message) | ||
} | ||
const response = await fetch(`${BASE_URL}/v1/activities`, { | ||
method: "DELETE", | ||
headers: { | ||
Authorization: `Bearer ${auth.token}`, | ||
}, | ||
body: JSON.stringify(payload), | ||
}); | ||
|
||
return result.data; | ||
if (!response.ok) { | ||
const result = await response.json(); | ||
throw new Error(result.message); | ||
} | ||
}; | ||
|
||
export const deleteActivity = async (id: string) => { | ||
const auth = useAuthStore(); | ||
|
||
const response = await fetch(`${BASE_URL}/v1/activities/${id}`, { | ||
method: "DELETE", | ||
headers: { | ||
"Authorization": `Bearer ${auth.token}` | ||
} | ||
}); | ||
|
||
if (!response.ok) { | ||
const result = await response.json(); | ||
throw new Error(result.message) | ||
} | ||
const auth = useAuthStore(); | ||
|
||
const response = await fetch(`${BASE_URL}/v1/activities/${id}`, { | ||
method: "DELETE", | ||
headers: { | ||
Authorization: `Bearer ${auth.token}`, | ||
}, | ||
}); | ||
|
||
if (!response.ok) { | ||
const result = await response.json(); | ||
throw new Error(result.message); | ||
} | ||
}; | ||
|
||
export const createActivity = async (payload: any) => { | ||
const auth = useAuthStore(); | ||
const auth = useAuthStore(); | ||
|
||
const response = await fetch(`${BASE_URL}/v1/activities`, { | ||
method: "POST", | ||
headers: { | ||
"Authorization": `Bearer ${auth.token}`, | ||
"Content-Type": "application/json" | ||
}, | ||
body: JSON.stringify(payload) | ||
}); | ||
const response = await fetch(`${BASE_URL}/v1/activities`, { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${auth.token}`, | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(payload), | ||
}); | ||
|
||
const result = await response.json(); | ||
const result = await response.json(); | ||
|
||
if (!response.ok) { | ||
throw new Error(result.message) | ||
} | ||
if (!response.ok) { | ||
throw new Error(result.message); | ||
} | ||
|
||
return result; | ||
}; | ||
return result; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters