Skip to content

Commit

Permalink
fix: function api parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
D33102 committed Jul 8, 2024
1 parent f2c9ffa commit f662288
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/app/reward/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ import TwoCircleMenu from '@/components/TwoCircleMenu';
import Link from 'next/link';
import React, { useState } from 'react';
import ConfirmationModal from '../../components/confirmationModal';
import { useAuth } from '@/context/AuthContext';
import { patchReward } from '@/utils/user';
import { useRouter } from 'next/navigation';

export default function Reward() {
const [isOpen, setIsOpen] = useState(false);
const { user } = useAuth();
const router = useRouter();

async function handleRedeem() {
const res = await patchReward(user?.id ?? '');
const res = await patchReward();
if (res) {
router.push('/rewarddone');
} else {
Expand Down
7 changes: 4 additions & 3 deletions src/utils/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ export const getUser = async (): Promise<User | null> => {
}
};

export const patchReward = async (id: string): Promise<boolean | null> => {
export const patchReward = async (): Promise<boolean | null> => {
const userId = await getUserId();
const accessToken = await getAccessToken();

if (!accessToken) {
if (!accessToken || !userId) {
return null;
}
try {
const res: AxiosResponse<{ success: boolean }> = await apiClient.patch(
`/user/profile/${id}`,
`/user/profile/${userId}`,
{ receive_gift: 1 },
{
headers: {
Expand Down

0 comments on commit f662288

Please sign in to comment.