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

refactor(library): remove library component and related localization files #429

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
186 changes: 0 additions & 186 deletions docs/thi-rest-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -598,189 +598,3 @@ to: c
"status": 0
}
```

## Reservations (library)

### getreservation

```http
service: thiapp
method: reservations
format: json
session: <session token>
type: 1
subtype: 1
cmd: getreservation
data:
```

As of 2021-06 the API returns "Service not available" when no reservations are available

```json
{
"data": "Service not available",
"date": "10.06.2021",
"time": "14:23:27",
"status": -112
}
```

Old response:

```json
{
"data": "No reservation data",
"date": "02.11.2020",
"status": -126,
"time": "20:36:31"
}
```

```json
{
"data": [
0,
[
{
"rcategory": "Lesesaal Galerie",
"reservation_begin": "2020-11-03 06:00:00",
"reservation_end": "2020-11-03 10:00:00",
"reservation_id": "6678",
"reserved_at": "2020-11-02 20:25:50",
"reserved_by": "<username>",
"resource": "2",
"resource_id": "3",
"rsubtype": "1"
}
]
],
"date": "02.11.2020",
"status": 0,
"time": "20:34:29"
}
```

### addreservation

```http
service: thiapp
method: reservations
format: json
session: <session token>
type: 1
subtype: 1
cmd: addreservation
data: {"resource":"3","from":"06:00","to":"10:00","at":"2020-11-03","place":"-1"}
```

```json
{
"data": [0, ["<reservation number>"]],
"date": "02.11.2020",
"status": 0,
"time": "21:29:51"
}
```

### delreservation

```http
service: thiapp
method: reservations
format: json
session: <session token>
type: 1
subtype: 1
cmd: delreservation
data: 6678
```

```json
{
"data": "No reservation data",
"date": "02.11.2020",
"status": -126,
"time": "20:36:31"
}
```

### getavailabilities

```http
service: thiapp
method: reservations
format: json
session: <session token>
type: 1
subtype: 1
cmd: getavailabilities
data:
```

parts redacted, see getavailabilities-full.json

```json
{
"date": "02.11.2020",
"time": "20:37:54",
"data": [
0,
[
{
"date": "2020-11-02",
"hasReservation": false,
"resource": [
{
"from": "18:00",
"to": "24:00",
"resources": {
"1": {
"room_name": "Lesesaal Nord (alte Bibliothek)",
"seats": [
"1",
"4",
"5",
"8",
"9",
"12",
"14",
"16",
"18",
"20",
"21",
"24",
"25",
"28",
"29",
"32",
"33",
"36",
"37",
"40",
"41",
"44",
"45",
"48",
"49",
"50",
"51",
"52",
"53",
"54",
"56",
"57"
],
"num_seats": 32,
"maxnum_seats": 32
}
// more rooms ...
}
}
]
}
// more days, more times ...
]
],
"status": 0
}
```
15 changes: 1 addition & 14 deletions rogue-thi-app/components/allCards.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import InstallPrompt from './cards/InstallPrompt'
import RoomCard from './cards/RoomCard'
import TimetableCard from './cards/TimetableCard'

import { GraduationCap, Library, Map, Scroll, User } from 'lucide-react'
import { GraduationCap, Map, Scroll, User } from 'lucide-react'

import { USER_EMPLOYEE, USER_GUEST, USER_STUDENT } from '../lib/hooks/user-kind'
// import ElectionPrompt from './cards/ElectionPrompt'
Expand Down Expand Up @@ -102,19 +102,6 @@ export const ALL_DASHBOARD_CARDS = [
/>
),
},
{
key: 'library',
removable: true,
default: [PLATFORM_DESKTOP, PLATFORM_MOBILE, USER_STUDENT, USER_EMPLOYEE],
card: () => (
<BaseCard
key="library"
icon={Library}
i18nKey="library"
link="/library"
/>
),
},
{
key: 'grades',
removable: true,
Expand Down
26 changes: 0 additions & 26 deletions rogue-thi-app/lib/backend-utils/library-utils.js

This file was deleted.

102 changes: 0 additions & 102 deletions rogue-thi-app/lib/backend/authenticated-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,108 +271,6 @@ export class AuthenticatedAPIClient extends AnonymousAPIClient {
return res
}

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

return res[1]
} catch (e) {
// 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() {
try {
const res = await this.requestAuthenticated({
service: 'thiapp',
method: 'reservations',
type: 1,
subtype: 1,
cmd: 'getavailabilities',
format: 'json',
})

return res[1]
} catch (e) {
// 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
}
}
}

/**
* TODO documentation
*/
async addLibraryReservation(roomId, day, start, end, place) {
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]
}

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

return true
} catch (e) {
// 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
}
}
}

async getImprint() {
const res = await this.requestAuthenticated({
service: 'thiapp',
Expand Down
Loading
Loading