i think i fixed a bug...

This commit is contained in:
Chop
2022-02-23 19:20:49 +01:00
parent e4478d7841
commit 95dfe2d202
14 changed files with 338 additions and 149 deletions

View File

@@ -1,5 +1,6 @@
import '../styles/globals.css'
import { SessionProvider } from "next-auth/react"
import Head from "next/head";
function MyApp({
Component,
@@ -7,6 +8,10 @@ function MyApp({
}) {
return (
<SessionProvider session={session}>
<Head>
<meta name="description" content="Wastpol" />
<link rel="icon" href="/icon.png" />
</Head>
<Component {...pageProps} />
</SessionProvider>
)

View File

@@ -1,10 +1,10 @@
import Head from "next/head";
import styles from "../styles/Home.module.css";
import Header from "./templates/header";
import Generator from "./templates/generator";
import Nav from "./templates/nav";
import Content from "./templates/content";
import Footer from "./templates/footer";
import Header from "../templates/header";
import Generator from "../templates/generator";
import Nav from "../templates/nav";
import UserTop from "../templates/userTop";
import Footer from "../templates/footer";
import { useState } from "react";
import { useSession, signIn, signOut } from "next-auth/react";
import { Button } from "evergreen-ui";
@@ -17,26 +17,18 @@ export default function Home() {
<div className={styles.container}>
<Head>
<title>Wastpol</title>
<meta name="description" content="Wastpol" />
<link rel="icon" href="/icon.png" />
</Head>
<div className="flex justify-between">
<Nav />
<div className="flex">
<h3 className="px-3 py-2 place-self-end">
Zalogowano jako {session.user.email}
</h3>
<Button onClick={() => signOut()} className="place-self-end">
Wyloguj
</Button>
</div>
<UserTop session={session} />
</div>
<main className={styles.main}>
<main className="flex flex-1 flex-col justify-center items-center p-8 mx-auto mt-24 rounded-md shadow-md transition-all duration-500 hover:shadow-xl">
<Header />
<Generator />
</main>
<Footer />
</div>
);
}
@@ -45,8 +37,6 @@ export default function Home() {
<div className="grid place-items-center h-screen">
<Head>
<title>Wastpol</title>
<meta name="description" content="Wastpol" />
<link rel="icon" href="/icon.png" />
</Head>
<div className="flex flex-col justify-center">
<h2 className="p-2">Nie zalogowano</h2>

View File

@@ -1,9 +1,9 @@
import Head from "next/head";
import styles from "../styles/Home.module.css";
import Header from "./templates/header";
import Nav from "./templates/nav";
import Content from "./templates/content";
import Footer from "./templates/footer";
import Header from "../templates/header";
import Nav from "../templates/nav";
import Content from "../templates/content";
import Footer from "../templates/footer";
import { useState } from "react";

View File

@@ -1,9 +1,9 @@
import Head from "next/head";
import styles from "../styles/Home.module.css";
import Header from "./templates/header";
import Nav from "./templates/nav";
import Content from "./templates/content";
import Footer from "./templates/footer";
import Header from "../templates/header";
import Nav from "../templates/nav";
import Content from "../templates/content";
import Footer from "../templates/footer";
export default function Onas() {
return (
@@ -15,6 +15,7 @@ export default function Onas() {
</Head>
<Nav />
<Footer />
<main className={styles.main}>
<p className="font-bold">
Głównym profilem działalności firmy jest projektowanie instalacji
@@ -29,7 +30,7 @@ export default function Onas() {
terminach realizacji.
</p>
</main>
<Footer />
</div>
);
}

View File

@@ -1,33 +0,0 @@
import styles from "../../styles/Home.module.css";
export default function Content() {
return (
<div>
<p className={styles.description}>
Lokalizacja
<br />
<b>Nowy Sącz, Aleje Wolności 6</b>
</p>
<p className={styles.description}>
Telefon kontaktowy
<br />
<b>
<a href="tel:+48504066513">+48 504 066 513</a>
</b>
<br />
<b>
<a href="tel:184420244">18 442 02 44</a>
</b>
</p>
<p className={styles.description}>
Adres email
<br />
<b>
<a href="mailto:biuro@wastpol.pl">biuro@wastpol.pl</a>
</b>
</p>
</div>
);
}

View File

@@ -1,9 +0,0 @@
import styles from "../../styles/Home.module.css";
export default function Footer() {
return (
<div>
<p></p>
</div>
);
}

View File

@@ -1,95 +0,0 @@
import { useState } from "react";
import {
Pane,
TextInputField,
TextareaField,
Button,
BuildIcon,
toaster,
Alert,
} from "evergreen-ui";
import axios from "axios";
export default function Generator() {
const [profil, setProfil] = useState();
const [args, setArgs] = useState({ scale: 200 });
const parsePreview = (e) => {
// console.log(dxf);
};
const py = (e, profil, args) => {
e.preventDefault();
axios
.post("/api/spawn", {
profil: profil,
arguments: args,
})
.then(function (response) {
console.log(response);
if (response.data.toString().startsWith("Py Error")) {
toaster.danger(response.data);
return;
}
toaster.warning(response.data.data);
document.getElementById("down").download =
response.data.filename.toString() + ".dxf";
document.getElementById("down").click();
})
.catch(function (error) {
console.log(error);
});
};
return (
<div className="flex flex-col">
<Pane width={480}>
<TextareaField
id="textarea-1"
label="Dane z Geoportalu:"
placeholder="Próbkowanie: 1 ..."
onChange={(e) => {
console.log(e.target.value);
setProfil(e.target.value);
parsePreview(e);
}}
/>
<TextInputField
label="Skala:"
placeholder="200"
width={100}
onChange={(e) => {
console.log(e.target.value);
setArgs({ ...args, scale: e.target.value });
}}
/>
<Button
marginY={8}
marginRight={12}
appearance="default"
iconAfter={BuildIcon}
onClick={(e) => {
if (document.getElementById("textarea-1").value == "") {
toaster.danger("Pole danych nie może być puste");
} else if (
!document
.getElementById("textarea-1")
.value.startsWith("Próbkowanie")
) {
toaster.danger("Błędne dane");
} else {
py(e, profil, args);
}
}}
>
Generuj
</Button>
</Pane>
<a href="test.dxf" download="test.dxf" id="down">
{" "}
</a>
</div>
);
}

View File

@@ -1,12 +0,0 @@
import styles from "../../styles/Home.module.css";
import { Pane, Heading } from "evergreen-ui";
export default function Header() {
return (
<Pane>
<Heading is="h1" size={800} marginBottom={42}>
Generuj profil przekroju terenu
</Heading>
</Pane>
);
}

View File

@@ -1,20 +0,0 @@
import Link from "next/link";
import { Pane, Heading } from "evergreen-ui";
export default function Nav() {
return (
<Pane display="flex">
<Link href="/">
<h2 className="px-2 place-self-center">
<img src="logo.png" className="h-12" />
</h2>
</Link>
<Link href="/onas">
<h3 className="px-3 py-2 place-self-end">O nas</h3>
</Link>
<Link href="/kontakt">
<h3 className="px-3 py-2 place-self-end">Kontakt</h3>
</Link>
</Pane>
);
}