@saasquatch/mint-components 2.1.8-12 → 2.1.8-14
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-41b061c2.js → ShadowViewAddon-83f599c1.js} +14 -23
- 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 +2 -13
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +3 -15
- package/dist/collection/components/sqm-share-link/ShareLink.stories.js +1 -12
- package/dist/collection/components/sqm-share-link/sqm-share-link-view.js +2 -8
- package/dist/collection/components/sqm-share-link/sqm-share-link.js +2 -37
- package/dist/collection/components/sqm-share-link/useShareLink.js +13 -16
- package/dist/esm/{ShadowViewAddon-0f97b25e.js → ShadowViewAddon-36f52afc.js} +15 -24
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mint-components.js +1 -1
- package/dist/esm/sqm-big-stat_45.entry.js +2 -13
- package/dist/esm/sqm-stencilbook.entry.js +3 -15
- package/dist/esm-es5/ShadowViewAddon-36f52afc.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-c3346e74.system.entry.js → p-121825d5.system.entry.js} +1 -1
- package/dist/mint-components/{p-4a69495a.js → p-45d44895.js} +31 -35
- package/dist/mint-components/{p-01274e61.entry.js → p-7ea37280.entry.js} +2 -2
- package/dist/mint-components/{p-58f63dec.system.entry.js → p-9e0b8775.system.entry.js} +1 -1
- package/dist/mint-components/p-c59b0471.system.js +1 -0
- package/dist/mint-components/{p-3ee8b29b.entry.js → p-c6f2983c.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 +0 -1
- package/dist/types/components/sqm-share-link/sqm-share-link-view.d.ts +1 -2
- package/dist/types/components/sqm-share-link/sqm-share-link.d.ts +0 -7
- package/dist/types/components/sqm-share-link/useShareLink.d.ts +0 -1
- package/dist/types/components.d.ts +0 -12
- 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-0f97b25e.js +0 -1
- package/dist/mint-components/p-c519220a.system.js +0 -1
|
@@ -9,7 +9,7 @@ const vanillaStyle = `
|
|
|
9
9
|
}
|
|
10
10
|
`;
|
|
11
11
|
export function ShareLinkView(props) {
|
|
12
|
-
const { copyTextViewProps, customizeUrl, customizeLinkLabel, saveLabelText, cancelLabelText,
|
|
12
|
+
const { copyTextViewProps, customizeUrl, customizeLinkLabel, saveLabelText, cancelLabelText, isEditing, editValue, domainPrefix, editsRemaining, maxEdits, limitReached, validationError, isValidating, isSaving, characterLimit, minCharacters, charactersRemaining, editLimitText, editLimitReachedText, supportLinkText, customizeDisabled, customizeDisabledTooltip, onCustomizeClick, onEditValueChange, onSave, onCancel, } = props;
|
|
13
13
|
const style = {
|
|
14
14
|
Container: {
|
|
15
15
|
display: "flex",
|
|
@@ -90,11 +90,6 @@ export function ShareLinkView(props) {
|
|
|
90
90
|
fontSize: "var(--sl-font-size-small)",
|
|
91
91
|
color: "var(--sqm-danger-color-text, #dc2626)",
|
|
92
92
|
},
|
|
93
|
-
SuccessText: {
|
|
94
|
-
margin: "0",
|
|
95
|
-
fontSize: "var(--sl-font-size-small)",
|
|
96
|
-
color: "var(--sl-color-success-600, #16a34a)",
|
|
97
|
-
},
|
|
98
93
|
ActionRow: {
|
|
99
94
|
display: "flex",
|
|
100
95
|
gap: "var(--sl-spacing-medium)",
|
|
@@ -150,7 +145,7 @@ export function ShareLinkView(props) {
|
|
|
150
145
|
validationError.description)),
|
|
151
146
|
isValidating && h("p", { class: sheet.classes.HelperText }, "Validating..."),
|
|
152
147
|
h("div", { class: sheet.classes.ActionRow },
|
|
153
|
-
h("button", { class: sheet.classes.SaveButton, onClick: onSave, disabled: isSaving || isValidating || !!validationError || !editValue }, isSaving ? "Saving..." : saveLabelText),
|
|
148
|
+
h("button", { class: sheet.classes.SaveButton, onClick: onSave, disabled: isSaving || isValidating || !!validationError || !editValue || editValue.length < minCharacters }, isSaving ? "Saving..." : saveLabelText),
|
|
154
149
|
h("button", { class: sheet.classes.CancelButton, onClick: onCancel, disabled: isSaving }, cancelLabelText))));
|
|
155
150
|
}
|
|
156
151
|
// Default / Customized / Limit reached states
|
|
@@ -159,7 +154,6 @@ export function ShareLinkView(props) {
|
|
|
159
154
|
styleString,
|
|
160
155
|
vanillaStyle),
|
|
161
156
|
h(CopyTextView, Object.assign({}, copyTextViewProps)),
|
|
162
|
-
showSuccess && h("p", { class: sheet.classes.SuccessText }, successMessage),
|
|
163
157
|
customizeUrl && (customizeDisabled ? (h("sl-tooltip", { content: customizeDisabledTooltip, placement: "top", style: { display: "inline-block", width: "fit-content" } },
|
|
164
158
|
h("p", { class: sheet.classes.CustomizeLinkDisabled }, customizeLinkLabel))) : (h("p", { class: limitReached
|
|
165
159
|
? sheet.classes.CustomizeLinkDisabled
|
|
@@ -86,13 +86,6 @@ export class ShareLink {
|
|
|
86
86
|
* @uiType string
|
|
87
87
|
*/
|
|
88
88
|
this.cancelLabelText = "Cancel";
|
|
89
|
-
/**
|
|
90
|
-
* Message shown briefly after successfully saving a custom link
|
|
91
|
-
*
|
|
92
|
-
* @uiName Success message
|
|
93
|
-
* @uiType string
|
|
94
|
-
*/
|
|
95
|
-
this.successMessage = "Link updated successfully";
|
|
96
89
|
/**
|
|
97
90
|
* Title text shown when the custom link is already taken
|
|
98
91
|
*
|
|
@@ -570,30 +563,6 @@ export class ShareLink {
|
|
|
570
563
|
"reflect": false,
|
|
571
564
|
"defaultValue": "\"Cancel\""
|
|
572
565
|
},
|
|
573
|
-
"successMessage": {
|
|
574
|
-
"type": "string",
|
|
575
|
-
"mutable": false,
|
|
576
|
-
"complexType": {
|
|
577
|
-
"original": "string",
|
|
578
|
-
"resolved": "string",
|
|
579
|
-
"references": {}
|
|
580
|
-
},
|
|
581
|
-
"required": false,
|
|
582
|
-
"optional": true,
|
|
583
|
-
"docs": {
|
|
584
|
-
"tags": [{
|
|
585
|
-
"text": "Success message",
|
|
586
|
-
"name": "uiName"
|
|
587
|
-
}, {
|
|
588
|
-
"text": "string",
|
|
589
|
-
"name": "uiType"
|
|
590
|
-
}],
|
|
591
|
-
"text": "Message shown briefly after successfully saving a custom link"
|
|
592
|
-
},
|
|
593
|
-
"attribute": "success-message",
|
|
594
|
-
"reflect": false,
|
|
595
|
-
"defaultValue": "\"Link updated successfully\""
|
|
596
|
-
},
|
|
597
566
|
"existingCodeConflictErrorTitle": {
|
|
598
567
|
"type": "string",
|
|
599
568
|
"mutable": false,
|
|
@@ -839,7 +808,7 @@ export class ShareLink {
|
|
|
839
808
|
"mutable": false,
|
|
840
809
|
"complexType": {
|
|
841
810
|
"original": "DemoData<ShareLinkViewProps>",
|
|
842
|
-
"resolved": "{ copyTextViewProps?: CopyTextViewProps; customizeUrl?: boolean; customizeLinkLabel?: string; saveLabelText?: string; cancelLabelText?: string;
|
|
811
|
+
"resolved": "{ copyTextViewProps?: CopyTextViewProps; customizeUrl?: boolean; customizeLinkLabel?: string; saveLabelText?: string; cancelLabelText?: string; isEditing?: boolean; editValue?: string; domainPrefix?: string; editsRemaining?: number; maxEdits?: number; limitReached?: boolean; validationError?: ValidationErrorInfo; isValidating?: boolean; isSaving?: boolean; characterLimit?: number; minCharacters?: number; charactersRemaining?: number; editLimitText?: string; editLimitReachedText?: string; supportLinkText?: string; customizeDisabled?: boolean; customizeDisabledTooltip?: string; onCustomizeClick?: () => void; onEditValueChange?: (value: string) => void; onSave?: () => void; onCancel?: () => void; }",
|
|
843
812
|
"references": {
|
|
844
813
|
"DemoData": {
|
|
845
814
|
"location": "import",
|
|
@@ -871,7 +840,6 @@ function useDemoShareLink(props) {
|
|
|
871
840
|
const [open, setOpen] = useState(false);
|
|
872
841
|
const [isEditing, setIsEditing] = useState(false);
|
|
873
842
|
const [editValue, setEditValue] = useState("");
|
|
874
|
-
const [showSuccess, setShowSuccess] = useState(false);
|
|
875
843
|
const copyString = "https://www.example.com/sharelink/abc";
|
|
876
844
|
const domainPrefix = "https://www.example.com/";
|
|
877
845
|
const baseProps = {
|
|
@@ -897,7 +865,6 @@ function useDemoShareLink(props) {
|
|
|
897
865
|
customizeLinkLabel: props.customizeLinkLabel,
|
|
898
866
|
saveLabelText: props.saveLabelText,
|
|
899
867
|
cancelLabelText: props.cancelLabelText,
|
|
900
|
-
successMessage: props.successMessage,
|
|
901
868
|
isEditing,
|
|
902
869
|
editValue,
|
|
903
870
|
domainPrefix,
|
|
@@ -907,8 +874,8 @@ function useDemoShareLink(props) {
|
|
|
907
874
|
validationError: null,
|
|
908
875
|
isValidating: false,
|
|
909
876
|
isSaving: false,
|
|
910
|
-
showSuccess,
|
|
911
877
|
characterLimit: 15,
|
|
878
|
+
minCharacters: 3,
|
|
912
879
|
charactersRemaining: 15 - editValue.length,
|
|
913
880
|
editLimitText: props.editLimitText,
|
|
914
881
|
editLimitReachedText: props.editLimitReachedText,
|
|
@@ -924,8 +891,6 @@ function useDemoShareLink(props) {
|
|
|
924
891
|
},
|
|
925
892
|
onSave: () => {
|
|
926
893
|
setIsEditing(false);
|
|
927
|
-
setShowSuccess(true);
|
|
928
|
-
setTimeout(() => setShowSuccess(false), 3000);
|
|
929
894
|
},
|
|
930
895
|
onCancel: () => {
|
|
931
896
|
setIsEditing(false);
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { useEngagementMedium, useLazyQuery, useMutation, useParentValue, useProgramId, useQuery, useUserIdentity, } from "@saasquatch/component-boilerplate";
|
|
1
|
+
import { useEngagementMedium, useLazyQuery, useMutation, useParentValue, useProgramId, useQuery, useRefreshDispatcher, 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";
|
|
5
5
|
const MAX_EDITS = 5;
|
|
6
6
|
const CHARACTER_LIMIT = 15;
|
|
7
|
+
const MIN_CHARACTERS = 3;
|
|
7
8
|
const MessageLinkQuery = gql `
|
|
8
|
-
query ($programId: ID
|
|
9
|
+
query ($programId: ID) {
|
|
9
10
|
user: viewer {
|
|
10
11
|
... on User {
|
|
11
|
-
shareLink(
|
|
12
|
-
programId: $programId
|
|
13
|
-
engagementMedium: $engagementMedium
|
|
14
|
-
shareMedium: DIRECT
|
|
15
|
-
)
|
|
12
|
+
shareLink(programId: $programId)
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
15
|
}
|
|
@@ -91,11 +88,12 @@ export function useShareLink(props) {
|
|
|
91
88
|
const user = useUserIdentity();
|
|
92
89
|
const engagementMedium = useEngagementMedium();
|
|
93
90
|
const contextData = useParentValue(REFERRAL_CODES_NAMESPACE);
|
|
94
|
-
const { data, refetch } = useQuery(MessageLinkQuery, { programId
|
|
91
|
+
const { data, refetch } = useQuery(MessageLinkQuery, { programId }, !(user === null || user === void 0 ? void 0 : user.jwt) || !!props.linkOverride || (contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) !== undefined);
|
|
95
92
|
const [sendLoadEvent] = useMutation(WIDGET_ENGAGEMENT_EVENT);
|
|
96
93
|
const [setCopied] = useMutation(SET_CODE_COPIED);
|
|
97
94
|
const [addShareLinkCode, { loading: isSaving }] = useMutation(ADD_SHARE_LINK_CODE);
|
|
98
95
|
const [validateLinkCode] = useLazyQuery(VALIDATE_LINK_CODE);
|
|
96
|
+
const { refresh } = useRefreshDispatcher();
|
|
99
97
|
const { data: linkDomainData } = useQuery(GET_LINK_DOMAIN, {}, !(user === null || user === void 0 ? void 0 : user.jwt) || !props.customizeUrl);
|
|
100
98
|
const { data: editCountData, refetch: refetchEditCount } = useQuery(SHARE_LINK_EDIT_COUNT, {}, !(user === null || user === void 0 ? void 0 : user.jwt) || !props.customizeUrl);
|
|
101
99
|
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 :
|
|
@@ -106,7 +104,6 @@ export function useShareLink(props) {
|
|
|
106
104
|
const [editValue, setEditValue] = useState("");
|
|
107
105
|
const [validationError, setValidationError] = useState(null);
|
|
108
106
|
const [isValidating, setIsValidating] = useState(false);
|
|
109
|
-
const [showSuccess, setShowSuccess] = useState(false);
|
|
110
107
|
const debounceTimerRef = useRef(undefined);
|
|
111
108
|
const domainPrefix = parseDomainPrefix(copyString);
|
|
112
109
|
const hasPrimaryLinkDomain = ((_c = linkDomainData === null || linkDomainData === void 0 ? void 0 : linkDomainData.tenantSettings) === null || _c === void 0 ? void 0 : _c.primaryLinkDomain) != null;
|
|
@@ -115,7 +112,6 @@ export function useShareLink(props) {
|
|
|
115
112
|
const editCount = vanityCount;
|
|
116
113
|
const editsRemaining = Math.max(0, MAX_EDITS - editCount);
|
|
117
114
|
const limitReached = editsRemaining <= 0;
|
|
118
|
-
console.log({ vanityCount, editCount, editsRemaining });
|
|
119
115
|
function mapErrorCodeToInfo(errorCode) {
|
|
120
116
|
if (!errorCode)
|
|
121
117
|
return null;
|
|
@@ -174,7 +170,7 @@ export function useShareLink(props) {
|
|
|
174
170
|
setValidationError(null);
|
|
175
171
|
if (debounceTimerRef.current)
|
|
176
172
|
clearTimeout(debounceTimerRef.current);
|
|
177
|
-
if (!trimmed) {
|
|
173
|
+
if (!trimmed || trimmed.length < MIN_CHARACTERS) {
|
|
178
174
|
setIsValidating(false);
|
|
179
175
|
return;
|
|
180
176
|
}
|
|
@@ -196,7 +192,10 @@ export function useShareLink(props) {
|
|
|
196
192
|
}
|
|
197
193
|
async function onSave() {
|
|
198
194
|
var _a, _b;
|
|
199
|
-
if (!editValue ||
|
|
195
|
+
if (!editValue ||
|
|
196
|
+
editValue.length < MIN_CHARACTERS ||
|
|
197
|
+
validationError ||
|
|
198
|
+
isValidating)
|
|
200
199
|
return;
|
|
201
200
|
try {
|
|
202
201
|
await addShareLinkCode({
|
|
@@ -209,9 +208,8 @@ export function useShareLink(props) {
|
|
|
209
208
|
},
|
|
210
209
|
});
|
|
211
210
|
setIsEditing(false);
|
|
212
|
-
setShowSuccess(true);
|
|
213
211
|
await Promise.all([refetch(), refetchEditCount()]);
|
|
214
|
-
|
|
212
|
+
refresh();
|
|
215
213
|
}
|
|
216
214
|
catch (e) {
|
|
217
215
|
const errorCode = (_a = e === null || e === void 0 ? void 0 : e.extensions) === null || _a === void 0 ? void 0 : _a.code;
|
|
@@ -239,7 +237,6 @@ export function useShareLink(props) {
|
|
|
239
237
|
customizeLinkLabel: props.customizeLinkLabel,
|
|
240
238
|
saveLabelText: props.saveLabelText,
|
|
241
239
|
cancelLabelText: props.cancelLabelText,
|
|
242
|
-
successMessage: props.successMessage,
|
|
243
240
|
isEditing,
|
|
244
241
|
editValue,
|
|
245
242
|
domainPrefix,
|
|
@@ -249,8 +246,8 @@ export function useShareLink(props) {
|
|
|
249
246
|
validationError,
|
|
250
247
|
isValidating,
|
|
251
248
|
isSaving,
|
|
252
|
-
showSuccess,
|
|
253
249
|
characterLimit: CHARACTER_LIMIT,
|
|
250
|
+
minCharacters: MIN_CHARACTERS,
|
|
254
251
|
charactersRemaining: CHARACTER_LIMIT - editValue.length,
|
|
255
252
|
editLimitText: props.editLimitText,
|
|
256
253
|
editLimitReachedText: props.editLimitReachedText,
|
|
@@ -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, X as Xe } 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, Q as Qe } 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';
|
|
@@ -4234,7 +4234,7 @@ const vanillaStyle$6 = `
|
|
|
4234
4234
|
}
|
|
4235
4235
|
`;
|
|
4236
4236
|
function ShareLinkView(props) {
|
|
4237
|
-
const { copyTextViewProps, customizeUrl, customizeLinkLabel, saveLabelText, cancelLabelText,
|
|
4237
|
+
const { copyTextViewProps, customizeUrl, customizeLinkLabel, saveLabelText, cancelLabelText, isEditing, editValue, domainPrefix, editsRemaining, maxEdits, limitReached, validationError, isValidating, isSaving, characterLimit, minCharacters, charactersRemaining, editLimitText, editLimitReachedText, supportLinkText, customizeDisabled, customizeDisabledTooltip, onCustomizeClick, onEditValueChange, onSave, onCancel, } = props;
|
|
4238
4238
|
const style = {
|
|
4239
4239
|
Container: {
|
|
4240
4240
|
display: "flex",
|
|
@@ -4315,11 +4315,6 @@ function ShareLinkView(props) {
|
|
|
4315
4315
|
fontSize: "var(--sl-font-size-small)",
|
|
4316
4316
|
color: "var(--sqm-danger-color-text, #dc2626)",
|
|
4317
4317
|
},
|
|
4318
|
-
SuccessText: {
|
|
4319
|
-
margin: "0",
|
|
4320
|
-
fontSize: "var(--sl-font-size-small)",
|
|
4321
|
-
color: "var(--sl-color-success-600, #16a34a)",
|
|
4322
|
-
},
|
|
4323
4318
|
ActionRow: {
|
|
4324
4319
|
display: "flex",
|
|
4325
4320
|
gap: "var(--sl-spacing-medium)",
|
|
@@ -4375,7 +4370,7 @@ function ShareLinkView(props) {
|
|
|
4375
4370
|
validationError.description)),
|
|
4376
4371
|
isValidating && h("p", { class: sheet.classes.HelperText }, "Validating..."),
|
|
4377
4372
|
h("div", { class: sheet.classes.ActionRow },
|
|
4378
|
-
h("button", { class: sheet.classes.SaveButton, onClick: onSave, disabled: isSaving || isValidating || !!validationError || !editValue }, isSaving ? "Saving..." : saveLabelText),
|
|
4373
|
+
h("button", { class: sheet.classes.SaveButton, onClick: onSave, disabled: isSaving || isValidating || !!validationError || !editValue || editValue.length < minCharacters }, isSaving ? "Saving..." : saveLabelText),
|
|
4379
4374
|
h("button", { class: sheet.classes.CancelButton, onClick: onCancel, disabled: isSaving }, cancelLabelText))));
|
|
4380
4375
|
}
|
|
4381
4376
|
// Default / Customized / Limit reached states
|
|
@@ -4384,7 +4379,6 @@ function ShareLinkView(props) {
|
|
|
4384
4379
|
styleString,
|
|
4385
4380
|
vanillaStyle$6),
|
|
4386
4381
|
h(CopyTextView, Object.assign({}, copyTextViewProps)),
|
|
4387
|
-
showSuccess && h("p", { class: sheet.classes.SuccessText }, successMessage),
|
|
4388
4382
|
customizeUrl && (customizeDisabled ? (h("sl-tooltip", { content: customizeDisabledTooltip, placement: "top", style: { display: "inline-block", width: "fit-content" } },
|
|
4389
4383
|
h("p", { class: sheet.classes.CustomizeLinkDisabled }, customizeLinkLabel))) : (h("p", { class: limitReached
|
|
4390
4384
|
? sheet.classes.CustomizeLinkDisabled
|
|
@@ -4399,15 +4393,12 @@ function ShareLinkView(props) {
|
|
|
4399
4393
|
|
|
4400
4394
|
const MAX_EDITS = 5;
|
|
4401
4395
|
const CHARACTER_LIMIT = 15;
|
|
4396
|
+
const MIN_CHARACTERS = 3;
|
|
4402
4397
|
const MessageLinkQuery$1 = dist.gql `
|
|
4403
|
-
query ($programId: ID
|
|
4398
|
+
query ($programId: ID) {
|
|
4404
4399
|
user: viewer {
|
|
4405
4400
|
... on User {
|
|
4406
|
-
shareLink(
|
|
4407
|
-
programId: $programId
|
|
4408
|
-
engagementMedium: $engagementMedium
|
|
4409
|
-
shareMedium: DIRECT
|
|
4410
|
-
)
|
|
4401
|
+
shareLink(programId: $programId)
|
|
4411
4402
|
}
|
|
4412
4403
|
}
|
|
4413
4404
|
}
|
|
@@ -4486,11 +4477,12 @@ function useShareLink(props) {
|
|
|
4486
4477
|
const user = J();
|
|
4487
4478
|
const engagementMedium = B();
|
|
4488
4479
|
const contextData = Fn(REFERRAL_CODES_NAMESPACE);
|
|
4489
|
-
const { data, refetch } = wn(MessageLinkQuery$1, { programId
|
|
4480
|
+
const { data, refetch } = wn(MessageLinkQuery$1, { programId }, !(user === null || user === void 0 ? void 0 : user.jwt) || !!props.linkOverride || (contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) !== undefined);
|
|
4490
4481
|
const [sendLoadEvent] = $e(WIDGET_ENGAGEMENT_EVENT);
|
|
4491
4482
|
const [setCopied] = $e(SET_CODE_COPIED);
|
|
4492
4483
|
const [addShareLinkCode, { loading: isSaving }] = $e(ADD_SHARE_LINK_CODE);
|
|
4493
4484
|
const [validateLinkCode] = Xe(VALIDATE_LINK_CODE);
|
|
4485
|
+
const { refresh } = Qe();
|
|
4494
4486
|
const { data: linkDomainData } = wn(GET_LINK_DOMAIN, {}, !(user === null || user === void 0 ? void 0 : user.jwt) || !props.customizeUrl);
|
|
4495
4487
|
const { data: editCountData, refetch: refetchEditCount } = wn(SHARE_LINK_EDIT_COUNT, {}, !(user === null || user === void 0 ? void 0 : user.jwt) || !props.customizeUrl);
|
|
4496
4488
|
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 :
|
|
@@ -4501,7 +4493,6 @@ function useShareLink(props) {
|
|
|
4501
4493
|
const [editValue, setEditValue] = useState("");
|
|
4502
4494
|
const [validationError, setValidationError] = useState(null);
|
|
4503
4495
|
const [isValidating, setIsValidating] = useState(false);
|
|
4504
|
-
const [showSuccess, setShowSuccess] = useState(false);
|
|
4505
4496
|
const debounceTimerRef = useRef(undefined);
|
|
4506
4497
|
const domainPrefix = parseDomainPrefix(copyString);
|
|
4507
4498
|
const hasPrimaryLinkDomain = ((_c = linkDomainData === null || linkDomainData === void 0 ? void 0 : linkDomainData.tenantSettings) === null || _c === void 0 ? void 0 : _c.primaryLinkDomain) != null;
|
|
@@ -4510,7 +4501,6 @@ function useShareLink(props) {
|
|
|
4510
4501
|
const editCount = vanityCount;
|
|
4511
4502
|
const editsRemaining = Math.max(0, MAX_EDITS - editCount);
|
|
4512
4503
|
const limitReached = editsRemaining <= 0;
|
|
4513
|
-
console.log({ vanityCount, editCount, editsRemaining });
|
|
4514
4504
|
function mapErrorCodeToInfo(errorCode) {
|
|
4515
4505
|
if (!errorCode)
|
|
4516
4506
|
return null;
|
|
@@ -4569,7 +4559,7 @@ function useShareLink(props) {
|
|
|
4569
4559
|
setValidationError(null);
|
|
4570
4560
|
if (debounceTimerRef.current)
|
|
4571
4561
|
clearTimeout(debounceTimerRef.current);
|
|
4572
|
-
if (!trimmed) {
|
|
4562
|
+
if (!trimmed || trimmed.length < MIN_CHARACTERS) {
|
|
4573
4563
|
setIsValidating(false);
|
|
4574
4564
|
return;
|
|
4575
4565
|
}
|
|
@@ -4591,7 +4581,10 @@ function useShareLink(props) {
|
|
|
4591
4581
|
}
|
|
4592
4582
|
async function onSave() {
|
|
4593
4583
|
var _a, _b;
|
|
4594
|
-
if (!editValue ||
|
|
4584
|
+
if (!editValue ||
|
|
4585
|
+
editValue.length < MIN_CHARACTERS ||
|
|
4586
|
+
validationError ||
|
|
4587
|
+
isValidating)
|
|
4595
4588
|
return;
|
|
4596
4589
|
try {
|
|
4597
4590
|
await addShareLinkCode({
|
|
@@ -4604,9 +4597,8 @@ function useShareLink(props) {
|
|
|
4604
4597
|
},
|
|
4605
4598
|
});
|
|
4606
4599
|
setIsEditing(false);
|
|
4607
|
-
setShowSuccess(true);
|
|
4608
4600
|
await Promise.all([refetch(), refetchEditCount()]);
|
|
4609
|
-
|
|
4601
|
+
refresh();
|
|
4610
4602
|
}
|
|
4611
4603
|
catch (e) {
|
|
4612
4604
|
const errorCode = (_a = e === null || e === void 0 ? void 0 : e.extensions) === null || _a === void 0 ? void 0 : _a.code;
|
|
@@ -4634,7 +4626,6 @@ function useShareLink(props) {
|
|
|
4634
4626
|
customizeLinkLabel: props.customizeLinkLabel,
|
|
4635
4627
|
saveLabelText: props.saveLabelText,
|
|
4636
4628
|
cancelLabelText: props.cancelLabelText,
|
|
4637
|
-
successMessage: props.successMessage,
|
|
4638
4629
|
isEditing,
|
|
4639
4630
|
editValue,
|
|
4640
4631
|
domainPrefix,
|
|
@@ -4644,8 +4635,8 @@ function useShareLink(props) {
|
|
|
4644
4635
|
validationError,
|
|
4645
4636
|
isValidating,
|
|
4646
4637
|
isSaving,
|
|
4647
|
-
showSuccess,
|
|
4648
4638
|
characterLimit: CHARACTER_LIMIT,
|
|
4639
|
+
minCharacters: MIN_CHARACTERS,
|
|
4649
4640
|
charactersRemaining: CHARACTER_LIMIT - editValue.length,
|
|
4650
4641
|
editLimitText: props.editLimitText,
|
|
4651
4642
|
editLimitReachedText: props.editLimitReachedText,
|