Skip to content

Commit

Permalink
update copy in widget editor, only show copied message for single use…
Browse files Browse the repository at this point in the history
… codes
  • Loading branch information
00salmon committed Feb 11, 2025
1 parent 20db24a commit 1928494
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/mint-components/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@saasquatch/mint-components",
"title": "Mint Components",
"version": "1.11.1",
"version": "1.11.1-68",
"description": "A minimal design library with components for referral and loyalty experiences. Built with Shoelace components by Saasquatch.",
"icon": "https://res.cloudinary.com/saasquatch/image/upload/v1652219900/squatch-assets/For_Mint.svg",
"raisins": "docs/raisins.json",
Expand Down
4 changes: 2 additions & 2 deletions packages/mint-components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2610,7 +2610,7 @@ export namespace Components {
*/
"demoData"?: DemoData<CopyTextViewProps>;
/**
* Shown underneath the referral code when the user has already copied the code
* Shown underneath single-use promo codes when the user has already copied the code
* @uiName Notification text
*/
"notificationText": string;
Expand Down Expand Up @@ -8562,7 +8562,7 @@ declare namespace LocalJSX {
*/
"demoData"?: DemoData<CopyTextViewProps>;
/**
* Shown underneath the referral code when the user has already copied the code
* Shown underneath single-use promo codes when the user has already copied the code
* @uiName Notification text
*/
"notificationText"?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
| `buttonStyle` | `copy-button-style` | Set the copy button style and placement | `"button-below" \| "button-outside" \| "icon"` | `"icon"` |
| `copyButtonLabel` | `copy-button-label` | | `string` | `"Copy Code"` |
| `demoData` | -- | | `{ loading?: boolean; copyString?: string; tooltiptext?: string; open?: boolean; copyButtonLabel?: string; disabled?: boolean; textAlign?: "left" \| "right" \| "center"; buttonStyle?: "icon" \| "button-outside" \| "button-below"; error?: boolean; errorText?: string; notificationText?: string; showNotificationText?: boolean; inputPlaceholderText?: string; dateAvailable?: string; isCopied?: boolean; onClick?: () => void; }` | `undefined` |
| `notificationText` | `notification-text` | Shown underneath the referral code when the user has already copied the code | `string` | `"You've copied this code before"` |
| `notificationText` | `notification-text` | Shown underneath single-use promo codes when the user has already copied the code | `string` | `"You've copied this code before"` |
| `programId` | `program-id` | The ID of the program that should generate the code. Defaults to the program ID in context where this widget is loaded. | `string` | `undefined` |
| `showNotificationText` | `show-notification-text` | Boolean used to show notification text below input | `boolean` | `false` |
| `textAlign` | `text-align` | Change the text alignment | `"center" \| "left" \| "right"` | `"left"` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ReferralCode {
})
showNotificationText: boolean = false;
/**
* Shown underneath the referral code when the user has already copied the code
* Shown underneath single-use promo codes when the user has already copied the code
*
* @uiName Notification text
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ import {
REFERRAL_CODES_NAMESPACE,
SET_CODE_COPIED,
} from "../sqm-referral-codes/useReferralCodes";

interface ReferralCodeProps {
programId?: string;
tooltiptext: string;
tooltiplifespan: number;
codeOverride?: string;
}
import { ReferralCode } from "./sqm-referral-code";

const MessageLinkQuery = gql`
query getReferralCode($programId: ID) {
Expand All @@ -38,7 +32,7 @@ const WIDGET_ENGAGEMENT_EVENT = gql`
}
`;

export function useReferralCode(props: ReferralCodeProps): CopyTextViewProps {
export function useReferralCode(props: ReferralCode): CopyTextViewProps {
const { programId = useProgramId() } = props;
const user = useUserIdentity();
const engagementMedium = useEngagementMedium();
Expand Down Expand Up @@ -92,5 +86,7 @@ export function useReferralCode(props: ReferralCodeProps): CopyTextViewProps {
open,
copyString: copyString,
isCopied: contextData?.isCopied,
showNotificationText:
props.showNotificationText && !!contextData?.singleUse,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export type ReferralCodeContext = {
isUsed: boolean;
isCopied: boolean;
shareLink: string;
singleUse: boolean;
email: {
messageLink: string;
};
Expand Down Expand Up @@ -165,6 +166,7 @@ export function useReferralCodes(props: ReferralCodes) {
shareLink: "",
isCopied: false,
isUsed: false,
singleUse: false,
email: {
messageLink: "",
},
Expand All @@ -184,6 +186,7 @@ export function useReferralCodes(props: ReferralCodes) {
referralCode: data.code,
isCopied: !!data.dateCopied,
isUsed: !!data.dateUsed,
singleUse: !!data.singleUse,
shareLink: data.shareLinkCodes?.data?.[0]?.direct,
email: {
messageLink: data.shareLinkCodes?.data?.[0]?.email,
Expand Down

0 comments on commit 1928494

Please sign in to comment.