serene-core-client 0.1.1

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.
Files changed (116) hide show
  1. package/dist/index.d.ts +36 -0
  2. package/dist/index.js +36 -0
  3. package/dist/src/apollo/access.d.ts +1 -0
  4. package/dist/src/apollo/access.js +9 -0
  5. package/dist/src/apollo/mailing-lists.d.ts +2 -0
  6. package/dist/src/apollo/mailing-lists.js +33 -0
  7. package/dist/src/apollo/quotas.d.ts +1 -0
  8. package/dist/src/apollo/quotas.js +21 -0
  9. package/dist/src/apollo/techs.d.ts +1 -0
  10. package/dist/src/apollo/techs.js +15 -0
  11. package/dist/src/apollo/tips.d.ts +3 -0
  12. package/dist/src/apollo/tips.js +45 -0
  13. package/dist/src/apollo/user-preferences.d.ts +2 -0
  14. package/dist/src/apollo/user-preferences.js +32 -0
  15. package/dist/src/apollo/users.d.ts +6 -0
  16. package/dist/src/apollo/users.js +60 -0
  17. package/dist/src/components/account/profile.d.ts +8 -0
  18. package/dist/src/components/account/profile.js +137 -0
  19. package/dist/src/components/basics/copy-text-icon.d.ts +7 -0
  20. package/dist/src/components/basics/copy-text-icon.js +15 -0
  21. package/dist/src/components/basics/editable-string-list.d.ts +7 -0
  22. package/dist/src/components/basics/editable-string-list.js +41 -0
  23. package/dist/src/components/basics/json-display.d.ts +7 -0
  24. package/dist/src/components/basics/json-display.js +37 -0
  25. package/dist/src/components/basics/mui-auto-focus.d.ts +2 -0
  26. package/dist/src/components/basics/mui-auto-focus.js +16 -0
  27. package/dist/src/components/basics/text-area-field.d.ts +12 -0
  28. package/dist/src/components/basics/text-area-field.js +23 -0
  29. package/dist/src/components/basics/view-link-field.d.ts +8 -0
  30. package/dist/src/components/basics/view-link-field.js +6 -0
  31. package/dist/src/components/basics/view-markdown-field.d.ts +7 -0
  32. package/dist/src/components/basics/view-markdown-field.js +7 -0
  33. package/dist/src/components/basics/view-text-field.d.ts +7 -0
  34. package/dist/src/components/basics/view-text-field.js +6 -0
  35. package/dist/src/components/buttons/labeled-icon-button.d.ts +12 -0
  36. package/dist/src/components/buttons/labeled-icon-button.js +19 -0
  37. package/dist/src/components/css/loaders.d.ts +0 -0
  38. package/dist/src/components/css/loaders.js +1 -0
  39. package/dist/src/components/mailing-lists/sign-up.d.ts +5 -0
  40. package/dist/src/components/mailing-lists/sign-up.js +75 -0
  41. package/dist/src/components/notifications/action.d.ts +8 -0
  42. package/dist/src/components/notifications/action.js +15 -0
  43. package/dist/src/components/tech/load-techs.d.ts +7 -0
  44. package/dist/src/components/tech/load-techs.js +41 -0
  45. package/dist/src/components/tech/tech-autocomplete.d.ts +17 -0
  46. package/dist/src/components/tech/tech-autocomplete.js +15 -0
  47. package/dist/src/components/tips/load-tips.d.ts +7 -0
  48. package/dist/src/components/tips/load-tips.js +47 -0
  49. package/dist/src/components/tips/tip.d.ts +11 -0
  50. package/dist/src/components/tips/tip.js +44 -0
  51. package/dist/src/services/access/service.d.ts +26 -0
  52. package/dist/src/services/access/service.js +82 -0
  53. package/dist/src/services/locale/countries.d.ts +6 -0
  54. package/dist/src/services/locale/countries.js +481 -0
  55. package/dist/src/services/rest-api/request.d.ts +1 -0
  56. package/dist/src/services/rest-api/request.js +8 -0
  57. package/dist/src/services/rest-api/service.d.ts +21 -0
  58. package/dist/src/services/rest-api/service.js +79 -0
  59. package/dist/src/services/users/profile-service.d.ts +16 -0
  60. package/dist/src/services/users/profile-service.js +24 -0
  61. package/dist/src/services/users/user-preferences-service.d.ts +6 -0
  62. package/dist/src/services/users/user-preferences-service.js +41 -0
  63. package/dist/src/services/users/user-service.d.ts +22 -0
  64. package/dist/src/services/users/user-service.js +208 -0
  65. package/dist/src/services/utils/date.d.ts +1 -0
  66. package/dist/src/services/utils/date.js +4 -0
  67. package/dist/src/services/utils/functions.d.ts +1 -0
  68. package/dist/src/services/utils/functions.js +6 -0
  69. package/dist/src/services/utils/service.d.ts +3 -0
  70. package/dist/src/services/utils/service.js +9 -0
  71. package/dist/src/services/utils/string.d.ts +5 -0
  72. package/dist/src/services/utils/string.js +37 -0
  73. package/dist/src/services/utils/tree.d.ts +4 -0
  74. package/dist/src/services/utils/tree.js +65 -0
  75. package/dist/src/types/types.d.ts +3 -0
  76. package/dist/src/types/types.js +3 -0
  77. package/index.ts +36 -0
  78. package/package.json +32 -0
  79. package/src/apollo/access.ts +10 -0
  80. package/src/apollo/mailing-lists.ts +35 -0
  81. package/src/apollo/quotas.ts +22 -0
  82. package/src/apollo/techs.ts +16 -0
  83. package/src/apollo/tips.ts +48 -0
  84. package/src/apollo/user-preferences.ts +34 -0
  85. package/src/apollo/users.ts +66 -0
  86. package/src/components/account/profile.tsx +279 -0
  87. package/src/components/basics/copy-text-icon.tsx +34 -0
  88. package/src/components/basics/editable-string-list.tsx +97 -0
  89. package/src/components/basics/json-display.tsx +71 -0
  90. package/src/components/basics/mui-auto-focus.tsx +19 -0
  91. package/src/components/basics/text-area-field.tsx +63 -0
  92. package/src/components/basics/view-link-field.tsx +32 -0
  93. package/src/components/basics/view-markdown-field.tsx +31 -0
  94. package/src/components/basics/view-text-field.tsx +28 -0
  95. package/src/components/buttons/labeled-icon-button.tsx +53 -0
  96. package/src/components/css/loaders.tsx +0 -0
  97. package/src/components/mailing-lists/sign-up.tsx +126 -0
  98. package/src/components/notifications/action.tsx +50 -0
  99. package/src/components/tech/load-techs.tsx +66 -0
  100. package/src/components/tech/tech-autocomplete.tsx +65 -0
  101. package/src/components/tips/load-tips.tsx +75 -0
  102. package/src/components/tips/tip.tsx +96 -0
  103. package/src/services/access/service.ts +126 -0
  104. package/src/services/locale/countries.ts +483 -0
  105. package/src/services/rest-api/request.ts +10 -0
  106. package/src/services/rest-api/service.ts +130 -0
  107. package/src/services/users/profile-service.ts +28 -0
  108. package/src/services/users/user-preferences-service.ts +64 -0
  109. package/src/services/users/user-service.ts +310 -0
  110. package/src/services/utils/date.ts +6 -0
  111. package/src/services/utils/functions.ts +8 -0
  112. package/src/services/utils/service.ts +12 -0
  113. package/src/services/utils/string.ts +48 -0
  114. package/src/services/utils/tree.ts +88 -0
  115. package/src/types/types.ts +4 -0
  116. package/tsconfig.json +26 -0
@@ -0,0 +1,36 @@
1
+ export * from './src/apollo/access';
2
+ export * from './src/apollo/mailing-lists';
3
+ export * from './src/apollo/quotas';
4
+ export * from './src/apollo/techs';
5
+ export * from './src/apollo/tips';
6
+ export * from './src/apollo/user-preferences';
7
+ export * from './src/apollo/users';
8
+ export * from './src/components/account/profile';
9
+ export * from './src/components/basics/copy-text-icon';
10
+ export * from './src/components/basics/editable-string-list';
11
+ export * from './src/components/basics/json-display';
12
+ export * from './src/components/basics/mui-auto-focus';
13
+ export * from './src/components/basics/text-area-field';
14
+ export * from './src/components/basics/view-link-field';
15
+ export * from './src/components/basics/view-markdown-field';
16
+ export * from './src/components/basics/view-text-field';
17
+ export * from './src/components/buttons/labeled-icon-button';
18
+ export * from './src/components/mailing-lists/sign-up';
19
+ export * from './src/components/notifications/action';
20
+ export * from './src/components/tech/load-techs';
21
+ export * from './src/components/tech/tech-autocomplete';
22
+ export * from './src/components/tips/load-tips';
23
+ export * from './src/components/tips/tip';
24
+ export * from './src/services/access/service';
25
+ export * from './src/services/locale/countries';
26
+ export * from './src/services/rest-api/request';
27
+ export * from './src/services/rest-api/service';
28
+ export * from './src/services/users/profile-service';
29
+ export * from './src/services/users/user-preferences-service';
30
+ export * from './src/services/users/user-service';
31
+ export * from './src/services/utils/date';
32
+ export * from './src/services/utils/functions';
33
+ export * from './src/services/utils/service';
34
+ export * from './src/services/utils/string';
35
+ export * from './src/services/utils/tree';
36
+ export * from './src/types/types';
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ export * from './src/apollo/access';
2
+ export * from './src/apollo/mailing-lists';
3
+ export * from './src/apollo/quotas';
4
+ export * from './src/apollo/techs';
5
+ export * from './src/apollo/tips';
6
+ export * from './src/apollo/user-preferences';
7
+ export * from './src/apollo/users';
8
+ export * from './src/components/account/profile';
9
+ export * from './src/components/basics/copy-text-icon';
10
+ export * from './src/components/basics/editable-string-list';
11
+ export * from './src/components/basics/json-display';
12
+ export * from './src/components/basics/mui-auto-focus';
13
+ export * from './src/components/basics/text-area-field';
14
+ export * from './src/components/basics/view-link-field';
15
+ export * from './src/components/basics/view-markdown-field';
16
+ export * from './src/components/basics/view-text-field';
17
+ export * from './src/components/buttons/labeled-icon-button';
18
+ export * from './src/components/mailing-lists/sign-up';
19
+ export * from './src/components/notifications/action';
20
+ export * from './src/components/tech/load-techs';
21
+ export * from './src/components/tech/tech-autocomplete';
22
+ export * from './src/components/tips/load-tips';
23
+ export * from './src/components/tips/tip';
24
+ export * from './src/services/access/service';
25
+ export * from './src/services/locale/countries';
26
+ export * from './src/services/rest-api/request';
27
+ export * from './src/services/rest-api/service';
28
+ export * from './src/services/users/profile-service';
29
+ export * from './src/services/users/user-preferences-service';
30
+ export * from './src/services/users/user-service';
31
+ export * from './src/services/utils/date';
32
+ export * from './src/services/utils/functions';
33
+ export * from './src/services/utils/service';
34
+ export * from './src/services/utils/string';
35
+ export * from './src/services/utils/tree';
36
+ export * from './src/types/types';
@@ -0,0 +1 @@
1
+ export declare const isAdminUserQuery: import("graphql").DocumentNode;
@@ -0,0 +1,9 @@
1
+ import { gql } from '@apollo/client';
2
+ export const isAdminUserQuery = gql `
3
+ query isAdminUser($userProfileId: String!) {
4
+ isAdminUser(userProfileId: $userProfileId) {
5
+ status
6
+ message
7
+ }
8
+ }
9
+ `;
@@ -0,0 +1,2 @@
1
+ export declare const mailingListSignupMutation: import("graphql").DocumentNode;
2
+ export declare const verifySignupMutation: import("graphql").DocumentNode;
@@ -0,0 +1,33 @@
1
+ import { gql } from '@apollo/client';
2
+ export const mailingListSignupMutation = gql `
3
+ mutation mailingListSignup(
4
+ $mailingListName: String!,
5
+ $email: String!,
6
+ $firstName: String)
7
+ {
8
+ mailingListSignup(
9
+ mailingListName: $mailingListName,
10
+ email: $email,
11
+ firstName: $firstName) {
12
+
13
+ verified
14
+ message
15
+ }
16
+ }
17
+ `;
18
+ export const verifySignupMutation = gql `
19
+ mutation verifySignup(
20
+ $mailingListName: String!,
21
+ $email: String!,
22
+ $verifyCode: String)
23
+ {
24
+ verifySignup(
25
+ mailingListName: $mailingListName,
26
+ email: $email,
27
+ verifyCode: $verifyCode) {
28
+
29
+ verified
30
+ message
31
+ }
32
+ }
33
+ `;
@@ -0,0 +1 @@
1
+ export declare const getResourceQuotaUsageQuery: import("graphql").DocumentNode;
@@ -0,0 +1,21 @@
1
+ import { gql } from '@apollo/client';
2
+ export const getResourceQuotaUsageQuery = gql `
3
+ query getResourceQuotaUsage(
4
+ $userProfileId: String!,
5
+ $resource: String!,
6
+ $day: String,
7
+ $viewUserProfileId: String) {
8
+ getResourceQuotaUsage(
9
+ userProfileId: $userProfileId,
10
+ resource: $resource,
11
+ day: $day,
12
+ viewUserProfileId: $viewUserProfileId) {
13
+
14
+ userProfileId
15
+ resource
16
+ day
17
+ quota
18
+ usage
19
+ }
20
+ }
21
+ `;
@@ -0,0 +1 @@
1
+ export declare const getTechsQuery: import("graphql").DocumentNode;
@@ -0,0 +1,15 @@
1
+ import { gql } from '@apollo/client';
2
+ export const getTechsQuery = gql `
3
+ query getTechs(
4
+ $userProfileId: String!,
5
+ $resource: String!) {
6
+ getTechs(
7
+ userProfileId: $userProfileId,
8
+ resource: $resource) {
9
+
10
+ id
11
+ resource
12
+ variantName
13
+ }
14
+ }
15
+ `;
@@ -0,0 +1,3 @@
1
+ export declare const getTipsByUserProfileIdAndTagsQuery: import("graphql").DocumentNode;
2
+ export declare const tipGotItExistsQuery: import("graphql").DocumentNode;
3
+ export declare const upsertTipGotItMutation: import("graphql").DocumentNode;
@@ -0,0 +1,45 @@
1
+ import { gql } from '@apollo/client';
2
+ export const getTipsByUserProfileIdAndTagsQuery = gql `
3
+ query getTipsByUserProfileIdAndTags(
4
+ $userProfileId: String!,
5
+ $tags: [String]) {
6
+ getTipsByUserProfileIdAndTags(
7
+ userProfileId: $userProfileId,
8
+ tags: $tags) {
9
+
10
+ status
11
+ message
12
+ tips {
13
+ id
14
+ name
15
+ }
16
+ }
17
+ }
18
+ `;
19
+ export const tipGotItExistsQuery = gql `
20
+ query tipGotItExists(
21
+ $name: String!,
22
+ $userProfileId: String!) {
23
+ tipGotItExists(
24
+ name: $name,
25
+ userProfileId: $userProfileId) {
26
+
27
+ status
28
+ message
29
+ exists
30
+ }
31
+ }
32
+ `;
33
+ export const upsertTipGotItMutation = gql `
34
+ mutation upsertTipGotIt(
35
+ $name: String!,
36
+ $userProfileId: String!) {
37
+ upsertTipGotIt(
38
+ name: $name,
39
+ userProfileId: $userProfileId) {
40
+
41
+ status
42
+ message
43
+ }
44
+ }
45
+ `;
@@ -0,0 +1,2 @@
1
+ export declare const getUserPreferencesQuery: import("graphql").DocumentNode;
2
+ export declare const upsertUserPreferenceMutation: import("graphql").DocumentNode;
@@ -0,0 +1,32 @@
1
+ import { gql } from '@apollo/client';
2
+ export const getUserPreferencesQuery = gql `
3
+ query getUserPreferences(
4
+ $userProfileId: String!,
5
+ $category: String!,
6
+ $keys: [String]) {
7
+ getUserPreferences(
8
+ userProfileId: $userProfileId,
9
+ category: $category,
10
+ keys: $keys) {
11
+ category
12
+ key
13
+ value
14
+ values
15
+ }
16
+ }
17
+ `;
18
+ export const upsertUserPreferenceMutation = gql `
19
+ mutation upsertUserPreference(
20
+ $userProfileId: String!,
21
+ $category: String!,
22
+ $key: String!,
23
+ $value: String,
24
+ $values: [String]) {
25
+ upsertUserPreference(
26
+ userProfileId: $userProfileId,
27
+ category: $category,
28
+ key: $key,
29
+ value: $value,
30
+ values: $values)
31
+ }
32
+ `;
@@ -0,0 +1,6 @@
1
+ export declare const createBlankUserMutation: import("graphql").DocumentNode;
2
+ export declare const createUserByEmailMutation: import("graphql").DocumentNode;
3
+ export declare const getOrCreateSignedOutUserMutation: import("graphql").DocumentNode;
4
+ export declare const getOrCreateUserByEmailMutation: import("graphql").DocumentNode;
5
+ export declare const updateIFileCreatedByMutation: import("graphql").DocumentNode;
6
+ export declare const verifySignedInUserProfileIdQuery: import("graphql").DocumentNode;
@@ -0,0 +1,60 @@
1
+ import { gql } from '@apollo/client';
2
+ export const createBlankUserMutation = gql `
3
+ mutation createBlankUser {
4
+ createBlankUser {
5
+
6
+ id
7
+ userId
8
+ isAdmin
9
+ }
10
+ }
11
+ `;
12
+ export const createUserByEmailMutation = gql `
13
+ mutation createUserByEmail($email: String!) {
14
+ createUserByEmail(email: $email)
15
+ }
16
+ `;
17
+ export const getOrCreateSignedOutUserMutation = gql `
18
+ mutation getOrCreateSignedOutUser(
19
+ $signedOutId: String,
20
+ $defaultUserPreferences: String) {
21
+ getOrCreateSignedOutUser(
22
+ signedOutId: $signedOutId,
23
+ defaultUserPreferences: $defaultUserPreferences) {
24
+
25
+ id
26
+ userId
27
+ isAdmin
28
+ }
29
+ }
30
+ `;
31
+ export const getOrCreateUserByEmailMutation = gql `
32
+ mutation getOrCreateUserByEmail(
33
+ $email: String!,
34
+ $defaultUserPreferences: String) {
35
+ getOrCreateUserByEmail(
36
+ email: $email,
37
+ defaultUserPreferences: $defaultUserPreferences) {
38
+
39
+ id
40
+ userId
41
+ isAdmin
42
+ }
43
+ }
44
+ `;
45
+ export const updateIFileCreatedByMutation = gql `
46
+ mutation updateIFileCreatedBy(
47
+ $id: String!,
48
+ $userId: String!,
49
+ $signedOutUserId: String!) {
50
+ updateIFileCreatedBy(
51
+ id: $id,
52
+ userId: $userId,
53
+ signedOutUserId: $signedOutUserId)
54
+ }
55
+ `;
56
+ export const verifySignedInUserProfileIdQuery = gql `
57
+ query verifySignedInUserProfileId($userProfileId: String!) {
58
+ verifySignedInUserProfileId(userProfileId: $userProfileId)
59
+ }
60
+ `;
@@ -0,0 +1,8 @@
1
+ interface Props {
2
+ userProfile: any;
3
+ clientUrl: string;
4
+ serverUrl: string;
5
+ session: any;
6
+ }
7
+ export default function Profile({ userProfile, clientUrl, serverUrl, session }: Props): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,137 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { signIn, signOut } from 'next-auth/react';
3
+ import { useQuery } from '@apollo/client/react';
4
+ import Button from '@mui/material/Button';
5
+ import TextField from '@mui/material/TextField';
6
+ import Select from '@mui/material/Select';
7
+ import { useEffect, useState } from 'react';
8
+ import ActionNotification from '../notifications/action';
9
+ import { RestApiService } from '../../services/rest-api/service';
10
+ import { FormControl, InputLabel, Typography } from '@mui/material';
11
+ import { countries } from '../../services/locale/countries';
12
+ import { getUserPreferencesQuery } from '../../apollo/user-preferences';
13
+ import { ProfileService } from '../../services/users/profile-service';
14
+ export default function Profile({ userProfile, clientUrl, serverUrl, session }) {
15
+ // Consts
16
+ const personalDetails = 'personal details';
17
+ // State
18
+ const [fullName, setFullName] = useState('');
19
+ const [firstName, setFirstName] = useState('');
20
+ const [country, setCountry] = useState('United States');
21
+ const [notificationSuccessText, setNotificationSuccessText] = useState('');
22
+ const [notificationSuccessOpened, setNotificationSuccessOpened] = useState(false);
23
+ const [notificationErrorText, setNotificationErrorText] = useState('');
24
+ const [notificationErrorOpened, setNotificationErrorOpened] = useState(false);
25
+ // Services
26
+ const profileService = new ProfileService();
27
+ // GraphQL
28
+ const { refetch: fetchGetUserPreferencesQuery } = useQuery(getUserPreferencesQuery, {
29
+ fetchPolicy: 'no-cache'
30
+ /* onCompleted: data => {
31
+ console.log('attributeTypeName: ' + attributeTypeName)
32
+ console.log(data)
33
+ },
34
+ onError: error => {
35
+ console.log(error)
36
+ } */
37
+ });
38
+ // Functions
39
+ function guessFirstNameFromFullName() {
40
+ // Get first instance of a space
41
+ let firstSpace = fullName.indexOf(' ');
42
+ // The space can't be either not found or the first char, return if so.
43
+ if (firstSpace <= 0) {
44
+ return;
45
+ }
46
+ setFirstName(fullName.substring(0, firstSpace));
47
+ }
48
+ const handleSignin = (e) => {
49
+ e.preventDefault();
50
+ signIn();
51
+ };
52
+ const handleSignout = (e) => {
53
+ e.preventDefault();
54
+ signOut();
55
+ };
56
+ async function setProfile() {
57
+ const restApiService = new RestApiService(clientUrl, serverUrl);
58
+ restApiService.submit({
59
+ relativeUrl: '/api/account/profile/update',
60
+ headers: undefined,
61
+ method: undefined,
62
+ values: {
63
+ // token: token,
64
+ userProfileId: userProfile.id,
65
+ fullName: fullName,
66
+ firstName: firstName,
67
+ country: country,
68
+ },
69
+ callbackOnSuccess: undefined,
70
+ routeOnSuccess: undefined,
71
+ setSubmitDisabled: undefined,
72
+ setNotificationSuccessText: setNotificationSuccessText,
73
+ setNotificationSuccessOpened: setNotificationSuccessOpened,
74
+ setNotificationErrorText: setNotificationErrorText,
75
+ setNotificationErrorOpened: setNotificationErrorOpened
76
+ });
77
+ }
78
+ // Events
79
+ // Get profile data on load
80
+ useEffect(() => {
81
+ const fetchData = async () => {
82
+ // Get profile data
83
+ // console.log(`fetching getUserPreferencesQuery for userProfileId: ${user.id}`)
84
+ const results = await fetchGetUserPreferencesQuery({
85
+ userProfileId: userProfile.id,
86
+ category: personalDetails,
87
+ keys: [
88
+ profileService.fullName,
89
+ profileService.firstName,
90
+ profileService.countryCode,
91
+ ]
92
+ });
93
+ // Set profile data
94
+ const keyValues = results.data['getUserPreferences'];
95
+ for (const keyValue of keyValues) {
96
+ switch (keyValue.key) {
97
+ case profileService.fullName: {
98
+ setFullName(keyValue.value);
99
+ break;
100
+ }
101
+ case profileService.firstName: {
102
+ setFirstName(keyValue.value);
103
+ break;
104
+ }
105
+ case profileService.countryCode: {
106
+ setCountry(profileService.getCountryByCode(keyValue.value));
107
+ break;
108
+ }
109
+ }
110
+ }
111
+ };
112
+ if (userProfile.id !== null) {
113
+ const result = fetchData()
114
+ .catch(console.error);
115
+ }
116
+ }, [userProfile.id]);
117
+ // Render
118
+ return (_jsx(_Fragment, { children: session ?
119
+ _jsxs(_Fragment, { children: [_jsxs("p", { children: ["You're signed in: \u00A0", _jsx("span", { style: { color: 'gray', fontWeight: '600' }, children: session.user.email }), _jsxs("span", { style: { marginLeft: '1em' }, children: ["(", _jsx("a", { href: '#', onClick: handleSignout, className: 'btn-signin', children: "Sign out" }), ")"] })] }), _jsxs("form", { onSubmit: (e) => { setProfile(); e.preventDefault(); }, style: { marginTop: '2em' }, children: [_jsx(Typography, { style: { marginBottom: '1em' }, variant: 'h6', children: "Personal details" }), _jsx(Typography, { style: { marginBottom: '1em' }, variant: 'body1', children: "These fields are required and are used to personalize your experience." }), _jsx(TextField, { autoFocus: true, fullWidth: true, variant: 'outlined', label: 'Full name', value: fullName, onChange: (e) => setFullName(e.target.value), onBlur: (e) => {
120
+ if (fullName == null) {
121
+ return;
122
+ }
123
+ else if (fullName.trim() === '') {
124
+ return;
125
+ }
126
+ if (firstName == null) {
127
+ guessFirstNameFromFullName();
128
+ }
129
+ else if (firstName.trim() === '') {
130
+ guessFirstNameFromFullName();
131
+ }
132
+ }, required: true }), _jsx("br", {}), _jsx("br", {}), _jsx(TextField, { fullWidth: true, variant: 'outlined', label: 'First name', value: firstName, onChange: (e) => setFirstName(e.target.value), required: true }), _jsx("br", {}), _jsx("br", {}), _jsxs(FormControl, { fullWidth: true, children: [_jsx(InputLabel, { htmlFor: 'select-country', required: true, shrink: true, children: "Country" }), _jsx(Select, { inputProps: {
133
+ id: 'select-country',
134
+ }, label: 'Country', native: true, onChange: (e) => setCountry(e.target.value), variant: 'outlined', value: country, children: countries.map((country) => (_jsx("option", { value: country.name, children: country.name }, country.name))) })] }), _jsx("br", {}), _jsx("br", {}), _jsx(Button, { type: 'submit', variant: 'contained', style: { marginTop: '2em' }, children: "Update" })] }), _jsx(ActionNotification, { message: 'Updated.', autoHideDuration: 5000, notificationOpened: notificationSuccessOpened, setNotificationOpened: setNotificationSuccessOpened }), _jsx(ActionNotification, { message: notificationErrorText, autoHideDuration: 5000, notificationOpened: notificationErrorOpened, setNotificationOpened: setNotificationErrorOpened })] })
135
+ :
136
+ _jsxs(_Fragment, { children: [_jsx(Typography, { variant: 'body1', children: "You aren't signed in." }), _jsx("a", { href: '#', onClick: handleSignin, className: 'btn-signin', children: "Sign in" })] }) }));
137
+ }
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ text: string;
3
+ title?: string;
4
+ style?: any;
5
+ }
6
+ export default function CopyTextIcon({ text, title, style }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import ContentCopyIcon from '@mui/icons-material/ContentCopy';
3
+ import { IconButton, Tooltip } from '@mui/material';
4
+ export default function CopyTextIcon({ text, title = 'Copy', style = {} }) {
5
+ const handleCopy = async () => {
6
+ try {
7
+ await navigator.clipboard.writeText(text);
8
+ }
9
+ catch (err) {
10
+ console.error('Failed to copy: ', err);
11
+ }
12
+ };
13
+ // Render
14
+ return (_jsx(Tooltip, { style: style, title: title, children: _jsx(IconButton, { onClick: (e) => handleCopy(), size: 'small', children: _jsx(ContentCopyIcon, { fontSize: 'small' }) }) }));
15
+ }
@@ -0,0 +1,7 @@
1
+ export interface Props {
2
+ label: string;
3
+ values: string[];
4
+ setValues?: any;
5
+ onChange?: any;
6
+ }
7
+ export default function EditableStringList({ label, values, setValues, onChange }: Props): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { TextField, List, ListItem, ListItemText, IconButton, Stack } from '@mui/material';
4
+ import { Add, Check, Delete, Edit } from '@mui/icons-material';
5
+ export default function EditableStringList({ label, values, setValues, onChange }) {
6
+ const [input, setInput] = useState('');
7
+ const [editIndex, setEditIndex] = useState(null);
8
+ const updateItems = (newItems) => {
9
+ setValues?.(newItems);
10
+ onChange?.(newItems);
11
+ };
12
+ const handleAddOrUpdate = () => {
13
+ if (input.trim() === '')
14
+ return;
15
+ if (editIndex !== null) {
16
+ const updated = [...values];
17
+ updated[editIndex] = input.trim();
18
+ updateItems(updated.sort());
19
+ setEditIndex(null);
20
+ }
21
+ else {
22
+ updateItems([...values, input.trim()].sort());
23
+ }
24
+ setInput('');
25
+ };
26
+ const handleEdit = (index) => {
27
+ setInput(values[index]);
28
+ setEditIndex(index);
29
+ };
30
+ const handleDelete = (index) => {
31
+ setValues(values.filter((_, i) => i !== index));
32
+ if (editIndex === index) {
33
+ setInput('');
34
+ setEditIndex(null);
35
+ }
36
+ };
37
+ return (_jsxs(Stack, { spacing: 2, children: [_jsxs(Stack, { direction: 'row', spacing: 1, children: [_jsx(TextField, { autoComplete: 'off', label: label, value: input, onChange: (e) => setInput(e.target.value), fullWidth: true }), _jsx(IconButton, { edge: 'end', onClick: () => handleAddOrUpdate(), children: editIndex !== null ?
38
+ _jsx(Check, {})
39
+ :
40
+ _jsx(Add, {}) })] }), _jsx(List, { children: values.map((item, index) => (_jsx(ListItem, { secondaryAction: _jsxs(_Fragment, { children: [_jsx(IconButton, { edge: 'end', onClick: () => handleEdit(index), children: _jsx(Edit, {}) }), _jsx(IconButton, { edge: 'end', onClick: () => handleDelete(index), children: _jsx(Delete, {}) })] }), children: _jsx(ListItemText, { primary: item }) }, index))) })] }));
41
+ }
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ str: string;
3
+ format?: boolean;
4
+ minified?: boolean;
5
+ }
6
+ export declare function JsonDisplay({ str, format, minified }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { Box, IconButton } from '@mui/material';
4
+ import AddIcon from '@mui/icons-material/Add';
5
+ import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter';
6
+ import { oneLight } from 'react-syntax-highlighter/dist/cjs/styles/prism';
7
+ export function JsonDisplay({ str, format = false, minified = false }) {
8
+ const [isMinified, setIsMinified] = useState(minified);
9
+ return (_jsxs(Box, { sx: { position: 'relative' }, children: [_jsx(Box, { component: 'pre', sx: {
10
+ fontFamily: 'monospace',
11
+ fontSize: '0.875rem',
12
+ whiteSpace: 'pre-wrap',
13
+ wordBreak: 'break-word',
14
+ position: 'relative',
15
+ maxHeight: isMinified ? '5rem' : 'none',
16
+ overflow: 'hidden',
17
+ '&::after': isMinified ? {
18
+ content: '""',
19
+ position: 'absolute',
20
+ bottom: 0,
21
+ left: 0,
22
+ right: 0,
23
+ height: '2rem',
24
+ background: 'linear-gradient(to bottom, transparent, white)',
25
+ pointerEvents: 'none'
26
+ } : {}
27
+ }, children: _jsx(SyntaxHighlighter, { style: oneLight, language: 'js', wrapLongLines: true, children: format === true ? JSON.stringify(JSON.parse(str), null, 2) : str }) }), isMinified && (_jsx(IconButton, { onClick: () => setIsMinified(false), sx: {
28
+ position: 'absolute',
29
+ bottom: 4,
30
+ right: 4,
31
+ backgroundColor: 'white',
32
+ boxShadow: 1,
33
+ '&:hover': {
34
+ backgroundColor: 'grey.100'
35
+ }
36
+ }, size: 'small', children: _jsx(AddIcon, { fontSize: 'small' }) }))] }));
37
+ }
@@ -0,0 +1,2 @@
1
+ import { InputProps as StandardInputProps } from '@mui/material/Input';
2
+ export declare const autoFocusInputProps: () => StandardInputProps;
@@ -0,0 +1,16 @@
1
+ export const autoFocusInputProps = () => {
2
+ return {
3
+ inputRef: (input) => {
4
+ if (input) {
5
+ input.focus();
6
+ }
7
+ },
8
+ };
9
+ };
10
+ /* Example usage:
11
+
12
+ <TextField
13
+ ...
14
+ InputProps={autoFocusInputProps()} />
15
+
16
+ */
@@ -0,0 +1,12 @@
1
+ interface Props {
2
+ disabled?: boolean;
3
+ id: string;
4
+ label: string;
5
+ minRows: number;
6
+ onChange: any;
7
+ required?: boolean;
8
+ value: string;
9
+ style?: any;
10
+ }
11
+ export default function TextAreaField({ disabled, id, label, minRows, onChange, required, value, style }: Props): import("react/jsx-runtime").JSX.Element;
12
+ export {};