浏览代码

force to english for admin login

master
jason.lam 1年前
父节点
当前提交
328778554b
共有 3 个文件被更改,包括 23 次插入21 次删除
  1. +12
    -19
      src/components/FiDataGrid.js
  2. +3
    -1
      src/pages/authentication/auth-forms/AuthLogin.js
  3. +8
    -1
      src/pages/authentication/auth-forms/AuthLoginCustom.js

+ 12
- 19
src/components/FiDataGrid.js 查看文件

@@ -4,7 +4,7 @@ import {
DataGrid, GridOverlay,
} from "@mui/x-data-grid";
import {FormattedMessage, useIntl} from "react-intl";
import {Typography} from '@mui/material';
import {TablePagination, Typography} from '@mui/material';

// ==============================|| EVENT TABLE ||============================== //

@@ -124,27 +124,12 @@ export function FiDataGrid({ rows, columns, sx, autoHeight,
return (
<GridOverlay>
<Typography variant="body1">
<FormattedMessage id="rowsPerPage" />
<FormattedMessage id="noRecordFound" />
</Typography>
</GridOverlay>
);
}

const CustomPagination = (props) => {
const { pagination } = props;
const { page, pageSize, rowCount } = pagination;

const startIndex = page * pageSize + 1;
const endIndex = Math.min((page + 1) * pageSize, rowCount);

return (
<div>
<div>{`${startIndex}-${endIndex} YES ${rowCount}`}</div>
{/* Render other pagination controls */}
</div>
);
};

return (
<DataGrid
{...props}
@@ -164,11 +149,19 @@ export function FiDataGrid({ rows, columns, sx, autoHeight,
)
}}
components={{
Pagination: CustomPagination,
Pagination: () => (
<TablePagination
labelDisplayedRows={
({ from, to, count }) => {
return '' + from + '-' + to + ' 123 ' + count
}
}
/>
),
}}
componentsProps={{
pagination: {
labelRowsPerPage: intl.formatMessage({id: 'rowsPerPage'}),
labelRowsPerPage: intl.formatMessage({id: 'rowsPerPage'}) + ":",
}
}}
/>


+ 3
- 1
src/pages/authentication/auth-forms/AuthLogin.js 查看文件

@@ -1,4 +1,4 @@
import React, {useEffect, useState} from 'react';
import React, {useContext, useEffect, useState} from 'react';
import {useNavigate} from 'react-router-dom';

// material-ui
@@ -36,6 +36,7 @@ import {useDispatch} from "react-redux";
import {handleLogin} from "auth/index";
import { notifyActionSuccess } from 'utils/CommonFunction';
import {FormattedMessage} from "react-intl";
import LocaleContext from "../../../components/I18nProvider";
// ============================|| FIREBASE - LOGIN ||============================ //

const AuthLogin = () => {
@@ -69,6 +70,7 @@ const AuthLogin = () => {
})
.then((response) => {
//setPosts("12354")
console.log(response.data);
setPosts(response.data);
const userData = {
id: response.data.id,


+ 8
- 1
src/pages/authentication/auth-forms/AuthLoginCustom.js 查看文件

@@ -1,7 +1,7 @@
import React, {
useEffect,
useState,
lazy
lazy, useContext
} from 'react';
import { Link as RouterLink } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
@@ -45,12 +45,14 @@ import { handleLogin } from "auth/index";
import useJwt from "../../../auth/jwt/useJwt";
import { handleLogoutFunction } from 'auth/index';
import {FormattedMessage, useIntl} from "react-intl";
import LocaleContext from "../../../components/I18nProvider";
// ============================|| FIREBASE - LOGIN ||============================ //

const AuthLoginCustom = () => {
const dispatch = useDispatch()
const navigate = useNavigate()
const intl = useIntl();
const { setLocale } = useContext(LocaleContext);

const [showPassword, setShowPassword] = useState(false);
const handleClickShowPassword = () => {
@@ -88,6 +90,11 @@ const AuthLoginCustom = () => {
}
const data = { ...userData, accessToken: response.data.accessToken, refreshToken: response.data.refreshToken }
// setSuccess(true)
console.log(response.data.role);
if(response.data.type === "GLD"){
setLocale("en");
localStorage.setItem('locale','en');
}
dispatch(handleLogin(data))
navigate('/dashboard');
location.reload()


正在加载...
取消
保存