fix(admin-ui): Ensure that default invite link uses __BASE__ if set (#4173)
* ensure default invite link uses __BASE__ if it exists * add changeset
This commit is contained in:
1 parent
92f01cefbc
commit
9a46c11f2a
2 files changed
+17
-6
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/admin-ui": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(admin-ui): Ensures that the default invite link uses the **BASE** in constructing the link if it exists
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Invite, User } from "@medusajs/medusa"
|
import { Invite, User } from "@medusajs/medusa"
|
||||||
import copy from "copy-to-clipboard"
|
import copy from "copy-to-clipboard"
|
||||||
import { useAdminStore } from "medusa-react"
|
import { useAdminStore } from "medusa-react"
|
||||||
import React, { useEffect, useState } from "react"
|
import React, { useEffect, useMemo, useState } from "react"
|
||||||
import useNotification from "../../hooks/use-notification"
|
import useNotification from "../../hooks/use-notification"
|
||||||
import Medusa from "../../services/api"
|
import Medusa from "../../services/api"
|
||||||
import ClipboardCopyIcon from "../fundamentals/icons/clipboard-copy-icon"
|
import ClipboardCopyIcon from "../fundamentals/icons/clipboard-copy-icon"
|
||||||
@@ -103,6 +103,16 @@ const UserTable: React.FC<UserTableProps> = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const inviteLink = useMemo(() => {
|
||||||
|
if (store?.invite_link_template) {
|
||||||
|
return store.invite_link_template
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${window.location.origin}${
|
||||||
|
__BASE__ ? `${__BASE__}/` : "/"
|
||||||
|
}invite?token={invite_token}`
|
||||||
|
}, [store])
|
||||||
|
|
||||||
const getInviteTableRow = (invite: Invite, index: number) => {
|
const getInviteTableRow = (invite: Invite, index: number) => {
|
||||||
return (
|
return (
|
||||||
<Table.Row
|
<Table.Row
|
||||||
@@ -128,11 +138,7 @@ const UserTable: React.FC<UserTableProps> = ({
|
|||||||
label: "Copy invite link",
|
label: "Copy invite link",
|
||||||
disabled: isLoading,
|
disabled: isLoading,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
const link_template =
|
copy(inviteLink.replace("{invite_token}", invite.token))
|
||||||
store?.invite_link_template ??
|
|
||||||
`${window.location.origin}/invite?token={invite_token}`
|
|
||||||
|
|
||||||
copy(link_template.replace("{invite_token}", invite.token))
|
|
||||||
notification(
|
notification(
|
||||||
"Success",
|
"Success",
|
||||||
"Invite link copied to clipboard",
|
"Invite link copied to clipboard",
|
||||||
|
|||||||
Reference in new issue
Block a user