From c18b5a31530352c1a795330da7b6599a6c986d14 Mon Sep 17 00:00:00 2001 From: Alex-zReeZ Date: Thu, 4 Jul 2024 09:29:39 +0200 Subject: [PATCH 1/2] refactor: changed branch and type execution of workflow --- .github/workflows/formating.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/formating.yml b/.github/workflows/formating.yml index 5112295..31debdd 100644 --- a/.github/workflows/formating.yml +++ b/.github/workflows/formating.yml @@ -2,9 +2,8 @@ name: Check formatting of project files with Prettier on: pull_request: - types: [opened, edited, synchronize] branches: - - Dev + - main concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} From 862334f2cc23d2bf196de2cefb786949b996cb06 Mon Sep 17 00:00:00 2001 From: Alex-zReeZ Date: Thu, 4 Jul 2024 09:31:04 +0200 Subject: [PATCH 2/2] style: reformated files --- nextjs-interface/src/app/dashboard/layout.tsx | 4 +- nextjs-interface/src/app/ui/all/providers.tsx | 14 +++--- .../src/app/ui/dashboard/ChartElement.tsx | 16 +++++-- .../src/app/ui/dashboard/EspLinksElement.tsx | 2 +- nextjs-interface/src/lib/cookies.ts | 48 +++++++++---------- 5 files changed, 46 insertions(+), 38 deletions(-) diff --git a/nextjs-interface/src/app/dashboard/layout.tsx b/nextjs-interface/src/app/dashboard/layout.tsx index baddcb4..cbc1654 100644 --- a/nextjs-interface/src/app/dashboard/layout.tsx +++ b/nextjs-interface/src/app/dashboard/layout.tsx @@ -11,7 +11,9 @@ export default function Layout({ children }: { children: React.ReactNode }) {
-
{children}
+
+ {children} +
); diff --git a/nextjs-interface/src/app/ui/all/providers.tsx b/nextjs-interface/src/app/ui/all/providers.tsx index 4f6cdb1..60e11ab 100644 --- a/nextjs-interface/src/app/ui/all/providers.tsx +++ b/nextjs-interface/src/app/ui/all/providers.tsx @@ -9,23 +9,23 @@ import { ThemeContext } from "@/lib/Theme"; // import scripts import { getCookie, setCookie } from "@/lib/cookies"; -export function Providers({ children }: { children: React.ReactNode; }) { +export function Providers({ children }: { children: React.ReactNode }) { // set dark mode const [darkMode, setDarkMode] = useState(() => { const savedMode = getCookie("darkMode"); - return savedMode ? savedMode === 'true' : false; + return savedMode ? savedMode === "true" : false; }); // toggle dark mode const toggleDarkMode = () => { const newDarkMode = !darkMode; setDarkMode(newDarkMode); - setCookie({name: "darkMode", value: newDarkMode}); + setCookie({ name: "darkMode", value: newDarkMode }); }; return ( - - {children} - + + {children} + ); -} \ No newline at end of file +} diff --git a/nextjs-interface/src/app/ui/dashboard/ChartElement.tsx b/nextjs-interface/src/app/ui/dashboard/ChartElement.tsx index 33aaaf9..2111b86 100644 --- a/nextjs-interface/src/app/ui/dashboard/ChartElement.tsx +++ b/nextjs-interface/src/app/ui/dashboard/ChartElement.tsx @@ -63,11 +63,17 @@ export function ChartElement({ data }: { data: avgData[] }) {
-

Date : {new Date(payload[0].payload.date).toLocaleDateString()}

-

- Temperature : {payload[0].payload.avg_temperature.toFixed(2)}°C

-

- Humidity : {payload[0].payload.avg_humidity.toFixed(2)}%

+

+ Date :{" "} + {new Date(payload[0].payload.date).toLocaleDateString()} +

+

+ Temperature :{" "} + {payload[0].payload.avg_temperature.toFixed(2)}°C +

+

+ Humidity : {payload[0].payload.avg_humidity.toFixed(2)}% +

diff --git a/nextjs-interface/src/app/ui/dashboard/EspLinksElement.tsx b/nextjs-interface/src/app/ui/dashboard/EspLinksElement.tsx index ebfb5d9..98f6411 100644 --- a/nextjs-interface/src/app/ui/dashboard/EspLinksElement.tsx +++ b/nextjs-interface/src/app/ui/dashboard/EspLinksElement.tsx @@ -90,7 +90,7 @@ export default function EspLinksElement() { - +
diff --git a/nextjs-interface/src/lib/cookies.ts b/nextjs-interface/src/lib/cookies.ts index 1b1c315..cc0974b 100644 --- a/nextjs-interface/src/lib/cookies.ts +++ b/nextjs-interface/src/lib/cookies.ts @@ -1,31 +1,31 @@ export function getCookie(cname: any) { - if (typeof window === 'undefined') { - return ""; // Early return if not in browser environment - } + if (typeof window === "undefined") { + return ""; // Early return if not in browser environment + } - const theme = cname + "="; - const decodedCookie = decodeURIComponent(document.cookie); - const ca = decodedCookie.split(';'); + const theme = cname + "="; + const decodedCookie = decodeURIComponent(document.cookie); + const ca = decodedCookie.split(";"); - for(let i = 0; i < ca.length; i++) { - let c = ca[i]; - while (c.charAt(0) == ' ') { - c = c.substring(1); - } - if (c.indexOf(theme) == 0) { - return c.substring(theme.length, c.length); - } + for (let i = 0; i < ca.length; i++) { + let c = ca[i]; + while (c.charAt(0) == " ") { + c = c.substring(1); + } + if (c.indexOf(theme) == 0) { + return c.substring(theme.length, c.length); } - return ""; + } + return ""; } -export function setCookie(name: { name: string, value:any }) { - if (typeof window === 'undefined') { - return; - } +export function setCookie(name: { name: string; value: any }) { + if (typeof window === "undefined") { + return; + } - const d = new Date(); - d.setTime(d.getTime() + (365*24*60*60*1000)); - const expires = "expires=" + d.toUTCString(); - document.cookie = name.name + "=" + name.value + ";" + expires + ";path=/"; -} \ No newline at end of file + const d = new Date(); + d.setTime(d.getTime() + 365 * 24 * 60 * 60 * 1000); + const expires = "expires=" + d.toUTCString(); + document.cookie = name.name + "=" + name.value + ";" + expires + ";path=/"; +}