Подключил шрифты

This commit is contained in:
2023-01-09 20:53:23 +03:00
parent 4c636c424a
commit c4d44e3855
28 changed files with 305 additions and 292 deletions

View File

@ -1,23 +1,23 @@
import { withAuthRedirect } from './authRedirect'
export const fetchForm = withAuthRedirect(async (link, info) => {
try {
const response = await fetch(link, {
method: 'POST',
headers: {
// 'Access-Control-Request-Headers': 'authorization',
Authorization: `Bearer ${localStorage.getItem('auth_token')}`,
Origin: `${process.env.REACT_APP_BASE_URL}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(info)
})
return response
} catch (error) {
console.log('Query error', error)
}
})
// export const fetchForm = withAuthRedirect(async (link, info) => {
// try {
// const response = await fetch(link, {
// method: 'POST',
// headers: {
// // 'Access-Control-Request-Headers': 'authorization',
// Authorization: `Bearer ${localStorage.getItem('auth_token')}`,
// Origin: `${process.env.REACT_APP_BASE_URL}`,
// 'Content-Type': 'application/json'
// },
// body: JSON.stringify(info)
// });
//
// return response
// } catch (error) {
// console.log('Query error', error)
// }
// });
export const fetchAuth = async ({
username,
@ -25,7 +25,7 @@ export const fetchAuth = async ({
dispatch,
catchError
}) => {
const apiURL = process.env.REACT_APP_API_URL
const apiURL = process.env.REACT_APP_API_URL;
try {
const response = await fetch(`${apiURL}/api/user/login`, {
method: 'POST',
@ -39,27 +39,27 @@ export const fetchAuth = async ({
username,
password
})
})
});
if (!response.ok) {
catchError()
catchError();
return response.statusText
}
response.json().then((resJSON) => {
localStorage.setItem('auth_token', resJSON.access_token)
localStorage.setItem('id', resJSON.id)
localStorage.setItem('cardId', resJSON.card_id)
localStorage.setItem('auth_token', resJSON.access_token);
localStorage.setItem('id', resJSON.id);
localStorage.setItem('cardId', resJSON.card_id);
localStorage.setItem(
'access_token_expired_at',
resJSON.access_token_expired_at
)
);
dispatch(resJSON)
})
} catch (error) {
console.error('Error occured: ', error)
}
}
};
export const fetchReportList = withAuthRedirect(async (link) => {
try {
@ -72,14 +72,14 @@ export const fetchReportList = withAuthRedirect(async (link) => {
Authorization: `Bearer ${localStorage.getItem('auth_token')}`
}
}
)
let data = await response.json()
);
let data = await response.json();
return data
} catch (error) {
console.log('Query error', error)
}
})
});
export const fetchGet = withAuthRedirect(async (link) => {
try {
@ -88,17 +88,17 @@ export const fetchGet = withAuthRedirect(async (link) => {
headers: {
Authorization: `Bearer ${localStorage.getItem('auth_token')}`
}
})
let data = await response.json()
});
let data = await response.json();
return data
} catch (error) {
console.log('Query error', error)
}
})
});
export const fetchPost = withAuthRedirect(async (link, body) => {
console.log('i', body)
console.log('i', body);
try {
const response = await fetch(link, {
method: 'POST',
@ -109,10 +109,10 @@ export const fetchPost = withAuthRedirect(async (link, body) => {
Origin: `${process.env.REACT_APP_BASE_URL}`
},
body: JSON.stringify(body)
})
});
return response
} catch (error) {
console.log('Query error', error)
}
})
});