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 | 7x 7x 2x 1x 1x 1x | import { useMutation } from "@tanstack/react-query";
import { generateNick } 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 { useNickHistoryStore } from "../presentation/stores/nick-history.store";
interface GenerateNickParams {
gender: Gender;
offenseLevel: OffenseLevel;
}
export function useGenerateNick() {
const setNick = useNickStore(s => s.setNick);
const addNickToHistory = useNickHistoryStore(s => s.addNick);
return useMutation<Nick, Error, GenerateNickParams>({
mutationFn: params => generateNick(params),
onSuccess: (nick: Nick) => {
setNick(nick);
addNickToHistory(nick);
}
});
} |