Skip to content

Commit

Permalink
Addition to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmonisit committed Jan 6, 2025
1 parent 066b161 commit 0ee6e57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Open [http://localhost:3000](http://localhost:3000) with your browser to see the
### UI
- [NextUI]()
- [Tailwind CSS]()

- [DaisyUI]


### Code Quality
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { UniqueIdentifier } from "@dnd-kit/core";
import { unstable_batchedUpdates } from "react-dom";
import { useScheduleStore } from "@/lib/hooks/stores/useScheduleStore";
import useHistoryStore from "@/lib/hooks/stores/useHistoryStore";

export default function useScheduleHandlers() {

Expand All @@ -13,12 +14,19 @@ export default function useScheduleHandlers() {

const handleAddColumn = () => {
const newContainerId = `semester${containers.length}`;
const newItems = {
...items,
[newContainerId]: [],
};

// Save current state to history before making changes
const currentState = useScheduleStore.getState();
useHistoryStore.getState().addToHistory(currentState);

// Update both states atomically
unstable_batchedUpdates(() => {
setSemesterOrder([...containers, newContainerId]);
setCoursesBySemesterID({
...items,
[newContainerId]: [],
});
setCoursesBySemesterID(newItems, true); // Skip history for this call since we already saved it
});
}

Expand Down

0 comments on commit 0ee6e57

Please sign in to comment.