@saasquatch/mint-components 2.1.8-8 → 2.1.8-9
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/dist/cjs/{ShadowViewAddon-032ec191.js → ShadowViewAddon-64549c19.js} +31 -28
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mint-components.cjs.js +1 -1
- package/dist/cjs/sqm-big-stat_45.cjs.entry.js +17 -17
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +9 -9
- package/dist/collection/components/sqm-share-link/ShareLink.stories.js +6 -6
- package/dist/collection/components/sqm-share-link/sqm-share-link-view.js +1 -1
- package/dist/collection/components/sqm-share-link/sqm-share-link.js +39 -39
- package/dist/collection/components/sqm-share-link/useShareLink.js +29 -27
- package/dist/esm/{ShadowViewAddon-c416da17.js → ShadowViewAddon-c6a80259.js} +32 -29
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mint-components.js +1 -1
- package/dist/esm/sqm-big-stat_45.entry.js +17 -17
- package/dist/esm/sqm-stencilbook.entry.js +9 -9
- package/dist/esm-es5/ShadowViewAddon-c6a80259.js +1 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mint-components.js +1 -1
- package/dist/esm-es5/sqm-big-stat_45.entry.js +1 -1
- package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/p-29545716.js +503 -0
- package/dist/mint-components/p-37619dff.system.js +1 -0
- package/dist/mint-components/{p-f81a82ef.system.entry.js → p-68a350d0.system.entry.js} +1 -1
- package/dist/mint-components/{p-fae169d4.system.entry.js → p-6f114e7e.system.entry.js} +1 -1
- package/dist/mint-components/{p-b2d6964f.entry.js → p-8c8b9246.entry.js} +2 -2
- package/dist/mint-components/{p-ac41bf4f.entry.js → p-b9b132d5.entry.js} +2 -2
- package/dist/mint-components/p-ca098be1.system.js +1 -1
- package/dist/types/components/sqm-share-link/ShareLink.stories.d.ts +2 -2
- package/dist/types/components/sqm-share-link/sqm-share-link-view.d.ts +1 -1
- package/dist/types/components/sqm-share-link/sqm-share-link.d.ts +16 -16
- package/dist/types/components/sqm-share-link/useShareLink.d.ts +6 -6
- package/dist/types/components.d.ts +46 -46
- package/docs/docs.docx +0 -0
- package/docs/raisins.json +1 -1
- package/grapesjs/grapesjs.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/ShadowViewAddon-c416da17.js +0 -1
- package/dist/mint-components/p-79d1f59e.js +0 -503
- package/dist/mint-components/p-d9d0cc60.system.js +0 -1
|
@@ -173,33 +173,33 @@ export const CustomizeUrlValidationError = () => {
|
|
|
173
173
|
editValue: "nvoiwb18",
|
|
174
174
|
charactersRemaining: 7,
|
|
175
175
|
validationError: {
|
|
176
|
-
code: "
|
|
176
|
+
code: "EXISTING_CODE_CONFLICT",
|
|
177
177
|
title: "This link is already taken",
|
|
178
178
|
description: "Try adding numbers, a dash or underscore to create a unique link.",
|
|
179
179
|
},
|
|
180
180
|
})));
|
|
181
181
|
};
|
|
182
|
-
export const
|
|
182
|
+
export const CustomizeUrlInvalidCharacters = () => {
|
|
183
183
|
return (h(ShareLinkView, Object.assign({}, {
|
|
184
184
|
...defaultCustomizeProps,
|
|
185
185
|
isEditing: true,
|
|
186
186
|
editValue: "nvoiwb18",
|
|
187
187
|
charactersRemaining: 7,
|
|
188
188
|
validationError: {
|
|
189
|
-
code: "
|
|
189
|
+
code: "INVALID_CHARACTERS",
|
|
190
190
|
title: "Please use only letters, numbers, dashes and underscores",
|
|
191
|
-
description: "Special
|
|
191
|
+
description: "Special characters can break the link when sharing.",
|
|
192
192
|
},
|
|
193
193
|
})));
|
|
194
194
|
};
|
|
195
|
-
export const
|
|
195
|
+
export const CustomizeUrlProfanity = () => {
|
|
196
196
|
return (h(ShareLinkView, Object.assign({}, {
|
|
197
197
|
...defaultCustomizeProps,
|
|
198
198
|
isEditing: true,
|
|
199
199
|
editValue: "nvoiwb18",
|
|
200
200
|
charactersRemaining: 7,
|
|
201
201
|
validationError: {
|
|
202
|
-
code: "
|
|
202
|
+
code: "PROFANITY",
|
|
203
203
|
title: "Please try a different link",
|
|
204
204
|
description: "This link contains a restricted word.",
|
|
205
205
|
},
|
|
@@ -129,7 +129,7 @@ export function ShareLinkView(props) {
|
|
|
129
129
|
};
|
|
130
130
|
const sheet = createStyleSheet(style);
|
|
131
131
|
const styleString = sheet.toString();
|
|
132
|
-
const errorMessageType = (validationError === null || validationError === void 0 ? void 0 : validationError.code) === "
|
|
132
|
+
const errorMessageType = (validationError === null || validationError === void 0 ? void 0 : validationError.code) === "EXISTING_CODE_CONFLICT" ? "info" : "warning";
|
|
133
133
|
const showCharactersRemaining = charactersRemaining <= 7;
|
|
134
134
|
// Editing state
|
|
135
135
|
if (isEditing) {
|
|
@@ -96,45 +96,45 @@ export class ShareLink {
|
|
|
96
96
|
/**
|
|
97
97
|
* Title text shown when the custom link is already taken
|
|
98
98
|
*
|
|
99
|
-
* @uiName
|
|
99
|
+
* @uiName Existing code conflict error title
|
|
100
100
|
* @uiType string
|
|
101
101
|
*/
|
|
102
|
-
this.
|
|
102
|
+
this.existingCodeConflictErrorTitle = "This link is already taken";
|
|
103
103
|
/**
|
|
104
104
|
* Description text shown when the custom link is already taken
|
|
105
105
|
*
|
|
106
|
-
* @uiName
|
|
106
|
+
* @uiName Existing code conflict error description
|
|
107
107
|
* @uiType string
|
|
108
108
|
*/
|
|
109
|
-
this.
|
|
109
|
+
this.existingCodeConflictErrorDescription = "Try adding numbers, a dash or underscore to create a unique link.";
|
|
110
110
|
/**
|
|
111
|
-
* Title text shown when the link contains invalid
|
|
111
|
+
* Title text shown when the link contains invalid characters
|
|
112
112
|
*
|
|
113
|
-
* @uiName Invalid
|
|
113
|
+
* @uiName Invalid characters error title
|
|
114
114
|
* @uiType string
|
|
115
115
|
*/
|
|
116
|
-
this.
|
|
116
|
+
this.invalidCharactersErrorTitle = "Please use only letters, numbers, dashes and underscores";
|
|
117
117
|
/**
|
|
118
|
-
* Description text shown when the link contains invalid
|
|
118
|
+
* Description text shown when the link contains invalid characters
|
|
119
119
|
*
|
|
120
|
-
* @uiName Invalid
|
|
120
|
+
* @uiName Invalid characters error description
|
|
121
121
|
* @uiType string
|
|
122
122
|
*/
|
|
123
|
-
this.
|
|
123
|
+
this.invalidCharactersErrorDescription = "Special characters can break the link when sharing.";
|
|
124
124
|
/**
|
|
125
|
-
* Title text shown when the link contains
|
|
125
|
+
* Title text shown when the link contains profanity
|
|
126
126
|
*
|
|
127
|
-
* @uiName
|
|
127
|
+
* @uiName Profanity error title
|
|
128
128
|
* @uiType string
|
|
129
129
|
*/
|
|
130
|
-
this.
|
|
130
|
+
this.profanityErrorTitle = "Please try a different link";
|
|
131
131
|
/**
|
|
132
|
-
* Description text shown when the link contains
|
|
132
|
+
* Description text shown when the link contains profanity
|
|
133
133
|
*
|
|
134
|
-
* @uiName
|
|
134
|
+
* @uiName Profanity error description
|
|
135
135
|
* @uiType string
|
|
136
136
|
*/
|
|
137
|
-
this.
|
|
137
|
+
this.profanityErrorDescription = "This link contains a restricted word.";
|
|
138
138
|
/**
|
|
139
139
|
* Text describing the edit limit
|
|
140
140
|
*
|
|
@@ -594,7 +594,7 @@ export class ShareLink {
|
|
|
594
594
|
"reflect": false,
|
|
595
595
|
"defaultValue": "\"Link updated successfully\""
|
|
596
596
|
},
|
|
597
|
-
"
|
|
597
|
+
"existingCodeConflictErrorTitle": {
|
|
598
598
|
"type": "string",
|
|
599
599
|
"mutable": false,
|
|
600
600
|
"complexType": {
|
|
@@ -606,7 +606,7 @@ export class ShareLink {
|
|
|
606
606
|
"optional": true,
|
|
607
607
|
"docs": {
|
|
608
608
|
"tags": [{
|
|
609
|
-
"text": "
|
|
609
|
+
"text": "Existing code conflict error title",
|
|
610
610
|
"name": "uiName"
|
|
611
611
|
}, {
|
|
612
612
|
"text": "string",
|
|
@@ -614,11 +614,11 @@ export class ShareLink {
|
|
|
614
614
|
}],
|
|
615
615
|
"text": "Title text shown when the custom link is already taken"
|
|
616
616
|
},
|
|
617
|
-
"attribute": "
|
|
617
|
+
"attribute": "existing-code-conflict-error-title",
|
|
618
618
|
"reflect": false,
|
|
619
619
|
"defaultValue": "\"This link is already taken\""
|
|
620
620
|
},
|
|
621
|
-
"
|
|
621
|
+
"existingCodeConflictErrorDescription": {
|
|
622
622
|
"type": "string",
|
|
623
623
|
"mutable": false,
|
|
624
624
|
"complexType": {
|
|
@@ -630,7 +630,7 @@ export class ShareLink {
|
|
|
630
630
|
"optional": true,
|
|
631
631
|
"docs": {
|
|
632
632
|
"tags": [{
|
|
633
|
-
"text": "
|
|
633
|
+
"text": "Existing code conflict error description",
|
|
634
634
|
"name": "uiName"
|
|
635
635
|
}, {
|
|
636
636
|
"text": "string",
|
|
@@ -638,11 +638,11 @@ export class ShareLink {
|
|
|
638
638
|
}],
|
|
639
639
|
"text": "Description text shown when the custom link is already taken"
|
|
640
640
|
},
|
|
641
|
-
"attribute": "
|
|
641
|
+
"attribute": "existing-code-conflict-error-description",
|
|
642
642
|
"reflect": false,
|
|
643
643
|
"defaultValue": "\"Try adding numbers, a dash or underscore to create a unique link.\""
|
|
644
644
|
},
|
|
645
|
-
"
|
|
645
|
+
"invalidCharactersErrorTitle": {
|
|
646
646
|
"type": "string",
|
|
647
647
|
"mutable": false,
|
|
648
648
|
"complexType": {
|
|
@@ -654,19 +654,19 @@ export class ShareLink {
|
|
|
654
654
|
"optional": true,
|
|
655
655
|
"docs": {
|
|
656
656
|
"tags": [{
|
|
657
|
-
"text": "Invalid
|
|
657
|
+
"text": "Invalid characters error title",
|
|
658
658
|
"name": "uiName"
|
|
659
659
|
}, {
|
|
660
660
|
"text": "string",
|
|
661
661
|
"name": "uiType"
|
|
662
662
|
}],
|
|
663
|
-
"text": "Title text shown when the link contains invalid
|
|
663
|
+
"text": "Title text shown when the link contains invalid characters"
|
|
664
664
|
},
|
|
665
|
-
"attribute": "invalid-
|
|
665
|
+
"attribute": "invalid-characters-error-title",
|
|
666
666
|
"reflect": false,
|
|
667
667
|
"defaultValue": "\"Please use only letters, numbers, dashes and underscores\""
|
|
668
668
|
},
|
|
669
|
-
"
|
|
669
|
+
"invalidCharactersErrorDescription": {
|
|
670
670
|
"type": "string",
|
|
671
671
|
"mutable": false,
|
|
672
672
|
"complexType": {
|
|
@@ -678,19 +678,19 @@ export class ShareLink {
|
|
|
678
678
|
"optional": true,
|
|
679
679
|
"docs": {
|
|
680
680
|
"tags": [{
|
|
681
|
-
"text": "Invalid
|
|
681
|
+
"text": "Invalid characters error description",
|
|
682
682
|
"name": "uiName"
|
|
683
683
|
}, {
|
|
684
684
|
"text": "string",
|
|
685
685
|
"name": "uiType"
|
|
686
686
|
}],
|
|
687
|
-
"text": "Description text shown when the link contains invalid
|
|
687
|
+
"text": "Description text shown when the link contains invalid characters"
|
|
688
688
|
},
|
|
689
|
-
"attribute": "invalid-
|
|
689
|
+
"attribute": "invalid-characters-error-description",
|
|
690
690
|
"reflect": false,
|
|
691
|
-
"defaultValue": "\"Special
|
|
691
|
+
"defaultValue": "\"Special characters can break the link when sharing.\""
|
|
692
692
|
},
|
|
693
|
-
"
|
|
693
|
+
"profanityErrorTitle": {
|
|
694
694
|
"type": "string",
|
|
695
695
|
"mutable": false,
|
|
696
696
|
"complexType": {
|
|
@@ -702,19 +702,19 @@ export class ShareLink {
|
|
|
702
702
|
"optional": true,
|
|
703
703
|
"docs": {
|
|
704
704
|
"tags": [{
|
|
705
|
-
"text": "
|
|
705
|
+
"text": "Profanity error title",
|
|
706
706
|
"name": "uiName"
|
|
707
707
|
}, {
|
|
708
708
|
"text": "string",
|
|
709
709
|
"name": "uiType"
|
|
710
710
|
}],
|
|
711
|
-
"text": "Title text shown when the link contains
|
|
711
|
+
"text": "Title text shown when the link contains profanity"
|
|
712
712
|
},
|
|
713
|
-
"attribute": "
|
|
713
|
+
"attribute": "profanity-error-title",
|
|
714
714
|
"reflect": false,
|
|
715
715
|
"defaultValue": "\"Please try a different link\""
|
|
716
716
|
},
|
|
717
|
-
"
|
|
717
|
+
"profanityErrorDescription": {
|
|
718
718
|
"type": "string",
|
|
719
719
|
"mutable": false,
|
|
720
720
|
"complexType": {
|
|
@@ -726,15 +726,15 @@ export class ShareLink {
|
|
|
726
726
|
"optional": true,
|
|
727
727
|
"docs": {
|
|
728
728
|
"tags": [{
|
|
729
|
-
"text": "
|
|
729
|
+
"text": "Profanity error description",
|
|
730
730
|
"name": "uiName"
|
|
731
731
|
}, {
|
|
732
732
|
"text": "string",
|
|
733
733
|
"name": "uiType"
|
|
734
734
|
}],
|
|
735
|
-
"text": "Description text shown when the link contains
|
|
735
|
+
"text": "Description text shown when the link contains profanity"
|
|
736
736
|
},
|
|
737
|
-
"attribute": "
|
|
737
|
+
"attribute": "profanity-error-description",
|
|
738
738
|
"reflect": false,
|
|
739
739
|
"defaultValue": "\"This link contains a restricted word.\""
|
|
740
740
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEngagementMedium, useMutation, useParentValue, useProgramId, useQuery, useUserIdentity, } from "@saasquatch/component-boilerplate";
|
|
1
|
+
import { useEngagementMedium, useLazyQuery, useMutation, useParentValue, useProgramId, useQuery, useUserIdentity, } from "@saasquatch/component-boilerplate";
|
|
2
2
|
import { useRef, useState } from "@saasquatch/universal-hooks";
|
|
3
3
|
import { gql } from "graphql-request";
|
|
4
4
|
import { REFERRAL_CODES_NAMESPACE, SET_CODE_COPIED, } from "../sqm-referral-codes/useReferralCodes";
|
|
@@ -35,12 +35,11 @@ const ADD_SHARE_LINK_CODE = gql `
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
`;
|
|
38
|
-
// TODO: Replace with actual validation query when backend is ready
|
|
39
38
|
const VALIDATE_LINK_CODE = gql `
|
|
40
|
-
query validateLinkCode($linkCode: String
|
|
41
|
-
|
|
39
|
+
query validateLinkCode($linkCode: String!) {
|
|
40
|
+
validateLinkCode(linkCode: $linkCode) {
|
|
42
41
|
valid
|
|
43
|
-
|
|
42
|
+
invalidReason
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
`;
|
|
@@ -53,7 +52,6 @@ const GET_LINK_DOMAIN = gql `
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
`;
|
|
56
|
-
// TODO: Replace with actual edit count query when backend is ready
|
|
57
55
|
const SHARE_LINK_EDIT_COUNT = gql `
|
|
58
56
|
query shareLinkEditCount {
|
|
59
57
|
viewer {
|
|
@@ -97,8 +95,8 @@ export function useShareLink(props) {
|
|
|
97
95
|
const [sendLoadEvent] = useMutation(WIDGET_ENGAGEMENT_EVENT);
|
|
98
96
|
const [setCopied] = useMutation(SET_CODE_COPIED);
|
|
99
97
|
const [addShareLinkCode, { loading: isSaving }] = useMutation(ADD_SHARE_LINK_CODE);
|
|
98
|
+
const [validateLinkCode] = useLazyQuery(VALIDATE_LINK_CODE);
|
|
100
99
|
const { data: linkDomainData } = useQuery(GET_LINK_DOMAIN, {}, !(user === null || user === void 0 ? void 0 : user.jwt) || !props.customizeUrl);
|
|
101
|
-
// TODO: Wire up when backend query is ready
|
|
102
100
|
const { data: editCountData } = useQuery(SHARE_LINK_EDIT_COUNT, {}, !(user === null || user === void 0 ? void 0 : user.jwt) || !props.customizeUrl);
|
|
103
101
|
const copyString = (_b = ((contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) || ((_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.shareLink))) !== null && _b !== void 0 ? _b :
|
|
104
102
|
// Shown during loading
|
|
@@ -112,9 +110,7 @@ export function useShareLink(props) {
|
|
|
112
110
|
const debounceTimerRef = useRef(undefined);
|
|
113
111
|
const domainPrefix = parseDomainPrefix(copyString);
|
|
114
112
|
const hasPrimaryLinkDomain = ((_c = linkDomainData === null || linkDomainData === void 0 ? void 0 : linkDomainData.tenantSettings) === null || _c === void 0 ? void 0 : _c.primaryLinkDomain) != null;
|
|
115
|
-
|
|
116
|
-
// const customizeDisabled = !hasPrimaryLinkDomain;
|
|
117
|
-
const customizeDisabled = false;
|
|
113
|
+
const customizeDisabled = !hasPrimaryLinkDomain;
|
|
118
114
|
const vanityCount = (_g = (_f = (_e = (_d = editCountData === null || editCountData === void 0 ? void 0 : editCountData.viewer) === null || _d === void 0 ? void 0 : _d.shareLinkCodes) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.filter((code) => code.isVanity).length) !== null && _g !== void 0 ? _g : 0;
|
|
119
115
|
const editCount = vanityCount;
|
|
120
116
|
const editsRemaining = Math.max(0, MAX_EDITS - editCount);
|
|
@@ -123,20 +119,20 @@ export function useShareLink(props) {
|
|
|
123
119
|
if (!errorCode)
|
|
124
120
|
return null;
|
|
125
121
|
const errorMap = {
|
|
126
|
-
|
|
127
|
-
code: "
|
|
128
|
-
title: props.
|
|
129
|
-
description: props.
|
|
122
|
+
EXISTING_CODE_CONFLICT: {
|
|
123
|
+
code: "EXISTING_CODE_CONFLICT",
|
|
124
|
+
title: props.existingCodeConflictErrorTitle,
|
|
125
|
+
description: props.existingCodeConflictErrorDescription,
|
|
130
126
|
},
|
|
131
|
-
|
|
132
|
-
code: "
|
|
133
|
-
title: props.
|
|
134
|
-
description: props.
|
|
127
|
+
INVALID_CHARACTERS: {
|
|
128
|
+
code: "INVALID_CHARACTERS",
|
|
129
|
+
title: props.invalidCharactersErrorTitle,
|
|
130
|
+
description: props.invalidCharactersErrorDescription,
|
|
135
131
|
},
|
|
136
|
-
|
|
137
|
-
code: "
|
|
138
|
-
title: props.
|
|
139
|
-
description: props.
|
|
132
|
+
PROFANITY: {
|
|
133
|
+
code: "PROFANITY",
|
|
134
|
+
title: props.profanityErrorTitle,
|
|
135
|
+
description: props.profanityErrorDescription,
|
|
140
136
|
},
|
|
141
137
|
};
|
|
142
138
|
return errorMap[errorCode];
|
|
@@ -183,11 +179,17 @@ export function useShareLink(props) {
|
|
|
183
179
|
}
|
|
184
180
|
setIsValidating(true);
|
|
185
181
|
debounceTimerRef.current = setTimeout(async () => {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
182
|
+
var _a, _b;
|
|
183
|
+
try {
|
|
184
|
+
const result = await validateLinkCode({ linkCode: trimmed });
|
|
185
|
+
if (!((_a = result === null || result === void 0 ? void 0 : result.validateLinkCode) === null || _a === void 0 ? void 0 : _a.valid)) {
|
|
186
|
+
const reason = (_b = result === null || result === void 0 ? void 0 : result.validateLinkCode) === null || _b === void 0 ? void 0 : _b.invalidReason;
|
|
187
|
+
setValidationError(mapErrorCodeToInfo(reason));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
// Validation query failed — don't block the user
|
|
192
|
+
}
|
|
191
193
|
setIsValidating(false);
|
|
192
194
|
}, 2000);
|
|
193
195
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h, c as Host, d as getAssetPath, F as Fragment, g as getElement } from './index-38ad4957.js';
|
|
2
2
|
import { i as intl } from './global-96c14d63.js';
|
|
3
3
|
import { b as browser, u as useMemo, k as useState, m as useRef } from './dom-context-hooks.module-50442785.js';
|
|
4
|
-
import { H, L, J, d as dist, w as wn, B, F as Fn, $ as $e, g as getEnvironmentSDK } from './index.module-b23fdad8.js';
|
|
4
|
+
import { H, L, J, d as dist, w as wn, B, F as Fn, $ as $e, g as getEnvironmentSDK, X as Xe } from './index.module-b23fdad8.js';
|
|
5
5
|
import { c as cjs } from './cjs-bdfb4486.js';
|
|
6
6
|
import { l as luxonLocale } from './utils-334c1e34.js';
|
|
7
7
|
import { c as createStyleSheet, j as jss, a as create } from './JSS-67b5cff8.js';
|
|
@@ -4354,7 +4354,7 @@ function ShareLinkView(props) {
|
|
|
4354
4354
|
};
|
|
4355
4355
|
const sheet = createStyleSheet(style);
|
|
4356
4356
|
const styleString = sheet.toString();
|
|
4357
|
-
const errorMessageType = (validationError === null || validationError === void 0 ? void 0 : validationError.code) === "
|
|
4357
|
+
const errorMessageType = (validationError === null || validationError === void 0 ? void 0 : validationError.code) === "EXISTING_CODE_CONFLICT" ? "info" : "warning";
|
|
4358
4358
|
const showCharactersRemaining = charactersRemaining <= 7;
|
|
4359
4359
|
// Editing state
|
|
4360
4360
|
if (isEditing) {
|
|
@@ -4430,12 +4430,11 @@ const ADD_SHARE_LINK_CODE = dist.gql `
|
|
|
4430
4430
|
}
|
|
4431
4431
|
}
|
|
4432
4432
|
`;
|
|
4433
|
-
// TODO: Replace with actual validation query when backend is ready
|
|
4434
4433
|
const VALIDATE_LINK_CODE = dist.gql `
|
|
4435
|
-
query validateLinkCode($linkCode: String
|
|
4436
|
-
|
|
4434
|
+
query validateLinkCode($linkCode: String!) {
|
|
4435
|
+
validateLinkCode(linkCode: $linkCode) {
|
|
4437
4436
|
valid
|
|
4438
|
-
|
|
4437
|
+
invalidReason
|
|
4439
4438
|
}
|
|
4440
4439
|
}
|
|
4441
4440
|
`;
|
|
@@ -4448,7 +4447,6 @@ const GET_LINK_DOMAIN = dist.gql `
|
|
|
4448
4447
|
}
|
|
4449
4448
|
}
|
|
4450
4449
|
`;
|
|
4451
|
-
// TODO: Replace with actual edit count query when backend is ready
|
|
4452
4450
|
const SHARE_LINK_EDIT_COUNT = dist.gql `
|
|
4453
4451
|
query shareLinkEditCount {
|
|
4454
4452
|
viewer {
|
|
@@ -4483,7 +4481,7 @@ function parsePathSuffix(url) {
|
|
|
4483
4481
|
}
|
|
4484
4482
|
}
|
|
4485
4483
|
function useShareLink(props) {
|
|
4486
|
-
var _a, _b, _d, _e, _f, _g;
|
|
4484
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4487
4485
|
const { programId = H() } = props;
|
|
4488
4486
|
const user = J();
|
|
4489
4487
|
const engagementMedium = B();
|
|
@@ -4492,8 +4490,8 @@ function useShareLink(props) {
|
|
|
4492
4490
|
const [sendLoadEvent] = $e(WIDGET_ENGAGEMENT_EVENT);
|
|
4493
4491
|
const [setCopied] = $e(SET_CODE_COPIED);
|
|
4494
4492
|
const [addShareLinkCode, { loading: isSaving }] = $e(ADD_SHARE_LINK_CODE);
|
|
4493
|
+
const [validateLinkCode] = Xe(VALIDATE_LINK_CODE);
|
|
4495
4494
|
const { data: linkDomainData } = wn(GET_LINK_DOMAIN, {}, !(user === null || user === void 0 ? void 0 : user.jwt) || !props.customizeUrl);
|
|
4496
|
-
// TODO: Wire up when backend query is ready
|
|
4497
4495
|
const { data: editCountData } = wn(SHARE_LINK_EDIT_COUNT, {}, !(user === null || user === void 0 ? void 0 : user.jwt) || !props.customizeUrl);
|
|
4498
4496
|
const copyString = (_b = ((contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) || ((_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.shareLink))) !== null && _b !== void 0 ? _b :
|
|
4499
4497
|
// Shown during loading
|
|
@@ -4506,9 +4504,8 @@ function useShareLink(props) {
|
|
|
4506
4504
|
const [showSuccess, setShowSuccess] = useState(false);
|
|
4507
4505
|
const debounceTimerRef = useRef(undefined);
|
|
4508
4506
|
const domainPrefix = parseDomainPrefix(copyString);
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
const customizeDisabled = false;
|
|
4507
|
+
const hasPrimaryLinkDomain = ((_c = linkDomainData === null || linkDomainData === void 0 ? void 0 : linkDomainData.tenantSettings) === null || _c === void 0 ? void 0 : _c.primaryLinkDomain) != null;
|
|
4508
|
+
const customizeDisabled = !hasPrimaryLinkDomain;
|
|
4512
4509
|
const vanityCount = (_g = (_f = (_e = (_d = editCountData === null || editCountData === void 0 ? void 0 : editCountData.viewer) === null || _d === void 0 ? void 0 : _d.shareLinkCodes) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.filter((code) => code.isVanity).length) !== null && _g !== void 0 ? _g : 0;
|
|
4513
4510
|
const editCount = vanityCount;
|
|
4514
4511
|
const editsRemaining = Math.max(0, MAX_EDITS - editCount);
|
|
@@ -4517,20 +4514,20 @@ function useShareLink(props) {
|
|
|
4517
4514
|
if (!errorCode)
|
|
4518
4515
|
return null;
|
|
4519
4516
|
const errorMap = {
|
|
4520
|
-
|
|
4521
|
-
code: "
|
|
4522
|
-
title: props.
|
|
4523
|
-
description: props.
|
|
4517
|
+
EXISTING_CODE_CONFLICT: {
|
|
4518
|
+
code: "EXISTING_CODE_CONFLICT",
|
|
4519
|
+
title: props.existingCodeConflictErrorTitle,
|
|
4520
|
+
description: props.existingCodeConflictErrorDescription,
|
|
4524
4521
|
},
|
|
4525
|
-
|
|
4526
|
-
code: "
|
|
4527
|
-
title: props.
|
|
4528
|
-
description: props.
|
|
4522
|
+
INVALID_CHARACTERS: {
|
|
4523
|
+
code: "INVALID_CHARACTERS",
|
|
4524
|
+
title: props.invalidCharactersErrorTitle,
|
|
4525
|
+
description: props.invalidCharactersErrorDescription,
|
|
4529
4526
|
},
|
|
4530
|
-
|
|
4531
|
-
code: "
|
|
4532
|
-
title: props.
|
|
4533
|
-
description: props.
|
|
4527
|
+
PROFANITY: {
|
|
4528
|
+
code: "PROFANITY",
|
|
4529
|
+
title: props.profanityErrorTitle,
|
|
4530
|
+
description: props.profanityErrorDescription,
|
|
4534
4531
|
},
|
|
4535
4532
|
};
|
|
4536
4533
|
return errorMap[errorCode];
|
|
@@ -4577,11 +4574,17 @@ function useShareLink(props) {
|
|
|
4577
4574
|
}
|
|
4578
4575
|
setIsValidating(true);
|
|
4579
4576
|
debounceTimerRef.current = setTimeout(async () => {
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4577
|
+
var _a, _b;
|
|
4578
|
+
try {
|
|
4579
|
+
const result = await validateLinkCode({ linkCode: trimmed });
|
|
4580
|
+
if (!((_a = result === null || result === void 0 ? void 0 : result.validateLinkCode) === null || _a === void 0 ? void 0 : _a.valid)) {
|
|
4581
|
+
const reason = (_b = result === null || result === void 0 ? void 0 : result.validateLinkCode) === null || _b === void 0 ? void 0 : _b.invalidReason;
|
|
4582
|
+
setValidationError(mapErrorCodeToInfo(reason));
|
|
4583
|
+
}
|
|
4584
|
+
}
|
|
4585
|
+
catch {
|
|
4586
|
+
// Validation query failed — don't block the user
|
|
4587
|
+
}
|
|
4585
4588
|
setIsValidating(false);
|
|
4586
4589
|
}, 2000);
|
|
4587
4590
|
}
|