use update_policy

This commit is contained in:
Sebastian 2021-11-05 11:26:12 -03:00
parent 543ed2a106
commit 4a8e4b9026
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1

View File

@ -24,14 +24,10 @@ export function ReviewPoliciesScreen(): VNode {
<EditPoliciesScreen <EditPoliciesScreen
index={editingPolicy} index={editingPolicy}
cancel={() => setEditingPolicy(undefined)} cancel={() => setEditingPolicy(undefined)}
confirm={(newMethods) => { confirm={async (newMethods) => {
reducer.runTransaction(async (tx) => { await reducer.transition("update_policy", {
await tx.transition("delete_policy", { policy_index: editingPolicy,
policy_index: editingPolicy policy: newMethods,
});
await tx.transition("add_policy", {
policy: newMethods
});
}); });
setEditingPolicy(undefined) setEditingPolicy(undefined)
}} }}
@ -50,7 +46,7 @@ export function ReviewPoliciesScreen(): VNode {
{policies.length < 1 && <p class="block"> {policies.length < 1 && <p class="block">
No policies had been created. Go back and add more authentication methods. No policies had been created. Go back and add more authentication methods.
</p>} </p>}
<div class="block" style={{justifyContent:'flex-end'}} > <div class="block" style={{ justifyContent: 'flex-end' }} >
<button class="button is-success" onClick={() => setEditingPolicy(policies.length + 1)}>Add new policy</button> <button class="button is-success" onClick={() => setEditingPolicy(policies.length + 1)}>Add new policy</button>
</div> </div>
{policies.map((p, policy_index) => { {policies.map((p, policy_index) => {