feat: Add copy invite action (#7413)
https://github.com/medusajs/medusa/assets/59018053/2a2d0d39-e020-4146-8679-cbc99d75c98e
This commit is contained in:
@@ -7,15 +7,15 @@ import { currencies } from "./currencies"
|
||||
import { customerGroups } from "./customer-groups"
|
||||
import { customers } from "./customers"
|
||||
import { fulfillmentProviders } from "./fulfillment-providers"
|
||||
import { fulfillments } from "./fulfillments"
|
||||
import { inventoryItems } from "./inventory"
|
||||
import { invites } from "./invites"
|
||||
import { orders } from "./orders"
|
||||
import { payments } from "./payments"
|
||||
import { priceLists } from "./price-lists"
|
||||
import { productTypes } from "./product-types"
|
||||
import { products } from "./products"
|
||||
import { promotions } from "./promotions"
|
||||
import { orders } from "./orders"
|
||||
import { fulfillments } from "./fulfillments"
|
||||
import { reservations } from "./reservations"
|
||||
import { salesChannels } from "./sales-channels"
|
||||
import { shippingOptions } from "./shipping-options"
|
||||
@@ -27,6 +27,8 @@ import { taxes } from "./taxes"
|
||||
import { users } from "./users"
|
||||
import { workflowExecutions } from "./workflow-executions"
|
||||
|
||||
export const backendUrl = __BACKEND_URL__ ?? "http://localhost:9000"
|
||||
|
||||
export const client = {
|
||||
apiKeys: apiKeys,
|
||||
campaigns: campaigns,
|
||||
@@ -58,7 +60,7 @@ export const client = {
|
||||
}
|
||||
|
||||
export const sdk = new Medusa({
|
||||
baseUrl: __BACKEND_URL__ ?? "http://localhost:9000",
|
||||
baseUrl: backendUrl,
|
||||
auth: {
|
||||
type: "session",
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { ArrowPath, Trash } from "@medusajs/icons"
|
||||
import { ArrowPath, Link, Trash } from "@medusajs/icons"
|
||||
import { InviteDTO } from "@medusajs/types"
|
||||
import {
|
||||
Alert,
|
||||
@@ -22,6 +22,7 @@ import { ActionMenu } from "../../../../../components/common/action-menu"
|
||||
import { useDataTable } from "../../../../../hooks/use-data-table"
|
||||
import { Form } from "../../../../../components/common/form"
|
||||
import { RouteFocusModal } from "../../../../../components/route-modal"
|
||||
import copy from "copy-to-clipboard"
|
||||
import {
|
||||
useCreateInvite,
|
||||
useDeleteInvite,
|
||||
@@ -30,6 +31,7 @@ import {
|
||||
} from "../../../../../hooks/api/invites"
|
||||
import { DataTable } from "../../../../../components/table/data-table"
|
||||
import { useUserInviteTableQuery } from "../../../../../hooks/table/query/use-user-invite-table-query"
|
||||
import { backendUrl } from "../../../../../lib/client"
|
||||
import { isFetchError } from "../../../../../lib/is-fetch-error.ts"
|
||||
|
||||
const InviteUserSchema = zod.object({
|
||||
@@ -203,6 +205,11 @@ const InviteActions = ({ invite }: { invite: InviteDTO }) => {
|
||||
await resendAsync()
|
||||
}
|
||||
|
||||
const handleCopyInviteLink = () => {
|
||||
const inviteUrl = `${backendUrl}/app/invite?token=${invite.token}`
|
||||
copy(inviteUrl)
|
||||
}
|
||||
|
||||
return (
|
||||
<ActionMenu
|
||||
groups={[
|
||||
@@ -215,6 +222,15 @@ const InviteActions = ({ invite }: { invite: InviteDTO }) => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
actions: [
|
||||
{
|
||||
icon: <Link />,
|
||||
label: t("users.copyInviteLink"),
|
||||
onClick: handleCopyInviteLink,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
actions: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user