Skip to content

Commit becdb28

Browse files
committed
#2063 use all design reviews hook
1 parent 6496df8 commit becdb28

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* This file is part of NER's FinishLine and licensed under GNU AGPLv3.
3+
* See the LICENSE file in the repository root folder for details.
4+
*/
5+
import axios from '../utils/axios';
6+
import { apiUrls } from '../utils/urls';
7+
import { designReviewTransformer } from '../../../backend/src/transformers/design-review.transformer';
8+
9+
/**
10+
* Gets all the design reviews
11+
*/
12+
export const getAllDesignReviews = () => {
13+
return axios.get(apiUrls.designReviews(), {
14+
transformResponse: (data) => JSON.parse(data).map(designReviewTransformer)
15+
});
16+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* This file is part of NER's FinishLine and licensed under GNU AGPLv3.
3+
* See the LICENSE file in the repository root folder for details.
4+
*/
5+
import { useQuery } from 'react-query';
6+
import { getAllDesignReviews } from '../apis/design-reviews.api';
7+
import { DesignReview } from 'shared';
8+
9+
/**
10+
* Custom react hook to get all design reviews
11+
*
12+
* @returns all the design reviews
13+
*/
14+
export const useGetAllDesignReviews = () => {
15+
return useQuery<DesignReview[], Error>(['design-reviews'], async () => {
16+
const { data } = await getAllDesignReviews();
17+
return data;
18+
});
19+
};

src/frontend/src/utils/urls.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ const bomCreateManufacturer = () => `${bomEndpoints()}/manufacturer/create`;
129129
const bomCreateMaterialType = () => `${bomEndpoints()}/material-type/create`;
130130
const bomCreateUnit = () => `${bomEndpoints()}/units/create`;
131131

132+
/**************** Design Reviews Endpoints ****************/
133+
const designReviews = () => `${API_URL}/design-reviews`;
134+
132135
/**************** Other Endpoints ****************/
133136
const version = () => `https://api.github.com/repos/Northeastern-Electric-Racing/FinishLine/releases/latest`;
134137

@@ -181,6 +184,8 @@ export const apiUrls = {
181184
changeRequestCreateProposeSolution,
182185
changeRequestRequestReviewer,
183186

187+
designReviews,
188+
184189
teams,
185190
teamsById,
186191
teamsDelete,

0 commit comments

Comments
 (0)