Skip to content

Commit

Permalink
Merge pull request #112 from Eagle2gle/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
m4nd4r1n authored Mar 26, 2023
2 parents 9db0c71 + 6225687 commit ea4d049
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/components/cahoot/BuyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Image from 'next/image';
import { useRouter } from 'next/router';

import { useSuspendedQuery } from '@/hooks/useSuspendedQuery';
import { api } from '@/libs/client/api';
import { fetcher } from '@/libs/client/fetcher';
import { useTypeSelector } from '@/store';
import type { CahootDetailType } from '@/types/cahoot';
Expand All @@ -24,17 +25,21 @@ const BuyButton = () => {
fetcher(`${process.env.NEXT_PUBLIC_HOST}/api/cahoots/${router.query.id}?info=detail`)
);
const quantity = useTypeSelector(({ cahootOrder }) => cahootOrder.quantity);
const token = useTypeSelector((state) => state.user.token);
const {
mutate,
isLoading,
data: response,
} = useMutation<Response, Error, { stocks: number }>({
mutationFn: (data) =>
fetch(`/api/cahoots/${router.query.id}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
}).then((res) => res.json()),
api
.post(`auth/cahoots/${router.query.id}`, {
json: data,
headers: {
Authorization: `Bearer ${token}`,
},
})
.json(),
});
const modalOpenRef = useRef<HTMLLabelElement>(null);

Expand Down

0 comments on commit ea4d049

Please sign in to comment.