fix(frontend): sign out errors

This commit is contained in:
leandrofars 2024-10-30 08:29:13 -03:00
parent 613501657d
commit e356716eee
2 changed files with 11 additions and 14 deletions

View File

@ -211,6 +211,8 @@ export const AuthProvider = (props) => {
}; };
const signOut = () => { const signOut = () => {
router.push("/auth/login")
localStorage.removeItem("token")
dispatch({ dispatch({
type: HANDLERS.SIGN_OUT type: HANDLERS.SIGN_OUT
}); });

View File

@ -172,8 +172,7 @@ const Page = () => {
} }
const getDeviceProtocol = (order) => { const getDeviceProtocol = (order) => {
console.log("order:", order) if (order.Cwmp != null) {
if (order.Cwmp == 2) {
return "cwmp" return "cwmp"
} else { } else {
return "usp" return "usp"
@ -204,15 +203,10 @@ const Page = () => {
useEffect(() => { useEffect(() => {
getColumns() getColumns()
setLoading(true) setLoading(true)
if (auth.user.token) {
console.log("auth.user.token =", auth.user.token)
} else {
auth.user.token = localStorage.getItem("token")
}
var myHeaders = new Headers(); var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json"); myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", auth.user.token); myHeaders.append("Authorization", localStorage.getItem("token"));
var requestOptions = { var requestOptions = {
method: 'GET', method: 'GET',
@ -293,8 +287,9 @@ const Page = () => {
console.log("set alias result:", content) console.log("set alias result:", content)
setShowSetDeviceAlias(false) setShowSetDeviceAlias(false)
setDeviceAlias(null) setDeviceAlias(null)
orders[deviceToBeChanged].Alias = alias devices[deviceToBeChanged].Alias = alias
setDeviceToBeChanged(null) setDeviceToBeChanged(null)
setDevices([...devices])
} }
// .then(response => { // .then(response => {
// if (response.status === 401) { // if (response.status === 401) {
@ -415,7 +410,7 @@ const Page = () => {
<> <>
<Head> <Head>
<title> <title>
Oktopus | TR-369 Oktopus | Controller
</title> </title>
</Head> </Head>
@ -651,7 +646,7 @@ const Page = () => {
</SvgIcon> </SvgIcon>
</Button> </Button>
</Tooltip>} </Tooltip>}
{/* <Tooltip title="Edit the device alias"> <Tooltip title="Edit the device alias">
<Button <Button
onClick={()=>{ onClick={()=>{
setDeviceToBeChanged(index) setDeviceToBeChanged(index)
@ -667,7 +662,7 @@ const Page = () => {
</SvgIcon> </SvgIcon>
</Button> </Button>
</Tooltip> </Tooltip>
<Tooltip title="Edit device labels"> {/* <Tooltip title="Edit device labels">
<Button <Button
onClick={()=>{ onClick={()=>{
setDeviceToBeChanged(index) setDeviceToBeChanged(index)
@ -724,7 +719,7 @@ const Page = () => {
<Input value={deviceAlias} onChange={(e) => { setDeviceAlias(e.target.value) }} <Input value={deviceAlias} onChange={(e) => { setDeviceAlias(e.target.value) }}
onKeyUp={e => { onKeyUp={e => {
if (e.key === 'Enter') { if (e.key === 'Enter') {
setNewDeviceAlias(deviceAlias, orders[deviceToBeChanged].SN) setNewDeviceAlias(deviceAlias, devices[deviceToBeChanged].SN)
} }
}}> }}>
</Input> </Input>
@ -736,7 +731,7 @@ const Page = () => {
setDeviceToBeChanged(null) setDeviceToBeChanged(null)
}}>Cancel</Button> }}>Cancel</Button>
<Button onClick={() => { <Button onClick={() => {
setNewDeviceAlias(deviceAlias, orders[deviceToBeChanged].SN) setNewDeviceAlias(deviceAlias, devices[deviceToBeChanged].SN)
}}>Save</Button> }}>Save</Button>
</DialogActions> </DialogActions>
</Dialog>} </Dialog>}