Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(library): remove booking and add new sheet #153

Merged
merged 11 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ android {
applicationId 'app.neuland'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 265
versionCode 271
versionName "0.11.0"
}
signingConfigs {
Expand Down
2 changes: 1 addition & 1 deletion app.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"android": {
"package": "app.neuland",
"userInterfaceStyle": "automatic",
"versionCode": 265
"versionCode": 271
},
"sdkVersion": "52.0.0",
"experiments": {
Expand Down
Binary file modified bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion docs/de/app/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Finde **verfügbare Räume**, checke Gebäude oder erkunde den Campus. Nutze uns

### Bibliothek

**Reserviere einen Platz** direkt in der App oder nutze deine Bibliotheks-ID, um Bücher an den Terminals auszuleihen und zurückzugeben.
Nutze deine **virtuelle Bibliotheks-ID**, um Bücher an den Terminals auszuleihen und zurückzugeben.
Oder buche einen **Arbeitsplatz** über den Link in der App.

### Quick Links

Expand Down
2 changes: 1 addition & 1 deletion docs/de/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ features:
link: /app/features#campusplan
- title: Bibliothek
icon: 📚
details: Reserviere einen Platz direkt in der App oder nutze deinen Bibliotheksausweis, um Bücher an den Terminals auszuleihen.
details: Nutze deine virtuelle Bibliotheks-ID, um Bücher an den Terminals auszuleihen und zurückzugeben.
link: /app/features#bibliothek
---
2 changes: 1 addition & 1 deletion docs/en/app/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Find **available rooms**, view buildings or explore the university campus. Use o

### Library

**Reserve a seat** directly from the app, or use your library ID to check out and return books at the terminals.
Use your **virtual library ID** to check out at the terminals to borrow and return books. Or book a **workplace** via the link in the app.

### Quick Links

Expand Down
2 changes: 1 addition & 1 deletion docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ features:
link: /en/app/features#campus-map
- title: Library
icon: 📚
details: Reserve a seat directly from the app, or use your library ID to check out at the terminals.
details: Use your virtual library ID to check out at the terminals to borrow and return books.
link: /en/app/features#library
---
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"@aptabase/react-native": "^0.3.10",
"@babel/runtime": "^7.26.0",
"@bottom-tabs/react-navigation": "^0.7.6",
"@bottom-tabs/react-navigation": "^0.7.7",
"@expo/metro-runtime": "^4.0.0",
"@expo/vector-icons": "^14.0.4",
"@gorhom/bottom-sheet": "^5.0.6",
Expand All @@ -36,7 +36,7 @@
"@react-native-community/datetimepicker": "8.2.0",
"@react-native-community/netinfo": "11.4.1",
"@react-navigation/native": "^7.0.14",
"@react-navigation/stack": "^7.1.0",
"@react-navigation/stack": "^7.1.1",
"@shopify/flash-list": "1.7.1",
"@tanstack/query-sync-storage-persister": "^5.62.8",
"@tanstack/react-query": "^5.62.8",
Expand Down Expand Up @@ -79,7 +79,7 @@
"react-native-calendars": "^1.1307.0",
"react-native-collapsible": "1.6.1",
"react-native-context-menu-view": "^1.16.0",
"react-native-device-info": "^14.0.1",
"react-native-device-info": "^14.0.2",
"react-native-drag-drop-ios": "^0.1.1",
"react-native-drag-sort": "^2.4.4",
"react-native-edge-to-edge": "^1.1.3",
Expand Down
117 changes: 0 additions & 117 deletions src/api/authenticated-api.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import {
type AvailableLibrarySeats,
type Exams,
type Grade,
type Lecturers,
type PersData,
type Reservation,
type Rooms,
type ThiNews,
type TimetableResponse,
Expand Down Expand Up @@ -206,121 +204,6 @@ export class AuthenticatedAPIClient extends AnonymousAPIClient {
return res
}

async getLibraryReservations(): Promise<Reservation[]> {
try {
const res = await this.requestAuthenticated({
service: 'thiapp',
method: 'reservations',
type: 1,
cmd: 'getreservations',
format: 'json',
})

return res[1]
} catch (e: any) {
// as of 2021-06 the API returns "Service not available" when the user has no reservations
// thus we dont alert the error here, but just silently set the reservations to none
if (
e.data === 'No reservation data' ||
e.data === 'Service not available'
) {
return []
} else {
throw e
}
}
}

async getAvailableLibrarySeats(): Promise<AvailableLibrarySeats[]> {
try {
const res = await this.requestAuthenticated({
service: 'thiapp',
method: 'reservations',
type: 1,
subtype: 1,
cmd: 'getavailabilities',
format: 'json',
})

return res[1]
} catch (e: any) {
// Unbekannter Fehler means the user has already reserved a spot
// and can not reserve additional ones
if (e.data === 'Unbekannter Fehler') {
return []
} else {
throw e
}
}
}

/**
* Adds a library reservation for a specific room, day, start and end time, and place
* @param {string} roomId ID of the room to reserve
* @param {string} day Date of the reservation
* @param {string} start Start time of the reservation
* @param {string} end End time of the reservation
* @param {string} place Place of the reservation
* @returns {Promise<any>} Promise that resolves with the reservation ID
*/
async addLibraryReservation(
roomId: string,
day: string,
start: string,
end: string,
place: string
): Promise<any> {
const res = await this.requestAuthenticated({
service: 'thiapp',
method: 'reservations',
type: 1,
subtype: 1,
cmd: 'addreservation',
data: JSON.stringify({
resource: roomId,
at: day,
from: start,
to: end,
place,
}),
dblslots: 0,
format: 'json',
})

return res[0]
}

/**
* Removes a library reservation
* @param {string} reservationId Reservation ID returned by `getLibraryReservations`
*/
async removeLibraryReservation(reservationId: string): Promise<boolean> {
try {
await this.requestAuthenticated({
service: 'thiapp',
method: 'reservations',
type: 1,
subtype: 1,
cmd: 'delreservation',
data: reservationId,
format: 'json',
})

return true
} catch (e: any) {
// as of 2021-06 the API returns "Service not available" when the user has no reservations
// thus we dont alert the error here, but just silently set the reservations to none
if (
e.data === 'No reservation data' ||
e.data === 'Service not available'
) {
return true
} else {
throw e
}
}
}

/**
* Fetches the latest thi news
* @returns {Promise<ThiNews[]>} Promise that resolves with the news
Expand Down
Loading
Loading