Skip to content

Commit

Permalink
feat: disconnect when logout (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyuhho committed Mar 23, 2024
1 parent 25dec3d commit 9bd9859
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/pages/Buyer/BuyerLogout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { patchAuthSignOut } from 'api/patch';
import { BackIcon, HeaderWrapper } from 'components/Buyer/Common/Header';
import { Button } from 'components/Common/Button';
import { useStompContext } from 'contexts/StompContext';
import { useNavigate } from 'react-router-dom';
import styled from 'styled-components';
import { Green, Grey1, LightGreen } from 'styles/color';
Expand All @@ -10,6 +11,8 @@ import { Characters } from 'utils/Characters';
export const BuyerLogout = () => {
const navigate = useNavigate();

const { stompClient } = useStompContext();

const patchSingOut = async (
accessTokenValue: string | null,
refreshTokenValue: string | null,
Expand All @@ -26,6 +29,7 @@ export const BuyerLogout = () => {
await patchAuthSignOut(body);
localStorage.removeItem('accessToken');
localStorage.removeItem('refreshToken');
stompClient.current?.disconnect();
navigate('/mypage');
} catch (e) {
console.log(e);
Expand Down
4 changes: 4 additions & 0 deletions src/pages/Seller/SellerLogout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { patchAuthSignOut } from 'api/patch';
import { BackIcon, HeaderWrapper } from 'components/Buyer/Common/Header';
import { Button } from 'components/Common/Button';
import { useStompContext } from 'contexts/StompContext';
import { useNavigate } from 'react-router-dom';
import styled from 'styled-components';
import { Green, Grey1, LightGreen } from 'styles/color';
Expand All @@ -10,6 +11,8 @@ import { Characters } from 'utils/Characters';
export const SellerLogout = () => {
const navigate = useNavigate();

const { stompClient } = useStompContext();

const patchSingOut = async (
accessTokenValue: string | null,
refreshTokenValue: string | null,
Expand All @@ -26,6 +29,7 @@ export const SellerLogout = () => {
await patchAuthSignOut(body);
localStorage.removeItem('accessToken');
localStorage.removeItem('refreshToken');
stompClient.current?.disconnect();
navigate('/mypage');
} catch (e) {
console.log(e);
Expand Down

0 comments on commit 9bd9859

Please sign in to comment.