Showing AI reviews for website
Project AI Score ?
71%
Quality Avg ?
72%
Security Avg ?
74%
Reviews ?
123

Review Result ?

solutionbowl/website · ce688794
The commit adds debounce logic to BetItem component to limit state update frequency, improves handling of fancy market types consistently across racing components, introduces filtering of unavailable runners from bets in HorseRacingDetails, and sets a default bet amount constant. These changes improve user experience, business logic correctness, and code consistency with minimal risk. The commit message is minimal and could be more descriptive.
Quality ?
85%
Security ?
80%
Business Value ?
80%
Maintainability ?
85%
Issues & Suggested Fixes ?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Insufficient Description
Where commit message
Issue / Evidence insufficient description
Suggested Fix provide a more detailed and descriptive commit message explaining the purpose and impact of changes
Unclear Intent Of Runner Availability Chec...
Where src/pages/HorseRacingDetails.tsx:63
Issue / Evidence unclear intent of runner availability check
Suggested Fix add comments explaining business logic for suspending/inactive/withdrawn runner filtering
Long Function
Where src/components/bets/BetItem.tsx:14
Issue / Evidence state initialisation complexity
Suggested Fix consider simplifying or adding comments to clarify logic behind localAmount initialization and debounce usage
Magic Number
Where src/components/bets/BetItem.tsx:34
Issue / Evidence magic number
Suggested Fix replace hardcoded debounce delay (300ms) with named constant for easier maintenance and clarity
Code Change Preview · src/components/bets/BetItem.tsx ?
Removed / Before Commit
- diff --git a/src/components/bets/BetItem.tsx b/src/components/bets/BetItem.tsx
- index dbedc4f..0dc7f58 100644
- import { memo, useCallback, useEffect, useState } from 'react';
- import { useThemeColors } from '../../hooks/useThemeColors';
- import { useBetStore } from '../../store/useBetStore';
- import type { RacingBet } from '../../store/useBetStore';
- const BetItem = memo(({ betKey, bet }: BetItemProps) => {
- const colors = useThemeColors();
- const { removeBet, updateBetAmount, toggleOddsType } = useBetStore();
-   const [localAmount, setLocalAmount] = useState(bet.amount.toString());
-   const [debounceTimer, setDebounceTimer] = useState<number | null>(null);
- 
- useEffect(() => {
-     if (bet.amount > 0 && bet.amount.toString() !== localAmount) {
-       setLocalAmount(bet.amount.toString());
-     }
-   }, [bet.amount, localAmount]);
- 
Added / After Commit
+ diff --git a/src/components/bets/BetItem.tsx b/src/components/bets/BetItem.tsx
+ index dbedc4f..0dc7f58 100644
+ import { memo, useCallback, useEffect, useRef, useState } from 'react';
+ import { useThemeColors } from '../../hooks/useThemeColors';
+ import { useBetStore } from '../../store/useBetStore';
+ import type { RacingBet } from '../../store/useBetStore';
+ const BetItem = memo(({ betKey, bet }: BetItemProps) => {
+ const colors = useThemeColors();
+ const { removeBet, updateBetAmount, toggleOddsType } = useBetStore();
+   const [localAmount, setLocalAmount] = useState(() => (
+     bet.amount > 0 ? bet.amount.toString() : ''
+   ));
+   const debounceTimerRef = useRef<number | null>(null);
+ 
+ useEffect(() => {
+     return () => {
+       if (debounceTimerRef.current) {
+         window.clearTimeout(debounceTimerRef.current);
Removed / Before Commit
- diff --git a/src/components/racing/BettingPanel.tsx b/src/components/racing/BettingPanel.tsx
- index e310c20..76dcba3 100644
- const selectedMarket = markets.find((m) => m.marketId === activeMarket)
- const marketNameLower = selectedMarket?.marketName?.toLowerCase() || ''
- const isWinnerMarket = marketNameLower.includes('winner') || marketNameLower.includes('win')
- const isFancyMarket =
-       marketNameLower.includes('fancy') || selectedMarket?.marketType?.toUpperCase() === 'FANCY'
- 
- // Check if there's an active bet for this market
- if (!activeBet || (activeMarket !== "all" && activeBet.marketId !== activeMarket)) {
- marketId={activeMarket}
- raceType={selectedMarket?.marketOddsType}
- marketType={selectedMarket?.marketType}
- activeBet={activeBet}
- setActiveBet={setActiveBet}
- profitLoss={pl[index] || 0}
Added / After Commit
+ diff --git a/src/components/racing/BettingPanel.tsx b/src/components/racing/BettingPanel.tsx
+ index e310c20..76dcba3 100644
+ const selectedMarket = markets.find((m) => m.marketId === activeMarket)
+ const marketNameLower = selectedMarket?.marketName?.toLowerCase() || ''
+ const isWinnerMarket = marketNameLower.includes('winner') || marketNameLower.includes('win')
+     const isPhotoFancyMarket =
+       selectedMarket?.marketType?.toUpperCase() === 'FANCY' &&
+       (selectedMarket?.fancy_type || selectedMarket?.fancyType)?.toLowerCase() === 'photo'
+ const isFancyMarket =
+       !isPhotoFancyMarket &&
+       (marketNameLower.includes('fancy') || selectedMarket?.marketType?.toUpperCase() === 'FANCY')
+ 
+ // Check if there's an active bet for this market
+ if (!activeBet || (activeMarket !== "all" && activeBet.marketId !== activeMarket)) {
+ marketId={activeMarket}
+ raceType={selectedMarket?.marketOddsType}
+ marketType={selectedMarket?.marketType}
+                     fancyType={selectedMarket?.fancy_type || selectedMarket?.fancyType}
Removed / Before Commit
- diff --git a/src/components/racing/HorseRow.tsx b/src/components/racing/HorseRow.tsx
- index c11e98a..f3a26f9 100644
- import { useState, useCallback, memo } from "react"
- import type { RunnerOdds } from "../../types/raceMarkets"
- import { useBetStore } from "../../store/useBetStore"
- import { BetChipAnimation } from "../bets/BetChipAnimation"
- import toast from 'react-hot-toast'
- import { useAuth } from "../../contexts/AuthContext"
- marketId?: string
- raceType?: string
- marketType?: string
- activeBet?: ActiveBet | null
- setActiveBet?: (bet: ActiveBet | null) => void
- profitLoss?: number
- marketId = 'unknown',
- raceType,
- marketType,
- activeBet,
Added / After Commit
+ diff --git a/src/components/racing/HorseRow.tsx b/src/components/racing/HorseRow.tsx
+ index c11e98a..f3a26f9 100644
+ import { useState, useCallback, memo } from "react"
+ import type { RunnerOdds } from "../../types/raceMarkets"
+ import { DEFAULT_RACING_BET_AMOUNT, useBetStore } from "../../store/useBetStore"
+ import { BetChipAnimation } from "../bets/BetChipAnimation"
+ import toast from 'react-hot-toast'
+ import { useAuth } from "../../contexts/AuthContext"
+ marketId?: string
+ raceType?: string
+ marketType?: string
+   fancyType?: string
+ activeBet?: ActiveBet | null
+ setActiveBet?: (bet: ActiveBet | null) => void
+ profitLoss?: number
+ marketId = 'unknown',
+ raceType,
+ marketType,
Removed / Before Commit
- diff --git a/src/components/racing/MarketCard.tsx b/src/components/racing/MarketCard.tsx
- index dd8ad66..15623f0 100644
- const calculatePL = () => {
- const marketNameLower = market.marketName?.toLowerCase() || ''
- const isWinnerMarket = marketNameLower.includes('winner') || marketNameLower.includes('win')
- const isFancyMarket =
-       marketNameLower.includes('fancy') || market.marketType?.toUpperCase() === 'FANCY'
- 
- // Check if there's an active bet for this market
- if (!activeBet || activeBet.marketId !== market.marketId) {
- marketId={market.marketId}
- raceType={raceType}
- marketType={market.marketType}
- activeBet={activeBet}
- setActiveBet={setActiveBet}
- profitLoss={pl[index] || 0}
Added / After Commit
+ diff --git a/src/components/racing/MarketCard.tsx b/src/components/racing/MarketCard.tsx
+ index dd8ad66..15623f0 100644
+ const calculatePL = () => {
+ const marketNameLower = market.marketName?.toLowerCase() || ''
+ const isWinnerMarket = marketNameLower.includes('winner') || marketNameLower.includes('win')
+     const isPhotoFancyMarket =
+       market.marketType?.toUpperCase() === 'FANCY' &&
+       (market.fancy_type || market.fancyType)?.toLowerCase() === 'photo'
+ const isFancyMarket =
+       !isPhotoFancyMarket &&
+       (marketNameLower.includes('fancy') || market.marketType?.toUpperCase() === 'FANCY')
+ 
+ // Check if there's an active bet for this market
+ if (!activeBet || activeBet.marketId !== market.marketId) {
+ marketId={market.marketId}
+ raceType={raceType}
+ marketType={market.marketType}
+                       fancyType={market.fancy_type || market.fancyType}
Removed / Before Commit
- diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx
- index 22b1484..39d2190 100644
- 
- return (
- <div className="pb-[80px] w-full max-w-[1240px] mx-auto px-4">
-       <BannerCarousel bannerType="Sports" />
- 
- {/* Tab Navigation */}
- <div className="mt-[20px]">
Added / After Commit
+ diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx
+ index 22b1484..39d2190 100644
+ 
+ return (
+ <div className="pb-[80px] w-full max-w-[1240px] mx-auto px-4">
+       <BannerCarousel bannerType="Home" />
+ 
+ {/* Tab Navigation */}
+ <div className="mt-[20px]">
Removed / Before Commit
- diff --git a/src/pages/HorseRacingDetails.tsx b/src/pages/HorseRacingDetails.tsx
- index d71ce26..26f0e6b 100644
- }
- if (fancySettle && marketTypeLower === 'fancy') {
- return false
-     }
- 
- return true
- })
- }
- 
- const transformRaceMarkets = (marketsData: Market[]) => {
- return marketsData.map(market => ({
- ...market,
- raceId: raceId || null,
- onOddsUpdate: async (updatedMarkets: Market[]) => {
- console.log(`âœ
- Socket update: ${updatedMarkets.length} markets received`)
Added / After Commit
+ diff --git a/src/pages/HorseRacingDetails.tsx b/src/pages/HorseRacingDetails.tsx
+ index d71ce26..26f0e6b 100644
+ }
+ if (fancySettle && marketTypeLower === 'fancy') {
+ return false
+     }    
+ 
+ return true
+ })
+ }
+ 
+ const isRunnerUnavailableForBetting = (runner: Market["odds"][number]) => {
+   return runner.suspended === true || runner.inactive === true || runner.withdrawn === true
+ }
+ 
+ const removeUnavailableBetsFromSlip = (marketsData: Market[]) => {
+   const { bets, removeBet } = useBetStore.getState()
+ 
Removed / Before Commit
- diff --git a/src/store/useBetStore.ts b/src/store/useBetStore.ts
- index 1fcf353..4a86e45 100644
- 
- type BetStore = BetState & BetActions;
- 
- const generateBetKey = (runnerId: string, marketId: string): string => {
- return `${runnerId}_${marketId}`;
- };
- bets: {
- [key]: {
- ...bet,
-               amount: 0,
- accept_any_odds: false,
- },
- },
Added / After Commit
+ diff --git a/src/store/useBetStore.ts b/src/store/useBetStore.ts
+ index 1fcf353..4a86e45 100644
+ 
+ type BetStore = BetState & BetActions;
+ 
+ export const DEFAULT_RACING_BET_AMOUNT = 100;
+ 
+ const generateBetKey = (runnerId: string, marketId: string): string => {
+ return `${runnerId}_${marketId}`;
+ };
+ bets: {
+ [key]: {
+ ...bet,
+               amount: DEFAULT_RACING_BET_AMOUNT,
+ accept_any_odds: false,
+ },
+ },
Removed / Before Commit
- diff --git a/src/types/raceMarkets.ts b/src/types/raceMarkets.ts
- index 15c5b2d..4848ff6 100644
- marketId: string
- marketName: string
- marketType: string
- back_static_volume: number | null
- lay_static_volume: number | null
- back_volume: number | null
Added / After Commit
+ diff --git a/src/types/raceMarkets.ts b/src/types/raceMarkets.ts
+ index 15c5b2d..4848ff6 100644
+ marketId: string
+ marketName: string
+ marketType: string
+   fancy_type?: string
+   fancyType?: string
+ back_static_volume: number | null
+ lay_static_volume: number | null
+ back_volume: number | null