Refactor loan and user management components and backend routes
- Updated LoanTable component to fetch loan data from new API endpoint and display notes. - Enhanced UserTable component to include additional user fields (first name, last name, email, admin status) and updated input handling. - Modified fetcher utility to use new user data API endpoint. - Adjusted login functionality to point to the new admin login endpoint and handle unauthorized access. - Refactored user actions utility to align with updated API endpoints for user management. - Updated backend routes for user and loan data management to reflect new structure and naming conventions. - Revised SQL schema and mock data to accommodate new fields and constraints. - Changed Docker configuration to use the new database name.
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
import React from "react";
|
||||
import { Button, Card, Field, Input, Stack } from "@chakra-ui/react";
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Field,
|
||||
Input,
|
||||
Stack,
|
||||
InputGroup,
|
||||
Span,
|
||||
} from "@chakra-ui/react";
|
||||
import { createAPIentry } from "@/utils/userActions";
|
||||
import { useState } from "react";
|
||||
|
||||
type AddAPIKeyProps = {
|
||||
onClose: () => void;
|
||||
@@ -12,6 +21,8 @@ type AddAPIKeyProps = {
|
||||
};
|
||||
|
||||
const AddAPIKey: React.FC<AddAPIKeyProps> = ({ onClose, alert }) => {
|
||||
const [value, setValue] = useState("");
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4">
|
||||
<Card.Root maxW="sm">
|
||||
@@ -23,13 +34,26 @@ const AddAPIKey: React.FC<AddAPIKeyProps> = ({ onClose, alert }) => {
|
||||
</Card.Header>
|
||||
<Card.Body>
|
||||
<Stack gap="4" w="full">
|
||||
<InputGroup
|
||||
endElement={
|
||||
<Span color="fg.muted" textStyle="xs">
|
||||
{value.length} / {15}
|
||||
</Span>
|
||||
}
|
||||
>
|
||||
<Input
|
||||
placeholder="Er muss 15 Zeichen lang sein"
|
||||
value={value}
|
||||
id="apiKey"
|
||||
maxLength={15}
|
||||
onChange={(e) => {
|
||||
setValue(e.currentTarget.value.slice(0, 15));
|
||||
}}
|
||||
/>
|
||||
</InputGroup>
|
||||
<Field.Root>
|
||||
<Field.Label>API key</Field.Label>
|
||||
<Input type="number" id="apiKey" />
|
||||
</Field.Root>
|
||||
<Field.Root>
|
||||
<Field.Label>Benutzer</Field.Label>
|
||||
<Input id="user" type="text" />
|
||||
<Field.Label>Name</Field.Label>
|
||||
<Input id="name" type="text" />
|
||||
</Field.Root>
|
||||
</Stack>
|
||||
</Card.Body>
|
||||
@@ -44,14 +68,14 @@ const AddAPIKey: React.FC<AddAPIKeyProps> = ({ onClose, alert }) => {
|
||||
(
|
||||
document.getElementById("apiKey") as HTMLInputElement
|
||||
)?.value.trim() || "";
|
||||
const user =
|
||||
const name =
|
||||
(
|
||||
document.getElementById("user") as HTMLInputElement
|
||||
document.getElementById("name") as HTMLInputElement
|
||||
)?.value.trim() || "";
|
||||
|
||||
if (!apiKey || !user) return;
|
||||
if (!apiKey || !name) return;
|
||||
|
||||
const res = await createAPIentry(apiKey, user);
|
||||
const res = await createAPIentry(apiKey, name);
|
||||
if (res.success) {
|
||||
alert(
|
||||
"success",
|
||||
|
||||
Reference in New Issue
Block a user