@imposium-hub/components 1.32.4 → 1.33.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imposium-hub/components",
3
- "version": "1.32.4",
3
+ "version": "1.33.0",
4
4
  "description": "React & Typescript component / asset library for Imposium front-ends",
5
5
  "main": "dist/components.js",
6
6
  "scripts": {
@@ -46,6 +46,30 @@ export const storyAdded = (storyId : string, storyName : string) : any => {
46
46
  };
47
47
  };
48
48
 
49
+ export const orgNameMutated = (orgId : string, newOrgName : string) : any => {
50
+ return (dispatch, getStore) => {
51
+ const {access, auth: {idTokenPayload: {exp}}} = getStore();
52
+
53
+ const accessData : any = {
54
+ ...access,
55
+ organizations: access.organizations.map((o : any) => {
56
+ if (o.id === orgId) {
57
+ return {
58
+ ...o,
59
+ name: newOrgName
60
+ };
61
+ }
62
+
63
+ return o;
64
+ })
65
+ };
66
+
67
+ SessionService.updateSession({stories_hash: SessionService.generateOrgsHash(accessData)}, exp);
68
+ doCacheAccessData(accessData);
69
+ dispatch({type: actions.ORG_NAME_MUTATION, accessData});
70
+ };
71
+ };
72
+
49
73
  export const storyNameMutated = (storyId : string, newStoryName : string) : any => {
50
74
  return (dispatch, getStore) => {
51
75
  const {access, auth: {idTokenPayload: {exp}}, routing: {locationBeforeTransitions: {query}}} = getStore();
@@ -118,6 +142,7 @@ const actions = {
118
142
  CLEAR: 'access/CLEAR',
119
143
  STORY_ADDED: 'access/STORY_ADDED',
120
144
  STORY_NAME_MUTATION: 'access/STORY_NAME_MUTATION',
145
+ ORG_NAME_MUTATION: 'access/ORG_NAME_MUTATION',
121
146
  STORY_DELETED: 'access/STORY_DELETED'
122
147
  };
123
148
 
@@ -13,6 +13,7 @@ function access(state = initialState, action) {
13
13
  case actions.SET:
14
14
  case actions.STORY_ADDED:
15
15
  case actions.STORY_NAME_MUTATION:
16
+ case actions.ORG_NAME_MUTATION:
16
17
  case actions.STORY_DELETED:
17
18
  return {...action.accessData};
18
19
  case actions.CLEAR:
package/services/API.ts CHANGED
@@ -932,6 +932,37 @@ export default class API {
932
932
  });
933
933
  }
934
934
 
935
+ public resendInvite = (orgId : string, email : string) : Promise<any | Error> => {
936
+ return this.doRequest({
937
+ url: `/account/${orgId}/resend`,
938
+ method: 'POST',
939
+ data: {
940
+ email,
941
+ }
942
+ });
943
+ }
944
+
945
+ public revokeInvite = (orgId : string, email : string) : Promise<any | Error> => {
946
+ return this.doRequest({
947
+ url: `/account/${orgId}/revoke`,
948
+ method: 'POST',
949
+ data: {
950
+ email,
951
+ }
952
+ });
953
+ }
954
+
955
+ public updateInviteRole = (orgId : string, email : string, role : number) : Promise<any | Error> => {
956
+ return this.doRequest({
957
+ url: `/account/${orgId}/grant`,
958
+ method: 'PATCH',
959
+ data: {
960
+ email,
961
+ role_id: role
962
+ }
963
+ });
964
+ }
965
+
935
966
  public updateRole = (organizationId : string, userId : string, roleId : number) : Promise<any | Error> => {
936
967
  return this.doRequest({
937
968
  url: `/account/${organizationId}/user`,
@@ -1006,4 +1037,98 @@ export default class API {
1006
1037
  }
1007
1038
  });
1008
1039
  }
1040
+
1041
+ public updateOrgName = (orgId : string, orgName : string) : Promise<any> => {
1042
+ return this.doRequest({
1043
+ url: `/account/${orgId}`,
1044
+ method: 'PATCH',
1045
+ data: {
1046
+ name: orgName,
1047
+ }
1048
+ });
1049
+ }
1050
+
1051
+ public deleteOrg = (orgId : string) : any => {
1052
+ // return this.doRequest({
1053
+ // url: `/account/${orgId}`,
1054
+ // method: 'PATCH',
1055
+ // data: {
1056
+ // name: orgName,
1057
+ // }
1058
+ // });
1059
+ }
1060
+
1061
+ public changeOrgPlan = (orgId : string, tier : number) : Promise<any> => {
1062
+
1063
+ return this.doRequest({
1064
+ url: `/account/${orgId}`,
1065
+ method: 'PATCH',
1066
+ data: {
1067
+ tier
1068
+ }
1069
+ });
1070
+ }
1071
+
1072
+ public getAccountInfo = (orgId : string) : Promise<any> => {
1073
+
1074
+ return this.doRequest({
1075
+ url: `/account/${orgId}`,
1076
+ method: 'GET',
1077
+ });
1078
+ }
1079
+
1080
+ public cancelOrgPlan = (orgId : string) : Promise<any> => {
1081
+
1082
+ return this.doRequest({
1083
+ url: `/account/${orgId}`,
1084
+ method: 'PATCH',
1085
+ data: {
1086
+ cancel: true
1087
+ }
1088
+ });
1089
+ }
1090
+
1091
+ public getNextBillingPeriod = (orgId : string) : Promise<any> => {
1092
+
1093
+ return this.doRequest({
1094
+ url: `/account/${orgId}/next-payment`,
1095
+ method: 'GET'
1096
+ });
1097
+ }
1098
+
1099
+ public redirectToBillingPortal = (orgId : string) : Promise<any> => {
1100
+
1101
+ return this.doRequest({
1102
+ url: `/account/${orgId}/billing-portal`,
1103
+ method: 'GET',
1104
+ });
1105
+ }
1106
+
1107
+ public getAPIUsageOverview = (startDate? : number, endDate? : number) : Promise<any> => {
1108
+
1109
+ const queryString = (startDate && endDate) ? `?start=${startDate}&end=${endDate}` : '';
1110
+
1111
+ return this.doRequest({
1112
+ url: `/usage${queryString}`,
1113
+ method: 'GET',
1114
+ });
1115
+ }
1116
+
1117
+ public getUsageGraph = (metric : string, startDate : number, endDate : number) : Promise<any> => {
1118
+
1119
+ const queryString = (startDate && endDate) ? `?start=${startDate}&end=${endDate}` : '';
1120
+
1121
+ return this.doRequest({
1122
+ url: `/usage/daily/${metric}${queryString}`,
1123
+ method: 'GET',
1124
+ });
1125
+ }
1126
+
1127
+ public getBillingPeriods = () : any => {
1128
+
1129
+ return this.doRequest({
1130
+ url: `/usage/billing-periods`,
1131
+ method: 'GET',
1132
+ });
1133
+ }
1009
1134
  }