Skip to content

Commit

Permalink
feat: Add copy invite action
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl committed May 23, 2024
1 parent 9a10adf commit 3a1ad26
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 5 additions & 3 deletions packages/admin-next/dashboard/src/lib/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down Expand Up @@ -58,7 +60,7 @@ export const client = {
}

export const sdk = new Medusa({
baseUrl: __BACKEND_URL__ ?? "http://localhost:9000",
baseUrl: backendUrl,
auth: {
type: "session",
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Button,
Expand All @@ -21,6 +21,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,
Expand All @@ -29,6 +30,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"

const InviteUserSchema = zod.object({
email: zod.string().email(),
Expand Down Expand Up @@ -188,6 +190,11 @@ const InviteActions = ({ invite }: { invite: InviteDTO }) => {
await resendAsync()
}

const handleCopyInviteLink = () => {
const inviteUrl = `${backendUrl}/app/invite?token=${invite.token}`
copy(inviteUrl)
}

return (
<ActionMenu
groups={[
Expand All @@ -200,6 +207,15 @@ const InviteActions = ({ invite }: { invite: InviteDTO }) => {
},
],
},
{
actions: [
{
icon: <Link />,
label: t("users.copyInviteLink"),
onClick: handleCopyInviteLink,
},
],
},
{
actions: [
{
Expand Down

0 comments on commit 3a1ad26

Please sign in to comment.