Poprawki w switcherach i internet Card
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// src/pages/api/switches/internet.js
|
||||
// src/pages/api/switches.js
|
||||
import Database from "better-sqlite3";
|
||||
|
||||
const DB_PATH =
|
||||
@@ -13,13 +13,11 @@ export function GET() {
|
||||
|
||||
try {
|
||||
const buildingTypes = db
|
||||
.prepare("SELECT code, label FROM jambox_building_types ORDER BY code")
|
||||
.prepare("SELECT code, label FROM jambox_building_types ORDER BY is_default DESC, code")
|
||||
.all();
|
||||
|
||||
const contractTypes = db
|
||||
.prepare(
|
||||
"SELECT code, label FROM jambox_contract_types ORDER BY code"
|
||||
)
|
||||
.prepare("SELECT code, label FROM jambox_contract_types ORDER BY is_default DESC, code")
|
||||
.all();
|
||||
|
||||
const switches = [
|
||||
@@ -29,7 +27,7 @@ export function GET() {
|
||||
domyslny: buildingTypes[0]?.code ?? 1,
|
||||
title: "Zmień rodzaj budynku by zobaczyć odpowiednie ceny",
|
||||
opcje: buildingTypes.map((b) => ({
|
||||
id: b.code, // 1,2,...
|
||||
id: b.code,
|
||||
nazwa: b.label,
|
||||
})),
|
||||
},
|
||||
@@ -39,7 +37,7 @@ export function GET() {
|
||||
domyslny: contractTypes[0]?.code ?? 1,
|
||||
title: "Wybierz okres umowy by zobaczyć odpowiednie ceny",
|
||||
opcje: contractTypes.map((c) => ({
|
||||
id: c.code, // 1,2,...
|
||||
id: c.code,
|
||||
nazwa: c.label,
|
||||
})),
|
||||
},
|
||||
@@ -56,7 +54,7 @@ export function GET() {
|
||||
}
|
||||
);
|
||||
} catch (err) {
|
||||
console.error("❌ Błąd w /api/switches/internet:", err);
|
||||
console.error("Błąd w /api/switches:", err);
|
||||
return new Response(
|
||||
JSON.stringify({ ok: false, error: err.message || "DB_ERROR" }),
|
||||
{
|
||||
Reference in New Issue
Block a user