Update the store after setting an authorized address

[MAILPOET-2681]
This commit is contained in:
Amine Ben hammou
2020-04-03 08:39:45 +02:00
committed by Veljko V
parent 9877ed3573
commit af4225bc87
2 changed files with 14 additions and 6 deletions

View File

@@ -66,9 +66,10 @@ const removeUnauthorizedEmailNotices = () => {
type Props = { type Props = {
onRequestClose: () => void, onRequestClose: () => void,
setAuthorizedAddress: (address: string) => any,
}; };
const SetFromAddressModal = ({ onRequestClose }: Props) => { const SetFromAddressModal = ({ onRequestClose, setAuthorizedAddress }: Props) => {
const [address, setAddress] = useState(null); const [address, setAddress] = useState(null);
const { notices } = React.useContext<any>(GlobalContext); const { notices } = React.useContext<any>(GlobalContext);
@@ -125,6 +126,7 @@ const SetFromAddressModal = ({ onRequestClose }: Props) => {
} }
try { try {
await handleSave(address); await handleSave(address);
setAuthorizedAddress(address);
onRequestClose(); onRequestClose();
removeUnauthorizedEmailNotices(); removeUnauthorizedEmailNotices();
notices.success(getSuccessMessage(), { timeout: false }); notices.success(getSuccessMessage(), { timeout: false });

View File

@@ -16,8 +16,13 @@ export default function KeyActivation() {
const verifyPremiumKey = useAction('verifyPremiumKey'); const verifyPremiumKey = useAction('verifyPremiumKey');
const installPremiumPlugin = useAction('installPremiumPlugin'); const installPremiumPlugin = useAction('installPremiumPlugin');
const activatePremiumPlugin = useAction('activatePremiumPlugin'); const activatePremiumPlugin = useAction('activatePremiumPlugin');
const [senderAddress] = useSetting('sender', 'address'); const [senderAddress, setSenderAddress] = useSetting('sender', 'address');
const [unauthorizedAddresses] = useSetting('authorized_emails_addresses_check'); const [unauthorizedAddresses, setUnauthorizedAddresses] = useSetting('authorized_emails_addresses_check');
const setAuthorizedAddress = async (address: string) => {
await setSenderAddress(address);
await setUnauthorizedAddresses(null);
};
const verifyKey = async (event) => { const verifyKey = async (event) => {
if (!state.key) { if (!state.key) {
@@ -94,6 +99,7 @@ export default function KeyActivation() {
{state.showFromAddressModal && ( {state.showFromAddressModal && (
<SetFromAddressModal <SetFromAddressModal
onRequestClose={() => setState({ showFromAddressModal: false })} onRequestClose={() => setState({ showFromAddressModal: false })}
setAuthorizedAddress={setAuthorizedAddress}
/> />
)} )}
</div> </div>