Skip to content

Commit d5c9894

Browse files
Merge pull request #422 from Workgrid/expose-new-query
2 parents 8a96a87 + 8464640 commit d5c9894

File tree

4 files changed

+51
-5
lines changed

4 files changed

+51
-5
lines changed

packages/workgrid-client-react/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@workgrid/client-react",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"main": "dist/client-react.js",
55
"types": "dist/client-react.d.ts",
66
"files": [
@@ -21,7 +21,7 @@
2121
},
2222
"dependencies": {
2323
"@testing-library/react-hooks": "^5.1.0",
24-
"@workgrid/client": "^0.0.9",
24+
"@workgrid/client": "^0.1.0",
2525
"react-query": "^3.12.2"
2626
},
2727
"devDependencies": {
@@ -39,4 +39,4 @@
3939
]
4040
},
4141
"license": "ISC"
42-
}
42+
}

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

0 commit comments

Comments
 (0)