Skip to content

Commit 0897f27

Browse files
committed
fixed fe linter
1 parent ef3bdd6 commit 0897f27

30 files changed

+876
-928
lines changed
Lines changed: 92 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,118 @@
11
import {
2-
TimeRange,
3-
CreateAvailabilityRequest,
4-
CreateAvailabilityResponse,
5-
AvailabilityEntity,
6-
DeleteAvailabilityRequest,
7-
DeleteAvailabilityResponse,
2+
TimeRange,
3+
CreateAvailabilityRequest,
4+
CreateAvailabilityResponse,
5+
AvailabilityEntity,
6+
DeleteAvailabilityRequest,
7+
DeleteAvailabilityResponse,
88
} from '../types/AvailabilityTypes';
99

1010
import baseAPIClient from './baseAPIClient';
1111
import { getCurrentUserId, getAuthHeaders } from '../utils/AuthUtils';
1212

1313
const getAvailability = async (): Promise<AvailabilityEntity | null> => {
14-
try {
15-
const userId = getCurrentUserId();
16-
if (!userId) {
17-
console.error('User ID not found in localStorage');
18-
return null;
19-
}
20-
21-
const { data } = await baseAPIClient.get<AvailabilityEntity>(
22-
`/availability?user_id=${userId}`,
23-
getAuthHeaders(),
24-
);
25-
return data;
26-
} catch (error) {
27-
console.error('Failed to get availability:', error);
28-
return null;
14+
try {
15+
const userId = getCurrentUserId();
16+
if (!userId) {
17+
console.error('User ID not found in localStorage');
18+
return null;
2919
}
20+
21+
const { data } = await baseAPIClient.get<AvailabilityEntity>(
22+
`/availability?user_id=${userId}`,
23+
getAuthHeaders(),
24+
);
25+
return data;
26+
} catch (error) {
27+
console.error('Failed to get availability:', error);
28+
return null;
29+
}
3030
};
3131

3232
const createAvailability = async (
33-
availableTimes: TimeRange[]
33+
availableTimes: TimeRange[],
3434
): Promise<CreateAvailabilityResponse | null> => {
35-
try {
36-
const userId = getCurrentUserId();
37-
if (!userId) {
38-
console.error('User ID not found in localStorage');
39-
return null;
40-
}
41-
42-
const createRequest: CreateAvailabilityRequest = {
43-
userId,
44-
availableTimes,
45-
};
46-
47-
const { data } = await baseAPIClient.post<CreateAvailabilityResponse>(
48-
"/availability",
49-
createRequest,
50-
getAuthHeaders(),
51-
);
52-
return data;
53-
} catch (error) {
54-
console.error('Failed to create availability:', error);
55-
return null;
35+
try {
36+
const userId = getCurrentUserId();
37+
if (!userId) {
38+
console.error('User ID not found in localStorage');
39+
return null;
5640
}
41+
42+
const createRequest: CreateAvailabilityRequest = {
43+
userId,
44+
availableTimes,
45+
};
46+
47+
const { data } = await baseAPIClient.post<CreateAvailabilityResponse>(
48+
'/availability',
49+
createRequest,
50+
getAuthHeaders(),
51+
);
52+
return data;
53+
} catch (error) {
54+
console.error('Failed to create availability:', error);
55+
return null;
56+
}
5757
};
5858

5959
const deleteAvailability = async (
60-
timeRangesToDelete: TimeRange[]
60+
timeRangesToDelete: TimeRange[],
6161
): Promise<DeleteAvailabilityResponse | null> => {
62-
try {
63-
const userId = getCurrentUserId();
64-
if (!userId) {
65-
console.error('User ID not found in localStorage');
66-
return null;
67-
}
68-
69-
const deleteRequest: DeleteAvailabilityRequest = {
70-
userId,
71-
delete: timeRangesToDelete,
72-
};
73-
74-
const { data } = await baseAPIClient.delete<DeleteAvailabilityResponse>(
75-
"/availability",
76-
{
77-
...getAuthHeaders(),
78-
data: deleteRequest,
79-
},
80-
);
81-
return data;
82-
} catch (error) {
83-
console.error('Failed to delete availability:', error);
84-
return null;
62+
try {
63+
const userId = getCurrentUserId();
64+
if (!userId) {
65+
console.error('User ID not found in localStorage');
66+
return null;
8567
}
68+
69+
const deleteRequest: DeleteAvailabilityRequest = {
70+
userId,
71+
delete: timeRangesToDelete,
72+
};
73+
74+
const { data } = await baseAPIClient.delete<DeleteAvailabilityResponse>('/availability', {
75+
...getAuthHeaders(),
76+
data: deleteRequest,
77+
});
78+
return data;
79+
} catch (error) {
80+
console.error('Failed to delete availability:', error);
81+
return null;
82+
}
8683
};
8784

8885
const updateAvailability = async (
89-
availableTimes: TimeRange[]
86+
availableTimes: TimeRange[],
9087
): Promise<CreateAvailabilityResponse | null> => {
91-
try {
92-
const userId = getCurrentUserId();
93-
if (!userId) {
94-
console.error('User ID not found in localStorage');
95-
return null;
96-
}
88+
try {
89+
const userId = getCurrentUserId();
90+
if (!userId) {
91+
console.error('User ID not found in localStorage');
92+
return null;
93+
}
9794

98-
const updateRequest: CreateAvailabilityRequest = {
99-
userId,
100-
availableTimes,
101-
};
95+
const updateRequest: CreateAvailabilityRequest = {
96+
userId,
97+
availableTimes,
98+
};
10299

103-
// Use PUT to completely replace availability
104-
const { data } = await baseAPIClient.put<CreateAvailabilityResponse>(
105-
"/availability",
106-
updateRequest,
107-
getAuthHeaders(),
108-
);
109-
return data;
110-
} catch (error) {
111-
console.error('Failed to update availability:', error);
112-
return null;
113-
}
100+
// Use PUT to completely replace availability
101+
const { data } = await baseAPIClient.put<CreateAvailabilityResponse>(
102+
'/availability',
103+
updateRequest,
104+
getAuthHeaders(),
105+
);
106+
return data;
107+
} catch (error) {
108+
console.error('Failed to update availability:', error);
109+
return null;
110+
}
114111
};
115112

116-
export default {
117-
getAvailability,
118-
createAvailability,
119-
deleteAvailability,
120-
updateAvailability
121-
};
113+
export default {
114+
getAvailability,
115+
createAvailability,
116+
deleteAvailability,
117+
updateAvailability,
118+
};

0 commit comments

Comments
 (0)