Showing AI reviews for avriti
Project AI Score ?
63%
Quality Avg ?
68%
Security Avg ?
45%
Reviews ?
56

Review Result ?

jattin01/avriti · 906e3861
The commit addresses pagination issues for slider dots across multiple components by calculating and setting snap points and active pages. The approach is systematic and improves UX responsiveness with auto-scroll and snap point calculation. However, some repeated patterns across similar components could be better abstracted to reduce code duplication and potential future bugs.
Quality ?
75%
Security ?
90%
Business Value ?
70%
Maintainability ?
73%
Issues & Suggested Fixes ?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Duplicate Logic
Where components/product-slider.tsx:32
Issue / Evidence repeated state initialization pattern similar to service-slider and testimonial-slider
Suggested Fix create a custom hook to manage slider state to reduce duplication and improve maintainability
Long Function
Where components/product-slider.tsx:73
Issue / Evidence complex nearestPage calculation logic in reduce function
Suggested Fix add comments or split logic for readability to reduce bug risk
Duplicate Logic
Where components/service-slider.tsx:29
Issue / Evidence similarly repeated logic in snap point calculation and state updates
Suggested Fix extract shared logic into reusable functions/hooks
Duplicate Logic
Where components/testimonial-slider.tsx:25
Issue / Evidence repeated slide checks and snap point calculations
Suggested Fix refactor to reduce duplication
Scrolltopage Function Can Benefit From Mem...
Where components/service-slider.tsx:103
Issue / Evidence scrollToPage function can benefit from memoization and clearer typing/documentation to improve maintainability
Suggested Fix Review and simplify this section.
Insufficient Description And Context
Where commit message
Issue / Evidence insufficient description and context
Suggested Fix improve commit message to describe the problem fixed, approach taken, and impact to improve business value and codebase traceability
Code Change Preview · components/product-slider.tsx ?
Removed / Before Commit
- 
- export function ProductSlider({ products }: ProductSliderProps) {
- const trackRef = useRef<HTMLDivElement>(null);
-   const [activeIndex, setActiveIndex] = useState(0);
- const [canScroll, setCanScroll] = useState(false);
- const [atStart, setAtStart] = useState(true);
- const [atEnd, setAtEnd] = useState(false);
- if (!track) return;
- 
- const slides = Array.from(track.children) as HTMLElement[];
-     const nearestSlide = slides.reduce(
-       (nearest, slide, index) => {
-         const distance = Math.abs(slide.offsetLeft - track.scrollLeft);
- return distance < nearest.distance ? { distance, index } : nearest;
- },
- { distance: Number.POSITIVE_INFINITY, index: 0 },
- );
- 
Added / After Commit
+ 
+ export function ProductSlider({ products }: ProductSliderProps) {
+ const trackRef = useRef<HTMLDivElement>(null);
+   const [snapPoints, setSnapPoints] = useState([0]);
+   const [activePage, setActivePage] = useState(0);
+ const [canScroll, setCanScroll] = useState(false);
+ const [atStart, setAtStart] = useState(true);
+ const [atEnd, setAtEnd] = useState(false);
+ if (!track) return;
+ 
+ const slides = Array.from(track.children) as HTMLElement[];
+ 
+     if (slides.length === 0) {
+       setSnapPoints([0]);
+       setActivePage(0);
+       setCanScroll(false);
+       setAtStart(true);
+       setAtEnd(false);
Removed / Before Commit
- 
- export function ServiceSlider() {
- const trackRef = useRef<HTMLDivElement>(null);
-   const [activeIndex, setActiveIndex] = useState(0);
- const [canScroll, setCanScroll] = useState(false);
- const [atStart, setAtStart] = useState(true);
- const [atEnd, setAtEnd] = useState(false);
- const autoScrollTimerRef = useRef<NodeJS.Timeout | null>(null);
- const [isAutoScrolling, setIsAutoScrolling] = useState(true);
- 
- const updateSliderState = useCallback(() => {
- }
- 
- const slides = Array.from(track.children) as HTMLElement[];
-     const nearestSlide = slides.reduce(
-       (nearest, slide, index) => {
-         const distance = Math.abs(slide.offsetLeft - track.scrollLeft);
- 
Added / After Commit
+ 
+ export function ServiceSlider() {
+ const trackRef = useRef<HTMLDivElement>(null);
+   const [snapPoints, setSnapPoints] = useState([0]);
+   const [activePage, setActivePage] = useState(0);
+ const [canScroll, setCanScroll] = useState(false);
+ const [atStart, setAtStart] = useState(true);
+ const [atEnd, setAtEnd] = useState(false);
+ const autoScrollTimerRef = useRef<NodeJS.Timeout | null>(null);
+   const resumeAutoScrollTimerRef = useRef<NodeJS.Timeout | null>(null);
+ const [isAutoScrolling, setIsAutoScrolling] = useState(true);
+ 
+ const updateSliderState = useCallback(() => {
+ }
+ 
+ const slides = Array.from(track.children) as HTMLElement[];
+ 
+     if (slides.length === 0) {
Removed / Before Commit
- 
- export function TestimonialSlider() {
- const trackRef = useRef<HTMLDivElement>(null);
-   const [activeIndex, setActiveIndex] = useState(0);
- const [canScroll, setCanScroll] = useState(false);
- const [atStart, setAtStart] = useState(true);
- const [atEnd, setAtEnd] = useState(false);
-   const [lastSnapIndex, setLastSnapIndex] = useState(0);
- 
- const updateSliderState = useCallback(() => {
- const track = trackRef.current;
- }
- 
- const slides = Array.from(track.children) as HTMLElement[];
-     const nearestSlide = slides.reduce(
-       (nearest, slide, index) => {
-         const distance = Math.abs(slide.offsetLeft - track.scrollLeft);
- 
Added / After Commit
+ 
+ export function TestimonialSlider() {
+ const trackRef = useRef<HTMLDivElement>(null);
+   const [snapPoints, setSnapPoints] = useState([0]);
+   const [activePage, setActivePage] = useState(0);
+ const [canScroll, setCanScroll] = useState(false);
+ const [atStart, setAtStart] = useState(true);
+ const [atEnd, setAtEnd] = useState(false);
+ 
+ const updateSliderState = useCallback(() => {
+ const track = trackRef.current;
+ }
+ 
+ const slides = Array.from(track.children) as HTMLElement[];
+ 
+     if (slides.length === 0) {
+       setSnapPoints([0]);
+       setActivePage(0);