🚚 Change setCookies to setCookie

This commit is contained in:
ajnart
2022-07-22 16:20:47 +02:00
parent 7b719c2273
commit 4628d1d1d7
5 changed files with 10 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
import { Center, Loader, Select, Tooltip } from '@mantine/core'; import { Center, Loader, Select, Tooltip } from '@mantine/core';
import { setCookies } from 'cookies-next'; import { setCookie } from 'cookies-next';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
@@ -26,7 +26,7 @@ export default function ConfigChanger() {
label="Config loader" label="Config loader"
onChange={(e) => { onChange={(e) => {
loadConfig(e ?? 'default'); loadConfig(e ?? 'default');
setCookies('config-name', e ?? 'default', { setCookie('config-name', e ?? 'default', {
maxAge: 60 * 60 * 24 * 30, maxAge: 60 * 60 * 24 * 30,
sameSite: 'strict', sameSite: 'strict',
}); });

View File

@@ -10,7 +10,7 @@ import { DropzoneStatus, FullScreenDropzone } from '@mantine/dropzone';
import { showNotification } from '@mantine/notifications'; import { showNotification } from '@mantine/notifications';
import { useRef } from 'react'; import { useRef } from 'react';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { setCookies } from 'cookies-next'; import { setCookie } from 'cookies-next';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
import { Config } from '../../tools/types'; import { Config } from '../../tools/types';
import { migrateToIdConfig } from '../../tools/migrate'; import { migrateToIdConfig } from '../../tools/migrate';
@@ -90,7 +90,7 @@ export default function LoadConfigComponent(props: any) {
icon: <Check />, icon: <Check />,
message: undefined, message: undefined,
}); });
setCookies('config-name', newConfig.name, { setCookie('config-name', newConfig.name, {
maxAge: 60 * 60 * 24 * 30, maxAge: 60 * 60 * 24 * 30,
sameSite: 'strict', sameSite: 'strict',
}); });

View File

@@ -1,7 +1,7 @@
import { GetServerSidePropsContext } from 'next'; import { GetServerSidePropsContext } from 'next';
import { useState } from 'react'; import { useState } from 'react';
import { AppProps } from 'next/app'; import { AppProps } from 'next/app';
import { getCookie, setCookies } from 'cookies-next'; import { getCookie, setCookie } from 'cookies-next';
import Head from 'next/head'; import Head from 'next/head';
import { MantineProvider, ColorScheme, ColorSchemeProvider, MantineTheme } from '@mantine/core'; import { MantineProvider, ColorScheme, ColorSchemeProvider, MantineTheme } from '@mantine/core';
import { NotificationsProvider } from '@mantine/notifications'; import { NotificationsProvider } from '@mantine/notifications';
@@ -30,7 +30,7 @@ export default function App(this: any, props: AppProps & { colorScheme: ColorSch
const toggleColorScheme = (value?: ColorScheme) => { const toggleColorScheme = (value?: ColorScheme) => {
const nextColorScheme = value || (colorScheme === 'dark' ? 'light' : 'dark'); const nextColorScheme = value || (colorScheme === 'dark' ? 'light' : 'dark');
setColorScheme(nextColorScheme); setColorScheme(nextColorScheme);
setCookies('color-scheme', nextColorScheme, { maxAge: 60 * 60 * 24 * 30 }); setCookie('color-scheme', nextColorScheme, { maxAge: 60 * 60 * 24 * 30 });
}; };
useHotkeys([['mod+J', () => toggleColorScheme()]]); useHotkeys([['mod+J', () => toggleColorScheme()]]);

View File

@@ -1,4 +1,4 @@
import { getCookie, setCookies } from 'cookies-next'; import { getCookie, setCookie } from 'cookies-next';
import { GetServerSidePropsContext } from 'next'; import { GetServerSidePropsContext } from 'next';
import { useEffect } from 'react'; import { useEffect } from 'react';
import AppShelf from '../components/AppShelf/AppShelf'; import AppShelf from '../components/AppShelf/AppShelf';
@@ -16,7 +16,7 @@ export async function getServerSideProps({
}: GetServerSidePropsContext): Promise<{ props: { config: Config } }> { }: GetServerSidePropsContext): Promise<{ props: { config: Config } }> {
let cookie = getCookie('config-name', { req, res }); let cookie = getCookie('config-name', { req, res });
if (!cookie) { if (!cookie) {
setCookies('config-name', 'default', { setCookie('config-name', 'default', {
req, req,
res, res,
maxAge: 60 * 60 * 24 * 30, maxAge: 60 * 60 * 24 * 30,

View File

@@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { PasswordInput, Anchor, Paper, Title, Text, Container, Group, Button } from '@mantine/core'; import { PasswordInput, Anchor, Paper, Title, Text, Container, Group, Button } from '@mantine/core';
import { setCookies } from 'cookies-next'; import { setCookie } from 'cookies-next';
import { useForm } from '@mantine/hooks'; import { useForm } from '@mantine/hooks';
import { showNotification, updateNotification } from '@mantine/notifications'; import { showNotification, updateNotification } from '@mantine/notifications';
import axios from 'axios'; import axios from 'axios';
@@ -53,7 +53,7 @@ export default function AuthenticationTitle() {
> >
<form <form
onSubmit={form.onSubmit((values) => { onSubmit={form.onSubmit((values) => {
setCookies('password', values.password, { setCookie('password', values.password, {
maxAge: 60 * 60 * 24 * 30, maxAge: 60 * 60 * 24 * 30,
sameSite: 'lax', sameSite: 'lax',
}); });