Skip to content

Commit

Permalink
chore: prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
felixerdy committed Sep 12, 2023
1 parent f0510ad commit 9de8deb
Show file tree
Hide file tree
Showing 18 changed files with 371 additions and 363 deletions.
12 changes: 6 additions & 6 deletions ios/App/App/capacitor.config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{

Check failure on line 1 in ios/App/App/capacitor.config.json

View workflow job for this annotation

GitHub Actions / Prettier

ios/App/App/capacitor.config.json#L1

There are issues with this file's formatting, please run Prettier to fix the errors
"appId": "com.example.app",
"appName": "senseBox:Bike X SIMPORT",
"webDir": "out",
"server": {
"url": "http://192.168.0.220:3000"
}
"appId": "com.example.app",
"appName": "senseBox:Bike X SIMPORT",
"webDir": "out",
"server": {
"url": "http://192.168.0.220:3000"
}
}
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Metadata } from "next";
import { Inter } from "next/font/google";
import { Navbar } from "@/components/ui/Navbar";
import { cn } from "@/lib/utils";
import { Toaster } from "@/components/ui/toaster"
import { Toaster } from "@/components/ui/toaster";

const inter = Inter({ subsets: ["latin"] });

Expand Down
57 changes: 28 additions & 29 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
'use client'
"use client";
import ConnectionSelection from "@/components/Home/ConnectionSelection";
import { Swiper, SwiperSlide } from 'swiper/react';
import { Navigation, Pagination } from 'swiper/modules';
import 'swiper/css';
import 'swiper/css/navigation';
import 'swiper/css/pagination';
import { Swiper, SwiperSlide } from "swiper/react";
import { Navigation, Pagination } from "swiper/modules";
import "swiper/css";
import "swiper/css/navigation";
import "swiper/css/pagination";
import Welcome from "@/components/Wizard/Welcome";
import OpenSenseMapLogin from "@/components/Wizard/OpenSenseMapLogin";
import SelectDevice from "@/components/Wizard/SelectDevice";
import { useState } from "react";

export default function Home() {

const [boxes, setBoxes] = useState([])
const [boxes, setBoxes] = useState([]);

return (
<Swiper
spaceBetween={50}
modules={[Navigation]}
slidesPerView={1}
onSlideChange={() => console.log('slide change')}
onSwiper={(swiper) => console.log(swiper)}
className="flex text-center h-full justify-center"
>
<SwiperSlide>
<Welcome />
</SwiperSlide>
<SwiperSlide>
<OpenSenseMapLogin />
</SwiperSlide>
<SwiperSlide>
<SelectDevice />
</SwiperSlide>
<SwiperSlide>
<ConnectionSelection />
</SwiperSlide>
</Swiper>
)
spaceBetween={50}
modules={[Navigation]}
slidesPerView={1}
onSlideChange={() => console.log("slide change")}
onSwiper={(swiper) => console.log(swiper)}
className="flex text-center h-full justify-center"
>
<SwiperSlide>
<Welcome />
</SwiperSlide>
<SwiperSlide>
<OpenSenseMapLogin />
</SwiperSlide>
<SwiperSlide>
<SelectDevice />
</SwiperSlide>
<SwiperSlide>
<ConnectionSelection />
</SwiperSlide>
</Swiper>
);
}
150 changes: 76 additions & 74 deletions src/components/Wizard/OpenSenseMapLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,94 +1,96 @@
'use client';
"use client";
import { useSwiper } from "swiper/react";
import { Button } from "../ui/button";
import { Input } from "../ui/input";
import { useState } from "react";
import useOpenSenseMapAuth from "@/lib/useOpenSenseMapAuth";
import { zodResolver } from "@hookform/resolvers/zod"
import { zodResolver } from "@hookform/resolvers/zod";
import * as z from "zod"; // import * as z from "zod";
import { useForm } from "react-hook-form";
import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "../ui/form";
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "../ui/form";
import { useToast } from "../ui/use-toast";
import Spinner from "../ui/Spinner";
import { useAuthStore } from "@/lib/store/useAuthStore";

const formSchema = z.object({
email: z.string().email(),
password: z.string(),
email: z.string().email(),
password: z.string(),
});

export default function OpenSenseMapLogin( ){
const swiper = useSwiper();
const [loading, setLoading] = useState(false);
const { login } = useOpenSenseMapAuth();
const { toast } = useToast();

const email = useAuthStore(state => state.email);
const password = useAuthStore(state => state.password);
export default function OpenSenseMapLogin() {
const swiper = useSwiper();
const [loading, setLoading] = useState(false);
const { login } = useOpenSenseMapAuth();
const { toast } = useToast();


const email = useAuthStore((state) => state.email);
const password = useAuthStore((state) => state.password);

const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
email,
password
},
})
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
email,
password,
},
});

const handleLogin = async (values: z.infer<typeof formSchema>) => {
setLoading(true);
const success = await login(values.email, values.password);
setLoading(false);
if (success) {
toast({title:"Login erfolgreich"})
swiper.slideNext();
}
else {
toast({ variant:"destructive", title: "Login fehlgeschlagen"})
}
const handleLogin = async (values: z.infer<typeof formSchema>) => {
setLoading(true);
const success = await login(values.email, values.password);
setLoading(false);
if (success) {
toast({ title: "Login erfolgreich" });
swiper.slideNext();
} else {
toast({ variant: "destructive", title: "Login fehlgeschlagen" });
}
};

return (
<div className="flex content-center h-full p-2 flex-col justify-center gap-4">
<div>Bitte loggen Sie sich mit Ihrem openSenseMap-Account ein.</div>
<Form {...form}>
<form onSubmit={form.handleSubmit(handleLogin)} className="space-y-8">
<FormField
control={form.control}
name="email"
render={({ field }) => (
<FormItem>
<FormLabel>Email</FormLabel>
<FormControl>
<Input placeholder="Email" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="password"
render={({ field }) => (
<FormItem>
<FormLabel>Passwort</FormLabel>
<FormControl>
<Input type="password" placeholder="Passwort" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>

return (
<div className="flex content-center h-full p-2 flex-col justify-center gap-4">
<div>
Bitte loggen Sie sich mit Ihrem openSenseMap-Account ein.
</div>
<Form {...form}>
<form onSubmit={form.handleSubmit(handleLogin)} className="space-y-8">
<FormField
control = {form.control}
name = "email"
render = {({field}) => (
<FormItem>
<FormLabel>Email</FormLabel>
<FormControl>
<Input placeholder="Email" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control = {form.control}
name = "password"
render = {({field}) => (
<FormItem>
<FormLabel>Passwort</FormLabel>
<FormControl>
<Input type="password" placeholder="Passwort" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>

<Button disabled={loading} type="submit">
{loading ? <Spinner/>: "Login"}
</Button>
</form>
</Form>
</div>
)
}
<Button disabled={loading} type="submit">
{loading ? <Spinner /> : "Login"}
</Button>
</form>
</Form>
</div>
);
}
30 changes: 15 additions & 15 deletions src/components/Wizard/Welcome.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { useSwiper } from "swiper/react"
import { useSwiper } from "swiper/react";
import { Button } from "../ui/button";
import Logo from "../../../public/senseboxbike.png";
import Image from "next/image";

export default function Welcome() {
const swiper = useSwiper();

const swiper = useSwiper();

return(
<div className="flex justify-center content-center flex-col gap-4 h-full">
<div className="flex flex-col items-center gap-2">
<Image src={Logo} alt="senseBox:bike" width={100} height={100} />
Willkommen beim senseBox Wizard
In den nächsten Schritten werden Sie durch die Einrichtung Ihrer senseBox geführt.
Dazu brauchen sie einen Account auf der <a href ="https://opensensemap.org">openSenseMap</a> sowie eine senseBox:bike mit einem Bluetooth-Modul.
</div>
<Button onClick={() => swiper.slideNext()}>Weiter</Button>
</div>
)
}
return (
<div className="flex justify-center content-center flex-col gap-4 h-full">
<div className="flex flex-col items-center gap-2">
<Image src={Logo} alt="senseBox:bike" width={100} height={100} />
Willkommen beim senseBox Wizard In den nächsten Schritten werden Sie
durch die Einrichtung Ihrer senseBox geführt. Dazu brauchen sie einen
Account auf der <a href="https://opensensemap.org">openSenseMap</a>{" "}
sowie eine senseBox:bike mit einem Bluetooth-Modul.
</div>
<Button onClick={() => swiper.slideNext()}>Weiter</Button>
</div>
);
}
31 changes: 22 additions & 9 deletions src/components/ui/Spinner.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
export default function Spinner () {
return(
export default function Spinner() {
return (
<div role="status">
<svg aria-hidden="true" className="w-8 h-8 mr-2 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
</svg>
<span className="sr-only">Loading...</span>
</div>)
}
<svg
aria-hidden="true"
className="w-8 h-8 mr-2 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
<span className="sr-only">Loading...</span>
</div>
);
}
Loading

0 comments on commit 9de8deb

Please sign in to comment.