Menambahkan source code website Next.js
This commit is contained in:
parent
5e39805136
commit
689400f600
1
kode web
1
kode web
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 9dc14b4108c14408acc92c8b63f0497819597ace
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
/.pnp
|
||||||
|
.pnp.*
|
||||||
|
.yarn/*
|
||||||
|
!.yarn/patches
|
||||||
|
!.yarn/plugins
|
||||||
|
!.yarn/releases
|
||||||
|
!.yarn/versions
|
||||||
|
|
||||||
|
# testing
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# next.js
|
||||||
|
/.next/
|
||||||
|
/out/
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
*.pem
|
||||||
|
|
||||||
|
# debug
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# env files (can opt-in for committing if needed)
|
||||||
|
.env*
|
||||||
|
|
||||||
|
# vercel
|
||||||
|
.vercel
|
||||||
|
|
||||||
|
# typescript
|
||||||
|
*.tsbuildinfo
|
||||||
|
next-env.d.ts
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
First, run the development server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
# or
|
||||||
|
yarn dev
|
||||||
|
# or
|
||||||
|
pnpm dev
|
||||||
|
# or
|
||||||
|
bun dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||||
|
|
||||||
|
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
||||||
|
|
||||||
|
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
||||||
|
|
||||||
|
## Learn More
|
||||||
|
|
||||||
|
To learn more about Next.js, take a look at the following resources:
|
||||||
|
|
||||||
|
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||||
|
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||||
|
|
||||||
|
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
||||||
|
|
||||||
|
## Deploy on Vercel
|
||||||
|
|
||||||
|
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||||
|
|
||||||
|
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
||||||
|
|
@ -0,0 +1,219 @@
|
||||||
|
"use client";
|
||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import dynamic from "next/dynamic";
|
||||||
|
import KartuStatus from "@/components/KartuStatus";
|
||||||
|
import TabelAir from "@/components/TabelAir";
|
||||||
|
import TabelPrediksi from "@/components/TabelPrediksi";
|
||||||
|
import { rtdb } from "@/lib/firebase";
|
||||||
|
import { ref, query, limitToLast, onValue } from "firebase/database";
|
||||||
|
|
||||||
|
// Dynamic import for Leaflet (CSR only)
|
||||||
|
const PetaLokasi = dynamic(() => import("@/components/PetaLokasi"), {
|
||||||
|
ssr: false,
|
||||||
|
loading: () => <div className="h-[500px] w-full bg-gray-100 animate-pulse rounded-2xl flex items-center justify-center">Memuat Peta...</div>
|
||||||
|
});
|
||||||
|
|
||||||
|
export default function DashboardPage() {
|
||||||
|
const [currentLevel, setCurrentLevel] = useState(0);
|
||||||
|
const [riskInfo, setRiskInfo] = useState({ status: "LOADING", risk: "Memuat...", color: "#9ca3af" });
|
||||||
|
const [history, setHistory] = useState<{ time: string; level: number; status: string }[]>([]);
|
||||||
|
const [location, setLocation] = useState<{ lat?: number; lng?: number }>({});
|
||||||
|
const [predictions, setPredictions] = useState<{
|
||||||
|
time: string;
|
||||||
|
predictedLevel: number | null;
|
||||||
|
currentLevel: number;
|
||||||
|
status: string;
|
||||||
|
currentStatus: string;
|
||||||
|
risk: string;
|
||||||
|
color: string;
|
||||||
|
}[]>([]);
|
||||||
|
const [isAlertDismissed, setIsAlertDismissed] = useState(false);
|
||||||
|
const [firebaseError, setFirebaseError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const getStatus = (level: number) => {
|
||||||
|
if (level < 56) return "NORMAL";
|
||||||
|
if (level <= 75) return "WASPADA";
|
||||||
|
return "BAHAYA";
|
||||||
|
};
|
||||||
|
|
||||||
|
const getRiskAnalysis = (current: number, predicted: number | null) => {
|
||||||
|
if (predicted === null) return { status: "LOADING", risk: "Menunggu Prediksi...", color: "#9ca3af" };
|
||||||
|
|
||||||
|
const curS = getStatus(current);
|
||||||
|
const predS = getStatus(predicted);
|
||||||
|
|
||||||
|
// Kasus 1, 2, 3: Current Normal (<56)
|
||||||
|
if (curS === "NORMAL") {
|
||||||
|
if (predS === "NORMAL") return { status: "NORMAL", risk: "Rendah", color: "#22c55e" };
|
||||||
|
if (predS === "WASPADA") return { status: "WASPADA", risk: "Sedang", color: "#f59e0b" };
|
||||||
|
if (predS === "BAHAYA") return { status: "BAHAYA", risk: "Tinggi", color: "#ef4444" };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kasus 4, 5, 6: Current Waspada (56-75)
|
||||||
|
if (curS === "WASPADA") {
|
||||||
|
if (predS === "NORMAL") return { status: "NORMAL", risk: "Waspada (Menurun)", color: "#f59e0b" };
|
||||||
|
if (predS === "WASPADA") return { status: "WASPADA", risk: "Waspada (Sedang)", color: "#f59e0b" };
|
||||||
|
if (predS === "BAHAYA") return { status: "BAHAYA", risk: "Bahaya (Tinggi)", color: "#ef4444" };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kasus 7, 8, 9: Current Bahaya (>75)
|
||||||
|
if (curS === "BAHAYA") {
|
||||||
|
if (predS === "NORMAL") return { status: "NORMAL", risk: "Menurun Signifikan", color: "#22c55e" };
|
||||||
|
if (predS === "WASPADA") return { status: "WASPADA", risk: "Menurun Bertahap", color: "#f59e0b" };
|
||||||
|
if (predS === "BAHAYA") return { status: "BAHAYA", risk: "Bahaya (Kritis)", color: "#ef4444" };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { status: "NORMAL", risk: "Rendah", color: "#22c55e" };
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// Mengambil data dari node 'iot/monitoring' di Realtime Database
|
||||||
|
const refSensor = ref(rtdb, "iot/monitoring");
|
||||||
|
|
||||||
|
const unsubscribeSensor = onValue(refSensor, (snapshot) => {
|
||||||
|
if (snapshot.exists()) {
|
||||||
|
const data = snapshot.val();
|
||||||
|
console.log("Data diterima dari Firebase:", data);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
// Menggunakan data elevasi_air sebagai elevasi air
|
||||||
|
const level = parseFloat(data.elevasi_air?.toString() || "0");
|
||||||
|
|
||||||
|
// Format timestamp if it exists, otherwise use current time
|
||||||
|
const timeStr = data.timestamp
|
||||||
|
? new Date(data.timestamp).toLocaleString("id-ID")
|
||||||
|
: new Date().toLocaleString("id-ID");
|
||||||
|
|
||||||
|
if (data.latitude && data.longitude) {
|
||||||
|
setLocation({ lat: parseFloat(data.latitude), lng: parseFloat(data.longitude) });
|
||||||
|
}
|
||||||
|
|
||||||
|
setCurrentLevel(level);
|
||||||
|
|
||||||
|
const status = getStatus(level);
|
||||||
|
if (status !== "BAHAYA") {
|
||||||
|
setIsAlertDismissed(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update history
|
||||||
|
setHistory([{ time: timeStr, level: level, status: status }]);
|
||||||
|
|
||||||
|
// Prediksi dari alat IoT
|
||||||
|
const predLevel = data.prediksi !== undefined && data.prediksi !== null ? parseFloat(data.prediksi) : null;
|
||||||
|
|
||||||
|
// Kita bisa tetap menggunakan getRiskAnalysis untuk menentukan status dan risk jika IoT tidak mengirimkannya,
|
||||||
|
// atau menggunakan data langsung dari IoT jika ada.
|
||||||
|
const analysis = getRiskAnalysis(level, predLevel);
|
||||||
|
|
||||||
|
setRiskInfo({
|
||||||
|
status: data.predicted_status || analysis.status,
|
||||||
|
risk: data.risk || analysis.risk,
|
||||||
|
color: analysis.color // color bisa tetap dari frontend atau sesuaikan
|
||||||
|
});
|
||||||
|
|
||||||
|
setPredictions([{
|
||||||
|
time: timeStr,
|
||||||
|
predictedLevel: predLevel,
|
||||||
|
currentLevel: level,
|
||||||
|
status: data.predicted_status || analysis.status,
|
||||||
|
currentStatus: status,
|
||||||
|
risk: data.risk || analysis.risk,
|
||||||
|
color: analysis.color
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("Node iot/monitoring tidak ditemukan di Firebase");
|
||||||
|
setFirebaseError("Data pada node iot/monitoring kosong atau tidak ditemukan. (Pastikan huruf kecil semua)");
|
||||||
|
}
|
||||||
|
}, (error) => {
|
||||||
|
console.error("Error mengambil data dari Firebase:", error);
|
||||||
|
setFirebaseError(error.message || "Gagal menghubungi Firebase. Pastikan koneksi internet stabil dan aturan (Rules) Firebase mengizinkan read.");
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => unsubscribeSensor();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main className="min-h-screen bg-gray-50 text-gray-900 pb-20 font-sans notranslate" translate="no">
|
||||||
|
{/* Error Message Display */}
|
||||||
|
{firebaseError && (
|
||||||
|
<div className="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mx-8 mt-4" role="alert">
|
||||||
|
<strong className="font-bold">Firebase Error: </strong>
|
||||||
|
<span className="block sm:inline">{firebaseError}</span>
|
||||||
|
<p className="mt-2 text-xs">DB URL Terbaca: {process.env.NEXT_PUBLIC_FIREBASE_DATABASE_URL || "TIDAK TERBACA"}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Floating Danger Alert */}
|
||||||
|
{riskInfo.status === "BAHAYA" && !isAlertDismissed && (
|
||||||
|
<div className="fixed top-6 left-1/2 transform -translate-x-1/2 z-[100] bg-[#e30000] text-white px-5 py-3.5 rounded-xl shadow-2xl flex items-center gap-4">
|
||||||
|
<div className="flex-shrink-0">
|
||||||
|
<svg className="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div className="flex-grow">
|
||||||
|
<h4 className="font-bold text-[15px] leading-tight tracking-wide">PERINGATAN! Kondisi Sungai Bahaya</h4>
|
||||||
|
<p className="text-[13px] mt-0.5 text-white/90">Segera lakukan pencegahan</p>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
onClick={() => setIsAlertDismissed(true)}
|
||||||
|
className="flex-shrink-0 p-1 hover:bg-black/10 rounded-md transition-colors ml-2"
|
||||||
|
>
|
||||||
|
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Navigasi / Header Refined */}
|
||||||
|
<nav className="bg-white border-b border-gray-100 px-8 py-6 flex justify-between items-center sticky top-0 z-50">
|
||||||
|
<div>
|
||||||
|
<h1 suppressHydrationWarning className="text-2xl font-bold text-[#001f3f] tracking-tight">Dashboard Monitoring Elevasi Air</h1>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<button
|
||||||
|
onClick={() => window.location.reload()}
|
||||||
|
className="flex items-center gap-2 px-4 py-2 bg-white border border-gray-100 rounded-lg text-sm font-medium text-gray-700 hover:bg-gray-50 transition-all shadow-sm"
|
||||||
|
>
|
||||||
|
<svg className="w-4 h-4 text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
|
||||||
|
</svg>
|
||||||
|
Refresh
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div className="max-w-7xl mx-auto px-6 pt-8">
|
||||||
|
{/* Section 1: Status Cards (3 Grid) */}
|
||||||
|
<KartuStatus level={currentLevel} />
|
||||||
|
|
||||||
|
{/* Section 2: Current Water Data */}
|
||||||
|
<TabelAir data={history} />
|
||||||
|
|
||||||
|
{/* Section 3: Prediction Data */}
|
||||||
|
<TabelPrediksi data={predictions} />
|
||||||
|
|
||||||
|
{/* Section 4: Maps Visualization */}
|
||||||
|
<div className="bg-white rounded-xl shadow-sm border border-gray-100 p-6 overflow-hidden">
|
||||||
|
<h3 className="text-sm font-bold text-gray-800 mb-4">Peta Lokasi Alat Monitoring</h3>
|
||||||
|
<div className="rounded-lg overflow-hidden h-[450px] border border-gray-100">
|
||||||
|
<PetaLokasi
|
||||||
|
currentLevel={currentLevel}
|
||||||
|
mapColor={riskInfo.color}
|
||||||
|
risk={riskInfo.risk}
|
||||||
|
status={riskInfo.status}
|
||||||
|
latitude={location.lat}
|
||||||
|
longitude={location.lng}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer className="mt-16 text-center text-[10px] text-gray-400 font-bold uppercase tracking-widest pb-10">
|
||||||
|
©
|
||||||
|
</footer>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
|
|
@ -0,0 +1,37 @@
|
||||||
|
@import "tailwindcss";
|
||||||
|
|
||||||
|
@theme {
|
||||||
|
--color-primary: #2563eb;
|
||||||
|
--color-primary-foreground: #f8fafc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@layer base {
|
||||||
|
body {
|
||||||
|
@apply antialiased text-slate-900 bg-slate-50;
|
||||||
|
font-family: 'Inter', system-ui, -apple-system, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Custom Scrollbar */
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
width: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-track {
|
||||||
|
background: #f1f1f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-thumb {
|
||||||
|
background: #cbd5e1;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: #94a3b8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass {
|
||||||
|
background: rgba(255, 255, 255, 0.7);
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
import { Geist, Geist_Mono } from "next/font/google";
|
||||||
|
import "./globals.css";
|
||||||
|
|
||||||
|
const geistSans = Geist({
|
||||||
|
variable: "--font-geist-sans",
|
||||||
|
subsets: ["latin"],
|
||||||
|
});
|
||||||
|
|
||||||
|
const geistMono = Geist_Mono({
|
||||||
|
variable: "--font-geist-mono",
|
||||||
|
subsets: ["latin"],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "E-Monitoring Elevasi Air",
|
||||||
|
description: "Sistem Monitoring Elevasi Air Realtime",
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function RootLayout({
|
||||||
|
children,
|
||||||
|
}: Readonly<{
|
||||||
|
children: React.ReactNode;
|
||||||
|
}>) {
|
||||||
|
return (
|
||||||
|
<html lang="id" suppressHydrationWarning>
|
||||||
|
<head>
|
||||||
|
<meta name="google" content="notranslate" />
|
||||||
|
</head>
|
||||||
|
<body
|
||||||
|
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
"use client";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
|
export default function Home() {
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
router.replace("/dashboard");
|
||||||
|
}, [router]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen flex items-center justify-center bg-gray-50">
|
||||||
|
<div className="animate-pulse text-blue-600 font-semibold text-lg">
|
||||||
|
Memuat sistem...
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,74 @@
|
||||||
|
"use client";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
interface StatusCardsProps {
|
||||||
|
level: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function KartuStatus({ level }: StatusCardsProps) {
|
||||||
|
const isNormal = level < 56;
|
||||||
|
const isWaspada = level >= 56 && level <= 75;
|
||||||
|
const isBahaya = level > 75;
|
||||||
|
|
||||||
|
const cards = [
|
||||||
|
{
|
||||||
|
title: "Normal",
|
||||||
|
active: isNormal,
|
||||||
|
color: "text-green-600",
|
||||||
|
bg: "bg-green-50/50",
|
||||||
|
border: "border-green-100",
|
||||||
|
iconBg: "bg-green-500",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Waspada",
|
||||||
|
active: isWaspada,
|
||||||
|
color: "text-amber-600",
|
||||||
|
bg: "bg-amber-50/50",
|
||||||
|
border: "border-amber-100",
|
||||||
|
iconBg: "bg-amber-500",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Bahaya",
|
||||||
|
active: isBahaya,
|
||||||
|
color: "text-red-600",
|
||||||
|
bg: "bg-red-50/50",
|
||||||
|
border: "border-red-100",
|
||||||
|
iconBg: "bg-red-500",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
|
||||||
|
{cards.map((card, idx) => (
|
||||||
|
<div
|
||||||
|
key={idx}
|
||||||
|
className={`relative p-6 rounded-xl border flex items-center justify-between shadow-sm transition-all duration-300 ${card.active ? `${card.bg} ${card.border} border-2 ring-1 ring-offset-0` : "bg-white border-gray-100 opacity-70"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<span className={`text-[10px] font-bold uppercase tracking-wider mb-1 ${card.active ? card.color : "text-gray-400"}`}>
|
||||||
|
Status
|
||||||
|
</span>
|
||||||
|
<h3 className={`text-2xl font-bold ${card.active ? card.color : "text-gray-400"}`}>
|
||||||
|
{card.title}
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div className={`w-12 h-12 rounded-full flex items-center justify-center text-white shadow-lg ${card.active ? card.iconBg : "bg-gray-200"}`}>
|
||||||
|
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
{card.active && (
|
||||||
|
<div className="absolute top-2 right-2 flex h-2 w-2">
|
||||||
|
<span className={`animate-ping absolute inline-flex h-full w-full rounded-full opacity-75 ${card.iconBg}`}></span>
|
||||||
|
<span className={`relative inline-flex rounded-full h-2 w-2 ${card.iconBg}`}></span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
"use client";
|
||||||
|
import React, { useEffect, useRef } from "react";
|
||||||
|
import L from "leaflet";
|
||||||
|
import "leaflet/dist/leaflet.css";
|
||||||
|
|
||||||
|
interface MapLeafletProps {
|
||||||
|
currentLevel: number;
|
||||||
|
mapColor: string;
|
||||||
|
risk: string;
|
||||||
|
status: string;
|
||||||
|
latitude?: number;
|
||||||
|
longitude?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PetaLokasi = ({ currentLevel, mapColor, risk, status, latitude, longitude }: MapLeafletProps) => {
|
||||||
|
const mapRef = useRef<HTMLDivElement>(null);
|
||||||
|
const mapInstance = useRef<L.Map | null>(null);
|
||||||
|
const markerRef = useRef<L.CircleMarker | null>(null);
|
||||||
|
|
||||||
|
const lat = latitude ?? -8.139603; // Default ke Jember jika belum ada data gps
|
||||||
|
const lng = longitude ?? 113.762384;
|
||||||
|
|
||||||
|
// Use mapColor prop directly
|
||||||
|
useEffect(() => {
|
||||||
|
if (!mapRef.current || mapInstance.current) return;
|
||||||
|
|
||||||
|
// Initialize map
|
||||||
|
mapInstance.current = L.map(mapRef.current).setView([lat, lng], 15);
|
||||||
|
|
||||||
|
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
|
||||||
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||||
|
}).addTo(mapInstance.current);
|
||||||
|
|
||||||
|
// Initial marker
|
||||||
|
markerRef.current = L.circleMarker([lat, lng], {
|
||||||
|
color: "white",
|
||||||
|
weight: 2,
|
||||||
|
fillColor: mapColor,
|
||||||
|
fillOpacity: 0.9,
|
||||||
|
radius: 20
|
||||||
|
})
|
||||||
|
.addTo(mapInstance.current)
|
||||||
|
.bindTooltip(`Sensor Jember Pusat<br/>Elevasi: ${currentLevel} cm<br/>Status: ${status}<br/>Risiko: ${risk}`, {
|
||||||
|
permanent: true,
|
||||||
|
direction: "top",
|
||||||
|
className: "status-tooltip"
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (mapInstance.current) {
|
||||||
|
mapInstance.current.remove();
|
||||||
|
mapInstance.current = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (markerRef.current && mapInstance.current) {
|
||||||
|
markerRef.current.setLatLng([lat, lng]);
|
||||||
|
mapInstance.current.setView([lat, lng]); // Menggeser peta mengikuti alat
|
||||||
|
markerRef.current.setStyle({ fillColor: mapColor });
|
||||||
|
markerRef.current.setTooltipContent(`Sensor Jember Pusat<br/>Elevasi: ${currentLevel} cm<br/>Status: ${status}<br/>Risiko: ${risk}`);
|
||||||
|
}
|
||||||
|
}, [currentLevel, mapColor, risk, status, lat, lng]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="bg-white rounded-3xl shadow-xl p-6 border border-gray-100">
|
||||||
|
<div className="mb-4">
|
||||||
|
<h3 className="text-xl font-bold flex items-center">
|
||||||
|
<svg className="w-6 h-6 mr-2 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" />
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 11a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||||
|
</svg>
|
||||||
|
Peta Lokasi Alat & Status Terkini
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
ref={mapRef}
|
||||||
|
className="h-[500px] w-full rounded-2xl border-4 border-white shadow-inner bg-gray-100 overflow-hidden"
|
||||||
|
></div>
|
||||||
|
<style jsx global>{`
|
||||||
|
.status-tooltip {
|
||||||
|
background: rgba(0,0,0,0.8);
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 8px 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
`}</style>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PetaLokasi;
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
"use client";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
interface WaterTableProps {
|
||||||
|
data: { time: string; level: number; status: string }[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function TabelAir({ data }: WaterTableProps) {
|
||||||
|
// We only show the latest record as "Current Data" per the image
|
||||||
|
const latest = data[0] || { time: "-", level: 0, status: "-" };
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="bg-white rounded-xl shadow-sm overflow-hidden mb-6 border border-gray-100">
|
||||||
|
<div className="px-6 py-4 border-b border-gray-100">
|
||||||
|
<h3 className="text-sm font-bold text-gray-800">Data Elevasi Air Saat Ini</h3>
|
||||||
|
</div>
|
||||||
|
<div className="overflow-x-auto">
|
||||||
|
<table className="w-full text-left">
|
||||||
|
<thead>
|
||||||
|
<tr className="text-gray-500 text-[11px] font-bold border-b border-gray-50">
|
||||||
|
<th className="px-6 py-4">Lokasi</th>
|
||||||
|
<th className="px-6 py-4">Elevasi (cm)</th>
|
||||||
|
<th className="px-6 py-4">Status</th>
|
||||||
|
<th className="px-6 py-4">Waktu Update</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr className="text-sm text-gray-700">
|
||||||
|
<td className="px-6 py-4 font-medium">Sungai Tegal Bal Karangrejo</td>
|
||||||
|
<td className="px-6 py-4 font-bold">{latest.level} cm</td>
|
||||||
|
<td className="px-6 py-4">
|
||||||
|
<span
|
||||||
|
className={`px-3 py-1 rounded-full text-[11px] font-bold text-white shadow-sm ${latest.status === "NORMAL"
|
||||||
|
? "bg-green-500"
|
||||||
|
: latest.status === "WASPADA"
|
||||||
|
? "bg-amber-500"
|
||||||
|
: latest.status === "BAHAYA"
|
||||||
|
? "bg-red-500"
|
||||||
|
: "bg-gray-400"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{latest.status.charAt(0).toUpperCase() + latest.status.slice(1).toLowerCase()}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td className="px-6 py-4 text-xs text-gray-500">{latest.time}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
"use client";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
interface PredictionData {
|
||||||
|
time: string;
|
||||||
|
predictedLevel: number | null;
|
||||||
|
currentLevel: number;
|
||||||
|
status: string;
|
||||||
|
currentStatus: string;
|
||||||
|
risk: string;
|
||||||
|
color: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PredictionTableProps {
|
||||||
|
data: PredictionData[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function TabelPrediksi({ data }: PredictionTableProps) {
|
||||||
|
if (data.length === 0) return null;
|
||||||
|
|
||||||
|
const item = data[0];
|
||||||
|
const hasPrediction = item.predictedLevel !== null;
|
||||||
|
const trendValue = hasPrediction ? item.predictedLevel! - item.currentLevel : null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="bg-white rounded-xl shadow-sm overflow-hidden mb-6 border border-gray-100">
|
||||||
|
<div className="px-6 py-4 border-b border-gray-100">
|
||||||
|
<h3 className="text-sm font-bold text-gray-800">Prediksi Elevasi Air (5 Menit Ke Depan)</h3>
|
||||||
|
</div>
|
||||||
|
<div className="overflow-x-auto">
|
||||||
|
<table className="w-full text-left">
|
||||||
|
<thead>
|
||||||
|
<tr className="text-gray-500 text-[11px] font-bold border-b border-gray-50">
|
||||||
|
<th className="px-6 py-4">Lokasi</th>
|
||||||
|
<th className="px-6 py-4">Status Saat Ini</th>
|
||||||
|
<th className="px-6 py-4">Elevasi Saat Ini</th>
|
||||||
|
<th className="px-6 py-4">Prediksi Elevasi</th>
|
||||||
|
<th className="px-6 py-4">Tren</th>
|
||||||
|
<th className="px-6 py-4">Status Prediksi</th>
|
||||||
|
<th className="px-6 py-4">Tingkat Risiko</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody className="text-sm text-gray-700">
|
||||||
|
<tr>
|
||||||
|
<td className="px-6 py-4 font-medium">Sungai Tegal Bal Karangrejo</td>
|
||||||
|
<td className="px-6 py-4">
|
||||||
|
<span className={`px-3 py-1 rounded-full text-[11px] font-bold text-white ${item.currentStatus === "NORMAL" ? "bg-green-500" : item.currentStatus === "WASPADA" ? "bg-amber-500" : "bg-red-500"
|
||||||
|
}`}>
|
||||||
|
{item.currentStatus.charAt(0).toUpperCase() + item.currentStatus.slice(1).toLowerCase()}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td className="px-6 py-4">{item.currentLevel} cm</td>
|
||||||
|
<td className="px-6 py-4 font-bold">{hasPrediction ? `${item.predictedLevel} cm` : "-"}</td>
|
||||||
|
<td className="px-6 py-4">
|
||||||
|
<div className="flex items-center gap-1 text-[11px] font-bold">
|
||||||
|
{hasPrediction && trendValue !== null ? (
|
||||||
|
<svg className={`w-4 h-4 ${trendValue >= 0 ? "text-red-500" : "text-green-500"}`} fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d={trendValue >= 0 ? "M13 7h8m0 0v8m0-8l-8 8-4-4-6 6" : "M13 17h8m0 0v-8m0 8l-8-8-4 4-6-6"} />
|
||||||
|
</svg>
|
||||||
|
) : (
|
||||||
|
<span className="text-gray-400">-</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td className="px-6 py-4">
|
||||||
|
<span
|
||||||
|
className={`px-3 py-1 rounded-full text-[11px] font-bold text-white`}
|
||||||
|
style={{ backgroundColor: hasPrediction ? item.color : "#9ca3af" }}
|
||||||
|
>
|
||||||
|
{!hasPrediction ? "Menunggu" : item.status.charAt(0).toUpperCase() + item.status.slice(1).toLowerCase()}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td className="px-6 py-4">
|
||||||
|
<span
|
||||||
|
className={`px-3 py-1 rounded-full text-[11px] font-bold text-white`}
|
||||||
|
style={{ backgroundColor: hasPrediction ? item.color : "#9ca3af" }}
|
||||||
|
>
|
||||||
|
{!hasPrediction ? "-" : item.risk}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { defineConfig, globalIgnores } from "eslint/config";
|
||||||
|
import nextVitals from "eslint-config-next/core-web-vitals";
|
||||||
|
import nextTs from "eslint-config-next/typescript";
|
||||||
|
|
||||||
|
const eslintConfig = defineConfig([
|
||||||
|
...nextVitals,
|
||||||
|
...nextTs,
|
||||||
|
// Override default ignores of eslint-config-next.
|
||||||
|
globalIgnores([
|
||||||
|
// Default ignores of eslint-config-next:
|
||||||
|
".next/**",
|
||||||
|
"out/**",
|
||||||
|
"build/**",
|
||||||
|
"next-env.d.ts",
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
|
||||||
|
export default eslintConfig;
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { initializeApp, getApps, getApp } from "firebase/app";
|
||||||
|
import { getDatabase } from "firebase/database";
|
||||||
|
|
||||||
|
const firebaseConfig = {
|
||||||
|
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
|
||||||
|
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
|
||||||
|
databaseURL: process.env.NEXT_PUBLIC_FIREBASE_DATABASE_URL,
|
||||||
|
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
|
||||||
|
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
|
||||||
|
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
|
||||||
|
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
|
||||||
|
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initialize Firebase
|
||||||
|
const app = getApps().length > 0 ? getApp() : initializeApp(firebaseConfig);
|
||||||
|
const rtdb = getDatabase(app, process.env.NEXT_PUBLIC_FIREBASE_DATABASE_URL);
|
||||||
|
|
||||||
|
export { app, rtdb };
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
|
const nextConfig: NextConfig = {
|
||||||
|
/* config options here */
|
||||||
|
};
|
||||||
|
|
||||||
|
export default nextConfig;
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,33 @@
|
||||||
|
{
|
||||||
|
"name": "website1",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "next dev",
|
||||||
|
"build": "next build",
|
||||||
|
"start": "next start",
|
||||||
|
"lint": "eslint"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"autoprefixer": "^10.4.27",
|
||||||
|
"enhanced-resolve": "^5.20.0",
|
||||||
|
"firebase": "^12.10.0",
|
||||||
|
"leaflet": "^1.9.4",
|
||||||
|
"next": "16.1.6",
|
||||||
|
"postcss": "^8.5.8",
|
||||||
|
"react": "19.2.3",
|
||||||
|
"react-dom": "19.2.3",
|
||||||
|
"react-leaflet": "^5.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tailwindcss/postcss": "^4.2.1",
|
||||||
|
"@types/leaflet": "^1.9.21",
|
||||||
|
"@types/node": "^20",
|
||||||
|
"@types/react": "^19",
|
||||||
|
"@types/react-dom": "^19",
|
||||||
|
"eslint": "^9",
|
||||||
|
"eslint-config-next": "16.1.6",
|
||||||
|
"tailwindcss": "^4.2.1",
|
||||||
|
"typescript": "^5"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
const config = {
|
||||||
|
plugins: {
|
||||||
|
"@tailwindcss/postcss": {},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>
|
||||||
|
After Width: | Height: | Size: 391 B |
|
|
@ -0,0 +1 @@
|
||||||
|
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
|
||||||
|
After Width: | Height: | Size: 1.0 KiB |
|
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
|
||||||
|
After Width: | Height: | Size: 1.3 KiB |
|
|
@ -0,0 +1 @@
|
||||||
|
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>
|
||||||
|
After Width: | Height: | Size: 128 B |
|
|
@ -0,0 +1 @@
|
||||||
|
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>
|
||||||
|
After Width: | Height: | Size: 385 B |
|
|
@ -0,0 +1,51 @@
|
||||||
|
import { initializeApp } from "firebase/app";
|
||||||
|
import { getDatabase, ref, get } from "firebase/database";
|
||||||
|
import fs from "fs";
|
||||||
|
|
||||||
|
const envLocal = fs.readFileSync(".env.local", "utf-8");
|
||||||
|
const env = {};
|
||||||
|
envLocal.split("\n").forEach(line => {
|
||||||
|
if (line && line.includes("=")) {
|
||||||
|
const parts = line.split("=");
|
||||||
|
const key = parts[0].trim();
|
||||||
|
const value = parts.slice(1).join("=").trim().replace(/['"]/g, "");
|
||||||
|
env[key] = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const firebaseConfig = {
|
||||||
|
apiKey: env["NEXT_PUBLIC_FIREBASE_API_KEY"],
|
||||||
|
authDomain: env["NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN"],
|
||||||
|
databaseURL: env["NEXT_PUBLIC_FIREBASE_DATABASE_URL"],
|
||||||
|
projectId: env["NEXT_PUBLIC_FIREBASE_PROJECT_ID"],
|
||||||
|
storageBucket: env["NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET"],
|
||||||
|
messagingSenderId: env["NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID"],
|
||||||
|
appId: env["NEXT_PUBLIC_FIREBASE_APP_ID"],
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log("Testing Firebase connection...");
|
||||||
|
console.log("URL:", firebaseConfig.databaseURL);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const app = initializeApp(firebaseConfig);
|
||||||
|
const rtdb = getDatabase(app, firebaseConfig.databaseURL);
|
||||||
|
const refRoot = ref(rtdb, "/");
|
||||||
|
|
||||||
|
get(refRoot).then((snapshot) => {
|
||||||
|
if (snapshot.exists()) {
|
||||||
|
console.log("✅ Data found at root. Keys available:");
|
||||||
|
const val = snapshot.val();
|
||||||
|
console.log(Object.keys(val));
|
||||||
|
console.log(JSON.stringify(val, null, 2));
|
||||||
|
} else {
|
||||||
|
console.log("❌ Database is completely EMPTY");
|
||||||
|
}
|
||||||
|
process.exit(0);
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error("❌ Error fetching data:", error.message);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error("❌ Init error:", e);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2017",
|
||||||
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strict": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"incremental": true,
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"name": "next"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"next-env.d.ts",
|
||||||
|
"**/*.ts",
|
||||||
|
"**/*.tsx",
|
||||||
|
".next/types/**/*.ts",
|
||||||
|
".next/dev/types/**/*.ts",
|
||||||
|
"**/*.mts"
|
||||||
|
],
|
||||||
|
"exclude": ["node_modules"]
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue