@spotsdev/sdk 1.0.0 → 1.2.0
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/api/client.d.ts +1 -1
- package/dist/api/client.js +7 -3
- package/dist/api/entities.d.ts +318 -0
- package/dist/api/entities.js +9 -0
- package/dist/api/mutations/clubs.d.ts +6 -6
- package/dist/api/mutations/clubs.js +12 -10
- package/dist/api/mutations/conversations.d.ts +7 -7
- package/dist/api/mutations/conversations.js +17 -13
- package/dist/api/mutations/index.js +1 -1
- package/dist/api/mutations/notifications.d.ts +4 -4
- package/dist/api/mutations/notifications.js +7 -7
- package/dist/api/mutations/orders.d.ts +7 -7
- package/dist/api/mutations/orders.js +11 -13
- package/dist/api/mutations/posts.d.ts +13 -13
- package/dist/api/mutations/posts.js +41 -29
- package/dist/api/mutations/products.d.ts +5 -5
- package/dist/api/mutations/products.js +9 -13
- package/dist/api/mutations/spots.d.ts +42 -8
- package/dist/api/mutations/spots.js +51 -13
- package/dist/api/mutations/users.d.ts +12 -10
- package/dist/api/mutations/users.js +20 -18
- package/dist/api/queries/auth.d.ts +5 -5
- package/dist/api/queries/auth.js +7 -7
- package/dist/api/queries/clubs.d.ts +7 -7
- package/dist/api/queries/clubs.js +11 -11
- package/dist/api/queries/conversations.d.ts +5 -5
- package/dist/api/queries/conversations.js +7 -7
- package/dist/api/queries/index.js +1 -1
- package/dist/api/queries/misc.d.ts +8 -32
- package/dist/api/queries/misc.js +28 -66
- package/dist/api/queries/notifications.d.ts +4 -4
- package/dist/api/queries/notifications.js +5 -5
- package/dist/api/queries/orders.d.ts +4 -4
- package/dist/api/queries/orders.js +7 -7
- package/dist/api/queries/posts.d.ts +44 -7
- package/dist/api/queries/posts.js +118 -15
- package/dist/api/queries/products.d.ts +6 -10
- package/dist/api/queries/products.js +7 -9
- package/dist/api/queries/spots.d.ts +31 -16
- package/dist/api/queries/spots.js +113 -31
- package/dist/api/queries/templates.d.ts +6 -9
- package/dist/api/queries/templates.js +8 -13
- package/dist/api/queries/users.d.ts +25 -11
- package/dist/api/queries/users.js +75 -27
- package/dist/api/types.d.ts +36 -33
- package/dist/api/types.js +6 -7
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -8
- package/package.json +6 -21
- package/src/api/client.ts +45 -30
- package/src/api/entities.ts +424 -0
- package/src/api/mutations/clubs.ts +73 -40
- package/src/api/mutations/conversations.ts +91 -47
- package/src/api/mutations/index.ts +8 -8
- package/src/api/mutations/notifications.ts +48 -25
- package/src/api/mutations/orders.ts +101 -70
- package/src/api/mutations/posts.ts +229 -118
- package/src/api/mutations/products.ts +120 -81
- package/src/api/mutations/spots.ts +167 -55
- package/src/api/mutations/users.ts +109 -76
- package/src/api/queries/auth.ts +49 -24
- package/src/api/queries/clubs.ts +53 -38
- package/src/api/queries/conversations.ts +48 -30
- package/src/api/queries/index.ts +21 -21
- package/src/api/queries/misc.ts +53 -82
- package/src/api/queries/notifications.ts +32 -21
- package/src/api/queries/orders.ts +59 -42
- package/src/api/queries/posts.ts +203 -48
- package/src/api/queries/products.ts +51 -44
- package/src/api/queries/spots.ts +216 -85
- package/src/api/queries/templates.ts +39 -32
- package/src/api/queries/users.ts +157 -64
- package/src/api/types.ts +72 -118
- package/src/index.ts +5 -11
|
@@ -4,20 +4,26 @@
|
|
|
4
4
|
* TanStack Query hooks for post/board mutation operations.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
ApiResponse,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
import {
|
|
8
|
+
useMutation,
|
|
9
|
+
type UseMutationOptions,
|
|
10
|
+
type UseMutationResult,
|
|
11
|
+
useQueryClient,
|
|
12
|
+
} from '@tanstack/react-query'
|
|
13
|
+
|
|
14
|
+
import {getApiClient} from '../client'
|
|
15
|
+
import {postKeys} from '../queries/posts'
|
|
16
|
+
import {
|
|
17
|
+
type ApiResponse,
|
|
18
|
+
type CreatePostRequest,
|
|
19
|
+
type CreateReplyRequest,
|
|
20
|
+
type Post,
|
|
21
|
+
type PostResponse,
|
|
22
|
+
type PostStatusDto,
|
|
23
|
+
type RespondToPostRequest,
|
|
24
|
+
type UpdateResponseRequest,
|
|
25
|
+
type UpvoteResponse,
|
|
26
|
+
} from '../types'
|
|
21
27
|
|
|
22
28
|
// ============================================================================
|
|
23
29
|
// MUTATION HOOKS
|
|
@@ -26,253 +32,358 @@ import type {
|
|
|
26
32
|
/**
|
|
27
33
|
* Create a new post
|
|
28
34
|
*
|
|
29
|
-
* @endpoint POST /
|
|
35
|
+
* @endpoint POST /spots/{spotId}/posts
|
|
30
36
|
*/
|
|
31
37
|
export function useCreatePost(
|
|
32
|
-
options?: Omit<
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
options?: Omit<
|
|
39
|
+
UseMutationOptions<Post, Error, {spotId: string} & CreatePostRequest>,
|
|
40
|
+
'mutationFn'
|
|
41
|
+
>,
|
|
42
|
+
): UseMutationResult<Post, Error, {spotId: string} & CreatePostRequest> {
|
|
43
|
+
const queryClient = useQueryClient()
|
|
35
44
|
|
|
36
45
|
return useMutation({
|
|
37
|
-
mutationFn: async ({
|
|
38
|
-
const client = getApiClient()
|
|
39
|
-
const response = await client.post<ApiResponse<Post>>(
|
|
40
|
-
|
|
46
|
+
mutationFn: async ({spotId, ...data}): Promise<Post> => {
|
|
47
|
+
const client = getApiClient()
|
|
48
|
+
const response = await client.post<ApiResponse<Post>>(
|
|
49
|
+
`/spots/${spotId}/posts`,
|
|
50
|
+
data,
|
|
51
|
+
)
|
|
52
|
+
return response.data.data
|
|
41
53
|
},
|
|
42
54
|
onSuccess: (_, variables) => {
|
|
43
|
-
queryClient.invalidateQueries({
|
|
55
|
+
queryClient.invalidateQueries({
|
|
56
|
+
queryKey: postKeys.bySpot(variables.spotId),
|
|
57
|
+
})
|
|
44
58
|
},
|
|
45
59
|
...options,
|
|
46
|
-
})
|
|
60
|
+
})
|
|
47
61
|
}
|
|
48
62
|
|
|
49
63
|
/**
|
|
50
64
|
* Update a post
|
|
51
65
|
*
|
|
52
|
-
* @endpoint PUT /
|
|
66
|
+
* @endpoint PUT /posts/{postId}
|
|
53
67
|
*/
|
|
54
68
|
export function useUpdatePost(
|
|
55
|
-
options?: Omit<
|
|
56
|
-
|
|
57
|
-
|
|
69
|
+
options?: Omit<
|
|
70
|
+
UseMutationOptions<
|
|
71
|
+
Post,
|
|
72
|
+
Error,
|
|
73
|
+
{postId: string; title?: string; content?: string}
|
|
74
|
+
>,
|
|
75
|
+
'mutationFn'
|
|
76
|
+
>,
|
|
77
|
+
): UseMutationResult<
|
|
78
|
+
Post,
|
|
79
|
+
Error,
|
|
80
|
+
{postId: string; title?: string; content?: string}
|
|
81
|
+
> {
|
|
82
|
+
const queryClient = useQueryClient()
|
|
58
83
|
|
|
59
84
|
return useMutation({
|
|
60
|
-
mutationFn: async ({
|
|
61
|
-
const client = getApiClient()
|
|
62
|
-
const response = await client.put<ApiResponse<Post>>(
|
|
63
|
-
|
|
85
|
+
mutationFn: async ({postId, ...data}): Promise<Post> => {
|
|
86
|
+
const client = getApiClient()
|
|
87
|
+
const response = await client.put<ApiResponse<Post>>(
|
|
88
|
+
`/posts/${postId}`,
|
|
89
|
+
data,
|
|
90
|
+
)
|
|
91
|
+
return response.data.data
|
|
64
92
|
},
|
|
65
93
|
onSuccess: (data, variables) => {
|
|
66
|
-
queryClient.setQueryData(postKeys.detail(variables.postId), data)
|
|
94
|
+
queryClient.setQueryData(postKeys.detail(variables.postId), data)
|
|
67
95
|
},
|
|
68
96
|
...options,
|
|
69
|
-
})
|
|
97
|
+
})
|
|
70
98
|
}
|
|
71
99
|
|
|
72
100
|
/**
|
|
73
101
|
* Delete a post
|
|
74
102
|
*
|
|
75
|
-
* @endpoint DELETE /
|
|
103
|
+
* @endpoint DELETE /posts/{postId}
|
|
76
104
|
*/
|
|
77
105
|
export function useDeletePost(
|
|
78
|
-
options?: Omit<UseMutationOptions<void, Error, string>, 'mutationFn'
|
|
106
|
+
options?: Omit<UseMutationOptions<void, Error, string>, 'mutationFn'>,
|
|
79
107
|
): UseMutationResult<void, Error, string> {
|
|
80
|
-
const queryClient = useQueryClient()
|
|
108
|
+
const queryClient = useQueryClient()
|
|
81
109
|
|
|
82
110
|
return useMutation({
|
|
83
111
|
mutationFn: async (postId: string): Promise<void> => {
|
|
84
|
-
const client = getApiClient()
|
|
85
|
-
await client.delete(`/
|
|
112
|
+
const client = getApiClient()
|
|
113
|
+
await client.delete(`/posts/${postId}`)
|
|
86
114
|
},
|
|
87
115
|
onSuccess: (_, postId) => {
|
|
88
|
-
queryClient.invalidateQueries({
|
|
89
|
-
queryClient.invalidateQueries({
|
|
116
|
+
queryClient.invalidateQueries({queryKey: postKeys.detail(postId)})
|
|
117
|
+
queryClient.invalidateQueries({queryKey: postKeys.lists()})
|
|
90
118
|
},
|
|
91
119
|
...options,
|
|
92
|
-
})
|
|
120
|
+
})
|
|
93
121
|
}
|
|
94
122
|
|
|
95
123
|
/**
|
|
96
124
|
* Fulfill a post (mark as fulfilled)
|
|
97
125
|
*
|
|
98
|
-
* @endpoint PUT /
|
|
126
|
+
* @endpoint PUT /posts/{postId}/fulfill
|
|
99
127
|
*/
|
|
100
128
|
export function useFulfillPost(
|
|
101
|
-
options?: Omit<UseMutationOptions<Post, Error, string>, 'mutationFn'
|
|
129
|
+
options?: Omit<UseMutationOptions<Post, Error, string>, 'mutationFn'>,
|
|
102
130
|
): UseMutationResult<Post, Error, string> {
|
|
103
|
-
const queryClient = useQueryClient()
|
|
131
|
+
const queryClient = useQueryClient()
|
|
104
132
|
|
|
105
133
|
return useMutation({
|
|
106
134
|
mutationFn: async (postId: string): Promise<Post> => {
|
|
107
|
-
const client = getApiClient()
|
|
108
|
-
const response = await client.put<ApiResponse<Post>>(
|
|
109
|
-
|
|
135
|
+
const client = getApiClient()
|
|
136
|
+
const response = await client.put<ApiResponse<Post>>(
|
|
137
|
+
`/posts/${postId}/fulfill`,
|
|
138
|
+
)
|
|
139
|
+
return response.data.data
|
|
110
140
|
},
|
|
111
141
|
onSuccess: (data, postId) => {
|
|
112
|
-
queryClient.setQueryData(postKeys.detail(postId), data)
|
|
142
|
+
queryClient.setQueryData(postKeys.detail(postId), data)
|
|
113
143
|
},
|
|
114
144
|
...options,
|
|
115
|
-
})
|
|
145
|
+
})
|
|
116
146
|
}
|
|
117
147
|
|
|
118
148
|
/**
|
|
119
149
|
* Upvote/unupvote a post
|
|
120
150
|
*
|
|
121
|
-
* @endpoint POST /
|
|
151
|
+
* @endpoint POST /posts/{postId}/upvote
|
|
122
152
|
*/
|
|
123
153
|
export function useUpvotePost(
|
|
124
|
-
options?: Omit<
|
|
154
|
+
options?: Omit<
|
|
155
|
+
UseMutationOptions<UpvoteResponse, Error, string>,
|
|
156
|
+
'mutationFn'
|
|
157
|
+
>,
|
|
125
158
|
): UseMutationResult<UpvoteResponse, Error, string> {
|
|
126
|
-
const queryClient = useQueryClient()
|
|
159
|
+
const queryClient = useQueryClient()
|
|
127
160
|
|
|
128
161
|
return useMutation({
|
|
129
162
|
mutationFn: async (postId: string): Promise<UpvoteResponse> => {
|
|
130
|
-
const client = getApiClient()
|
|
131
|
-
const response = await client.post<ApiResponse<UpvoteResponse>>(
|
|
132
|
-
|
|
163
|
+
const client = getApiClient()
|
|
164
|
+
const response = await client.post<ApiResponse<UpvoteResponse>>(
|
|
165
|
+
`/posts/${postId}/upvote`,
|
|
166
|
+
)
|
|
167
|
+
return response.data.data
|
|
133
168
|
},
|
|
134
169
|
onSuccess: (_, postId) => {
|
|
135
|
-
queryClient.invalidateQueries({
|
|
170
|
+
queryClient.invalidateQueries({queryKey: postKeys.detail(postId)})
|
|
136
171
|
},
|
|
137
172
|
...options,
|
|
138
|
-
})
|
|
173
|
+
})
|
|
139
174
|
}
|
|
140
175
|
|
|
141
176
|
/**
|
|
142
177
|
* Create a reply to a post
|
|
143
178
|
*
|
|
144
|
-
* @endpoint POST /
|
|
179
|
+
* @endpoint POST /posts/{postId}/reply
|
|
145
180
|
*/
|
|
146
181
|
export function useCreateReply(
|
|
147
|
-
options?: Omit<
|
|
148
|
-
|
|
149
|
-
|
|
182
|
+
options?: Omit<
|
|
183
|
+
UseMutationOptions<unknown, Error, {postId: string} & CreateReplyRequest>,
|
|
184
|
+
'mutationFn'
|
|
185
|
+
>,
|
|
186
|
+
): UseMutationResult<unknown, Error, {postId: string} & CreateReplyRequest> {
|
|
187
|
+
const queryClient = useQueryClient()
|
|
150
188
|
|
|
151
189
|
return useMutation({
|
|
152
|
-
mutationFn: async ({
|
|
153
|
-
const client = getApiClient()
|
|
154
|
-
const response = await client.post<ApiResponse<unknown>>(
|
|
155
|
-
|
|
190
|
+
mutationFn: async ({postId, ...data}) => {
|
|
191
|
+
const client = getApiClient()
|
|
192
|
+
const response = await client.post<ApiResponse<unknown>>(
|
|
193
|
+
`/posts/${postId}/reply`,
|
|
194
|
+
data,
|
|
195
|
+
)
|
|
196
|
+
return response.data.data
|
|
156
197
|
},
|
|
157
198
|
onSuccess: (_, variables) => {
|
|
158
|
-
queryClient.invalidateQueries({
|
|
199
|
+
queryClient.invalidateQueries({
|
|
200
|
+
queryKey: postKeys.detail(variables.postId),
|
|
201
|
+
})
|
|
159
202
|
},
|
|
160
203
|
...options,
|
|
161
|
-
})
|
|
204
|
+
})
|
|
162
205
|
}
|
|
163
206
|
|
|
164
207
|
/**
|
|
165
208
|
* Delete a reply
|
|
166
209
|
*
|
|
167
|
-
* @endpoint DELETE /
|
|
210
|
+
* @endpoint DELETE /replies/{replyId}
|
|
168
211
|
*/
|
|
169
212
|
export function useDeleteReply(
|
|
170
|
-
options?: Omit<
|
|
171
|
-
|
|
172
|
-
|
|
213
|
+
options?: Omit<
|
|
214
|
+
UseMutationOptions<void, Error, {replyId: string; postId: string}>,
|
|
215
|
+
'mutationFn'
|
|
216
|
+
>,
|
|
217
|
+
): UseMutationResult<void, Error, {replyId: string; postId: string}> {
|
|
218
|
+
const queryClient = useQueryClient()
|
|
173
219
|
|
|
174
220
|
return useMutation({
|
|
175
|
-
mutationFn: async ({
|
|
176
|
-
const client = getApiClient()
|
|
177
|
-
await client.delete(`/
|
|
221
|
+
mutationFn: async ({replyId}): Promise<void> => {
|
|
222
|
+
const client = getApiClient()
|
|
223
|
+
await client.delete(`/replies/${replyId}`)
|
|
178
224
|
},
|
|
179
225
|
onSuccess: (_, variables) => {
|
|
180
|
-
queryClient.invalidateQueries({
|
|
226
|
+
queryClient.invalidateQueries({
|
|
227
|
+
queryKey: postKeys.detail(variables.postId),
|
|
228
|
+
})
|
|
181
229
|
},
|
|
182
230
|
...options,
|
|
183
|
-
})
|
|
231
|
+
})
|
|
184
232
|
}
|
|
185
233
|
|
|
186
234
|
/**
|
|
187
235
|
* Respond to a post (express interest)
|
|
188
236
|
*
|
|
189
|
-
* @endpoint POST /
|
|
237
|
+
* @endpoint POST /posts/{postId}/respond
|
|
190
238
|
*/
|
|
191
239
|
export function useRespondToPost(
|
|
192
|
-
options?: Omit<
|
|
193
|
-
|
|
194
|
-
|
|
240
|
+
options?: Omit<
|
|
241
|
+
UseMutationOptions<
|
|
242
|
+
PostResponse,
|
|
243
|
+
Error,
|
|
244
|
+
{postId: string} & RespondToPostRequest
|
|
245
|
+
>,
|
|
246
|
+
'mutationFn'
|
|
247
|
+
>,
|
|
248
|
+
): UseMutationResult<
|
|
249
|
+
PostResponse,
|
|
250
|
+
Error,
|
|
251
|
+
{postId: string} & RespondToPostRequest
|
|
252
|
+
> {
|
|
253
|
+
const queryClient = useQueryClient()
|
|
195
254
|
|
|
196
255
|
return useMutation({
|
|
197
|
-
mutationFn: async ({
|
|
198
|
-
const client = getApiClient()
|
|
199
|
-
const response = await client.post<ApiResponse<PostResponse>>(
|
|
200
|
-
|
|
256
|
+
mutationFn: async ({postId, ...data}): Promise<PostResponse> => {
|
|
257
|
+
const client = getApiClient()
|
|
258
|
+
const response = await client.post<ApiResponse<PostResponse>>(
|
|
259
|
+
`/posts/${postId}/respond`,
|
|
260
|
+
data,
|
|
261
|
+
)
|
|
262
|
+
return response.data.data
|
|
201
263
|
},
|
|
202
264
|
onSuccess: (_, variables) => {
|
|
203
|
-
queryClient.invalidateQueries({
|
|
204
|
-
|
|
265
|
+
queryClient.invalidateQueries({
|
|
266
|
+
queryKey: postKeys.detail(variables.postId),
|
|
267
|
+
})
|
|
268
|
+
queryClient.invalidateQueries({
|
|
269
|
+
queryKey: postKeys.responses(variables.postId),
|
|
270
|
+
})
|
|
205
271
|
},
|
|
206
272
|
...options,
|
|
207
|
-
})
|
|
273
|
+
})
|
|
208
274
|
}
|
|
209
275
|
|
|
210
276
|
/**
|
|
211
277
|
* Accept or decline a response
|
|
212
278
|
*
|
|
213
|
-
* @endpoint PUT /
|
|
279
|
+
* @endpoint PUT /responses/{responseId}
|
|
214
280
|
*/
|
|
215
281
|
export function useUpdateResponse(
|
|
216
|
-
options?: Omit<
|
|
217
|
-
|
|
218
|
-
|
|
282
|
+
options?: Omit<
|
|
283
|
+
UseMutationOptions<
|
|
284
|
+
PostResponse,
|
|
285
|
+
Error,
|
|
286
|
+
{responseId: string; postId: string} & UpdateResponseRequest
|
|
287
|
+
>,
|
|
288
|
+
'mutationFn'
|
|
289
|
+
>,
|
|
290
|
+
): UseMutationResult<
|
|
291
|
+
PostResponse,
|
|
292
|
+
Error,
|
|
293
|
+
{responseId: string; postId: string} & UpdateResponseRequest
|
|
294
|
+
> {
|
|
295
|
+
const queryClient = useQueryClient()
|
|
219
296
|
|
|
220
297
|
return useMutation({
|
|
221
|
-
mutationFn: async ({
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
298
|
+
mutationFn: async ({
|
|
299
|
+
responseId,
|
|
300
|
+
postId: _,
|
|
301
|
+
...data
|
|
302
|
+
}): Promise<PostResponse> => {
|
|
303
|
+
const client = getApiClient()
|
|
304
|
+
const response = await client.put<ApiResponse<PostResponse>>(
|
|
305
|
+
`/responses/${responseId}`,
|
|
306
|
+
data,
|
|
307
|
+
)
|
|
308
|
+
return response.data.data
|
|
225
309
|
},
|
|
226
310
|
onSuccess: (_, variables) => {
|
|
227
|
-
queryClient.invalidateQueries({
|
|
311
|
+
queryClient.invalidateQueries({
|
|
312
|
+
queryKey: postKeys.responses(variables.postId),
|
|
313
|
+
})
|
|
228
314
|
},
|
|
229
315
|
...options,
|
|
230
|
-
})
|
|
316
|
+
})
|
|
231
317
|
}
|
|
232
318
|
|
|
233
319
|
/**
|
|
234
320
|
* Report a post
|
|
235
321
|
*
|
|
236
|
-
* @endpoint POST /
|
|
322
|
+
* @endpoint POST /posts/{postId}/report
|
|
237
323
|
*/
|
|
238
324
|
export function useReportPost(
|
|
239
|
-
options?: Omit<
|
|
240
|
-
|
|
325
|
+
options?: Omit<
|
|
326
|
+
UseMutationOptions<
|
|
327
|
+
void,
|
|
328
|
+
Error,
|
|
329
|
+
{postId: string; reason: string; details?: string}
|
|
330
|
+
>,
|
|
331
|
+
'mutationFn'
|
|
332
|
+
>,
|
|
333
|
+
): UseMutationResult<
|
|
334
|
+
void,
|
|
335
|
+
Error,
|
|
336
|
+
{postId: string; reason: string; details?: string}
|
|
337
|
+
> {
|
|
241
338
|
return useMutation({
|
|
242
|
-
mutationFn: async ({
|
|
243
|
-
const client = getApiClient()
|
|
244
|
-
await client.post(`/
|
|
339
|
+
mutationFn: async ({postId, ...data}): Promise<void> => {
|
|
340
|
+
const client = getApiClient()
|
|
341
|
+
await client.post(`/posts/${postId}/report`, data)
|
|
245
342
|
},
|
|
246
343
|
...options,
|
|
247
|
-
})
|
|
344
|
+
})
|
|
248
345
|
}
|
|
249
346
|
|
|
250
347
|
// PostStatusUpdate matches partial PostStatusDto for updates
|
|
251
348
|
interface PostStatusUpdate {
|
|
252
|
-
isRead?: boolean
|
|
253
|
-
isHidden?: boolean
|
|
254
|
-
isPinned?: boolean
|
|
349
|
+
isRead?: boolean
|
|
350
|
+
isHidden?: boolean
|
|
351
|
+
isPinned?: boolean
|
|
255
352
|
}
|
|
256
353
|
|
|
257
354
|
/**
|
|
258
355
|
* Update user's status for a post (read/hidden/pinned)
|
|
259
356
|
*
|
|
260
|
-
* @endpoint PUT /
|
|
357
|
+
* @endpoint PUT /posts/{postId}/status
|
|
261
358
|
*/
|
|
262
359
|
export function useUpdatePostStatus(
|
|
263
|
-
options?: Omit<
|
|
264
|
-
|
|
265
|
-
|
|
360
|
+
options?: Omit<
|
|
361
|
+
UseMutationOptions<
|
|
362
|
+
PostStatusDto,
|
|
363
|
+
Error,
|
|
364
|
+
{postId: string} & PostStatusUpdate
|
|
365
|
+
>,
|
|
366
|
+
'mutationFn'
|
|
367
|
+
>,
|
|
368
|
+
): UseMutationResult<
|
|
369
|
+
PostStatusDto,
|
|
370
|
+
Error,
|
|
371
|
+
{postId: string} & PostStatusUpdate
|
|
372
|
+
> {
|
|
373
|
+
const queryClient = useQueryClient()
|
|
266
374
|
|
|
267
375
|
return useMutation({
|
|
268
|
-
mutationFn: async ({
|
|
269
|
-
const client = getApiClient()
|
|
270
|
-
const response = await client.put<ApiResponse<PostStatusDto>>(
|
|
271
|
-
|
|
376
|
+
mutationFn: async ({postId, ...data}): Promise<PostStatusDto> => {
|
|
377
|
+
const client = getApiClient()
|
|
378
|
+
const response = await client.put<ApiResponse<PostStatusDto>>(
|
|
379
|
+
`/posts/${postId}/status`,
|
|
380
|
+
data,
|
|
381
|
+
)
|
|
382
|
+
return response.data.data
|
|
272
383
|
},
|
|
273
384
|
onSuccess: (data, variables) => {
|
|
274
|
-
queryClient.setQueryData(postKeys.status(variables.postId), data)
|
|
385
|
+
queryClient.setQueryData(postKeys.status(variables.postId), data)
|
|
275
386
|
},
|
|
276
387
|
...options,
|
|
277
|
-
})
|
|
388
|
+
})
|
|
278
389
|
}
|