remove Role entity and set language to pt-BR
This commit is contained in:
@@ -11,6 +11,7 @@ import { classNames } from '../../utils';
|
||||
import { DashboardRoutePaths, QuestionRoutePaths, SessionRoutePaths } from '../../routes'
|
||||
import { turnOff } from '../../services/store/unsavedChanges';
|
||||
import { CurrentUserAvatar } from "../CurrentUserAvatar";
|
||||
import { localFetch } from '../../utils/localFetch';
|
||||
|
||||
const UserMenu: FC = () => {
|
||||
const { user } = useCurrentUser();
|
||||
@@ -21,8 +22,14 @@ const UserMenu: FC = () => {
|
||||
|
||||
const doLogout = () => {
|
||||
setConfirmLogout(false)
|
||||
|
||||
dispatch(turnOff())
|
||||
history.push('/')
|
||||
|
||||
localFetch('/users/sign_out', {
|
||||
method: 'DELETE'
|
||||
}).then(() => {
|
||||
window.location.href = '/'
|
||||
})
|
||||
}
|
||||
|
||||
const handleLogout = () => {
|
||||
|
||||
24
app/javascript/utils/localFetch.ts
Normal file
24
app/javascript/utils/localFetch.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
type LocalFetch = typeof fetch
|
||||
|
||||
export const localFetch: LocalFetch = (input, init) => {
|
||||
const { headers, ...rest } = init ?? {}
|
||||
|
||||
const crfsToken = document
|
||||
.querySelector("[name='csrf-token']")
|
||||
?.getAttribute('content')
|
||||
|
||||
if (!crfsToken) {
|
||||
throw new Error('CSRF token not found')
|
||||
}
|
||||
|
||||
const customInt: RequestInit = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-Token': crfsToken,
|
||||
...(headers ?? {}),
|
||||
},
|
||||
...rest,
|
||||
}
|
||||
|
||||
return fetch(input, customInt)
|
||||
}
|
||||
Reference in New Issue
Block a user