fix(dashboard): user invite search (#9973)

**What**
- fix prefix for table search which caused the other table rendered on the page to fire query
- additionally, fix a typo in js SDK and only format the file

---

FIXES SUP-112
CLOSES https://github.com/medusajs/medusa/issues/9968
This commit is contained in:
Frane Polić
2024-11-07 19:13:28 +00:00
committed by GitHub
parent 1a0882cc01
commit 576da17da3
2 changed files with 291 additions and 287 deletions
@@ -32,7 +32,7 @@ import {
} from "../../../../../hooks/api/invites" } from "../../../../../hooks/api/invites"
import { useUserInviteTableQuery } from "../../../../../hooks/table/query/use-user-invite-table-query" import { useUserInviteTableQuery } from "../../../../../hooks/table/query/use-user-invite-table-query"
import { useDataTable } from "../../../../../hooks/use-data-table" import { useDataTable } from "../../../../../hooks/use-data-table"
import { isFetchError } from "../../../../../lib/is-fetch-error.ts" import { isFetchError } from "../../../../../lib/is-fetch-error"
const InviteUserSchema = zod.object({ const InviteUserSchema = zod.object({
email: zod.string().email(), email: zod.string().email(),
@@ -168,6 +168,7 @@ export const InviteUserForm = () => {
search="autofocus" search="autofocus"
isLoading={isLoading} isLoading={isLoading}
queryObject={raw} queryObject={raw}
prefix={PREFIX}
orderBy={[ orderBy={[
{ key: "email", label: t("fields.email") }, { key: "email", label: t("fields.email") },
{ key: "created_at", label: t("fields.createdAt") }, { key: "created_at", label: t("fields.createdAt") },
+105 -102
View File
@@ -1,8 +1,4 @@
import { import { FindParams, HttpTypes, SelectParams } from "@medusajs/types"
FindParams,
HttpTypes,
SelectParams,
} from "@medusajs/types"
import { Client } from "../client" import { Client } from "../client"
import { ClientHeaders } from "../types" import { ClientHeaders } from "../types"
@@ -72,12 +68,13 @@ export class Store {
query?: FindParams & HttpTypes.StoreRegionFilters, query?: FindParams & HttpTypes.StoreRegionFilters,
headers?: ClientHeaders headers?: ClientHeaders
) => { ) => {
return this.client.fetch< return this.client.fetch<HttpTypes.StoreRegionListResponse>(
HttpTypes.StoreRegionListResponse `/store/regions`,
>(`/store/regions`, { {
query, query,
headers, headers,
}) }
)
}, },
/** /**
* This method retrieves a region by its ID. It sends a request to the [Get Region](https://docs.medusajs.com/api/store#regions_getregionsid) * This method retrieves a region by its ID. It sends a request to the [Get Region](https://docs.medusajs.com/api/store#regions_getregionsid)
@@ -184,12 +181,13 @@ export class Store {
query?: FindParams & HttpTypes.StoreCollectionFilters, query?: FindParams & HttpTypes.StoreCollectionFilters,
headers?: ClientHeaders headers?: ClientHeaders
) => { ) => {
return this.client.fetch< return this.client.fetch<HttpTypes.StoreCollectionListResponse>(
HttpTypes.StoreCollectionListResponse `/store/collections`,
>(`/store/collections`, { {
query, query,
headers, headers,
}) }
)
}, },
/** /**
* This method retrieves a collection by its ID. It sends a request to the [Get Collection](https://docs.medusajs.com/api/store#collections_getcollectionsid) * This method retrieves a collection by its ID. It sends a request to the [Get Collection](https://docs.medusajs.com/api/store#collections_getcollectionsid)
@@ -249,10 +247,10 @@ export class Store {
* *
* @param query - Filters and pagination configurations. * @param query - Filters and pagination configurations.
* @param headers - Headers to pass in the request. * @param headers - Headers to pass in the request.
* @returns The paginated list of categoreis. * @returns The paginated list of categories.
* *
* @example * @example
* To retrieve the list of categoreis: * To retrieve the list of categories:
* *
* ```ts * ```ts
* sdk.store.category.list() * sdk.store.category.list()
@@ -293,12 +291,13 @@ export class Store {
query?: FindParams & HttpTypes.StoreProductCategoryListParams, query?: FindParams & HttpTypes.StoreProductCategoryListParams,
headers?: ClientHeaders headers?: ClientHeaders
) => { ) => {
return this.client.fetch< return this.client.fetch<HttpTypes.StoreProductCategoryListResponse>(
HttpTypes.StoreProductCategoryListResponse `/store/product-categories`,
>(`/store/product-categories`, { {
query, query,
headers, headers,
}) }
)
}, },
/** /**
* This method retrieves a category by its ID. It sends a request to the * This method retrieves a category by its ID. It sends a request to the
@@ -339,12 +338,13 @@ export class Store {
query?: HttpTypes.StoreProductCategoryParams, query?: HttpTypes.StoreProductCategoryParams,
headers?: ClientHeaders headers?: ClientHeaders
) => { ) => {
return this.client.fetch< return this.client.fetch<HttpTypes.StoreProductCategoryResponse>(
HttpTypes.StoreProductCategoryResponse `/store/product-categories/${id}`,
>(`/store/product-categories/${id}`, { {
query, query,
headers, headers,
}) }
)
}, },
} }
@@ -762,13 +762,14 @@ export class Store {
query?: SelectParams, query?: SelectParams,
headers?: ClientHeaders headers?: ClientHeaders
) => { ) => {
return this.client.fetch< return this.client.fetch<HttpTypes.StoreCompleteCartResponse>(
HttpTypes.StoreCompleteCartResponse `/store/carts/${cartId}/complete`,
>(`/store/carts/${cartId}/complete`, { {
method: "POST", method: "POST",
headers, headers,
query, query,
}) }
)
}, },
} }
@@ -796,12 +797,13 @@ export class Store {
query?: HttpTypes.StoreGetShippingOptionList, query?: HttpTypes.StoreGetShippingOptionList,
headers?: ClientHeaders headers?: ClientHeaders
) => { ) => {
return this.client.fetch< return this.client.fetch<HttpTypes.StoreShippingOptionListResponse>(
HttpTypes.StoreShippingOptionListResponse `/store/shipping-options`,
>(`/store/shipping-options`, { {
headers, headers,
query, query,
}) }
)
}, },
} }
@@ -866,12 +868,13 @@ export class Store {
query?: FindParams & HttpTypes.StorePaymentProviderFilters, query?: FindParams & HttpTypes.StorePaymentProviderFilters,
headers?: ClientHeaders headers?: ClientHeaders
) => { ) => {
return this.client.fetch< return this.client.fetch<HttpTypes.StorePaymentProviderListResponse>(
HttpTypes.StorePaymentProviderListResponse `/store/payment-providers`,
>(`/store/payment-providers`, { {
headers, headers,
query, query,
}) }
)
}, },
/** /**
@@ -917,24 +920,26 @@ export class Store {
cart_id: cart.id, cart_id: cart.id,
} }
paymentCollectionId = ( paymentCollectionId = (
await this.client.fetch< await this.client.fetch<HttpTypes.StorePaymentCollectionResponse>(
HttpTypes.StorePaymentCollectionResponse `/store/payment-collections`,
>(`/store/payment-collections`, { {
method: "POST", method: "POST",
headers, headers,
body: collectionBody, body: collectionBody,
}) }
)
).payment_collection.id ).payment_collection.id
} }
return this.client.fetch< return this.client.fetch<HttpTypes.StorePaymentCollectionResponse>(
HttpTypes.StorePaymentCollectionResponse `/store/payment-collections/${paymentCollectionId}/payment-sessions`,
>(`/store/payment-collections/${paymentCollectionId}/payment-sessions`, { {
method: "POST", method: "POST",
headers, headers,
body, body,
query, query,
}) }
)
}, },
} }
@@ -990,12 +995,13 @@ export class Store {
query?: HttpTypes.StoreOrderFilters, query?: HttpTypes.StoreOrderFilters,
headers?: ClientHeaders headers?: ClientHeaders
) => { ) => {
return this.client.fetch< return this.client.fetch<HttpTypes.StoreOrderListResponse>(
HttpTypes.StoreOrderListResponse `/store/orders`,
>(`/store/orders`, { {
query, query,
headers, headers,
}) }
)
}, },
/** /**
* This method retrieves an order by its ID. It sends a request to the * This method retrieves an order by its ID. It sends a request to the
@@ -1083,14 +1089,15 @@ export class Store {
query?: SelectParams, query?: SelectParams,
headers?: ClientHeaders headers?: ClientHeaders
) => { ) => {
return this.client.fetch< return this.client.fetch<HttpTypes.StoreCustomerResponse>(
HttpTypes.StoreCustomerResponse `/store/customers`,
>(`/store/customers`, { {
method: "POST", method: "POST",
headers, headers,
body, body,
query, query,
}) }
)
}, },
/** /**
* This method updates the logged-in customer's details. The customer must be logged in * This method updates the logged-in customer's details. The customer must be logged in
@@ -1119,9 +1126,7 @@ export class Store {
query?: SelectParams, query?: SelectParams,
headers?: ClientHeaders headers?: ClientHeaders
) => { ) => {
return this.client.fetch< return this.client.fetch<HttpTypes.StoreCustomerResponse>(
HttpTypes.StoreCustomerResponse
>(
`/store/customers/me`, `/store/customers/me`,
{ {
method: "POST", method: "POST",
@@ -1184,14 +1189,15 @@ export class Store {
query?: SelectParams, query?: SelectParams,
headers?: ClientHeaders headers?: ClientHeaders
) => { ) => {
return this.client.fetch< return this.client.fetch<HttpTypes.StoreCustomerResponse>(
HttpTypes.StoreCustomerResponse `/store/customers/me/addresses`,
>(`/store/customers/me/addresses`, { {
method: "POST", method: "POST",
headers, headers,
body, body,
query, query,
}) }
)
}, },
/** /**
* This method updates the address of the logged-in customer. The customer must be logged in * This method updates the address of the logged-in customer. The customer must be logged in
@@ -1225,9 +1231,7 @@ export class Store {
query?: SelectParams, query?: SelectParams,
headers?: ClientHeaders headers?: ClientHeaders
) => { ) => {
return this.client.fetch< return this.client.fetch<HttpTypes.StoreCustomerResponse>(
HttpTypes.StoreCustomerResponse
>(
`/store/customers/me/addresses/${addressId}`, `/store/customers/me/addresses/${addressId}`,
{ {
method: "POST", method: "POST",
@@ -1292,12 +1296,13 @@ export class Store {
query?: FindParams & HttpTypes.StoreCustomerAddressFilters, query?: FindParams & HttpTypes.StoreCustomerAddressFilters,
headers?: ClientHeaders headers?: ClientHeaders
) => { ) => {
return this.client.fetch< return this.client.fetch<HttpTypes.StoreCustomerAddressListResponse>(
HttpTypes.StoreCustomerAddressListResponse `/store/customers/me/addresses`,
>(`/store/customers/me/addresses`, { {
query, query,
headers, headers,
}) }
)
}, },
/** /**
* This method retrieves an address of the logged-in customer. The customer must be logged in * This method retrieves an address of the logged-in customer. The customer must be logged in
@@ -1346,9 +1351,7 @@ export class Store {
query?: SelectParams, query?: SelectParams,
headers?: ClientHeaders headers?: ClientHeaders
) => { ) => {
return this.client.fetch< return this.client.fetch<HttpTypes.StoreCustomerAddressResponse>(
HttpTypes.StoreCustomerAddressResponse
>(
`/store/customers/me/addresses/${addressId}`, `/store/customers/me/addresses/${addressId}`,
{ {
query, query,