Page MenuHomePhabricator

D5828.id19316.diff
No OneTemporary

D5828.id19316.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,32 @@
+// @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,
+ );
+}
+
+export { acknowledgePolicy };

File Metadata

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

Event Timeline