Skip to content

Commit 8df249e

Browse files
committed
Expose getNotificationDetail query
1 parent 8a96a87 commit 8df249e

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

packages/workgrid-client/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@workgrid/client",
3-
"version": "0.0.9",
3+
"version": "0.1.0",
44
"main": "dist/client.js",
55
"types": "dist/client.d.ts",
66
"files": [
@@ -33,4 +33,4 @@
3333
]
3434
},
3535
"license": "ISC"
36-
}
36+
}

packages/workgrid-client/src/client.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ const server = setupServer(
8888

8989
return res(ctx.status(400))
9090
}),
91+
rest.get(`https://company-code.workgrid.com/v1/usernotifications/:id/detail`, (req, res, ctx) => {
92+
if (req.headers.get('accept') === 'application/vnd.com.workgrid.ast+json;version=3') {
93+
return res(
94+
ctx.json([
95+
{
96+
type: 'TextBlock',
97+
text: `${req.params.id}`,
98+
},
99+
])
100+
)
101+
}
102+
103+
return res(ctx.status(400))
104+
}),
91105
rest.post(`https://company-code.workgrid.com/v1/usernotifications/:id/action`, (req, res, ctx) => {
92106
return res(ctx.json({ data: { id: req.params.id, title: `${req.method} ${req.url.pathname}` } }))
93107
}),
@@ -296,6 +310,19 @@ describe('@workgrid/client', () => {
296310
`)
297311
})
298312

313+
test('getNotificationDetail', async () => {
314+
const result = await client.query(['getNotificationDetail', { spaceId: 'space-id', id: '1234' }])
315+
316+
expect(result).toMatchInlineSnapshot(`
317+
Array [
318+
Object {
319+
"text": "1234",
320+
"type": "TextBlock",
321+
},
322+
]
323+
`)
324+
})
325+
299326
test('actionNotification', async () => {
300327
const result = await client.mutate('actionNotification', { spaceId: 'space-id', id: '1234' })
301328

packages/workgrid-client/src/client.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,25 @@ setTypedQueryDefaults('getNotification', (client) => ({
471471
},
472472
}))
473473

474+
// getNotificationDetail
475+
// ================================================================================================================================
476+
477+
/** @beta */
478+
export interface Queries {
479+
getNotificationDetail: Query<['getNotificationDetail', { spaceId: string; id: string }], Notification>
480+
}
481+
482+
setTypedQueryDefaults('getNotificationDetail', (client) => ({
483+
queryFn: async (context) => {
484+
const { spaceId, id } = context.queryKey[1]
485+
486+
const response = await client.httpClient.get(`/v1/usernotifications/${id}/detail`, {
487+
headers: { 'x-workgrid-space': spaceId, Accept: 'application/vnd.com.workgrid.ast+json;version=3' },
488+
})
489+
return response.data
490+
},
491+
}))
492+
474493
// actionNotification
475494
// ================================================================================================================================
476495

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,14 @@
16821682
resolved "https://registry.yarnpkg.com/@wessberg/stringutil/-/stringutil-1.0.19.tgz#baadcb6f4471fe2d46462a7d7a8294e4b45b29ad"
16831683
integrity sha512-9AZHVXWlpN8Cn9k5BC/O0Dzb9E9xfEMXzYrNunwvkUTvuK7xgQPVRZpLo+jWCOZ5r8oBa8NIrHuPEu1hzbb6bg==
16841684

1685+
"@workgrid/client@^0.0.9":
1686+
version "0.0.9"
1687+
resolved "https://registry.yarnpkg.com/@workgrid/client/-/client-0.0.9.tgz#77c64bc3d044c5f81f6e1c307733abce8562a16b"
1688+
integrity sha512-PN/QhhUfnLUDlbK897rWz8wyno3tDafMf658A73ObOk5sf0lMupu++d6X0uyU1Vcj6/QY+4vUapOimyXCyrwJw==
1689+
dependencies:
1690+
lodash "^4.17.11"
1691+
react-query "^3.12.2"
1692+
16851693
abab@^2.0.3, abab@^2.0.5:
16861694
version "2.0.5"
16871695
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.5.tgz#c0b678fb32d60fc1219c784d6a826fe385aeb79a"

0 commit comments

Comments
 (0)