@@ -2,11 +2,12 @@ import dayjs from "dayjs";
22
33import { request } from "./client" ;
44import { GearTypeWithFee } from "./gear" ;
5+ import { GearItemID , PeopleGroupID , PersonID } from "./idTypes" ;
56import { ListWrapper , Note } from "./types" ;
67
78/** The minimal representation of a person*/
89export interface PersonBase {
9- id : string ;
10+ id : PersonID ;
1011 firstName : string ;
1112 lastName : string ;
1213}
@@ -28,7 +29,7 @@ export interface Expireable {
2829
2930export interface PeopleGroup {
3031 groupName : string ;
31- id : number ;
32+ id : PeopleGroupID ;
3233}
3334
3435/** The representation of a person in the retrieve endpoint*/
@@ -44,7 +45,7 @@ export interface Person extends PersonSummary {
4445}
4546
4647export interface Rental {
47- id : string ;
48+ id : GearItemID ;
4849 checkedout : string ;
4950 returned ?: string ;
5051 totalAmount : number ;
@@ -53,16 +54,10 @@ export interface Rental {
5354}
5455
5556export interface GearToReturn {
56- id : string ;
57+ id : GearItemID ;
5758 daysCharged ?: number ;
5859}
5960
60- export interface Affiliation {
61- id : string ;
62- name : string ;
63- dues : number ;
64- }
65-
6661export type CreatePersonArgs = {
6762 firstName : string ;
6863 lastName : string ;
@@ -73,51 +68,51 @@ async function createPerson(args: CreatePersonArgs): Promise<PersonSummary> {
7368 return request ( `/people/` , "POST" , args ) ;
7469}
7570
76- async function addFFChecks ( id : string , date : Date , checkNumber : string ) {
71+ async function addFFChecks ( id : PersonID , date : Date , checkNumber : string ) {
7772 return request ( `/people/${ id } /frequent_flyer_check/` , "POST" , {
7873 expires : dayjs ( date ) . format ( "YYYY-MM-DD" ) ,
7974 ...( checkNumber && { checkNumber } ) ,
8075 } ) ;
8176}
8277
83- async function addWaiver ( id : string , date : Date ) {
78+ async function addWaiver ( id : PersonID , date : Date ) {
8479 return request ( `/people/${ id } /waiver/` , "POST" , {
8580 expires : dayjs ( date ) . format ( "YYYY-MM-DD" ) ,
8681 } ) ;
8782}
8883
89- async function addMembership ( id : string , date : Date , membershipType : string ) {
84+ async function addMembership ( id : PersonID , date : Date , membershipType : string ) {
9085 return request ( `/people/${ id } /membership/` , "POST" , {
9186 expires : dayjs ( date ) . format ( "YYYY-MM-DD" ) ,
9287 membershipType,
9388 } ) ;
9489}
9590
96- async function addNote ( id : string , note : string ) {
91+ async function addNote ( id : PersonID , note : string ) {
9792 return request ( `/people/${ id } /note/` , "POST" , {
9893 note,
9994 } ) ;
10095}
10196
102- async function archiveNote ( personId : string , noteId : string ) {
97+ async function archiveNote ( personId : PersonID , noteId : number ) {
10398 return request ( `/people/${ personId } /note/${ noteId } /archive/` , "POST" ) ;
10499}
105100
106101async function getPersonRentalHistory (
107- id : string ,
102+ id : PersonID ,
108103 page ?: number ,
109104) : Promise < ListWrapper < Rental > > {
110105 return request ( `/people/${ id } /rentals/` , "GET" , { ...( page && { page } ) } ) ;
111106}
112107
113- async function checkoutGear ( personID : string , gearIDs : string [ ] ) {
108+ async function checkoutGear ( personID : PersonID , gearIDs : string [ ] ) {
114109 return request ( `/people/${ personID } /rentals/` , "POST" , { gearIds : gearIDs } ) ;
115110}
116111
117112async function returnGear (
118- personID : string ,
113+ personID : PersonID ,
119114 gear : GearToReturn [ ] ,
120- purchases : string [ ] = [ ] ,
115+ purchases : number [ ] = [ ] ,
121116 checkNumber : string = "" ,
122117 useMitocCredit ?: number ,
123118) {
@@ -130,7 +125,7 @@ async function returnGear(
130125}
131126
132127async function editPerson (
133- id : string ,
128+ id : PersonID ,
134129 firstName : string ,
135130 lastName : string ,
136131 email : string ,
@@ -144,11 +139,11 @@ async function editPerson(
144139 } ) ;
145140}
146141
147- async function updatePersonGroups ( id : string , groups : number [ ] ) {
142+ async function updatePersonGroups ( id : PersonID , groups : number [ ] ) {
148143 return request ( `/people/${ id } /groups/` , "PUT" , { groups } ) ;
149144}
150145
151- async function addMitocCredit ( id : string , amount : number ) {
146+ async function addMitocCredit ( id : PersonID , amount : number ) {
152147 return request ( `/people/${ id } /credit/add/` , "PATCH" , { amount } ) ;
153148}
154149
0 commit comments