Initial commit
Build / run (push) Has been cancelled

This commit is contained in:
maher
2026-05-14 13:42:10 +02:00
commit 511fad8199
4595 changed files with 385164 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
import {useMutation} from '@tanstack/react-query';
import {apiClient} from '@common/http/query-client';
import {BackendResponse} from '@common/http/backend-response/backend-response';
import {VotableModel} from '@common/votes/votable-model';
import {showHttpErrorToast} from '@common/utils/http/show-http-error-toast';
interface Response extends BackendResponse {
model: VotableModel;
}
interface Payload {
voteType: 'upvote' | 'downvote';
}
export function useStoreVote(model: VotableModel) {
return useMutation({
mutationFn: (payload: Payload) => changeVote(model, payload),
onSuccess: response => {
//
},
onError: err => showHttpErrorToast(err),
});
}
function changeVote(model: VotableModel, payload: Payload) {
return apiClient
.post<Response>('vote', {
vote_type: payload.voteType,
model_id: model.id,
model_type: model.model_type,
})
.then(r => r.data);
}