mirror of
https://github.com/LucasVbr/meeting-app.git
synced 2026-07-09 15:08:06 +00:00
refactor: Set default colorScheme to purple
Took 1 hour 12 minutes
This commit is contained in:
+2
-1
@@ -3,6 +3,7 @@ import type { AppProps } from "next/app";
|
||||
import { ChakraProvider } from "@chakra-ui/react";
|
||||
import { SessionProvider } from "next-auth/react";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import theme from '@/styles/theme';
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
@@ -12,7 +13,7 @@ export default function App({
|
||||
}: AppProps) {
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<ChakraProvider>
|
||||
<ChakraProvider theme={theme}>
|
||||
<SessionProvider session={session}>
|
||||
<Component {...pageProps} />
|
||||
</SessionProvider>
|
||||
|
||||
@@ -1,95 +1,83 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Flex,
|
||||
FormControl,
|
||||
FormErrorMessage,
|
||||
FormLabel,
|
||||
Input,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useRouter } from "next/router";
|
||||
import { useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
} from '@chakra-ui/react';
|
||||
import {useSession} from 'next-auth/react';
|
||||
import {useRouter} from 'next/router';
|
||||
import {useState} from 'react';
|
||||
import {useForm} from 'react-hook-form';
|
||||
import LoadingPage from '@/components/LoadingPage';
|
||||
import {Session} from '@/models/auth/Session';
|
||||
|
||||
export default function settings() {
|
||||
const router = useRouter();
|
||||
const toast = useToast({ position: "top", isClosable: true });
|
||||
const toast = useToast({position: 'top', isClosable: true});
|
||||
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
register,
|
||||
formState: { errors, isSubmitting },
|
||||
formState: {errors, isSubmitting},
|
||||
} = useForm();
|
||||
|
||||
const [userData, setUserData] = useState({});
|
||||
const {data: session, status} = useSession({required: true});
|
||||
|
||||
const { data: session, status } = useSession();
|
||||
if (status === "unauthenticated") router.push("/login");
|
||||
if (status === "loading") return <LoadingPage/>
|
||||
if (status === 'authenticated') {
|
||||
const {user} = session as unknown as Session;
|
||||
|
||||
if (status === "authenticated") {
|
||||
const { user } = session as unknown as Session;
|
||||
|
||||
if (user.role !== "ADMIN") router.push("/login");
|
||||
if (user.role !== 'ADMIN') router.push('/login');
|
||||
|
||||
const savePassion = (passion: any) => {
|
||||
const options = {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify(passion),
|
||||
};
|
||||
|
||||
fetch(`/api/passions`, options)
|
||||
.then((res) => {
|
||||
setIsLoading(false);
|
||||
toast({
|
||||
title: `Passion ajoutée`,
|
||||
status: "success",
|
||||
.then(res => {
|
||||
setIsLoading(false);
|
||||
toast({
|
||||
title: `Passion ajoutée`,
|
||||
status: 'success',
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
setIsLoading(false);
|
||||
toast({
|
||||
title: `Erreur lors de l'ajout`,
|
||||
status: 'error',
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
setIsLoading(false);
|
||||
toast({
|
||||
title: `Erreur lors de l'ajout`,
|
||||
status: "error",
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
as="form"
|
||||
id="form_passion"
|
||||
width={"80%"}
|
||||
onSubmit={handleSubmit(savePassion)}
|
||||
>
|
||||
<FormControl isInvalid={errors.name}>
|
||||
<FormLabel htmlFor="passion">Passion</FormLabel>
|
||||
<Input
|
||||
id="passion"
|
||||
placeholder="passion"
|
||||
{...register("name", {
|
||||
required: "This is required",
|
||||
})}
|
||||
/>
|
||||
<FormErrorMessage>
|
||||
{errors.name && errors.name.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
<Button
|
||||
mt={4}
|
||||
colorScheme="purple"
|
||||
isLoading={isSubmitting}
|
||||
type="submit"
|
||||
>
|
||||
Submit
|
||||
</Button>
|
||||
</Box>
|
||||
</>
|
||||
<>
|
||||
<Box as="form" id="form_passion" width={'80%'}
|
||||
onSubmit={handleSubmit(savePassion)}>
|
||||
<FormControl isInvalid={errors.name as boolean | undefined}>
|
||||
<FormLabel htmlFor="passion">Passion</FormLabel>
|
||||
<Input id="passion" placeholder="passion"
|
||||
{...register('name', {
|
||||
required: 'This is required',
|
||||
})}/>
|
||||
<FormErrorMessage>
|
||||
{errors.name && errors.name.message as string}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
<Button mt={4} isLoading={isSubmitting} type="submit">
|
||||
Submit
|
||||
</Button>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ export default function ChatId() {
|
||||
<MessageList user={session.user as User} messages={messages}/>
|
||||
|
||||
<Flex gap={5} mt={5}>
|
||||
<Input type={"text"} colorScheme={'purple'} onChange={(evt) => setText(evt.target.value) } value={text} />
|
||||
<Input type={"text"} colorScheme={'purple'} onChange={evt => setText(evt.target.value)} value={text} />
|
||||
<Button colorScheme={'purple'} onClick={handleSubmit}>Envoyer</Button>
|
||||
</Flex>
|
||||
</Container>
|
||||
|
||||
Reference in New Issue
Block a user