Skip to content

Commit a891f26

Browse files
committed
Handle delete properly in store
1 parent 1af15a4 commit a891f26

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

components/modal/createApp.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
title: values.title,
2727
},
2828
{
29-
onSuccess: (key: string) => {
29+
onSuccess: (key?: string) => {
30+
if (!key) {
31+
throw new Error('Key not provided in onSuccess callback.');
32+
}
33+
3034
emit('success', key);
3135
handleClose();
3236
},

stores/useApp.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type UpdateProps = {
1414
};
1515

1616
type Options = {
17-
onSuccess?: (key: string) => void;
17+
onSuccess?: (key?: string) => void;
1818
};
1919

2020
export default defineStore('apps', () => {
@@ -55,11 +55,11 @@ export default defineStore('apps', () => {
5555
await $fetch(`/apps/${id}`, {
5656
method: 'DELETE',
5757
async onResponse({ response }) {
58-
if (response.status === 200) {
58+
if (response.status === 204) {
5959
toast.success('Deleted the app!');
6060

6161
if (typeof options.onSuccess === 'function') {
62-
options.onSuccess(response._data);
62+
options.onSuccess();
6363
}
6464

6565
await refresh();

stores/useModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default defineStore('models', () => {
8181
method: 'DELETE',
8282
query: { apiKey: apiKey.value },
8383
async onResponse({ response }) {
84-
if (response.status === 200) {
84+
if (response.status === 204) {
8585
toast.success('Deleted the model!');
8686

8787
await refresh();

stores/useModelData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default defineStore('model-data', () => {
5353
method: 'DELETE',
5454
query: { ids, apiKey: apiKey.value },
5555
async onResponse({ response }) {
56-
if (response.status === 200) {
56+
if (response.status === 204) {
5757
toast.success('Deleted the model data!');
5858

5959
await refresh();

0 commit comments

Comments
 (0)