Page MenuHomePhabricator

D5828.id19181.diff
No OneTemporary

D5828.id19181.diff

diff --git a/lib/utils/policy-acknowledge-utlis.js b/lib/utils/policy-acknowledge-utlis.js
new file mode 100644
--- /dev/null
+++ b/lib/utils/policy-acknowledge-utlis.js
@@ -0,0 +1,34 @@
+// @flow
+
+import { policyAcknowledgmentActionTypes } from '../actions/user-actions.js';
+import type { PolicyType } from '../facts/policies.js';
+import type { PolicyAcknowledgmentRequest } from '../types/account-types.js';
+import type { DispatchActionPromise } from './action-utils.js';
+
+function acknowledgePolicy(
+ policy: PolicyType,
+ dispatchActionPromise: DispatchActionPromise,
+ acknowledgmentServerCall: (
+ request: PolicyAcknowledgmentRequest,
+ ) => Promise<void>,
+ onError: (message: string) => void,
+) {
+ const acknowledgePolicyPromise = (async () => {
+ try {
+ await acknowledgmentServerCall({ policy });
+ return { policy };
+ } catch (e) {
+ console.warn('error acknowledging policy', e);
+ onError('unknown error');
+ throw e;
+ }
+ })();
+ dispatchActionPromise(
+ policyAcknowledgmentActionTypes,
+ acknowledgePolicyPromise,
+ undefined,
+ { policy },
+ );
+}
+
+export { acknowledgePolicy };

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 5:09 PM (18 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678103
Default Alt Text
D5828.id19181.diff (1 KB)

Event Timeline