What's new

Help ask lang

1713924455944.png


ayaw

pag inlogin ko sa pc ko yung ibang account nagana pero pag sa ibang pc ayaw
 

Attachments

Last edited:
<Formik
initialValues={{ email: '', password: '' }}
validationSchema={LoginSchema}
onSubmit={onHandleFormSubmit}

useEffect(() => {
if (loginSWR && loginSWR.data) {
authStore.setAccessToken(loginSWR.data.accessToken);
authStore.setUserProfile(loginSWR.data.userProfile);
router.reload();
}
}, [loginSWR.data]);

pa overwrite ako nung formik at usereffect mo
 
initialValues={{ email: '', password: '' }}

tapos sa useeffect

if (loginSWR && loginSWR.data) {

ahh ganto boss.

copy paste mo nalalng tong buo. kung d mo padin ma gets ahaha

import { useRouter } from "next/router";
import {
Alert,
Box,
Button,
FormControl,
FormErrorMessage,
FormLabel,
Input,
} from "chakra-ui/react";
import { Field, Form, Formik } from "formik";
import { useEffect, useState } from "react";
import AuthService from "@/services/auth-service";
import MiscellaneousService from "@/services/miscellaneous-service";
import useApi from "@/hooks/useApi";
import useAuthStore from "@/hooks/useAuth";
import { LoginData, LoginSchema } from "@/util/ValidationSchemas";
export const Login = () => {
const [error, seterror] = useState("");
const [isLogging, setisLogging] = useState(false);
const router = useRouter();
const loginSWR = useApi(null);
const authStore = useAuthStore();
useEffect(() => {
if (loginSWR && loginSWR.data) {
authStore.setAccessToken(loginSWR.data.accessToken);
authStore.setUserProfile(loginSWR.data.userProfile);
router.reload();
}
}, [loginSWR.data]);
const onHandleFormSubmit = async (values) => {
seterror("");
setisLogging(true);
try {
await loginSWR.mutateServer(AuthService.login(values));
} catch (error) {
seterror(error.message);
}
setisLogging(false);
};
return (
<Box
w={["full", "md"]}
p={[8, 10]}
mt={[10]}
mx="auto"
background="secondary"
borderRadius={10}
boxShadow="md"
<Formik
initialValues={{ email: '', password: '' }}
validationSchema={LoginSchema}
onSubmit={onHandleFormSubmit}
{({ errors, touched }) => (
<Form>
{error && (
<Alert status="error" variant="left-accent" mb={2} fontSize="sm">
{error}
</Alert>
)}
<FormControl isInvalid={errors.email && touched.email}>
<FormLabel>Email</FormLabel>
<Field as={Input} name="email" type="email" />
<FormErrorMessage>{errors.email}</FormErrorMessage>
</FormControl>
<FormControl mt={4} isInvalid={errors.password && touched.password}>
<FormLabel>Password</FormLabel>
<Field as={Input} name="password" type="password" />
<FormErrorMessage>{errors.password}</FormErrorMessage>
</FormControl>
<Button
colorScheme="blue"
w="full"
mt={10}
type="submit"
isLoading={isLogging}
loadingText="Logging In"
Login
</Button>
</Form>
)}
</Formik>
</Box>
);
};
 
initialValues={{ email: '', password: '' }}

tapos sa useeffect

if (loginSWR && loginSWR.data) {

ahh ganto boss.

copy paste mo nalalng tong buo. kung d mo padin ma gets ahaha

import { useRouter } from "next/router";
import {
Alert,
Box,
Button,
FormControl,
FormErrorMessage,
FormLabel,
Input,
} from "chakra-ui/react";
import { Field, Form, Formik } from "formik";
import { useEffect, useState } from "react";
import AuthService from "@/services/auth-service";
import MiscellaneousService from "@/services/miscellaneous-service";
import useApi from "@/hooks/useApi";
import useAuthStore from "@/hooks/useAuth";
import { LoginData, LoginSchema } from "@/util/ValidationSchemas";
export const Login = () => {
const [error, seterror] = useState("");
const [isLogging, setisLogging] = useState(false);
const router = useRouter();
const loginSWR = useApi(null);
const authStore = useAuthStore();
useEffect(() => {
if (loginSWR && loginSWR.data) {
authStore.setAccessToken(loginSWR.data.accessToken);
authStore.setUserProfile(loginSWR.data.userProfile);
router.reload();
}
}, [loginSWR.data]);
const onHandleFormSubmit = async (values) => {
seterror("");
setisLogging(true);
try {
await loginSWR.mutateServer(AuthService.login(values));
} catch (error) {
seterror(error.message);
}
setisLogging(false);
};
return (
<Box
w={["full", "md"]}
p={[8, 10]}
mt={[10]}
mx="auto"
background="secondary"
borderRadius={10}
boxShadow="md"

<Formik
initialValues={{ email: '', password: '' }}
validationSchema={LoginSchema}
onSubmit={onHandleFormSubmit}

{({ errors, touched }) => (
<Form>
{error && (
<Alert status="error" variant="left-accent" mb={2} fontSize="sm">
{error}
</Alert>
)}
<FormControl isInvalid={errors.email && touched.email}>
<FormLabel>Email</FormLabel>
<Field as={Input} name="email" type="email" />
<FormErrorMessage>{errors.email}</FormErrorMessage>
</FormControl>
<FormControl mt={4} isInvalid={errors.password && touched.password}>
<FormLabel>Password</FormLabel>
<Field as={Input} name="password" type="password" />
<FormErrorMessage>{errors.password}</FormErrorMessage>
</FormControl>
<Button
colorScheme="blue"
w="full"
mt={10}
type="submit"
isLoading={isLogging}
loadingText="Logging In"

Login
</Button>
</Form>
)}
</Formik>
</Box>
);
};

ito po paayos hehehe para sure

yung indention kasi ayaw

ganun parin
 

Attachments

Last edited:

Similar threads

Users search this thread by keywords

  1. ticketing system
  2. IT ticketing system
  3. VNC
  4. Ticket
  5. local host
  6. capstone
Back
Top