Skip to content

Commit

Permalink
Fix faulty type import
Browse files Browse the repository at this point in the history
  • Loading branch information
x183 committed Aug 17, 2023
1 parent b1087b0 commit eb77c31
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { useUser } from '@/src/hooks/api/auth';
import { useAddRating } from '@/src/hooks/api/useAddRating';
import { useAddRating, Rating } from '@/src/hooks/api/useAddRating';
import StarIcon from '@/src/icons/Star';
import { FC, useMemo, useState } from 'react';
import { toast } from 'react-toastify';
import Button from '../../Forms/Button/Button';
import styles from './GameRatings.module.scss';
import TextArea from '../../Forms/TextArea/TextArea';
import { Rating } from '@/src/hooks/api/useGameRatings';
import { useApiGet } from '@/src/hooks/apiHooks';

interface GameRatingsProps {
Expand Down Expand Up @@ -45,7 +44,7 @@ const GameRatings: FC<GameRatingsProps> = ({ gameId, userRating, userMotivation

return (
<div className={styles.layout}>
<Ratings gameId={gameId} />
<Ratings gameId={gameId} userRating={null} />
<div className={styles.rateLayout}>
<StarPicker
starCount={starCount}
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/hooks/api/useAddRating.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import axios from 'axios';

export type Rating = { game: string; rating: number; motivation?: string }

export const useAddRating = () => {
const queryClient = useQueryClient();

return useMutation({
mutationFn: (data: { game: string; rating: number; motivation?: string }) =>
mutationFn: (data: Rating) =>
axios.post('/api/v1/rating/rate', data),
onSuccess: (_, variables) => {
queryClient.invalidateQueries(['gamesList']);
Expand Down

0 comments on commit eb77c31

Please sign in to comment.