feat(medusa, medusa-js, medusa-react): Implement Sales Channel list (#1815)

**What**
Support sales channel list in medusa, medusa-js and medusa-react

**How**

By implementing a new endpoint and the associated service method as well as the repository methods.

Medusa-js new list method in the resource

Medusa-react new hook in the queries

**Tests**

Endpoint test
Service test
Integration test
Hook tests

Fixes CORE-280
This commit is contained in:
Adrien de Peretti
2022-07-13 10:28:53 +00:00
committed by GitHub
parent c20d720040
commit a1a5848827
23 changed files with 750 additions and 53 deletions
@@ -1,4 +1,8 @@
import { AdminSalesChannelsRes } from "@medusajs/medusa"
import {
AdminSalesChannelsRes,
AdminSalesChannelsListRes,
AdminGetSalesChannelsParams,
} from "@medusajs/medusa"
import { Response } from "@medusajs/medusa-js"
import { useQuery } from "react-query"
import { useMedusa } from "../../../contexts"
@@ -36,21 +40,26 @@ export const useAdminSalesChannel = (
return { ...data, ...rest } as const
}
/*
/**
* retrieve a list of sales channels
* @experimental This feature is under development and may change in the future.
* To use this feature please enable feature flag `sales_channels` in your medusa backend project.
* @description Retrieve a list of sales channel
* @returns a list of sales channel as well as the pagination properties
*/
export const useAdminSalesChannels = (
query?: AdminGetSalesChannelsParams,
options?: UseQueryOptionsWrapper<
Response<AdminProductsListRes>,
Response<AdminSalesChannelsListRes>,
Error,
ReturnType<SalesChannelsQueryKeys["list"]>
>
) => {
const { client } = useMedusa()
const { data, ...rest } = useQuery(
adminProductKeys.list(query),
adminSalesChannelsKeys.list(query),
() => client.admin.salesChannels.list(query),
options
)
return { ...data, ...rest } as const
}
*/