@wzyjs/next 0.2.55 → 0.2.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/useHabitGroupCRUD.ts +27 -1
- package/package.json +2 -2
|
@@ -15,10 +15,11 @@ interface Option {
|
|
|
15
15
|
create?: Parameters<typeof api.habitGroup.create.useMutation>[0],
|
|
16
16
|
update?: Parameters<typeof api.habitGroup.update.useMutation>[0],
|
|
17
17
|
remove?: Parameters<typeof api.habitGroup.update.useMutation>[0],
|
|
18
|
+
delete?: Parameters<typeof api.habitGroup.delete.useMutation>[0],
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export const useHabitGroupCRUD = (option: Option = {}) => {
|
|
21
|
-
const { list, create, update, remove, showTip = true } = option
|
|
22
|
+
const { list, create, update, remove, delete: deleteOption, showTip = true } = option
|
|
22
23
|
|
|
23
24
|
const apiUtils = api.useUtils()
|
|
24
25
|
|
|
@@ -109,11 +110,36 @@ export const useHabitGroupCRUD = (option: Option = {}) => {
|
|
|
109
110
|
},
|
|
110
111
|
}
|
|
111
112
|
|
|
113
|
+
const baseDeleteState = api.habitGroup.delete.useMutation({
|
|
114
|
+
...deleteOption,
|
|
115
|
+
onSuccess: (...args) => {
|
|
116
|
+
if (deleteOption?.onSuccess) {
|
|
117
|
+
deleteOption.onSuccess(...args)
|
|
118
|
+
}
|
|
119
|
+
onSuccess('删除成功')
|
|
120
|
+
},
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
const deleteState = {
|
|
124
|
+
...baseDeleteState as unknown as typeof baseDeleteState,
|
|
125
|
+
mutate: (id: string) => {
|
|
126
|
+
return baseDeleteState.mutate({
|
|
127
|
+
where: { id },
|
|
128
|
+
})
|
|
129
|
+
},
|
|
130
|
+
mutateAsync: (id: string) => {
|
|
131
|
+
return baseDeleteState.mutateAsync({
|
|
132
|
+
where: { id },
|
|
133
|
+
})
|
|
134
|
+
},
|
|
135
|
+
}
|
|
136
|
+
|
|
112
137
|
return {
|
|
113
138
|
listState,
|
|
114
139
|
createState,
|
|
115
140
|
removeState,
|
|
116
141
|
updateState,
|
|
142
|
+
deleteState,
|
|
117
143
|
apiUtils,
|
|
118
144
|
}
|
|
119
145
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wzyjs/next",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.56",
|
|
4
4
|
"description": "description",
|
|
5
5
|
"author": "wzy",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@zenstackhq/sdk": "^2.12.3"
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "2a14d6fdc5a381dd93390472cdfbc409f12e65db",
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"access": "public"
|
|
22
22
|
}
|