Reconcile website_* schema to the live AtomCMS DB (amx_test)
Introspected the live DB and fixed real drift between the hand-modeled
schema and the actual columns:
- Added missing @map("snake_case") on camelCase fields that silently
failed at query time: website_teams (rank_name/hidden_rank/...),
website_paypal_transactions/user_guestbooks/help_center_tickets(+replies)/
used_shop_vouchers/maintenance_tasks (user_id), website_rare_values
(currency_type).
- website_permissions was modeled as key/value/comment but is actually
permission/min_rank/description — fixed the model + the admin page/action.
- website_shop_articles.icon -> icon_url (+ added category_id, is_giftable);
updated the shop page + admin shop CRUD.
- website_shop_categories: dropped non-existent slug/timestamps, added the
real description/order columns; updated the shop page.
- website_shop_article_features.features(Json) -> content(Text).
Verified against amx_test: all website_* query errors gone; home renders
the real hotel_name ("Habbo"), rankings shows real users, /staff + /shop
200. tsc 0, vitest 49/49, next build 0. Remaining missing tables
(radio_*/game_*/staff_activities/alert_logs/article_comments+reactions)
don't exist in this DB and degrade gracefully via try/catch.
This commit is contained in:
1 parent
4eccd146ba
commit
b97a88c561
6 files changed
+92
-93
No files matched your search
+27
-26
@@ -1645,12 +1645,12 @@ model WebsiteIpBlacklist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model WebsitePermissions {
|
model WebsitePermissions {
|
||||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||||
key String @unique @db.VarChar(255)
|
permission String @unique @db.VarChar(255)
|
||||||
value String? @db.VarChar(255)
|
minRank Int @map("min_rank")
|
||||||
comment String? @db.VarChar(255)
|
description String? @db.Text
|
||||||
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
||||||
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
|
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
|
||||||
|
|
||||||
@@map("website_permissions")
|
@@map("website_permissions")
|
||||||
}
|
}
|
||||||
@@ -1686,12 +1686,12 @@ model WebsiteBetaCodes {
|
|||||||
|
|
||||||
model WebsiteTeams {
|
model WebsiteTeams {
|
||||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||||
rankName String @unique @db.VarChar(255)
|
rankName String @unique @map("rank_name") @db.VarChar(255)
|
||||||
hiddenRank Boolean @default(false)
|
hiddenRank Boolean @default(false) @map("hidden_rank")
|
||||||
badge String? @db.VarChar(255)
|
badge String? @db.VarChar(255)
|
||||||
jobDescription String? @db.VarChar(255)
|
jobDescription String? @map("job_description") @db.VarChar(255)
|
||||||
staffColor String @default("#327fa8") @db.VarChar(255)
|
staffColor String @default("#327fa8") @map("staff_color") @db.VarChar(255)
|
||||||
staffBackground String @default("staff-bg.png") @db.VarChar(255)
|
staffBackground String @default("staff-bg.png") @map("staff_background") @db.VarChar(255)
|
||||||
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
||||||
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
|
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
|
||||||
|
|
||||||
@@ -1750,7 +1750,7 @@ model WebsiteRareValues {
|
|||||||
name String @db.VarChar(255)
|
name String @db.VarChar(255)
|
||||||
creditValue String? @map("credit_value") @db.VarChar(255)
|
creditValue String? @map("credit_value") @db.VarChar(255)
|
||||||
currencyValue String? @map("currency_value") @db.VarChar(255)
|
currencyValue String? @map("currency_value") @db.VarChar(255)
|
||||||
currencyType String @default("diamonds") @db.VarChar(255)
|
currencyType String @default("diamonds") @map("currency_type") @db.VarChar(255)
|
||||||
furnitureIcon String @map("furniture_icon") @db.VarChar(255)
|
furnitureIcon String @map("furniture_icon") @db.VarChar(255)
|
||||||
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
||||||
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
|
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
|
||||||
@@ -1809,7 +1809,7 @@ model WebsiteHelpCenterCategories {
|
|||||||
|
|
||||||
model WebsiteHelpCenterTickets {
|
model WebsiteHelpCenterTickets {
|
||||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||||
userId Int?
|
userId Int? @map("user_id")
|
||||||
categoryId BigInt? @map("category_id") @db.UnsignedBigInt
|
categoryId BigInt? @map("category_id") @db.UnsignedBigInt
|
||||||
title String @db.VarChar(255)
|
title String @db.VarChar(255)
|
||||||
content String @db.Text
|
content String @db.Text
|
||||||
@@ -1822,7 +1822,7 @@ model WebsiteHelpCenterTickets {
|
|||||||
|
|
||||||
model WebsitePaypalTransactions {
|
model WebsitePaypalTransactions {
|
||||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||||
userId Int
|
userId Int @map("user_id")
|
||||||
transactionId String @map("transaction_id") @db.VarChar(255)
|
transactionId String @map("transaction_id") @db.VarChar(255)
|
||||||
status String? @db.VarChar(255)
|
status String? @db.VarChar(255)
|
||||||
description String? @map("description") @db.VarChar(512)
|
description String? @map("description") @db.VarChar(512)
|
||||||
@@ -1836,12 +1836,14 @@ model WebsitePaypalTransactions {
|
|||||||
|
|
||||||
model WebsiteShopArticles {
|
model WebsiteShopArticles {
|
||||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||||
|
categoryId BigInt? @map("website_shop_category_id") @db.UnsignedBigInt
|
||||||
name String @unique @db.VarChar(255)
|
name String @unique @db.VarChar(255)
|
||||||
info String @db.VarChar(255)
|
info String @db.VarChar(255)
|
||||||
icon String @db.VarChar(255)
|
iconUrl String @map("icon_url") @db.VarChar(255)
|
||||||
color String @db.VarChar(255)
|
color String @db.VarChar(255)
|
||||||
costs Int @db.UnsignedInt
|
costs Int @db.UnsignedInt
|
||||||
giveRank Int? @map("give_rank")
|
giveRank Int? @map("give_rank")
|
||||||
|
isGiftable Boolean @default(false) @map("is_giftable")
|
||||||
credits Int? @db.UnsignedInt
|
credits Int? @db.UnsignedInt
|
||||||
duckets Int? @db.UnsignedInt
|
duckets Int? @db.UnsignedInt
|
||||||
diamonds Int? @db.UnsignedInt
|
diamonds Int? @db.UnsignedInt
|
||||||
@@ -1869,7 +1871,7 @@ model WebsiteShopVouchers {
|
|||||||
|
|
||||||
model WebsiteUsedShopVouchers {
|
model WebsiteUsedShopVouchers {
|
||||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||||
userId Int
|
userId Int @map("user_id")
|
||||||
voucherId BigInt @map("voucher_id") @db.UnsignedBigInt
|
voucherId BigInt @map("voucher_id") @db.UnsignedBigInt
|
||||||
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
||||||
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
|
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
|
||||||
@@ -1880,7 +1882,7 @@ model WebsiteUsedShopVouchers {
|
|||||||
model WebsiteShopArticleFeatures {
|
model WebsiteShopArticleFeatures {
|
||||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||||
articleId BigInt @map("article_id") @db.UnsignedBigInt
|
articleId BigInt @map("article_id") @db.UnsignedBigInt
|
||||||
features Json
|
content String @db.Text
|
||||||
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
||||||
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
|
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
|
||||||
|
|
||||||
@@ -1890,7 +1892,7 @@ model WebsiteShopArticleFeatures {
|
|||||||
model WebsiteHelpCenterTicketReplies {
|
model WebsiteHelpCenterTicketReplies {
|
||||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||||
ticketId BigInt @map("ticket_id") @db.UnsignedBigInt
|
ticketId BigInt @map("ticket_id") @db.UnsignedBigInt
|
||||||
userId Int
|
userId Int @map("user_id")
|
||||||
content String @db.Text
|
content String @db.Text
|
||||||
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
||||||
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
|
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
|
||||||
@@ -1917,7 +1919,7 @@ model AlertLogs {
|
|||||||
model WebsiteUserGuestbooks {
|
model WebsiteUserGuestbooks {
|
||||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||||
profileId Int @map("profile_id")
|
profileId Int @map("profile_id")
|
||||||
userId Int
|
userId Int @map("user_id")
|
||||||
message String @db.VarChar(255)
|
message String @db.VarChar(255)
|
||||||
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
||||||
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
|
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
|
||||||
@@ -1926,19 +1928,18 @@ model WebsiteUserGuestbooks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model WebsiteShopCategories {
|
model WebsiteShopCategories {
|
||||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||||
name String @db.VarChar(255)
|
name String @db.VarChar(255)
|
||||||
slug String @unique @db.VarChar(255)
|
description String? @db.Text
|
||||||
icon String? @db.VarChar(255)
|
icon String? @db.VarChar(255)
|
||||||
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
order Int @default(0)
|
||||||
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
|
|
||||||
|
|
||||||
@@map("website_shop_categories")
|
@@map("website_shop_categories")
|
||||||
}
|
}
|
||||||
|
|
||||||
model WebsiteMaintenanceTasks {
|
model WebsiteMaintenanceTasks {
|
||||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||||
userId Int?
|
userId Int? @map("user_id")
|
||||||
task String @db.VarChar(255)
|
task String @db.VarChar(255)
|
||||||
completed Boolean @default(false)
|
completed Boolean @default(false)
|
||||||
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
createdAt DateTime? @map("created_at") @db.Timestamp(0)
|
||||||
|
|||||||
@@ -5,36 +5,34 @@ import { requireStaff } from "@/lib/admin/guard";
|
|||||||
import { prisma } from "@/lib/prisma";
|
import { prisma } from "@/lib/prisma";
|
||||||
import { logStaffActivity } from "@/lib/services/staff-activity";
|
import { logStaffActivity } from "@/lib/services/staff-activity";
|
||||||
|
|
||||||
// website_permissions (model WebsitePermissions) is the CMS-owned rank-permission
|
// website_permissions (model WebsitePermissions) is the CMS-owned permission ->
|
||||||
// mapping AtomCMS exposes in admin: a key/value(/comment) row per permission.
|
// minimum-rank mapping. Editable columns are exactly: permission (unique name),
|
||||||
// Editable columns on the table are exactly: key (unique), value, comment.
|
// min_rank (lowest rank that may use it), description. id is BigInt and
|
||||||
// id is BigInt and created_at/updated_at are managed here — no other columns
|
// created_at/updated_at are managed here.
|
||||||
// exist, so there are no extra staff flags to toggle.
|
|
||||||
|
function parseMinRank(formData: FormData): number {
|
||||||
|
const n = Number(String(formData.get("minRank") ?? "").trim());
|
||||||
|
return Number.isInteger(n) && n >= 0 ? n : 1;
|
||||||
|
}
|
||||||
|
|
||||||
export async function createPermission(formData: FormData): Promise<void> {
|
export async function createPermission(formData: FormData): Promise<void> {
|
||||||
const staff = await requireStaff();
|
const staff = await requireStaff();
|
||||||
const key = String(formData.get("key") ?? "").trim().slice(0, 255);
|
const permission = String(formData.get("permission") ?? "").trim().slice(0, 255);
|
||||||
const value = String(formData.get("value") ?? "").trim().slice(0, 255);
|
const minRank = parseMinRank(formData);
|
||||||
const comment = String(formData.get("comment") ?? "").trim().slice(0, 255);
|
const description = String(formData.get("description") ?? "").trim() || null;
|
||||||
if (!key) return;
|
if (!permission) return;
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
try {
|
try {
|
||||||
await prisma.websitePermissions.upsert({
|
await prisma.websitePermissions.upsert({
|
||||||
where: { key },
|
where: { permission },
|
||||||
update: { value: value || null, comment: comment || null, updatedAt: now },
|
update: { minRank, description, updatedAt: now },
|
||||||
create: {
|
create: { permission, minRank, description, createdAt: now, updatedAt: now },
|
||||||
key,
|
|
||||||
value: value || null,
|
|
||||||
comment: comment || null,
|
|
||||||
createdAt: now,
|
|
||||||
updatedAt: now,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
await logStaffActivity({
|
await logStaffActivity({
|
||||||
staffId: staff.id,
|
staffId: staff.id,
|
||||||
action: "permission_create",
|
action: "permission_create",
|
||||||
description: `Saved permission "${key}" = "${value}"`,
|
description: `Saved permission "${permission}" (min rank ${minRank})`,
|
||||||
targetType: "permission",
|
targetType: "permission",
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
@@ -48,29 +46,24 @@ export async function updatePermission(formData: FormData): Promise<void> {
|
|||||||
const raw = String(formData.get("id") ?? "");
|
const raw = String(formData.get("id") ?? "");
|
||||||
if (!raw) return;
|
if (!raw) return;
|
||||||
const id = BigInt(raw);
|
const id = BigInt(raw);
|
||||||
const key = String(formData.get("key") ?? "").trim().slice(0, 255);
|
const permission = String(formData.get("permission") ?? "").trim().slice(0, 255);
|
||||||
const value = String(formData.get("value") ?? "").trim().slice(0, 255);
|
const minRank = parseMinRank(formData);
|
||||||
const comment = String(formData.get("comment") ?? "").trim().slice(0, 255);
|
const description = String(formData.get("description") ?? "").trim() || null;
|
||||||
if (!key) return;
|
if (!permission) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await prisma.websitePermissions.update({
|
await prisma.websitePermissions.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
data: {
|
data: { permission, minRank, description, updatedAt: new Date() },
|
||||||
key,
|
|
||||||
value: value || null,
|
|
||||||
comment: comment || null,
|
|
||||||
updatedAt: new Date(),
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
await logStaffActivity({
|
await logStaffActivity({
|
||||||
staffId: staff.id,
|
staffId: staff.id,
|
||||||
action: "permission_update",
|
action: "permission_update",
|
||||||
description: `Updated permission #${raw} ("${key}" = "${value}")`,
|
description: `Updated permission #${raw} ("${permission}" min rank ${minRank})`,
|
||||||
targetType: "permission",
|
targetType: "permission",
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
// ignore (e.g. duplicate key) — page re-renders current state
|
// ignore (e.g. duplicate) — page re-renders current state
|
||||||
}
|
}
|
||||||
revalidatePath("/admin/permissions");
|
revalidatePath("/admin/permissions");
|
||||||
}
|
}
|
||||||
@@ -83,12 +76,12 @@ export async function deletePermission(formData: FormData): Promise<void> {
|
|||||||
try {
|
try {
|
||||||
const deleted = await prisma.websitePermissions.delete({
|
const deleted = await prisma.websitePermissions.delete({
|
||||||
where: { id: BigInt(raw) },
|
where: { id: BigInt(raw) },
|
||||||
select: { key: true },
|
select: { permission: true },
|
||||||
});
|
});
|
||||||
await logStaffActivity({
|
await logStaffActivity({
|
||||||
staffId: staff.id,
|
staffId: staff.id,
|
||||||
action: "permission_delete",
|
action: "permission_delete",
|
||||||
description: `Deleted permission #${raw} ("${deleted.key}")`,
|
description: `Deleted permission #${raw} ("${deleted.permission}")`,
|
||||||
targetType: "permission",
|
targetType: "permission",
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export async function createShopArticle(formData: FormData): Promise<void> {
|
|||||||
data: {
|
data: {
|
||||||
name,
|
name,
|
||||||
info: String(formData.get("info") ?? "").trim().slice(0, 255),
|
info: String(formData.get("info") ?? "").trim().slice(0, 255),
|
||||||
icon: String(formData.get("icon") ?? "").trim().slice(0, 255),
|
iconUrl: String(formData.get("icon") ?? "").trim().slice(0, 255),
|
||||||
color: String(formData.get("color") ?? "").trim().slice(0, 255),
|
color: String(formData.get("color") ?? "").trim().slice(0, 255),
|
||||||
costs: reqUInt(formData, "costs"),
|
costs: reqUInt(formData, "costs"),
|
||||||
giveRank: optUInt(formData, "giveRank"),
|
giveRank: optUInt(formData, "giveRank"),
|
||||||
@@ -86,7 +86,7 @@ export async function updateShopArticle(formData: FormData): Promise<void> {
|
|||||||
data: {
|
data: {
|
||||||
name,
|
name,
|
||||||
info: String(formData.get("info") ?? "").trim().slice(0, 255),
|
info: String(formData.get("info") ?? "").trim().slice(0, 255),
|
||||||
icon: String(formData.get("icon") ?? "").trim().slice(0, 255),
|
iconUrl: String(formData.get("icon") ?? "").trim().slice(0, 255),
|
||||||
color: String(formData.get("color") ?? "").trim().slice(0, 255),
|
color: String(formData.get("color") ?? "").trim().slice(0, 255),
|
||||||
costs: reqUInt(formData, "costs"),
|
costs: reqUInt(formData, "costs"),
|
||||||
giveRank: optUInt(formData, "giveRank"),
|
giveRank: optUInt(formData, "giveRank"),
|
||||||
|
|||||||
@@ -8,21 +8,21 @@ import { prisma } from "@/lib/prisma";
|
|||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
// Manages website_permissions (model WebsitePermissions) — the CMS-owned
|
// Manages website_permissions (model WebsitePermissions) — the CMS-owned
|
||||||
// rank-permission mapping AtomCMS exposes in admin. Each row is a key with an
|
// permission -> minimum-rank mapping. Each row names a permission and the lowest
|
||||||
// optional value and comment; those are the only editable columns on the table.
|
// rank allowed to use it, with an optional description.
|
||||||
type PermissionRow = {
|
type PermissionRow = {
|
||||||
id: bigint;
|
id: bigint;
|
||||||
key: string;
|
permission: string;
|
||||||
value: string | null;
|
minRank: number;
|
||||||
comment: string | null;
|
description: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function AdminPermissions() {
|
export default async function AdminPermissions() {
|
||||||
let permissions: PermissionRow[] = [];
|
let permissions: PermissionRow[] = [];
|
||||||
try {
|
try {
|
||||||
permissions = await prisma.websitePermissions.findMany({
|
permissions = await prisma.websitePermissions.findMany({
|
||||||
select: { id: true, key: true, value: true, comment: true },
|
select: { id: true, permission: true, minRank: true, description: true },
|
||||||
orderBy: { key: "asc" },
|
orderBy: { minRank: "asc" },
|
||||||
take: 500,
|
take: 500,
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
@@ -33,21 +33,27 @@ export default async function AdminPermissions() {
|
|||||||
<main>
|
<main>
|
||||||
<h1>Permissions</h1>
|
<h1>Permissions</h1>
|
||||||
<p className="muted">
|
<p className="muted">
|
||||||
CMS-owned rank permissions (<code>website_permissions</code>). Each entry
|
CMS-owned permissions (<code>website_permissions</code>). Each entry maps
|
||||||
maps a permission key to its value/name and an optional comment.
|
a permission name to the minimum rank allowed to use it.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<form action={createPermission} className="card" style={{ marginBottom: "1.5rem" }}>
|
<form action={createPermission} className="card" style={{ marginBottom: "1.5rem" }}>
|
||||||
<h3 style={{ marginTop: 0 }}>Add / overwrite permission</h3>
|
<h3 style={{ marginTop: 0 }}>Add / overwrite permission</h3>
|
||||||
<div style={{ display: "flex", gap: "0.5rem", flexWrap: "wrap" }}>
|
<div style={{ display: "flex", gap: "0.5rem", flexWrap: "wrap" }}>
|
||||||
<input name="key" placeholder="key" required maxLength={255} />
|
<input name="permission" placeholder="permission" required maxLength={255} />
|
||||||
<input
|
<input
|
||||||
name="value"
|
name="minRank"
|
||||||
placeholder="value / name"
|
type="number"
|
||||||
maxLength={255}
|
min={0}
|
||||||
|
placeholder="min rank"
|
||||||
|
defaultValue={1}
|
||||||
|
style={{ width: 110 }}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
name="description"
|
||||||
|
placeholder="description"
|
||||||
style={{ flex: 1, minWidth: 160 }}
|
style={{ flex: 1, minWidth: 160 }}
|
||||||
/>
|
/>
|
||||||
<input name="comment" placeholder="comment" maxLength={255} />
|
|
||||||
<button type="submit" className="btn btn-primary">
|
<button type="submit" className="btn btn-primary">
|
||||||
Save
|
Save
|
||||||
</button>
|
</button>
|
||||||
@@ -61,9 +67,9 @@ export default async function AdminPermissions() {
|
|||||||
<thead>
|
<thead>
|
||||||
<tr style={{ textAlign: "left", color: "var(--muted)" }}>
|
<tr style={{ textAlign: "left", color: "var(--muted)" }}>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
<th>Key</th>
|
<th>Permission</th>
|
||||||
<th>Value</th>
|
<th>Min rank</th>
|
||||||
<th>Comment</th>
|
<th>Description</th>
|
||||||
<th />
|
<th />
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -78,24 +84,24 @@ export default async function AdminPermissions() {
|
|||||||
style={{ display: "contents" }}
|
style={{ display: "contents" }}
|
||||||
>
|
>
|
||||||
<input type="hidden" name="id" value={String(p.id)} />
|
<input type="hidden" name="id" value={String(p.id)} />
|
||||||
<input name="key" defaultValue={p.key} required maxLength={255} />
|
<input name="permission" defaultValue={p.permission} required maxLength={255} />
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input
|
<input
|
||||||
form={`perm-${String(p.id)}`}
|
form={`perm-${String(p.id)}`}
|
||||||
name="value"
|
name="minRank"
|
||||||
defaultValue={p.value ?? ""}
|
type="number"
|
||||||
maxLength={255}
|
min={0}
|
||||||
style={{ width: "100%" }}
|
defaultValue={p.minRank}
|
||||||
|
style={{ width: 90 }}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input
|
<input
|
||||||
form={`perm-${String(p.id)}`}
|
form={`perm-${String(p.id)}`}
|
||||||
name="comment"
|
name="description"
|
||||||
defaultValue={p.comment ?? ""}
|
defaultValue={p.description ?? ""}
|
||||||
maxLength={255}
|
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export default async function EditShopArticle({
|
|||||||
<input type="hidden" name="id" value={String(pkg.id)} />
|
<input type="hidden" name="id" value={String(pkg.id)} />
|
||||||
<input name="name" defaultValue={pkg.name} placeholder="Name" required maxLength={255} />
|
<input name="name" defaultValue={pkg.name} placeholder="Name" required maxLength={255} />
|
||||||
<input name="info" defaultValue={pkg.info} placeholder="Info / description" maxLength={255} />
|
<input name="info" defaultValue={pkg.info} placeholder="Info / description" maxLength={255} />
|
||||||
<input name="icon" defaultValue={pkg.icon} placeholder="Icon" maxLength={255} />
|
<input name="icon" defaultValue={pkg.iconUrl} placeholder="Icon URL" maxLength={255} />
|
||||||
<input name="color" defaultValue={pkg.color} placeholder="Color (e.g. #ffcc00)" maxLength={255} />
|
<input name="color" defaultValue={pkg.color} placeholder="Color (e.g. #ffcc00)" maxLength={255} />
|
||||||
<input name="costs" type="number" min={0} defaultValue={pkg.costs} placeholder="Costs (store price)" required />
|
<input name="costs" type="number" min={0} defaultValue={pkg.costs} placeholder="Costs (store price)" required />
|
||||||
<input name="credits" type="number" min={0} defaultValue={pkg.credits ?? undefined} placeholder="Credits given (optional)" />
|
<input name="credits" type="number" min={0} defaultValue={pkg.credits ?? undefined} placeholder="Credits given (optional)" />
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ type ShopArticle = {
|
|||||||
id: bigint;
|
id: bigint;
|
||||||
name: string;
|
name: string;
|
||||||
info: string;
|
info: string;
|
||||||
icon: string;
|
iconUrl: string;
|
||||||
color: string;
|
color: string;
|
||||||
costs: number;
|
costs: number;
|
||||||
credits: number | null;
|
credits: number | null;
|
||||||
@@ -28,7 +28,6 @@ type ShopArticle = {
|
|||||||
type ShopCategory = {
|
type ShopCategory = {
|
||||||
id: bigint;
|
id: bigint;
|
||||||
name: string;
|
name: string;
|
||||||
slug: string;
|
|
||||||
icon: string | null;
|
icon: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -36,7 +35,7 @@ const ARTICLE_SELECT = {
|
|||||||
id: true,
|
id: true,
|
||||||
name: true,
|
name: true,
|
||||||
info: true,
|
info: true,
|
||||||
icon: true,
|
iconUrl: true,
|
||||||
color: true,
|
color: true,
|
||||||
costs: true,
|
costs: true,
|
||||||
credits: true,
|
credits: true,
|
||||||
@@ -59,7 +58,7 @@ export default async function ShopPage({
|
|||||||
let categories: ShopCategory[] = [];
|
let categories: ShopCategory[] = [];
|
||||||
try {
|
try {
|
||||||
categories = await prisma.websiteShopCategories.findMany({
|
categories = await prisma.websiteShopCategories.findMany({
|
||||||
select: { id: true, name: true, slug: true, icon: true },
|
select: { id: true, name: true, icon: true },
|
||||||
orderBy: { name: "asc" },
|
orderBy: { name: "asc" },
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
@@ -169,12 +168,12 @@ export default async function ShopPage({
|
|||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{a.icon ? (
|
{a.iconUrl ? (
|
||||||
// Article icons are arbitrary external/Imgur URLs from the
|
// Article icons are arbitrary external/Imgur URLs from the
|
||||||
// emulator data, so a plain <img> is correct here.
|
// emulator data, so a plain <img> is correct here.
|
||||||
// eslint-disable-next-line @next/next/no-img-element
|
// eslint-disable-next-line @next/next/no-img-element
|
||||||
<img
|
<img
|
||||||
src={a.icon}
|
src={a.iconUrl}
|
||||||
alt=""
|
alt=""
|
||||||
width={48}
|
width={48}
|
||||||
height={48}
|
height={48}
|
||||||
|
|||||||
Reference in new issue
Block a user