Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 7x 7x 2x 1x 1x 1x | import { useMutation } from "@tanstack/react-query";
import { replaceWord } from "../infrastructure/nick.api";
import { useNickStore } from "../presentation/stores/nick.store";
import type { Nick } from "../domain/model/Nick";
import type { Gender } from "../domain/model/Gender";
import type { OffenseLevel } from "../domain/model/OffenseLevel";
import type { WordRole } from "../domain/model/Word";
import { useNickHistoryStore } from "../presentation/stores/nick-history.store";
interface ReplaceWordParams {
role: WordRole;
gender: Gender;
offenseLevel: OffenseLevel;
previousId: number;
}
export function useReplaceWord() {
const setNick = useNickStore(s => s.setNick);
const addNickToHistory = useNickHistoryStore(s => s.addNick);
return useMutation<Nick, Error, ReplaceWordParams>({
mutationFn: params => replaceWord(params),
onSuccess: (newNick: Nick) => {
setNick(newNick);
addNickToHistory(newNick);
}
});
} |