feat: show image

This commit is contained in:
redglow
2026-06-21 15:04:11 +02:00
parent 3ea13bf9c9
commit eb9f3deac8
3 changed files with 49 additions and 15 deletions
@@ -23,6 +23,7 @@ export function AnnouncementTable({
<Table> <Table>
<TableHead> <TableHead>
<TableRow> <TableRow>
<TableCell />
<TableCell /> <TableCell />
<TableCell>Title</TableCell> <TableCell>Title</TableCell>
<TableCell>Text</TableCell> <TableCell>Text</TableCell>
+32 -1
View File
@@ -1,6 +1,16 @@
import DeleteIcon from "@mui/icons-material/Delete"; import DeleteIcon from "@mui/icons-material/Delete";
import { IconButton, TableCell, TableRow } from "@mui/material"; import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp";
import {
Collapse,
IconButton,
TableCell,
TableRow,
Typography,
} from "@mui/material";
import { Box } from "@mui/system";
import type { Announcement } from "../services"; import type { Announcement } from "../services";
import { useBoolean } from "./use-boolean";
export interface AnnouncementTableRowProps { export interface AnnouncementTableRowProps {
announcement: Announcement; announcement: Announcement;
@@ -11,8 +21,15 @@ export function AnnouncementTableRow({
openDeleteConfirmation, openDeleteConfirmation,
announcement, announcement,
}: AnnouncementTableRowProps) { }: AnnouncementTableRowProps) {
const [isOpen, { toggle }] = useBoolean();
return ( return (
<>
<TableRow> <TableRow>
<TableCell>
<IconButton aria-label="expand row" size="small" onClick={toggle}>
{isOpen ? <KeyboardArrowUpIcon /> : <KeyboardArrowDownIcon />}
</IconButton>
</TableCell>
<TableCell>{announcement.id}</TableCell> <TableCell>{announcement.id}</TableCell>
<TableCell>{announcement.title}</TableCell> <TableCell>{announcement.title}</TableCell>
<TableCell> <TableCell>
@@ -26,5 +43,19 @@ export function AnnouncementTableRow({
</IconButton> </IconButton>
</TableCell> </TableCell>
</TableRow> </TableRow>
<TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={6}>
<Collapse in={isOpen} timeout="auto" unmountOnExit>
<Box>
<Typography>Image:</Typography>
<img
src={`/images/${announcement.image}`}
alt={`${announcement.title}`}
/>
</Box>
</Collapse>
</TableCell>
</TableRow>
</>
); );
} }
+2
View File
@@ -76,6 +76,8 @@ app.delete("/api/announcements/:announcementId", async (req, res) => {
res.status(204).send(); res.status(204).send();
}); });
app.use("/images", express.static(baseUploadsFolder));
ViteExpress.listen(app, 3000, () => ViteExpress.listen(app, 3000, () =>
console.log("Server is listening on port 3000..."), console.log("Server is listening on port 3000..."),
); );