@sprucelabs/spruce-profile-utils 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  export { default as RoleSelectCardViewController } from './adding/RoleSelectCard.vc';
2
2
  export { default as ProfileCardViewController } from './root/ProfileCard.vc';
3
+ export * from './root/ProfileCard.vc';
3
4
  export * from './types-module';
4
5
  export * from './profile.types';
@@ -1,4 +1,5 @@
1
1
  export { default as RoleSelectCardViewController } from './adding/RoleSelectCard.vc.js';
2
2
  export { default as ProfileCardViewController } from './root/ProfileCard.vc.js';
3
+ export * from './root/ProfileCard.vc.js';
3
4
  export * from './types-module.js';
4
5
  export * from './profile.types.js';
@@ -12,16 +12,15 @@ export default class ProfileCardViewController extends AbstractViewController<Ca
12
12
  private CardVc;
13
13
  private FormVc;
14
14
  private handleSubmit;
15
- load(options: LoadOptions): Promise<void>;
15
+ load(options: ProfileCardLoadOptions): Promise<void>;
16
16
  render(): import("@sprucelabs/calendar-utils").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
17
17
  }
18
- interface LoadOptions {
18
+ export interface ProfileCardLoadOptions {
19
19
  person: Person;
20
20
  authenticator: Authenticator;
21
21
  locale: Locale;
22
22
  }
23
- type OnSubmitHandler = (person?: Person) => Promise<void>;
23
+ export type OnSubmitHandler = (person: Person) => Promise<void>;
24
24
  export interface ProfileCardViewControllerOptions {
25
25
  onSubmit?: OnSubmitHandler;
26
26
  }
27
- export {};
@@ -61,7 +61,7 @@ class ProfileCardViewController extends AbstractViewController {
61
61
  }));
62
62
  }
63
63
  handleSubmit() {
64
- var _a, _b, _c, _d;
64
+ var _a, _b, _c;
65
65
  return __awaiter(this, void 0, void 0, function* () {
66
66
  try {
67
67
  const client = yield this.connectToApi();
@@ -69,16 +69,18 @@ class ProfileCardViewController extends AbstractViewController {
69
69
  yield client.emitAndFlattenResponses('update-person::v2020_12_25', {
70
70
  payload: Object.assign({}, values),
71
71
  });
72
- const token = (_a = this.authenticator) === null || _a === void 0 ? void 0 : _a.getSessionToken();
73
- const current = (_b = this.authenticator) === null || _b === void 0 ? void 0 : _b.getPerson();
72
+ const token = this.authenticator.getSessionToken();
73
+ const current = this.authenticator.getPerson();
74
74
  const updatedPerson = Object.assign(Object.assign({}, current), values);
75
- (_c = this.authenticator) === null || _c === void 0 ? void 0 : _c.setSessionToken(token, updatedPerson);
75
+ if (current.id === ((_a = this.person) === null || _a === void 0 ? void 0 : _a.id)) {
76
+ (_b = this.authenticator) === null || _b === void 0 ? void 0 : _b.setSessionToken(token, updatedPerson);
77
+ }
76
78
  yield this.alert({
77
79
  title: 'Changes saved!',
78
80
  message: 'Your profile has been updated. This is so much fun!',
79
81
  style: 'success',
80
82
  });
81
- yield ((_d = this.onSubmitHandler) === null || _d === void 0 ? void 0 : _d.call(this, updatedPerson));
83
+ yield ((_c = this.onSubmitHandler) === null || _c === void 0 ? void 0 : _c.call(this, updatedPerson));
82
84
  }
83
85
  catch (err) {
84
86
  yield this.alert({ message: err.message, style: 'error' });
@@ -1,4 +1,5 @@
1
1
  export { default as RoleSelectCardViewController } from './adding/RoleSelectCard.vc';
2
2
  export { default as ProfileCardViewController } from './root/ProfileCard.vc';
3
+ export * from './root/ProfileCard.vc';
3
4
  export * from './types-module';
4
5
  export * from './profile.types';
@@ -22,5 +22,6 @@ var RoleSelectCard_vc_1 = require("./adding/RoleSelectCard.vc");
22
22
  Object.defineProperty(exports, "RoleSelectCardViewController", { enumerable: true, get: function () { return __importDefault(RoleSelectCard_vc_1).default; } });
23
23
  var ProfileCard_vc_1 = require("./root/ProfileCard.vc");
24
24
  Object.defineProperty(exports, "ProfileCardViewController", { enumerable: true, get: function () { return __importDefault(ProfileCard_vc_1).default; } });
25
+ __exportStar(require("./root/ProfileCard.vc"), exports);
25
26
  __exportStar(require("./types-module"), exports);
26
27
  __exportStar(require("./profile.types"), exports);
@@ -12,16 +12,15 @@ export default class ProfileCardViewController extends AbstractViewController<Ca
12
12
  private CardVc;
13
13
  private FormVc;
14
14
  private handleSubmit;
15
- load(options: LoadOptions): Promise<void>;
15
+ load(options: ProfileCardLoadOptions): Promise<void>;
16
16
  render(): import("@sprucelabs/calendar-utils").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
17
17
  }
18
- interface LoadOptions {
18
+ export interface ProfileCardLoadOptions {
19
19
  person: Person;
20
20
  authenticator: Authenticator;
21
21
  locale: Locale;
22
22
  }
23
- type OnSubmitHandler = (person?: Person) => Promise<void>;
23
+ export type OnSubmitHandler = (person: Person) => Promise<void>;
24
24
  export interface ProfileCardViewControllerOptions {
25
25
  onSubmit?: OnSubmitHandler;
26
26
  }
27
- export {};
@@ -54,23 +54,25 @@ class ProfileCardViewController extends heartwood_view_controllers_1.AbstractVie
54
54
  }));
55
55
  }
56
56
  async handleSubmit() {
57
- var _a, _b, _c, _d;
57
+ var _a, _b, _c;
58
58
  try {
59
59
  const client = await this.connectToApi();
60
60
  const values = this.formVc.getValues();
61
61
  await client.emitAndFlattenResponses('update-person::v2020_12_25', {
62
62
  payload: Object.assign({}, values),
63
63
  });
64
- const token = (_a = this.authenticator) === null || _a === void 0 ? void 0 : _a.getSessionToken();
65
- const current = (_b = this.authenticator) === null || _b === void 0 ? void 0 : _b.getPerson();
64
+ const token = this.authenticator.getSessionToken();
65
+ const current = this.authenticator.getPerson();
66
66
  const updatedPerson = Object.assign(Object.assign({}, current), values);
67
- (_c = this.authenticator) === null || _c === void 0 ? void 0 : _c.setSessionToken(token, updatedPerson);
67
+ if (current.id === ((_a = this.person) === null || _a === void 0 ? void 0 : _a.id)) {
68
+ (_b = this.authenticator) === null || _b === void 0 ? void 0 : _b.setSessionToken(token, updatedPerson);
69
+ }
68
70
  await this.alert({
69
71
  title: 'Changes saved!',
70
72
  message: 'Your profile has been updated. This is so much fun!',
71
73
  style: 'success',
72
74
  });
73
- await ((_d = this.onSubmitHandler) === null || _d === void 0 ? void 0 : _d.call(this, updatedPerson));
75
+ await ((_c = this.onSubmitHandler) === null || _c === void 0 ? void 0 : _c.call(this, updatedPerson));
74
76
  }
75
77
  catch (err) {
76
78
  await this.alert({ message: err.message, style: 'error' });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-profile-utils",
3
3
  "description": "Useeful utilities",
4
- "version": "3.0.0",
4
+ "version": "3.0.2",
5
5
  "skill": {
6
6
  "namespace": "profile"
7
7
  },