first commit
This commit is contained in:
commit
b7b0f253ce
85 files changed
+7560
No files matched your search
@@ -0,0 +1,76 @@
|
||||
import { IconDownload } from "@tabler/icons-react";
|
||||
import { deleteBook, updateBook } from "@/actions/books";
|
||||
import { ConfirmSubmit } from "@/components/confirm-submit";
|
||||
import { PageBody, PageHeader } from "@/components/page";
|
||||
import { getT } from "@/i18n/server";
|
||||
import { requireBook } from "@/lib/session";
|
||||
|
||||
export const metadata = { title: "Bokinställningar" };
|
||||
|
||||
export default async function SettingsPage({ params }: { params: Promise<{ bookId: string }> }) {
|
||||
const { bookId } = await params;
|
||||
const book = await requireBook(bookId);
|
||||
const { t } = await getT();
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHeader title={t("settings.title")} />
|
||||
<PageBody>
|
||||
<div className="row row-cards">
|
||||
<div className="col-lg-8">
|
||||
<form action={updateBook} className="card">
|
||||
<input type="hidden" name="bookId" value={book.id} />
|
||||
<div className="card-body">
|
||||
<div className="row g-3">
|
||||
<div className="col-md-6">
|
||||
<label className="form-label required">{t("common.title")}</label>
|
||||
<input name="title" className="form-control" required maxLength={200} defaultValue={book.title} />
|
||||
</div>
|
||||
<div className="col-md-6">
|
||||
<label className="form-label">{t("books.subtitle")}</label>
|
||||
<input name="subtitle" className="form-control" maxLength={200} defaultValue={book.subtitle ?? ""} />
|
||||
</div>
|
||||
<div className="col-md-6">
|
||||
<label className="form-label">{t("books.genre")}</label>
|
||||
<input name="genre" className="form-control" maxLength={100} defaultValue={book.genre ?? ""} />
|
||||
</div>
|
||||
<div className="col-12">
|
||||
<label className="form-label">{t("common.description")}</label>
|
||||
<textarea name="description" className="form-control" rows={4} defaultValue={book.description ?? ""} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card-footer text-end">
|
||||
<button type="submit" className="btn btn-primary">
|
||||
{t("common.save")}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div className="col-lg-4">
|
||||
<div className="card mb-3">
|
||||
<div className="card-body">
|
||||
<p className="text-secondary">{t("settings.exportHelp")}</p>
|
||||
<a className="btn" href={`/api/books/${book.id}/export`}>
|
||||
<IconDownload size={18} className="me-1" />
|
||||
{t("settings.export")}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card border-danger">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title text-danger">{t("settings.danger")}</h3>
|
||||
</div>
|
||||
<form action={deleteBook} className="card-body">
|
||||
<input type="hidden" name="bookId" value={book.id} />
|
||||
<p className="text-secondary">{t("settings.deleteBookHelp")}</p>
|
||||
<ConfirmSubmit>{t("settings.deleteBook")}</ConfirmSubmit>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</PageBody>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user