pleroma/src/actions/account-notes.ts

40 lines
1.1 KiB
TypeScript
Raw Normal View History

import { getClient } from '../api';
2022-05-27 11:08:41 -07:00
import type { AnyAction } from 'redux';
import type { RootState } from 'soapbox/store';
2022-05-27 11:08:41 -07:00
const ACCOUNT_NOTE_SUBMIT_REQUEST = 'ACCOUNT_NOTE_SUBMIT_REQUEST';
const ACCOUNT_NOTE_SUBMIT_SUCCESS = 'ACCOUNT_NOTE_SUBMIT_SUCCESS';
const ACCOUNT_NOTE_SUBMIT_FAIL = 'ACCOUNT_NOTE_SUBMIT_FAIL';
const submitAccountNote = (id: string, value: string) =>
(dispatch: React.Dispatch<AnyAction>, getState: () => RootState) => {
dispatch(submitAccountNoteRequest());
return getClient(getState).accounts.updateAccountNote(id, value)
.then(response => {
dispatch(submitAccountNoteSuccess(response));
}).catch(error => dispatch(submitAccountNoteFail(error)));
2022-05-27 11:08:41 -07:00
};
const submitAccountNoteRequest = () => ({
type: ACCOUNT_NOTE_SUBMIT_REQUEST,
});
2022-05-27 11:08:41 -07:00
const submitAccountNoteSuccess = (relationship: any) => ({
type: ACCOUNT_NOTE_SUBMIT_SUCCESS,
relationship,
});
2022-05-27 11:08:41 -07:00
2023-10-23 15:22:10 -07:00
const submitAccountNoteFail = (error: unknown) => ({
type: ACCOUNT_NOTE_SUBMIT_FAIL,
error,
});
2022-05-27 11:08:41 -07:00
export {
submitAccountNote,
ACCOUNT_NOTE_SUBMIT_REQUEST,
ACCOUNT_NOTE_SUBMIT_SUCCESS,
ACCOUNT_NOTE_SUBMIT_FAIL,
};