changelog-restored+internal-auth-fix
All checks were successful
Deploy on push / deploy (push) Successful in 6s
All checks were successful
Deploy on push / deploy (push) Successful in 6s
This commit is contained in:
@@ -66,9 +66,15 @@ export async function query<T = unknown>(
|
||||
console.log(`[GraphQL] Making request to ${endpoint}`)
|
||||
console.log(`[GraphQL] Query: ${query.substring(0, 100)}...`)
|
||||
|
||||
// Используем существующую функцию для получения всех необходимых заголовков
|
||||
const headers = getRequestHeaders()
|
||||
console.log(
|
||||
`[GraphQL] Заголовки установлены, Authorization: ${headers['Authorization'] ? 'присутствует' : 'отсутствует'}`
|
||||
)
|
||||
|
||||
const response = await fetch(endpoint, {
|
||||
method: 'POST',
|
||||
headers: getRequestHeaders(),
|
||||
headers,
|
||||
credentials: 'include',
|
||||
body: JSON.stringify({
|
||||
query,
|
||||
|
@@ -132,15 +132,13 @@ const InviteEditModal: Component<InviteEditModalProps> = (props) => {
|
||||
<input
|
||||
type="number"
|
||||
value={formData().inviter_id}
|
||||
onInput={(e) => updateField('inviter_id', parseInt(e.target.value) || 0)}
|
||||
onInput={(e) => updateField('inviter_id', Number.parseInt(e.target.value) || 0)}
|
||||
class={`${formStyles.input} ${errors().inviter_id ? formStyles.inputError : ''}`}
|
||||
placeholder="1"
|
||||
required
|
||||
disabled={!isCreating()} // При редактировании ID нельзя менять
|
||||
/>
|
||||
<div class={formStyles.fieldHint}>
|
||||
ID автора, который отправляет приглашение
|
||||
</div>
|
||||
<div class={formStyles.fieldHint}>ID автора, который отправляет приглашение</div>
|
||||
{errors().inviter_id && <div class={formStyles.fieldError}>{errors().inviter_id}</div>}
|
||||
</div>
|
||||
|
||||
@@ -151,15 +149,13 @@ const InviteEditModal: Component<InviteEditModalProps> = (props) => {
|
||||
<input
|
||||
type="number"
|
||||
value={formData().author_id}
|
||||
onInput={(e) => updateField('author_id', parseInt(e.target.value) || 0)}
|
||||
onInput={(e) => updateField('author_id', Number.parseInt(e.target.value) || 0)}
|
||||
class={`${formStyles.input} ${errors().author_id ? formStyles.inputError : ''}`}
|
||||
placeholder="2"
|
||||
required
|
||||
disabled={!isCreating()} // При редактировании ID нельзя менять
|
||||
/>
|
||||
<div class={formStyles.fieldHint}>
|
||||
ID автора, которого приглашают к сотрудничеству
|
||||
</div>
|
||||
<div class={formStyles.fieldHint}>ID автора, которого приглашают к сотрудничеству</div>
|
||||
{errors().author_id && <div class={formStyles.fieldError}>{errors().author_id}</div>}
|
||||
</div>
|
||||
|
||||
@@ -170,15 +166,13 @@ const InviteEditModal: Component<InviteEditModalProps> = (props) => {
|
||||
<input
|
||||
type="number"
|
||||
value={formData().shout_id}
|
||||
onInput={(e) => updateField('shout_id', parseInt(e.target.value) || 0)}
|
||||
onInput={(e) => updateField('shout_id', Number.parseInt(e.target.value) || 0)}
|
||||
class={`${formStyles.input} ${errors().shout_id ? formStyles.inputError : ''}`}
|
||||
placeholder="123"
|
||||
required
|
||||
disabled={!isCreating()} // При редактировании ID нельзя менять
|
||||
/>
|
||||
<div class={formStyles.fieldHint}>
|
||||
ID публикации, к которой приглашают на сотрудничество
|
||||
</div>
|
||||
<div class={formStyles.fieldHint}>ID публикации, к которой приглашают на сотрудничество</div>
|
||||
{errors().shout_id && <div class={formStyles.fieldError}>{errors().shout_id}</div>}
|
||||
</div>
|
||||
|
||||
@@ -196,9 +190,7 @@ const InviteEditModal: Component<InviteEditModalProps> = (props) => {
|
||||
<option value="ACCEPTED">Принято</option>
|
||||
<option value="REJECTED">Отклонено</option>
|
||||
</select>
|
||||
<div class={formStyles.fieldHint}>
|
||||
Текущий статус приглашения
|
||||
</div>
|
||||
<div class={formStyles.fieldHint}>Текущий статус приглашения</div>
|
||||
</div>
|
||||
|
||||
{/* Информация о связанных объектах при редактировании */}
|
||||
|
@@ -10,6 +10,7 @@ import styles from '../styles/Table.module.css'
|
||||
import Button from '../ui/Button'
|
||||
import Modal from '../ui/Modal'
|
||||
import Pagination from '../ui/Pagination'
|
||||
import { getAuthTokenFromCookie } from '../utils/auth'
|
||||
|
||||
/**
|
||||
* Интерфейсы для приглашений
|
||||
@@ -74,16 +75,21 @@ const InvitesRoute: Component<InvitesRouteProps> = (props) => {
|
||||
/**
|
||||
* Загружает список приглашений с учетом фильтров и пагинации
|
||||
*/
|
||||
const loadInvites = async (page: number = 1) => {
|
||||
const loadInvites = async (page = 1) => {
|
||||
setLoading(true)
|
||||
try {
|
||||
const limit = pagination().perPage
|
||||
const offset = (page - 1) * limit
|
||||
|
||||
// Получаем токен авторизации из localStorage или cookie
|
||||
const authToken = localStorage.getItem('auth_token') || getAuthTokenFromCookie()
|
||||
console.log(`[InvitesRoute] Загрузка приглашений, токен: ${authToken ? 'найден' : 'не найден'}`)
|
||||
|
||||
const response = await fetch('/graphql', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: authToken ? `Bearer ${authToken}` : ''
|
||||
},
|
||||
body: JSON.stringify({
|
||||
query: ADMIN_GET_INVITES_QUERY,
|
||||
@@ -177,10 +183,15 @@ const InvitesRoute: Component<InvitesRouteProps> = (props) => {
|
||||
const isCreating = !editModal().invite && createModal().show
|
||||
const mutation = isCreating ? ADMIN_CREATE_INVITE_MUTATION : ADMIN_UPDATE_INVITE_MUTATION
|
||||
|
||||
// Получаем токен авторизации из localStorage или cookie
|
||||
const authToken = localStorage.getItem('auth_token') || getAuthTokenFromCookie()
|
||||
console.log(`[InvitesRoute] Сохранение приглашения, токен: ${authToken ? 'найден' : 'не найден'}`)
|
||||
|
||||
const response = await fetch('/graphql', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: authToken ? `Bearer ${authToken}` : ''
|
||||
},
|
||||
body: JSON.stringify({
|
||||
query: mutation,
|
||||
@@ -215,10 +226,15 @@ const InvitesRoute: Component<InvitesRouteProps> = (props) => {
|
||||
*/
|
||||
const deleteInvite = async (invite: Invite) => {
|
||||
try {
|
||||
// Получаем токен авторизации из localStorage или cookie
|
||||
const authToken = localStorage.getItem('auth_token') || getAuthTokenFromCookie()
|
||||
console.log(`[InvitesRoute] Удаление приглашения, токен: ${authToken ? 'найден' : 'не найден'}`)
|
||||
|
||||
const response = await fetch('/graphql', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: authToken ? `Bearer ${authToken}` : ''
|
||||
},
|
||||
body: JSON.stringify({
|
||||
query: ADMIN_DELETE_INVITE_MUTATION,
|
||||
|
Reference in New Issue
Block a user