Skip to content

Commit

Permalink
reload page to see new deck
Browse files Browse the repository at this point in the history
  • Loading branch information
JollyGrin committed Mar 26, 2024
1 parent b6042ea commit 55fc6df
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/hooks/useUnmatchedDeck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export const useUnmatchedDeck = () => {
* and manipulates localstorage
* */
export const useLoadRouterDeck = () => {
const { query } = useRouter();
const { query, reload } = useRouter();
const deckId = query.deckId as string | undefined;

const { data, setDeckId } = useUnmatchedDeck();
const { decks, pushDeck, setStar, star } = useLocalDeckStorage();
const { decks, pushDeck, setStar } = useLocalDeckStorage();

useEffect(() => {
if (!deckId) return;
Expand Down Expand Up @@ -85,11 +85,11 @@ export const useLoadRouterDeck = () => {
useEffect(() => {
if (!data) return;
if (!deckId) return;
console.log({ data, deckId });

// once api data is available, push the deck to local storage and star it
pushDeck(data);
setStar(data.id);
toast.success("Refresh the page if you do not see your new deck");
toast.success("Success! Refreshing page to load new deck");
reload();
}, [data]);
};

0 comments on commit 55fc6df

Please sign in to comment.