2023-09-30 15:12:09 +08:00
|
|
|
import React, { useState, useEffect } from "react";
|
2023-09-19 20:47:04 +08:00
|
|
|
import { Link } from "react-router-dom";
|
2023-09-19 20:51:40 +08:00
|
|
|
import { IconCrossStroked } from "@douyinfe/semi-icons";
|
2023-10-24 18:04:33 +08:00
|
|
|
import Navbar from "../components/Navbar";
|
2023-10-26 21:34:50 +08:00
|
|
|
import { useLiveQuery } from "dexie-react-hooks";
|
|
|
|
import { db } from "../data/db";
|
2023-09-19 20:47:04 +08:00
|
|
|
|
|
|
|
export default function LandingPage() {
|
2023-09-19 20:51:40 +08:00
|
|
|
const [showSurvey, setShowSurvey] = useState(true);
|
|
|
|
|
2023-10-26 21:34:50 +08:00
|
|
|
const clearDatabase = () => {
|
|
|
|
db.delete()
|
|
|
|
.then(() => {
|
|
|
|
console.log("Database cleared.");
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error("Failed to clear the database:", error);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const diagrams = useLiveQuery(() => db.diagrams.toArray());
|
|
|
|
useEffect(() => {
|
|
|
|
console.log(diagrams);
|
|
|
|
}, [diagrams]);
|
|
|
|
|
2023-10-24 18:04:33 +08:00
|
|
|
useEffect(() => {
|
|
|
|
document.body.setAttribute("theme-mode", "light");
|
|
|
|
document.title =
|
|
|
|
"drawDB | Online database diagram editor and SQL generator";
|
|
|
|
});
|
2023-09-30 15:12:09 +08:00
|
|
|
|
2023-09-19 20:47:04 +08:00
|
|
|
return (
|
|
|
|
<div>
|
2023-09-19 20:51:40 +08:00
|
|
|
{showSurvey && (
|
|
|
|
<div className="text-white font-semibold py-1.5 px-4 text-sm text-center bg-gradient-to-r from-slate-700 from-10% via-slate-500 via-30% to-90% to-slate-700">
|
|
|
|
<Link to="/survey" className="hover:underline">
|
|
|
|
Help us improve! Share your feedback.
|
|
|
|
</Link>
|
|
|
|
<div className="float-right">
|
|
|
|
<button onClick={() => setShowSurvey(false)}>
|
|
|
|
<IconCrossStroked size="small" />
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
2023-10-24 18:04:33 +08:00
|
|
|
<Navbar />
|
2023-10-26 21:34:50 +08:00
|
|
|
<button onClick={clearDatabase}>delete db</button>
|
2023-09-19 20:47:04 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|