File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import axios from 'axios' ;
2+ import { DesignReview } from 'shared' ;
3+ import { apiUrls } from '../utils/urls' ;
4+ import { CreateDesignReviewsPayload } from '../hooks/design-reviews.hooks' ;
5+
6+ /**
7+ * Create a design review
8+ * @param payload all info needed to create a design review
9+ */
10+ export const createDesignReviews = async ( payload : CreateDesignReviewsPayload ) => {
11+ return axios . post < DesignReview > ( apiUrls . designReviewsCreate ( ) , payload ) ;
12+ } ;
Original file line number Diff line number Diff line change 1+ import { useMutation , useQueryClient } from 'react-query' ;
2+ import { DesignReview , WbsNumber } from 'shared' ;
3+ import { createDesignReviews } from '../apis/design-reviews.api' ;
4+
5+ export interface CreateDesignReviewsPayload {
6+ dateScheduled : Date ;
7+ teamTypeId : string ;
8+ requiredMemberIds : number [ ] ;
9+ optionalMemberIds : number [ ] ;
10+ location ?: string ;
11+ isOnline : boolean ;
12+ isInPerson : boolean ;
13+ zoomLink ?: string ;
14+ docTemplateLink ?: string ;
15+ wbsNum : WbsNumber ;
16+ meetingTimes : number [ ] ;
17+ }
18+
19+ export const useCreateDesignReviews = ( ) => {
20+ const queryClient = useQueryClient ( ) ;
21+ return useMutation < DesignReview , Error , CreateDesignReviewsPayload > (
22+ [ 'design reviews' , 'create' ] ,
23+ async ( formData : CreateDesignReviewsPayload ) => {
24+ const { data} = await createDesignReviews ( formData ) ;
25+ return data ;
26+ } ,
27+ {
28+ onSuccess : ( ) => {
29+ queryClient . invalidateQueries ( [ 'design reviews' ] ) ;
30+ }
31+ }
32+ ) ;
33+ } ;
Original file line number Diff line number Diff line change @@ -129,6 +129,10 @@ const bomCreateManufacturer = () => `${bomEndpoints()}/manufacturer/create`;
129129const bomCreateMaterialType = ( ) => `${ bomEndpoints ( ) } /material-type/create` ;
130130const bomCreateUnit = ( ) => `${ bomEndpoints ( ) } /units/create` ;
131131
132+ /************** Design Review Endpoints *******************************/
133+ const designReviewsEndpoints = ( ) => `${ API_URL } /design-reviews` ;
134+ const designReviewsCreate = ( ) => `${ designReviewsEndpoints } /create`
135+
132136/**************** Other Endpoints ****************/
133137const version = ( ) => `https://api.github.com/repos/Northeastern-Electric-Racing/FinishLine/releases/latest` ;
134138
@@ -233,5 +237,8 @@ export const apiUrls = {
233237 bomCreateMaterialType,
234238 bomCreateUnit,
235239
240+ designReviewsEndpoints,
241+ designReviewsCreate,
242+
236243 version
237244} ;
You can’t perform that action at this time.
0 commit comments