diff --git a/.env.development b/.env.development
index 01556f5..78c9e3b 100644
--- a/.env.development
+++ b/.env.development
@@ -4,7 +4,8 @@ GENERATE_SOURCEMAP=false
# VITE_APP_API_URL=
# VITE_APP_API_URL=http://127.0.0.1:4003/apitest
-VITE_APP_API_URL=https://tpay.shiblysolution.id/api
+# VITE_APP_API_URL=https://tpay.shiblysolution.id/api
+VITE_APP_API_URL=http://127.0.0.1:7001/api
# VITE_APP_API_URL=http://api-v2.tpay.tl/api
# VITE_APP_URL_TRANSACTION=https://tpay.shiblysolution.id/test/x/api
# VITE_APP_API_URL=http://127.0.0.1:4003/apitesting
diff --git a/.env.staging b/.env.staging
index e02ae19..1df5cec 100644
--- a/.env.staging
+++ b/.env.staging
@@ -2,7 +2,7 @@ VITE_APP_NAME=tpay-dashboard-tl
VITE_APP_VERSION=1=9.1.1
GENERATE_SOURCEMAP=false
-VITE_APP_API_URL=https://tpay.shiblysolution.id/api
+VITE_APP_API_URL=http://127.0.0.1:7001/api
# VITE_APP_API_URL=http://api-v2.tpay.tl/api
VITE_BASE_URL=/dashboard/
VITE_ENV=staging
\ No newline at end of file
diff --git a/src/auth/_helpers.ts b/src/auth/_helpers.ts
index ecb6bf9..916d562 100644
--- a/src/auth/_helpers.ts
+++ b/src/auth/_helpers.ts
@@ -41,9 +41,9 @@ export function setupAxios(axios: any) {
(config: { headers: { Authorization: string }; params?: any; url?: any; httpsAgent: any }) => {
const auth = getAuth();
- // if (auth?.access_token) {
- // config.headers.Authorization = `Bearer ${auth.access_token}`;
- // }
+ if (auth?.access_token) {
+ config.headers.Authorization = `Bearer ${auth.access_token}`;
+ }
return config;
},
async (err: any) => await Promise.reject(err)
diff --git a/src/auth/pages/jwt/Login.tsx b/src/auth/pages/jwt/Login.tsx
index cb4e002..9374ec6 100644
--- a/src/auth/pages/jwt/Login.tsx
+++ b/src/auth/pages/jwt/Login.tsx
@@ -1,33 +1,33 @@
import { type MouseEvent, useState } from 'react';
-import { useLocation, useNavigate } from 'react-router-dom';
+import { Link, useLocation, useNavigate } from 'react-router-dom';
import clsx from 'clsx';
import * as Yup from 'yup';
import { useFormik } from 'formik';
import { KeenIcon } from '@/components';
-import { Alert } from '@/components';
+import { toAbsoluteUrl } from '@/utils';
import { useAuthContext } from '@/auth';
+import { useLayout } from '@/providers';
+import { Alert } from '@/components';
import moment from 'moment';
import { Helmet } from 'react-helmet';
-// ---------------------------------------------------------------------------
-// Hardcoded credentials (no API call). The actual session (auth/currentUser)
-// is still set through AuthContext's login(), which — while its provider is
-// in DUMMY_MODE — stores a local dummy session instead of hitting the API.
-// ---------------------------------------------------------------------------
-const HARDCODED_USERNAME = 'admin';
-const HARDCODED_PASSWORD = 'admin';
-
const loginSchema = Yup.object().shape({
username: Yup.string().required('Username is required'),
password: Yup.string()
.min(3, 'Minimum 3 symbols')
.max(50, 'Maximum 50 symbols')
- .required('Password is required')
+ .required('Password is required'),
+ token: Yup.string(),
+ // .max(3, 'Maximum 6 code'),
+ // .required('Token is required'),
+ remember: Yup.boolean()
});
const initialValues = {
username: '',
- password: ''
+ password: '',
+ token: '',
+ remember: false
};
const Login = () => {
@@ -35,33 +35,36 @@ const Login = () => {
const { login } = useAuthContext();
const navigate = useNavigate();
const location = useLocation();
- const from = (location.state as any)?.from?.pathname || '/';
+ const from = location.state?.from?.pathname || '/';
const [showPassword, setShowPassword] = useState(false);
+ const { currentLayout } = useLayout();
const formik = useFormik({
initialValues,
validationSchema: loginSchema,
onSubmit: async (values, { setStatus, setSubmitting }) => {
setLoading(true);
- setStatus(undefined);
-
- if (values.username !== HARDCODED_USERNAME || values.password !== HARDCODED_PASSWORD) {
- setStatus('Incorrect username or password. Please try again.');
- setSubmitting(false);
- setLoading(false);
- return;
- }
try {
- if (!login) throw new Error('AuthProvider is required for this form.');
- await login(values.username, values.password);
+ if (!login) throw new Error('JWTProvider is required for this form.');
+ await login(values.username, values.password, values.token);
+
+ if (values.remember) {
+ localStorage.setItem('username', values.username);
+ } else {
+ localStorage.removeItem('username');
+ }
+
navigate(from, { replace: true });
- } catch (error) {
- console.error('Login error:', error);
- setStatus('Something went wrong while signing in. Please try again.');
+ } catch (error: any) {
+ if (error.response && error.response.data) {
+ setStatus(error.response.data.message);
+ } else {
+ setStatus('The login details are incorrect');
+ }
+
setSubmitting(false);
}
-
setLoading(false);
}
});
@@ -80,10 +83,14 @@ const Login = () => {
return (
<>
- REVENUE | Sign In
+ TPAY | Sign In
+