some-inbox-auth-fixes
This commit is contained in:
parent
8b230d2a03
commit
a5ef0ed60b
|
@ -1,8 +1,8 @@
|
|||
import { gql } from '@urql/core'
|
||||
|
||||
export default gql`
|
||||
mutation RegisterMutation($email: String!, $password: String!) {
|
||||
registerUser(email: $email, password: $password) {
|
||||
mutation RegisterMutation($email: String!, $password: String, $username: String) {
|
||||
registerUser(email: $email, password: $password, username: $username) {
|
||||
error
|
||||
token
|
||||
user {
|
||||
|
|
|
@ -2,8 +2,8 @@ import { ClientOptions, dedupExchange, fetchExchange, createClient, Exchange } f
|
|||
import { devtoolsExchange } from '@urql/devtools'
|
||||
import { isDev } from '../utils/config'
|
||||
|
||||
export const baseUrl = 'https://newapi.discours.io'
|
||||
//export const baseUrl = 'http://localhost:8000'
|
||||
//export const baseUrl = 'https://newapi.discours.io'
|
||||
export const baseUrl = 'http://localhost:8000'
|
||||
|
||||
const exchanges: Exchange[] = [dedupExchange, fetchExchange]
|
||||
|
||||
|
|
23
src/graphql/query/my-chats.ts
Normal file
23
src/graphql/query/my-chats.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { gql } from '@urql/core'
|
||||
|
||||
export default gql`
|
||||
query GetChatsQuery {
|
||||
myChats {
|
||||
messages {
|
||||
chatId
|
||||
id
|
||||
author
|
||||
body
|
||||
replyTo
|
||||
createdAt
|
||||
}
|
||||
users {
|
||||
slug
|
||||
name
|
||||
pic
|
||||
}
|
||||
title
|
||||
createdAt
|
||||
}
|
||||
}
|
||||
`
|
|
@ -242,6 +242,7 @@ export type MutationRateUserArgs = {
|
|||
export type MutationRegisterUserArgs = {
|
||||
email: Scalars['String']
|
||||
password?: InputMaybe<Scalars['String']>
|
||||
username?: InputMaybe<Scalars['String']>
|
||||
}
|
||||
|
||||
export type MutationRemoveAuthorArgs = {
|
||||
|
@ -475,7 +476,7 @@ export type QueryShoutsForFeedArgs = {
|
|||
offset: Scalars['Int']
|
||||
}
|
||||
|
||||
export type QuerySignInArgs = {
|
||||
export type MutationSignInArgs = {
|
||||
email: Scalars['String']
|
||||
password?: InputMaybe<Scalars['String']>
|
||||
}
|
||||
|
|
|
@ -4,9 +4,8 @@ import Zine from '../layouts/zine.astro'
|
|||
import { apiClient } from '../utils/apiClient'
|
||||
import { initRouter } from '../stores/router'
|
||||
|
||||
const slug = Astro.params.slug?.toString() || ''
|
||||
|
||||
if (slug.includes('/') || slug.includes('.map')) {
|
||||
const slug = Astro.params.slug?.toString()
|
||||
if (Boolean(slug) === false || slug.includes('/') || slug.includes('.map')) {
|
||||
return Astro.redirect('/404')
|
||||
}
|
||||
|
||||
|
|
15
src/pages/inbox.astro
Normal file
15
src/pages/inbox.astro
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
import Zine from '../layouts/zine.astro'
|
||||
import { Root } from '../components/Root'
|
||||
import { apiClient } from '../utils/apiClient'
|
||||
import { initRouter } from '../stores/router'
|
||||
|
||||
const chatrooms = await apiClient.getInboxes()
|
||||
|
||||
const { pathname, search } = Astro.url
|
||||
initRouter(pathname, search)
|
||||
---
|
||||
|
||||
<Zine>
|
||||
<Root client:load />
|
||||
</Zine>
|
|
@ -1,13 +0,0 @@
|
|||
---
|
||||
import InboxPage from '../components/Views/Inbox'
|
||||
import About from '../layouts/about.astro'
|
||||
|
||||
import { initRouter } from '../../stores/router'
|
||||
|
||||
const { pathname, search } = Astro.url
|
||||
initRouter(pathname, search)
|
||||
---
|
||||
|
||||
<About>
|
||||
<InboxPage client:load />
|
||||
</About>
|
|
@ -30,6 +30,7 @@ import reactionDestroy from '../graphql/mutation/reaction-destroy'
|
|||
import reactionUpdate from '../graphql/mutation/reaction-update'
|
||||
import authorsBySlugs from '../graphql/query/authors-by-slugs'
|
||||
import incrementView from '../graphql/mutation/increment-view'
|
||||
import myChats from '../graphql/query/my-chats'
|
||||
|
||||
const log = getLogger('api-client')
|
||||
|
||||
|
@ -69,9 +70,9 @@ export const apiClient = {
|
|||
|
||||
return response.data.signIn
|
||||
},
|
||||
authRegister: async ({ email, password }): Promise<AuthResult> => {
|
||||
authRegister: async ({ email, password = '', username = '' }): Promise<AuthResult> => {
|
||||
const response = await publicGraphQLClient
|
||||
.mutation(authRegisterMutation, { email, password })
|
||||
.mutation(authRegisterMutation, { email, password, username })
|
||||
.toPromise()
|
||||
return response.data.registerUser
|
||||
},
|
||||
|
@ -224,7 +225,7 @@ export const apiClient = {
|
|||
},
|
||||
|
||||
getAllAuthors: async () => {
|
||||
const response = await publicGraphQLClient.query(authorsAll, { limit: 9999, offset: 9999 }).toPromise()
|
||||
const response = await publicGraphQLClient.query(authorsAll, {}).toPromise()
|
||||
return response.data.authorsAll
|
||||
},
|
||||
getArticle: async ({ slug }: { slug: string }): Promise<Shout> => {
|
||||
|
@ -293,5 +294,8 @@ export const apiClient = {
|
|||
},
|
||||
incrementView: async ({ articleSlug }) => {
|
||||
await privateGraphQLClient.mutation(incrementView, { shout: articleSlug })
|
||||
},
|
||||
getInboxes: async (payload = {}) => {
|
||||
await privateGraphQLClient.query(myChats, payload)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user