@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,11 +4,17 @@
|
|
|
4
4
|
* TanStack Query hooks for club mutation operations.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 {clubKeys} from '../queries/clubs'
|
|
16
|
+
import {userKeys} from '../queries/users'
|
|
17
|
+
import {type ApiResponse, type Club} from '../types'
|
|
12
18
|
|
|
13
19
|
// ============================================================================
|
|
14
20
|
// MUTATION HOOKS
|
|
@@ -17,91 +23,118 @@ import type { Club, ApiResponse } from '../types';
|
|
|
17
23
|
/**
|
|
18
24
|
* Create a new club
|
|
19
25
|
*
|
|
20
|
-
* @endpoint POST /
|
|
26
|
+
* @endpoint POST /clubs
|
|
21
27
|
*/
|
|
22
28
|
export function useCreateClub(
|
|
23
|
-
options?: Omit<
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
options?: Omit<
|
|
30
|
+
UseMutationOptions<
|
|
31
|
+
Club,
|
|
32
|
+
Error,
|
|
33
|
+
{spotId: string; name: string; description?: string}
|
|
34
|
+
>,
|
|
35
|
+
'mutationFn'
|
|
36
|
+
>,
|
|
37
|
+
): UseMutationResult<
|
|
38
|
+
Club,
|
|
39
|
+
Error,
|
|
40
|
+
{spotId: string; name: string; description?: string}
|
|
41
|
+
> {
|
|
42
|
+
const queryClient = useQueryClient()
|
|
26
43
|
|
|
27
44
|
return useMutation({
|
|
28
45
|
mutationFn: async (data): Promise<Club> => {
|
|
29
|
-
const client = getApiClient()
|
|
30
|
-
const response = await client.post<ApiResponse<Club>>('/
|
|
31
|
-
return response.data.data
|
|
46
|
+
const client = getApiClient()
|
|
47
|
+
const response = await client.post<ApiResponse<Club>>('/clubs', data)
|
|
48
|
+
return response.data.data
|
|
32
49
|
},
|
|
33
50
|
onSuccess: (_, variables) => {
|
|
34
|
-
queryClient.invalidateQueries({
|
|
51
|
+
queryClient.invalidateQueries({
|
|
52
|
+
queryKey: clubKeys.bySpot(variables.spotId),
|
|
53
|
+
})
|
|
35
54
|
},
|
|
36
55
|
...options,
|
|
37
|
-
})
|
|
56
|
+
})
|
|
38
57
|
}
|
|
39
58
|
|
|
40
59
|
/**
|
|
41
60
|
* Update a club
|
|
42
61
|
*
|
|
43
|
-
* @endpoint PUT /
|
|
62
|
+
* @endpoint PUT /clubs/{id}
|
|
44
63
|
*/
|
|
45
64
|
export function useUpdateClub(
|
|
46
|
-
options?: Omit<
|
|
47
|
-
|
|
48
|
-
|
|
65
|
+
options?: Omit<
|
|
66
|
+
UseMutationOptions<
|
|
67
|
+
Club,
|
|
68
|
+
Error,
|
|
69
|
+
{clubId: string; name?: string; description?: string}
|
|
70
|
+
>,
|
|
71
|
+
'mutationFn'
|
|
72
|
+
>,
|
|
73
|
+
): UseMutationResult<
|
|
74
|
+
Club,
|
|
75
|
+
Error,
|
|
76
|
+
{clubId: string; name?: string; description?: string}
|
|
77
|
+
> {
|
|
78
|
+
const queryClient = useQueryClient()
|
|
49
79
|
|
|
50
80
|
return useMutation({
|
|
51
|
-
mutationFn: async ({
|
|
52
|
-
const client = getApiClient()
|
|
53
|
-
const response = await client.put<ApiResponse<Club>>(
|
|
54
|
-
|
|
81
|
+
mutationFn: async ({clubId, ...data}): Promise<Club> => {
|
|
82
|
+
const client = getApiClient()
|
|
83
|
+
const response = await client.put<ApiResponse<Club>>(
|
|
84
|
+
`/clubs/${clubId}`,
|
|
85
|
+
data,
|
|
86
|
+
)
|
|
87
|
+
return response.data.data
|
|
55
88
|
},
|
|
56
89
|
onSuccess: (data, variables) => {
|
|
57
|
-
queryClient.setQueryData(clubKeys.detail(variables.clubId), data)
|
|
90
|
+
queryClient.setQueryData(clubKeys.detail(variables.clubId), data)
|
|
58
91
|
},
|
|
59
92
|
...options,
|
|
60
|
-
})
|
|
93
|
+
})
|
|
61
94
|
}
|
|
62
95
|
|
|
63
96
|
/**
|
|
64
97
|
* Join a club
|
|
65
98
|
*
|
|
66
|
-
* @endpoint POST /
|
|
99
|
+
* @endpoint POST /clubs/{id}/join
|
|
67
100
|
*/
|
|
68
101
|
export function useJoinClub(
|
|
69
|
-
options?: Omit<UseMutationOptions<void, Error, string>, 'mutationFn'
|
|
102
|
+
options?: Omit<UseMutationOptions<void, Error, string>, 'mutationFn'>,
|
|
70
103
|
): UseMutationResult<void, Error, string> {
|
|
71
|
-
const queryClient = useQueryClient()
|
|
104
|
+
const queryClient = useQueryClient()
|
|
72
105
|
|
|
73
106
|
return useMutation({
|
|
74
107
|
mutationFn: async (clubId: string): Promise<void> => {
|
|
75
|
-
const client = getApiClient()
|
|
76
|
-
await client.post(`/
|
|
108
|
+
const client = getApiClient()
|
|
109
|
+
await client.post(`/clubs/${clubId}/join`)
|
|
77
110
|
},
|
|
78
111
|
onSuccess: (_, clubId) => {
|
|
79
|
-
queryClient.invalidateQueries({
|
|
80
|
-
queryClient.invalidateQueries({
|
|
112
|
+
queryClient.invalidateQueries({queryKey: clubKeys.detail(clubId)})
|
|
113
|
+
queryClient.invalidateQueries({queryKey: userKeys.clubs()})
|
|
81
114
|
},
|
|
82
115
|
...options,
|
|
83
|
-
})
|
|
116
|
+
})
|
|
84
117
|
}
|
|
85
118
|
|
|
86
119
|
/**
|
|
87
120
|
* Leave a club
|
|
88
121
|
*
|
|
89
|
-
* @endpoint POST /
|
|
122
|
+
* @endpoint POST /clubs/{id}/leave
|
|
90
123
|
*/
|
|
91
124
|
export function useLeaveClub(
|
|
92
|
-
options?: Omit<UseMutationOptions<void, Error, string>, 'mutationFn'
|
|
125
|
+
options?: Omit<UseMutationOptions<void, Error, string>, 'mutationFn'>,
|
|
93
126
|
): UseMutationResult<void, Error, string> {
|
|
94
|
-
const queryClient = useQueryClient()
|
|
127
|
+
const queryClient = useQueryClient()
|
|
95
128
|
|
|
96
129
|
return useMutation({
|
|
97
130
|
mutationFn: async (clubId: string): Promise<void> => {
|
|
98
|
-
const client = getApiClient()
|
|
99
|
-
await client.post(`/
|
|
131
|
+
const client = getApiClient()
|
|
132
|
+
await client.post(`/clubs/${clubId}/leave`)
|
|
100
133
|
},
|
|
101
134
|
onSuccess: (_, clubId) => {
|
|
102
|
-
queryClient.invalidateQueries({
|
|
103
|
-
queryClient.invalidateQueries({
|
|
135
|
+
queryClient.invalidateQueries({queryKey: clubKeys.detail(clubId)})
|
|
136
|
+
queryClient.invalidateQueries({queryKey: userKeys.clubs()})
|
|
104
137
|
},
|
|
105
138
|
...options,
|
|
106
|
-
})
|
|
139
|
+
})
|
|
107
140
|
}
|
|
@@ -4,10 +4,22 @@
|
|
|
4
4
|
* TanStack Query hooks for conversation/messaging mutation operations.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 {conversationKeys} from '../queries/conversations'
|
|
16
|
+
import {
|
|
17
|
+
type ApiResponse,
|
|
18
|
+
type Conversation,
|
|
19
|
+
type CreateConversationRequest,
|
|
20
|
+
type Message,
|
|
21
|
+
type SendMessageRequest,
|
|
22
|
+
} from '../types'
|
|
11
23
|
|
|
12
24
|
// ============================================================================
|
|
13
25
|
// MUTATION HOOKS
|
|
@@ -16,109 +28,141 @@ import type { Conversation, Message, CreateConversationRequest, SendMessageReque
|
|
|
16
28
|
/**
|
|
17
29
|
* Create a new conversation
|
|
18
30
|
*
|
|
19
|
-
* @endpoint POST /
|
|
31
|
+
* @endpoint POST /conversations
|
|
20
32
|
*/
|
|
21
33
|
export function useCreateConversation(
|
|
22
|
-
options?: Omit<
|
|
34
|
+
options?: Omit<
|
|
35
|
+
UseMutationOptions<Conversation, Error, CreateConversationRequest>,
|
|
36
|
+
'mutationFn'
|
|
37
|
+
>,
|
|
23
38
|
): UseMutationResult<Conversation, Error, CreateConversationRequest> {
|
|
24
|
-
const queryClient = useQueryClient()
|
|
39
|
+
const queryClient = useQueryClient()
|
|
25
40
|
|
|
26
41
|
return useMutation({
|
|
27
|
-
mutationFn: async (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
mutationFn: async (
|
|
43
|
+
data: CreateConversationRequest,
|
|
44
|
+
): Promise<Conversation> => {
|
|
45
|
+
const client = getApiClient()
|
|
46
|
+
const response = await client.post<ApiResponse<Conversation>>(
|
|
47
|
+
'/conversations',
|
|
48
|
+
data,
|
|
49
|
+
)
|
|
50
|
+
return response.data.data
|
|
31
51
|
},
|
|
32
52
|
onSuccess: () => {
|
|
33
|
-
queryClient.invalidateQueries({
|
|
53
|
+
queryClient.invalidateQueries({queryKey: conversationKeys.lists()})
|
|
34
54
|
},
|
|
35
55
|
...options,
|
|
36
|
-
})
|
|
56
|
+
})
|
|
37
57
|
}
|
|
38
58
|
|
|
39
59
|
/**
|
|
40
60
|
* Create or get direct conversation with a user
|
|
41
61
|
*
|
|
42
|
-
* @endpoint POST /
|
|
62
|
+
* @endpoint POST /conversations/direct
|
|
43
63
|
*/
|
|
44
64
|
export function useCreateDirectConversation(
|
|
45
|
-
options?: Omit<
|
|
46
|
-
|
|
47
|
-
|
|
65
|
+
options?: Omit<
|
|
66
|
+
UseMutationOptions<Conversation, Error, {userId: string}>,
|
|
67
|
+
'mutationFn'
|
|
68
|
+
>,
|
|
69
|
+
): UseMutationResult<Conversation, Error, {userId: string}> {
|
|
70
|
+
const queryClient = useQueryClient()
|
|
48
71
|
|
|
49
72
|
return useMutation({
|
|
50
|
-
mutationFn: async (data: {
|
|
51
|
-
const client = getApiClient()
|
|
52
|
-
const response = await client.post<ApiResponse<Conversation>>(
|
|
53
|
-
|
|
73
|
+
mutationFn: async (data: {userId: string}): Promise<Conversation> => {
|
|
74
|
+
const client = getApiClient()
|
|
75
|
+
const response = await client.post<ApiResponse<Conversation>>(
|
|
76
|
+
'/conversations/direct',
|
|
77
|
+
data,
|
|
78
|
+
)
|
|
79
|
+
return response.data.data
|
|
54
80
|
},
|
|
55
81
|
onSuccess: () => {
|
|
56
|
-
queryClient.invalidateQueries({
|
|
82
|
+
queryClient.invalidateQueries({queryKey: conversationKeys.lists()})
|
|
57
83
|
},
|
|
58
84
|
...options,
|
|
59
|
-
})
|
|
85
|
+
})
|
|
60
86
|
}
|
|
61
87
|
|
|
62
88
|
/**
|
|
63
89
|
* Send a message in a conversation
|
|
64
90
|
*
|
|
65
|
-
* @endpoint POST /
|
|
91
|
+
* @endpoint POST /conversations/{id}/messages
|
|
66
92
|
*/
|
|
67
93
|
export function useSendMessage(
|
|
68
|
-
options?: Omit<
|
|
69
|
-
|
|
70
|
-
|
|
94
|
+
options?: Omit<
|
|
95
|
+
UseMutationOptions<
|
|
96
|
+
Message,
|
|
97
|
+
Error,
|
|
98
|
+
{conversationId: string} & SendMessageRequest
|
|
99
|
+
>,
|
|
100
|
+
'mutationFn'
|
|
101
|
+
>,
|
|
102
|
+
): UseMutationResult<
|
|
103
|
+
Message,
|
|
104
|
+
Error,
|
|
105
|
+
{conversationId: string} & SendMessageRequest
|
|
106
|
+
> {
|
|
107
|
+
const queryClient = useQueryClient()
|
|
71
108
|
|
|
72
109
|
return useMutation({
|
|
73
|
-
mutationFn: async ({
|
|
74
|
-
const client = getApiClient()
|
|
75
|
-
const response = await client.post<ApiResponse<Message>>(
|
|
76
|
-
|
|
110
|
+
mutationFn: async ({conversationId, ...data}): Promise<Message> => {
|
|
111
|
+
const client = getApiClient()
|
|
112
|
+
const response = await client.post<ApiResponse<Message>>(
|
|
113
|
+
`/conversations/${conversationId}/messages`,
|
|
114
|
+
data,
|
|
115
|
+
)
|
|
116
|
+
return response.data.data
|
|
77
117
|
},
|
|
78
118
|
onSuccess: (_, variables) => {
|
|
79
|
-
queryClient.invalidateQueries({
|
|
80
|
-
|
|
119
|
+
queryClient.invalidateQueries({
|
|
120
|
+
queryKey: conversationKeys.messages(variables.conversationId),
|
|
121
|
+
})
|
|
122
|
+
queryClient.invalidateQueries({queryKey: conversationKeys.lists()})
|
|
81
123
|
},
|
|
82
124
|
...options,
|
|
83
|
-
})
|
|
125
|
+
})
|
|
84
126
|
}
|
|
85
127
|
|
|
86
128
|
/**
|
|
87
129
|
* Mark conversation as read
|
|
88
130
|
*
|
|
89
|
-
* @endpoint PUT /
|
|
131
|
+
* @endpoint PUT /conversations/{id}/read
|
|
90
132
|
*/
|
|
91
133
|
export function useMarkConversationAsRead(
|
|
92
|
-
options?: Omit<UseMutationOptions<void, Error, string>, 'mutationFn'
|
|
134
|
+
options?: Omit<UseMutationOptions<void, Error, string>, 'mutationFn'>,
|
|
93
135
|
): UseMutationResult<void, Error, string> {
|
|
94
|
-
const queryClient = useQueryClient()
|
|
136
|
+
const queryClient = useQueryClient()
|
|
95
137
|
|
|
96
138
|
return useMutation({
|
|
97
139
|
mutationFn: async (conversationId: string): Promise<void> => {
|
|
98
|
-
const client = getApiClient()
|
|
99
|
-
await client.put(`/
|
|
140
|
+
const client = getApiClient()
|
|
141
|
+
await client.put(`/conversations/${conversationId}/read`)
|
|
100
142
|
},
|
|
101
143
|
onSuccess: (_, conversationId) => {
|
|
102
|
-
queryClient.invalidateQueries({
|
|
103
|
-
|
|
144
|
+
queryClient.invalidateQueries({
|
|
145
|
+
queryKey: conversationKeys.detail(conversationId),
|
|
146
|
+
})
|
|
147
|
+
queryClient.invalidateQueries({queryKey: conversationKeys.lists()})
|
|
104
148
|
},
|
|
105
149
|
...options,
|
|
106
|
-
})
|
|
150
|
+
})
|
|
107
151
|
}
|
|
108
152
|
|
|
109
153
|
/**
|
|
110
154
|
* Send typing indicator
|
|
111
155
|
*
|
|
112
|
-
* @endpoint POST /
|
|
156
|
+
* @endpoint POST /conversations/{id}/typing
|
|
113
157
|
*/
|
|
114
158
|
export function useSendTypingIndicator(
|
|
115
|
-
options?: Omit<UseMutationOptions<void, Error, string>, 'mutationFn'
|
|
159
|
+
options?: Omit<UseMutationOptions<void, Error, string>, 'mutationFn'>,
|
|
116
160
|
): UseMutationResult<void, Error, string> {
|
|
117
161
|
return useMutation({
|
|
118
162
|
mutationFn: async (conversationId: string): Promise<void> => {
|
|
119
|
-
const client = getApiClient()
|
|
120
|
-
await client.post(`/
|
|
163
|
+
const client = getApiClient()
|
|
164
|
+
await client.post(`/conversations/${conversationId}/typing`)
|
|
121
165
|
},
|
|
122
166
|
...options,
|
|
123
|
-
})
|
|
167
|
+
})
|
|
124
168
|
}
|
|
@@ -5,25 +5,25 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
// Users
|
|
8
|
-
export * from './users'
|
|
8
|
+
export * from './users'
|
|
9
9
|
|
|
10
10
|
// Posts
|
|
11
|
-
export * from './posts'
|
|
11
|
+
export * from './posts'
|
|
12
12
|
|
|
13
13
|
// Spots
|
|
14
|
-
export * from './spots'
|
|
14
|
+
export * from './spots'
|
|
15
15
|
|
|
16
16
|
// Conversations
|
|
17
|
-
export * from './conversations'
|
|
17
|
+
export * from './conversations'
|
|
18
18
|
|
|
19
19
|
// Clubs
|
|
20
|
-
export * from './clubs'
|
|
20
|
+
export * from './clubs'
|
|
21
21
|
|
|
22
22
|
// Notifications
|
|
23
|
-
export * from './notifications'
|
|
23
|
+
export * from './notifications'
|
|
24
24
|
|
|
25
25
|
// Products (marketplace)
|
|
26
|
-
export * from './products'
|
|
26
|
+
export * from './products'
|
|
27
27
|
|
|
28
28
|
// Orders (marketplace)
|
|
29
|
-
export * from './orders'
|
|
29
|
+
export * from './orders'
|
|
@@ -4,9 +4,15 @@
|
|
|
4
4
|
* TanStack Query hooks for notification mutation operations.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
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 {notificationKeys} from '../queries/notifications'
|
|
10
16
|
|
|
11
17
|
// ============================================================================
|
|
12
18
|
// MUTATION HOOKS
|
|
@@ -15,56 +21,73 @@ import { notificationKeys } from '../queries/notifications';
|
|
|
15
21
|
/**
|
|
16
22
|
* Mark notifications as read
|
|
17
23
|
*
|
|
18
|
-
* @endpoint PUT /
|
|
24
|
+
* @endpoint PUT /notifications/read
|
|
19
25
|
*/
|
|
20
26
|
export function useMarkNotificationsRead(
|
|
21
|
-
options?: Omit<
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
options?: Omit<
|
|
28
|
+
UseMutationOptions<void, Error, {notificationIds?: string[]}>,
|
|
29
|
+
'mutationFn'
|
|
30
|
+
>,
|
|
31
|
+
): UseMutationResult<void, Error, {notificationIds?: string[]}> {
|
|
32
|
+
const queryClient = useQueryClient()
|
|
24
33
|
|
|
25
34
|
return useMutation({
|
|
26
|
-
mutationFn: async (data: {
|
|
27
|
-
const client = getApiClient()
|
|
28
|
-
await client.put('/
|
|
35
|
+
mutationFn: async (data: {notificationIds?: string[]}): Promise<void> => {
|
|
36
|
+
const client = getApiClient()
|
|
37
|
+
await client.put('/notifications/read', data)
|
|
29
38
|
},
|
|
30
39
|
onSuccess: () => {
|
|
31
|
-
queryClient.invalidateQueries({
|
|
32
|
-
queryClient.invalidateQueries({
|
|
40
|
+
queryClient.invalidateQueries({queryKey: notificationKeys.lists()})
|
|
41
|
+
queryClient.invalidateQueries({queryKey: notificationKeys.unreadCount()})
|
|
33
42
|
},
|
|
34
43
|
...options,
|
|
35
|
-
})
|
|
44
|
+
})
|
|
36
45
|
}
|
|
37
46
|
|
|
38
47
|
/**
|
|
39
48
|
* Register device token for push notifications
|
|
40
49
|
*
|
|
41
|
-
* @endpoint POST /
|
|
50
|
+
* @endpoint POST /device-tokens
|
|
42
51
|
*/
|
|
43
52
|
export function useRegisterDeviceToken(
|
|
44
|
-
options?: Omit<
|
|
45
|
-
|
|
53
|
+
options?: Omit<
|
|
54
|
+
UseMutationOptions<
|
|
55
|
+
void,
|
|
56
|
+
Error,
|
|
57
|
+
{token: string; platform: 'ios' | 'android' | 'web'}
|
|
58
|
+
>,
|
|
59
|
+
'mutationFn'
|
|
60
|
+
>,
|
|
61
|
+
): UseMutationResult<
|
|
62
|
+
void,
|
|
63
|
+
Error,
|
|
64
|
+
{token: string; platform: 'ios' | 'android' | 'web'}
|
|
65
|
+
> {
|
|
46
66
|
return useMutation({
|
|
47
67
|
mutationFn: async (data): Promise<void> => {
|
|
48
|
-
const client = getApiClient()
|
|
49
|
-
await client.post('/
|
|
68
|
+
const client = getApiClient()
|
|
69
|
+
await client.post('/device-tokens', data)
|
|
50
70
|
},
|
|
51
71
|
...options,
|
|
52
|
-
})
|
|
72
|
+
})
|
|
53
73
|
}
|
|
54
74
|
|
|
55
75
|
/**
|
|
56
76
|
* Remove device token
|
|
57
77
|
*
|
|
58
|
-
* @endpoint DELETE /
|
|
78
|
+
* @endpoint DELETE /device-tokens
|
|
59
79
|
*/
|
|
60
80
|
export function useRemoveDeviceToken(
|
|
61
|
-
options?: Omit<
|
|
62
|
-
|
|
81
|
+
options?: Omit<
|
|
82
|
+
UseMutationOptions<void, Error, {token: string}>,
|
|
83
|
+
'mutationFn'
|
|
84
|
+
>,
|
|
85
|
+
): UseMutationResult<void, Error, {token: string}> {
|
|
63
86
|
return useMutation({
|
|
64
87
|
mutationFn: async (data): Promise<void> => {
|
|
65
|
-
const client = getApiClient()
|
|
66
|
-
await client.delete('/
|
|
88
|
+
const client = getApiClient()
|
|
89
|
+
await client.delete('/device-tokens', {data})
|
|
67
90
|
},
|
|
68
91
|
...options,
|
|
69
|
-
})
|
|
92
|
+
})
|
|
70
93
|
}
|