File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change 11// useMazeStore.ts
2- import create from 'zustand' ;
2+ import { create } from 'zustand' ;
33import { Cell } from '../algorithms/utils/PathfindingUtils' ;
44
55interface MazeState {
@@ -21,7 +21,7 @@ interface MazeState {
2121export const useMazeStore = create < MazeState > ( ( set ) => ( {
2222 maze : [ ] ,
2323 startNode : [ 0 , 0 ] ,
24- endNode : [ 1 , 1 ] ,
24+ endNode : [ 0 , 0 ] ,
2525 setMaze : ( newMaze ) => set ( { maze : newMaze } ) ,
2626 setCell : ( row , col , updates ) => {
2727 set ( ( state ) => {
@@ -101,7 +101,7 @@ export const useMazeStore = create<MazeState>((set) => ({
101101 setEndPosition : ( flatHeight , flatWidth ) => {
102102 set ( ( state ) => {
103103 const rowIndex = Math . floor ( flatHeight / 2 ) ;
104- const colIndex = Math . floor ( flatWidth * 3 / 4 ) ;
104+ const colIndex = Math . floor ( flatWidth * ( 3 / 4 ) ) ;
105105 const newMaze = state . maze . map ( ( row , i ) =>
106106 i === rowIndex ? row . map ( ( cell , j ) => ( j === colIndex ? { ...cell , end : true } : cell ) ) : row
107107 ) ;
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ const PathfindingVisualiser: React.FC = () => {
1616 maze,
1717 startNode,
1818 endNode,
19- setMaze, // Make sure setMaze is destructured here
19+ setMaze,
2020 generateMaze,
2121 setStartPosition,
2222 setEndPosition,
@@ -38,7 +38,7 @@ const PathfindingVisualiser: React.FC = () => {
3838 maze,
3939 startNode,
4040 endNode,
41- setMaze, // Ensure setMaze is passed here
41+ setMaze,
4242 } ) ;
4343
4444 const handleMouseDown = ( rowIndex : number , colIndex : number ) => {
You can’t perform that action at this time.
0 commit comments