Skip to content

Commit

Permalink
[SOK-16]
Browse files Browse the repository at this point in the history
*fix lint error
*add types from yandex api for user
  • Loading branch information
gloginov committed Sep 27, 2024
1 parent 1597380 commit 442c996
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions packages/client/src/app/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

// const appContent = 'Вот тут будет жить ваше приложение :)'

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore @typescript-eslint/ban-ts-comment
global.fetch = jest.fn(() =>
Promise.resolve({ json: () => Promise.resolve('hey') })
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/components/ui/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const Button = (props: {
className?: string | undefined
useFixWidth?: boolean | undefined
href?: string | undefined
/* eslint-disable @typescript-eslint/no-explicit-any */
onClick?: (() => Promise<void>) | (() => any) | undefined
}) => {
const { text, className, useFixWidth = false, href = '/', onClick } = props
Expand Down
31 changes: 18 additions & 13 deletions packages/client/src/store/reducers/user-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,28 @@ export const getUser = () => async (dispatch: AppDispatch) => {
method: 'get',
url: `${import.meta.env.VITE_AUTH_URL}/auth/user`,
})
.then((data: any) => {
.then((data: { data: UserType }) => {
if (data) {
dispatch(actions.setUser(data.data))
}
})
.catch(() => {})
.catch((error) => {
console.error(error)
})
}

export const logoutUser = () => async (dispatch: AppDispatch) => {
await backendApi({
method: 'post',
url: `${import.meta.env.VITE_AUTH_URL}/auth/logout`,
})
.then((data: any) => {
if (data) {
dispatch(actions.setUser(null))

window.location.href = '/'
}
.then(() => {
dispatch(actions.setUser(null))
window.location.href = '/'
})
.catch((error) => {
console.error(error)
})
.catch(() => {})
}

export const signInUser =
Expand All @@ -78,7 +79,9 @@ export const signInUser =
}
}
})
.catch(() => {})
.catch((error) => {
console.error(error)
})
}

export const signUpUser =
Expand All @@ -88,13 +91,15 @@ export const signUpUser =
url: `${import.meta.env.VITE_AUTH_URL}/auth/signup`,
data: form,
})
.then(data => {
.then((data: { data: UserType }) => {
if (data) {
dispatch(actions.setUser(data))
dispatch(actions.setUser(data.data))
dispatch(getUser())
}
})
.catch(() => {})
.catch((error) => {
console.error(error)
})
}

export type ActionsType = InferAppActions<typeof actions>
Expand Down

0 comments on commit 442c996

Please sign in to comment.