Farmbot-Web-App/src/account/state_to_props.ts

24 lines
765 B
TypeScript
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

import { Everything } from "../interfaces";
import { deleteUser } from "./actions";
import { Props } from "./interfaces";
import { getUserAccountSettings } from "../resources/selectors";
import { User } from "../auth/interfaces";
import { edit, save } from "../api/crud";
export function mapStateToProps(props: Everything): Props {
let user = getUserAccountSettings(props.resources.index);
return {
user,
saveUser(dispatch: Function, update: Partial<User>) {
dispatch(edit(user, update));
dispatch(save(user.uuid))
},
enactDeletion(dispatch: Function, password: string | undefined) {
dispatch(deleteUser({ password: password || "NEVER SET" }));
},
dispatch: () => { throw new Error("NEVER SHOULD HAPPEN"); }
};
}