Compare commits

...

7 Commits

Author SHA1 Message Date
theis.gaedigk 67c704009e refactored loan code creation function 2026-05-13 19:42:54 +02:00
theis.gaedigk 831de8b610 added new loan code function - NOT TESTED YET 2026-05-13 14:04:12 +02:00
theis.gaedigk fd43e84c0c refactored code 2026-05-11 22:40:34 +02:00
theis.gaedigk 1ce8d33b0d pulled naas 2026-05-09 23:32:12 +02:00
theis.gaedigk c48da71cd5 improved translation 2026-05-09 11:37:44 +02:00
theis.gaedigk 8e35e81e8f Fixed bug: #16 2026-05-09 11:35:13 +02:00
theis.gaedigk 95aae1c050 cleaned changelog 2026-05-01 13:41:30 +02:00
6 changed files with 52 additions and 48 deletions
+24 -6
View File
@@ -121,10 +121,28 @@ export const MyLoansPage = () => {
const formatDate = (iso: string | null) => {
if (!iso) return "-";
const m = iso.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/);
if (!m) return iso;
const [, y, M, d, h, min] = m;
return `${d}.${M}.${y} ${h}:${min}`;
const date = new Date(iso);
if (isNaN(date.getTime())) return iso;
return date.toLocaleString("de-DE", {
timeZone: "Europe/Berlin",
day: "2-digit",
month: "2-digit",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
});
};
const dateAndTime = (isISO: boolean) => {
const date = new Date();
if (isISO) {
return date.toISOString();
}
if (!isISO) {
return date;
}
};
const handleTakeAction = async (loanCode: string) => {
@@ -151,7 +169,7 @@ export const MyLoansPage = () => {
setLoans((prev) =>
prev.map((loan) =>
loan.loan_code === loanCode
? { ...loan, take_date: new Date().toISOString() }
? { ...loan, take_date: dateAndTime(true) }
: loan,
),
);
@@ -191,7 +209,7 @@ export const MyLoansPage = () => {
setLoans((prev) =>
prev.map((loan) =>
loan.loan_code === loanCode
? { ...loan, returned_date: new Date().toISOString() }
? { ...loan, returned_date: dateAndTime(true) }
: loan,
),
);
+1 -1
View File
@@ -60,7 +60,7 @@
"sure-delete-loan-2": "Für den Admin bleibt sie weiterhin sichtbar.",
"delete": "Löschen",
"change-language": "Sprache ändern",
"timezone-info": "Die angezeigten Daten und Uhrzeiten werden in deutscher Zeitzone dargestellt und müssen auch so eingegeben werden.",
"timezone-info": "Die angezeigten Daten und Uhrzeiten werden in deutscher Zeitzone dargestellt und müssen auch so eingegeben werden. Das gesamte System ist auf die deutsche Zeitzone eingestellt.",
"optional-note": "Optionale Notiz",
"note": "Notiz",
"user-info-desc": "Hier können Sie Ihre persönlichen Informationen einsehen und das Passwort ändern. Falls Sie weitere Änderungen benötigen, wenden Sie sich bitte an einen Administrator.",
+1 -1
View File
@@ -60,7 +60,7 @@
"sure-delete-loan-2": "It will remain visible to the admin.",
"delete": "Delete",
"change-language": "Change language",
"timezone-info": "The displayed dates and times are shown in Berlin timezone and must also be entered as such.",
"timezone-info": "The displayed dates and times are shown in Berlin timezone and must also be entered as such. The entire system is set to Berlin timezone.",
"optional-note": "Optional note",
"note": "Note",
"user-info-desc": "Here you can view your personal information and change your password. If you need to make further changes, please contact an administrator.",
@@ -63,11 +63,9 @@ export const createLoanInDatabase = async (
};
}
const itemNames = itemIds
.map(
(id) => itemsRows.find((r) => Number(r.id) === Number(id))?.item_name,
)
.filter(Boolean);
const itemNames = itemIds.map(
(id) => itemsRows.find((r) => Number(r.id) === Number(id)).item_name,
);
// Build lockers array (unique, only 2-digit numbers from safe_nr)
const lockers = [
@@ -109,27 +107,24 @@ export const createLoanInDatabase = async (
};
}
// Generate unique loan_code (retry a few times)
let loanCode = null;
for (let i = 0; i < 6; i++) {
const candidate = Math.floor(100000 + Math.random() * 899999); // 6 digits
const [exists] = await conn.query(
"SELECT 1 FROM loans WHERE loan_code = ? LIMIT 1",
let index = false;
let candidate;
let loanCode;
// Generates 6-digit loan code
do {
candidate = Math.floor(100000 + Math.random() * 899999);
const [rows] = await conn.query(
"SELECT 1 FROM loans where loan_code = ? LIMIT 1",
[candidate],
);
if (exists.length === 0) {
if (rows.length == 0) {
index = true;
loanCode = candidate;
break;
}
}
if (!loanCode) {
await conn.rollback();
return {
success: false,
code: "SERVER_ERROR",
message: "Failed to generate unique loan code",
};
}
} while (index === false);
// Insert loan (now includes lockers)
const [insertRes] = await conn.query(
+8 -17
View File
@@ -1,37 +1,28 @@
# Changelog for upcoming version: v2.2
# Changelog for upcoming version: vX.X
This update provides some new features for the design. It also contains some improvements and I have also fixed some bugs.
Introduction
## New features
- **Deactivatable services:** I have added the ability to deactivate services, which can be useful for maintenance or other purposes. The admin can activate and deactivate services in the admin panel. If a service is deactivated, it will not be available for users and they will get an error message if they try to use it. They will also get an warning banner on the homepage.
- **New Animations:** I have added some new animations to the frontend, which make the user experience more enjoyable.
- **New Icon:** I have added a new icon for the frontend, which is now also used in the header and the favicon. It is a dark version of the old icon, which fits better to the overall design. I have made it with Icon Composer. The old icon is still used for the admin panel, which has a light design. (Maybe I will change the admin panel design in the future...)
- **New Button:** When you go to your user card (over the user icon in the header) you have a new button "Click me". If you click it, you will get an message... _I am just saying: I have implemented the no-as-a-service code in to my Backend._
-
## Improvements
- The overview page now shows the note column and is overall better organised.
- Improved error logging
- If you try to delete a loan that has not been returned yet, you will get an 507 error code.
- When the admin deletes a loan, the loan will be still visible in the database, but it will be marked as deleted. This is to prevent data loss and to keep track of deleted loans.
- Mailer improvements: The mailer is now more clearly organised. Two large code files are now split into five smaller code files which are easier to maintain. Also the design of the mails has improved.
-
## Fixed bugs
- Fixed bug: #13
- Fixed bug for messaging when server has an error
- Fixed footer height
-
---
## New version numbers
**Backend:** v2.2
**Backend:** vX.X
**Frontend:** v2.2
**Frontend:** vX.X
**Admin panel:** v1.4
**Admin panel:** vX.X
---