From 5b7856a6ed533bbbff45681f6565702221b31ee3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 19 Jan 2023 20:00:09 +0200 Subject: [PATCH 01/17] chore(docs): Generated Docs Announcement Bar (automated) (#3073) Co-authored-by: olivermrbl --- www/docs/announcement.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/docs/announcement.json b/www/docs/announcement.json index dbca515b43..15289f12a5 100644 --- a/www/docs/announcement.json +++ b/www/docs/announcement.json @@ -1 +1 @@ -{"id":"https://github.com/medusajs/medusa/releases/tag/v1.7.4","content":"v1.7.4 is out","isCloseable":true} \ No newline at end of file +{"id":"https://github.com/medusajs/medusa/releases/tag/v1.7.5","content":"v1.7.5 is out","isCloseable":true} \ No newline at end of file From b5d2625d821e78eeb003c6264ee7db19c881769a Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Mon, 23 Jan 2023 10:58:04 +0200 Subject: [PATCH 02/17] chore: fixed redirect urls for upgrade guides (#3084) --- www/docs/netlify.toml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/www/docs/netlify.toml b/www/docs/netlify.toml index 407bb4e164..8de5fc42d5 100644 --- a/www/docs/netlify.toml +++ b/www/docs/netlify.toml @@ -88,28 +88,28 @@ [[redirects]] from="/advanced/backend/upgrade-guides/1-7-3" - to="advanced/backend/upgrade-guides/medusa-core/1-7-3" + to="/advanced/backend/upgrade-guides/medusa-core/1-7-3" [[redirects]] from="/advanced/backend/upgrade-guides/1-7-1" - to="advanced/backend/upgrade-guides/medusa-core/1-7-1" + to="/advanced/backend/upgrade-guides/medusa-core/1-7-1" [[redirects]] from="/advanced/backend/upgrade-guides/1-7-0" - to="advanced/backend/upgrade-guides/medusa-core/1-7-0" + to="/advanced/backend/upgrade-guides/medusa-core/1-7-0" [[redirects]] from="/advanced/backend/upgrade-guides/1-6-1" - to="advanced/backend/upgrade-guides/medusa-core/1-6-1" + to="/advanced/backend/upgrade-guides/medusa-core/1-6-1" [[redirects]] from="/advanced/backend/upgrade-guides/1-3-8" - to="advanced/backend/upgrade-guides/medusa-core/1-3-8" + to="/advanced/backend/upgrade-guides/medusa-core/1-3-8" [[redirects]] from="/advanced/backend/upgrade-guides/1-3-6" - to="advanced/backend/upgrade-guides/medusa-core/1-3-6" + to="/advanced/backend/upgrade-guides/medusa-core/1-3-6" [[redirects]] from="/advanced/backend/upgrade-guides/1-3-0" - to="advanced/backend/upgrade-guides/medusa-core/1-3-0" \ No newline at end of file + to="/advanced/backend/upgrade-guides/medusa-core/1-3-0" \ No newline at end of file From 7418a0025cf469f1ec2dc538f8732b573015779f Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Mon, 23 Jan 2023 16:23:49 +0200 Subject: [PATCH 03/17] docs: added a fix for QueryClient error in medusa-react upgrade guide (#3089) --- .../upgrade-guides/medusa-react/4-0-2.md | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/content/advanced/backend/upgrade-guides/medusa-react/4-0-2.md b/docs/content/advanced/backend/upgrade-guides/medusa-react/4-0-2.md index 22d7089c61..a78ddd1b46 100644 --- a/docs/content/advanced/backend/upgrade-guides/medusa-react/4-0-2.md +++ b/docs/content/advanced/backend/upgrade-guides/medusa-react/4-0-2.md @@ -52,3 +52,36 @@ import { QueryClient } from "@tanstack/react-query" // this remains the same const queryClient = new QueryClient() ``` + +### Fix No QueryClient set Errors + +If you're using a Next.js storefront, you might face the following error after this update when you run your storefront: + +```bash +No QueryClient set +``` + +This is due to an issue related to Tanstack Query shipping `esm` modules in its latest versions and how Next.js uses Webpack. + +Although in future versions of `medusa-react` this issue will be fixed, you can add the following into `next.config.js` to fix this error: + +```js +const path = require("path") + +/** @type {import('next').NextConfig} */ +const nextConfig = { + // ... other configs + webpack: (config, options) => { + if (options.isServer) { + config.externals = ["@tanstack/react-query", ...config.externals] + } + const reactQuery = path.resolve( + require.resolve("@tanstack/react-query") + ) + config.resolve.alias["@tanstack/react-query"] = reactQuery + return config + }, +} + +module.exports = nextConfig +``` From a248bf6e4f4b3d2310dc34820842d9479f7deb27 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Mon, 23 Jan 2023 21:04:09 +0200 Subject: [PATCH 04/17] docs: added medusa-react snippets in how-to guides (#3091) * added medusa-react snippets * added more code snippets * added medusa-react snippets * docs: added medusa-react snippets to storefront how-to * docs: added medusa-react snippets in admin how-to * docs: fixed incorrect link --- docs/api/admin-spec3-base.yaml | 13 +- docs/content/advanced/admin/import-prices.mdx | 117 ++++++- .../advanced/admin/import-products.mdx | 117 ++++++- .../advanced/admin/manage-customers.mdx | 98 ++++++ .../advanced/admin/manage-discounts.mdx | 236 +++++++++++++-- .../advanced/admin/manage-gift-cards.mdx | 225 +++++++++++++- .../admin/manage-publishable-api-keys.mdx | 216 ++++++++++++- .../content/advanced/admin/manage-regions.mdx | 162 +++++++++- docs/content/advanced/admin/order-edit.mdx | 218 +++++++++++++- .../advanced/admin/use-customergroups-api.mdx | 253 ++++++++++++++-- .../advanced/backend/price-lists/use-api.mdx | 188 +++++++++++- .../backend/sales-channels/manage-admin.mdx | 285 ++++++++++++++++-- .../advanced/storefront/customer-profiles.mdx | 99 +++++- .../storefront/handle-order-edits.mdx | 109 ++++++- .../how-to-implement-checkout-flow.mdx | 228 +++++++++++++- .../storefront/implement-claim-order.mdx | 38 ++- .../storefront/use-discounts-in-checkout.mdx | 45 ++- .../advanced/storefront/use-gift-cards.mdx | 88 +++++- .../advanced/storefront/use-regions.mdx | 97 +++++- .../storefront/use-sales-channels.mdx | 103 ++++++- docs/content/guides/carts-in-medusa.mdx | 247 +++++++++++++-- docs/content/js-client/overview.md | 2 +- docs/content/medusa-react/overview.md | 17 +- 23 files changed, 3032 insertions(+), 169 deletions(-) diff --git a/docs/api/admin-spec3-base.yaml b/docs/api/admin-spec3-base.yaml index 3253d88df8..89413a84c8 100644 --- a/docs/api/admin-spec3-base.yaml +++ b/docs/api/admin-spec3-base.yaml @@ -286,11 +286,20 @@ components: In this API reference, you'll find in the cURL request samples the use of `{api_token}`. This is where you must pass the API token. - If you're alternatively following along with the JS Client request samples, you must provide the `apiKey` option when creating the Medusa client: + If you're following along with the JS Client request samples, you must provide the `apiKey` option when creating the Medusa client: - ```js + ```ts const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3, apiKey: '{api_token}' }) ``` + + If you're using Medusa React, you can pass the `apiKey` prop to `MedusaProvider`: + + ```tsx + + ``` scheme: bearer cookie_auth: type: apiKey diff --git a/docs/content/advanced/admin/import-prices.mdx b/docs/content/advanced/admin/import-prices.mdx index 3fe74fe75c..8345426968 100644 --- a/docs/content/advanced/admin/import-prices.mdx +++ b/docs/content/advanced/admin/import-prices.mdx @@ -40,10 +40,16 @@ You must have a CSV file that you will use to import prices into your Medusa ser ### JS Client -This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, JavaScript’s Fetch API, or cURL. +This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, among other methods. If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../js-client/overview.md) installed and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + ### Authenticated Admin User You must be an authenticated admin user before following along with the steps in the tutorial. @@ -67,17 +73,37 @@ You can do that by sending the following request to the [Upload Files](https://d -```jsx +```ts medusa.admin.uploads.create(file) // file is an instance of File .then(({ uploads }) => { const key = uploads[0].key }) ``` + + + +```tsx +import { useAdminUploadFile } from "medusa-react" + +const ImportPrices = () => { + const uploadFile = useAdminUploadFile() + // ... + + const handleFileUpload = (file: File) => { + uploadFile.mutate(file) + } + + // ... +} + +export default ImportPrices +``` + -```jsx +```ts const formData = new FormData() formData.append("files", file) // file is an instance of File @@ -121,7 +147,7 @@ You can do that by sending the following request to the [Create a Batch Job](htt -```jsx +```ts medusa.admin.batchJobs.create({ type: "price-list-import", context: { @@ -135,10 +161,36 @@ medusa.admin.batchJobs.create({ }) ``` + + + +```tsx +import { useAdminCreateBatchJob } from "medusa-react" + +const ImportPrices = () => { + const createBatchJob = useAdminCreateBatchJob() + // ... + + const handleCreateBatchJob = () => { + createBatchJob.mutate({ + type: "price-list-import", + context: { + fileKey: key, // obtained from previous step + }, + dry_run: true, + }) + } + + // ... +} + +export default ImportPrices +``` + -```jsx +```ts fetch(`/admin/batch-jobs`, { method: "POST", credentials: "include", @@ -209,17 +261,44 @@ You can retrieve all the details of the batch job, including its status and the -```jsx +```ts medusa.admin.batchJobs.retrieve(batchJobId) .then(( batch_job ) => { console.log(batch_job.status, batch_job.result) }) ``` + + + +```tsx +import { useAdminBatchJob } from "medusa-react" + +const ImportPrices = () => { + const { batch_job, isLoading } = useAdminBatchJob(batchJobId) + // ... + + return ( +
+ {/* ... */} + {isLoading && Loading} + {batch_job && ( + + Status: {batch_job.status}. + Number of Prices: {batch_job.result.count} + + )} +
+ ) +} + +export default ImportPrices +``` +
-```jsx +```ts fetch(`/admin/batch-jobs/${batchJobId}`, { credentials: "include", }) @@ -272,17 +351,37 @@ To confirm a batch job send the following request: -```jsx +```ts medusa.admin.batchJobs.confirm(batchJobId) .then(( batch_job ) => { console.log(batch_job.status) }) ``` + + + +```tsx +import { useAdminConfirmBatchJob } from "medusa-react" + +const ImportPrices = () => { + const confirmBatchJob = useAdminConfirmBatchJob(batchJobId) + // ... + + const handleConfirmJob = () => { + confirmBatchJob.mutate() + } + + // ... +} + +export default ImportPrices +``` + -```jsx +```ts fetch(`/admin/batch-jobs/${batchJobId}/confirm`, { method: "POST", credentials: "include", diff --git a/docs/content/advanced/admin/import-products.mdx b/docs/content/advanced/admin/import-products.mdx index ee9074d0ca..8b93dbea5c 100644 --- a/docs/content/advanced/admin/import-products.mdx +++ b/docs/content/advanced/admin/import-products.mdx @@ -40,10 +40,16 @@ If you have Sales Channels enabled on your server, you must use [this CSV exampl ### JS Client -This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, JavaScript’s Fetch API, or cURL. +This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, among other methods. If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../js-client/overview.md) installed and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + ### Authenticated Admin User You must be an authenticated admin user before following along with the steps in the tutorial. @@ -61,17 +67,37 @@ You can do that by sending the following request to the [Upload Files](https://d -```jsx +```ts medusa.admin.uploads.create(file) // file is an instance of File .then(({ uploads }) => { const key = uploads[0].key }) ``` + + + +```tsx +import { useAdminUploadFile } from "medusa-react" + +const ImportProducts = () => { + const uploadFile = useAdminUploadFile() + // ... + + const handleFileUpload = (file: File) => { + uploadFile.mutate(file) + } + + // ... +} + +export default ImportProducts +``` + -```jsx +```ts const formData = new FormData() formData.append("files", file) // file is an instance of File @@ -115,7 +141,7 @@ You can do that by sending the following request to the [Create a Batch Job](htt -```jsx +```ts medusa.admin.batchJobs.create({ type: "product-import", context: { @@ -128,10 +154,36 @@ medusa.admin.batchJobs.create({ }) ``` + + + +```tsx +import { useAdminCreateBatchJob } from "medusa-react" + +const ImportProducts = () => { + const createBatchJob = useAdminCreateBatchJob() + // ... + + const handleCreateBatchJob = () => { + createBatchJob.mutate({ + type: "product-import", + context: { + fileKey: key, // obtained from previous step + }, + dry_run: true, + }) + } + + // ... +} + +export default ImportProducts +``` + -```jsx +```ts fetch(`/admin/batch-jobs`, { method: "POST", credentials: "include", @@ -197,17 +249,44 @@ You can retrieve all the details of the batch job, including its status and the -```jsx +```ts medusa.admin.batchJobs.retrieve(batchJobId) .then(( batch_job ) => { console.log(batch_job.status, batch_job.result) }) ``` + + + +```tsx +import { useAdminBatchJob } from "medusa-react" + +const ImportProducts = () => { + const { batch_job, isLoading } = useAdminBatchJob(batchJobId) + // ... + + return ( +
+ {/* ... */} + {isLoading && Loading} + {batch_job && ( + + Status: {batch_job.status}. + Number of Products: {batch_job.result.count} + + )} +
+ ) +} + +export default ImportProducts +``` +
-```jsx +```ts fetch(`/admin/batch-jobs/${batchJobId}`, { credentials: "include", }) @@ -260,17 +339,37 @@ To confirm a batch job send the following request: -```jsx +```ts medusa.admin.batchJobs.confirm(batchJobId) .then(( batch_job ) => { console.log(batch_job.status) }) ``` + + + +```tsx +import { useAdminConfirmBatchJob } from "medusa-react" + +const ImportProducts = () => { + const confirmBatchJob = useAdminConfirmBatchJob(batchJobId) + // ... + + const handleConfirmJob = () => { + confirmBatchJob.mutate() + } + + // ... +} + +export default ImportProducts +``` + -```jsx +```ts fetch(`/admin/batch-jobs/${batchJobId}/confirm`, { method: "POST", credentials: "include", diff --git a/docs/content/advanced/admin/manage-customers.mdx b/docs/content/advanced/admin/manage-customers.mdx index 94b2734b26..de5beedd17 100644 --- a/docs/content/advanced/admin/manage-customers.mdx +++ b/docs/content/advanced/admin/manage-customers.mdx @@ -31,6 +31,12 @@ This guide includes code snippets to send requests to your Medusa server using M If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../js-client/overview.md) installed and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + ### Authenticated Admin User You must be an authenticated admin user before following along with the steps in the tutorial. @@ -53,6 +59,34 @@ medusa.admin.customers.list() }) ``` + + + +```tsx +import { Customer } from "@medusajs/medusa" +import { useAdminCustomers } from "medusa-react" + +const Customers = () => { + const { customers, isLoading } = useAdminCustomers() + + return ( +
+ {isLoading && Loading...} + {customers && !customers.length && No customers} + {customers && customers.length > 0 && ( +
    + {customers.map((customer: Customer) => ( +
  • {customer.first_name}
  • + ))} +
+ )} +
+ ) +} + +export default Customers +``` +
@@ -115,6 +149,38 @@ medusa.admin.customers.create({ }) ``` + + + +```tsx +import { useAdminCreateCustomer } from "medusa-react" + +const CreateCustomer = () => { + const createCustomer = useAdminCreateCustomer() + // ... + + const handleCreate = () => { + // ... + createCustomer.mutate({ + first_name, + last_name, + email, + password, + }) + } + + // ... + + return ( +
+ {/* Render form */} +
+ ) +} + +export default CreateCustomer +``` +
@@ -187,6 +253,38 @@ medusa.admin.customers.update(customerId, { }) ``` + + + +```tsx +import { useAdminUpdateCustomer } from "medusa-react" + +const UpdateCustomer = () => { + const updateCustomer = useAdminUpdateCustomer(customerId) + // ... + + const handleUpdate = () => { + // ... + updateCustomer.mutate({ + email, + password, + first_name, + last_name, + }) + } + + // ... + + return ( +
+ {/* Render form */} +
+ ) +} + +export default UpdateCustomer +``` +
diff --git a/docs/content/advanced/admin/manage-discounts.mdx b/docs/content/advanced/admin/manage-discounts.mdx index c3a148e7b1..56f72570fc 100644 --- a/docs/content/advanced/admin/manage-discounts.mdx +++ b/docs/content/advanced/admin/manage-discounts.mdx @@ -43,6 +43,12 @@ This guide includes code snippets to send requests to your Medusa server using M If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../js-client/overview.md) installed and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + ### Authenticated Admin User You must be an authenticated admin user before following along with the steps in the tutorial. @@ -58,7 +64,7 @@ You can create a discount by sending a request to the [Create Discount](/api/adm -```jsx +```ts import { AllocationType, DiscountRuleType } from "@medusajs/medusa" // ... medusa.admin.discounts.create({ @@ -69,18 +75,54 @@ medusa.admin.discounts.create({ allocation: AllocationType.ITEM, }, regions: [ - regionId, + regionId, ], + is_dynamic: false, + is_disabled: false, }) .then(({ discount }) => { console.log(discount.id) }) ``` + + + +```tsx +import { useAdminCreateDiscount } from "medusa-react" +import { AllocationType, DiscountRuleType } from "@medusajs/medusa" + +const CreateDiscount = () => { + const createDiscount = useAdminCreateDiscount() + // ... + + const handleCreate = () => { + // ... + createDiscount.mutate({ + code, + rule: { + type: DiscountRuleType.FIXED, + value: 10, + allocation: AllocationType.ITEM, + }, + regions: [ + regionId, + ], + is_dynamic: false, + is_disabled: false, + }) + } + + // ... +} + +export default CreateDiscount +``` + -```jsx +```ts fetch(`/admin/discounts`, { method: "POST", credentials: "include", @@ -97,6 +139,8 @@ fetch(`/admin/discounts`, { regions: [ regionId, ], + is_dynamic: false, + is_disabled: false, }), }) .then((response) => response.json()) @@ -121,7 +165,9 @@ curl -L -X POST '/admin/discounts' \ }, "regions": [ "" - ] + ], + "is_dynamic": false, + "is_disabled": false }' ``` @@ -150,9 +196,8 @@ For example, you can update the discount’s description and status by sending t -```jsx +```ts medusa.admin.discounts.update(discountId, { - description: "New description", is_disabled: true, }) .then(({ discount }) => { @@ -160,10 +205,33 @@ medusa.admin.discounts.update(discountId, { }) ``` + + + +```tsx +import { useAdminUpdateDiscount } from "medusa-react" + +const UpdateDiscount = () => { + const updateDiscount = useAdminUpdateDiscount(discount_id) + // ... + + const handleUpdate = () => { + // ... + updateDiscount.mutate({ + is_disabled: true, + }) + } + + // ... +} + +export default UpdateDiscount +``` + -```jsx +```ts fetch(`/admin/discounts/${discountId}`, { method: "POST", credentials: "include", @@ -171,7 +239,6 @@ fetch(`/admin/discounts/${discountId}`, { "Content-Type": "application/json", }, body: JSON.stringify({ - description: "New description", is_disabled: true, }), }) @@ -189,7 +256,6 @@ curl -L -X POST '/admin/discounts/' \ -H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ --data-raw '{ - "description": "New description", "is_disabled": true }' ``` @@ -197,7 +263,7 @@ curl -L -X POST '/admin/discounts/' \ -This request accepts the discount ID as a path parameter. You can pass the parameters you want to update in the request body. In the example above, you pass the `description` and `is_disabled` parameters to update them. +This request accepts the discount ID as a path parameter. You can pass the parameters you want to update in the request body. In the example above, is_disabled` parameter to update it. You can check the [API reference](/api/admin/#tag/Discount/operation/PostDiscountsDiscount) for all the accepted parameters to update the discount. @@ -220,7 +286,7 @@ You can send a request to the [Create Condition](/api/admin/#tag/Discount-Condit -```jsx +```ts import { DiscountConditionOperator } from "@medusajs/medusa" // ... medusa.admin.discounts.createCondition(discount_id, { @@ -234,10 +300,40 @@ medusa.admin.discounts.createCondition(discount_id, { }) ``` + + + +```tsx +import { useAdminDiscountCreateCondition } from "medusa-react" +import { DiscountConditionOperator } from "@medusajs/medusa" + +const Discount = () => { + const createCondition = useAdminDiscountCreateCondition(discount_id) + // ... + + const handleCreateCondition = ( + operator: DiscountConditionOperator, + productId: string + ) => { + // ... + createCondition.mutate({ + operator, + products: [ + productId, + ], + }) + } + + // ... +} + +export default Discount +``` + -```jsx +```ts fetch(`/admin/discounts/${discountId}/conditions`, { method: "POST", credentials: "include", @@ -299,7 +395,7 @@ You can retrieve a condition and its resources by sending a request to the [Get -```jsx +```ts medusa.admin.discounts.getCondition(discountId, conditionId, { expand: "products", }) @@ -308,10 +404,44 @@ medusa.admin.discounts.getCondition(discountId, conditionId, { }) ``` + + + +```tsx +import { useAdminGetDiscountCondition } from "medusa-react" +import { Product } from "@medusajs/medusa" + +const DiscountCondition = () => { + const { discount_condition, isLoading } = useAdminGetDiscountCondition( + discount_id, + conditionId + ) + // ... + + return ( +
+ {isLoading && Loading} + {discount_condition && ( + <> + {discount_condition.id} +
    + {discount_condition.products.map((product: Product) => ( +
  • {product.title}
  • + ))} +
+ + )} +
+ ) +} + +export default DiscountCondition +``` +
-```jsx +```ts fetch( `/admin/discounts/${discountId}` + `/conditions/${conditionId}&expand=products`, @@ -351,7 +481,7 @@ For example, to update the products in a condition: -```jsx +```ts medusa.admin.discounts.updateCondition(discountId, conditionId, { products: [ productId1, @@ -363,10 +493,36 @@ medusa.admin.discounts.updateCondition(discountId, conditionId, { }) ``` + + + +```tsx +import { useAdminDiscountUpdateCondition } from "medusa-react" +import { Product } from "@medusajs/medusa" + +const DiscountCondition = () => { + const updateCondition = useAdminDiscountUpdateCondition( + discount_id, + conditionId + ) + // ... + + const handleUpdateCondition = (productIds: string[]) => { + updateCondition.mutate({ + products: productIds, + }) + } + + // ... +} + +export default DiscountCondition +``` + -```jsx +```ts fetch( `/admin/discounts/${discountId}/conditions/${conditionId}`, { @@ -420,17 +576,37 @@ You can delete a condition by sending a request to the [Delete Condition](/api/a -```jsx +```ts medusa.admin.discounts.deleteCondition(discountId, conditionId) .then(({ discount }) => { console.log(discount) }) ``` + + + +```tsx +import { useAdminDiscountRemoveCondition } from "medusa-react" + +const Discount = () => { + const deleteCondition = useAdminDiscountRemoveCondition(discount_id) + // ... + + const handleUpdateCondition = (conditionId: string) => { + deleteCondition.mutate(conditionId) + } + + // ... +} + +export default Discount +``` + -```jsx +```ts fetch( `/admin/discounts/${discountId}/conditions/${conditionId}`, { @@ -468,17 +644,37 @@ You can delete a discount by sending a request to the [Delete Discount](/api/adm -```jsx +```ts medusa.admin.discounts.delete(discount_id) .then(({ id, object, deleted }) => { console.log(id) }) ``` + + + +```tsx +import { useAdminDeleteDiscount } from "medusa-react" + +const Discount = () => { + const deleteDiscount = useAdminDeleteDiscount(discount_id) + // ... + + const handleDelete = () => { + deleteDiscount.mutate() + } + + // ... +} + +export default Discount +``` + -```jsx +```ts fetch(`/admin/discounts/${discountId}`, { method: "DELETE", credentials: "include", diff --git a/docs/content/advanced/admin/manage-gift-cards.mdx b/docs/content/advanced/admin/manage-gift-cards.mdx index 64437c8114..389ceebe4a 100644 --- a/docs/content/advanced/admin/manage-gift-cards.mdx +++ b/docs/content/advanced/admin/manage-gift-cards.mdx @@ -32,10 +32,16 @@ It is assumed that you already have a Medusa server installed and set up. If not ### JS Client -This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, JavaScript’s Fetch API, or cURL. +This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, among other methods. If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../js-client/overview.md) installed and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + ### Authenticated Admin User You must be an authenticated admin user before following along with the steps in the tutorial. @@ -71,6 +77,37 @@ medusa.admin.products.list({ }) ``` + + + +```tsx +import { Product } from "@medusajs/medusa" +import { PricedProduct } from "@medusajs/medusa/dist/types/pricing" +import { useAdminProducts } from "medusa-react" + +const GiftCard = () => { + const { products, isLoading } = useAdminProducts({ + is_giftcard: true, + }) + + return ( +
+ {isLoading && Loading...} + {products && products.length > 0 && ( +
    + {products.map((product: (Product | PricedProduct)) => ( +
  • {product.title}
  • + ))} +
+ )} + {products && !products.length && No Gift Cards} +
+ ) +} + +export default GiftCard +``` +
@@ -149,6 +186,55 @@ medusa.admin.products.create({ }) ``` + + + +```tsx +import { useAdminCreateProduct } from "medusa-react" +import { ProductStatus } from "@medusajs/medusa" + +const CreateGiftCard = () => { + const createGiftCard = useAdminCreateProduct() + // ... + + const handleCreate = () => { + createGiftCard.mutate({ + title: "My Gift Card", + is_giftcard: true, + discountable: false, + status: ProductStatus.PUBLISHED, + options: [ + { + title: "Denomination", + }, + ], + variants: [ + { + title: "1", + inventory_quantity: 0, + manage_inventory: false, + prices: [ + { + amount: 2000, + currency_code: "usd", + }, + ], + options: [ + { + value: "2000", + }, + ], + }, + ], + }) + } + + // ... +} + +export default CreateGiftCard +``` + @@ -266,6 +352,28 @@ medusa.admin.products.update(giftCardId, { }) ``` + + + +```tsx +import { useAdminUpdateProduct } from "medusa-react" + +const UpdateGiftCard = () => { + const createGiftCard = useAdminUpdateProduct(giftCardId) + // ... + + const handleUpdate = () => { + createGiftCard.mutate({ + description: "The best gift card", + }) + } + + // ... +} + +export default UpdateGiftCard +``` + @@ -321,6 +429,26 @@ medusa.admin.products.delete(giftCardId) }) ``` + + + +```tsx +import { useAdminDeleteProduct } from "medusa-react" + +const GiftCard = () => { + const deleteGiftCard = useAdminDeleteProduct(giftCardId) + // ... + + const handleDelete = () => { + deleteGiftCard.mutate() + } + + // ... +} + +export default GiftCard +``` + @@ -374,6 +502,36 @@ medusa.admin.giftCards.list() }) ``` + + + +```tsx +import { GiftCard } from "@medusajs/medusa" +import { useAdminGiftCards } from "medusa-react" + +const CustomGiftCards = () => { + const { gift_cards, isLoading } = useAdminGiftCards() + + return ( +
+ {isLoading && Loading...} + {gift_cards && !gift_cards.length && ( + No custom gift cards... + )} + {gift_cards && gift_cards.length > 0 && ( +
    + {gift_cards.map((giftCard: GiftCard) => ( +
  • {giftCard.code}
  • + ))} +
+ )} +
+ ) +} + +export default CustomGiftCards +``` +
@@ -421,6 +579,29 @@ medusa.admin.giftCards.create({ }) ``` + + + +```tsx +import { useAdminCreateGiftCard } from "medusa-react" + +const CreateCustomGiftCards = () => { + const createGiftCard = useAdminCreateGiftCard() + // ... + + const handleCreate = (regionId: string, value: number) => { + createGiftCard.mutate({ + region_id: regionId, + value, + }) + } + + // ... +} + +export default CreateCustomGiftCards +``` + @@ -482,6 +663,28 @@ medusa.admin.giftCards.update(giftCardId, { }) ``` + + + +```tsx +import { useAdminUpdateGiftCard } from "medusa-react" + +const UpdateCustomGiftCards = () => { + const updateGiftCard = useAdminUpdateGiftCard(customGiftCardId) + // ... + + const handleUpdate = (regionId: string) => { + updateGiftCard.mutate({ + region_id: regionId, + }) + } + + // ... +} + +export default UpdateCustomGiftCards +``` + @@ -537,6 +740,26 @@ medusa.admin.giftCards.delete(giftCardId) }) ``` + + + +```tsx +import { useAdminDeleteGiftCard } from "medusa-react" + +const CustomGiftCard = () => { + const deleteGiftCard = useAdminDeleteGiftCard(customGiftCardId) + // ... + + const handleDelete = () => { + deleteGiftCard.mutate() + } + + // ... +} + +export default CustomGiftCard +``` + diff --git a/docs/content/advanced/admin/manage-publishable-api-keys.mdx b/docs/content/advanced/admin/manage-publishable-api-keys.mdx index 2c0e210121..ceab6d2cd6 100644 --- a/docs/content/advanced/admin/manage-publishable-api-keys.mdx +++ b/docs/content/advanced/admin/manage-publishable-api-keys.mdx @@ -36,10 +36,16 @@ It is assumed that you already have a Medusa server installed and set up. If not ### JS Client -This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, JavaScript’s Fetch API, or cURL. +This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, among other methods. If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../js-client/overview.md) installed and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + ### Authenticated Admin User You must be an authenticated admin user before following along with the steps in the tutorial. @@ -62,6 +68,38 @@ medusa.admin.publishableApiKeys.list() }) ``` + + + +```tsx +import { PublishableApiKey } from "@medusajs/medusa" +import { useAdminPublishableApiKeys } from "medusa-react" + +const PublishabelApiKeys = () => { + const { publishable_api_keys, isLoading } = useAdminPublishableApiKeys() + + return ( +
+ {isLoading && Loading...} + {publishable_api_keys && !publishable_api_keys.length && ( + No Publishable API Keys + )} + {publishable_api_keys && publishable_api_keys.length > 0 && ( +
    + {publishable_api_keys.map( + (publishableApiKey: PublishableApiKey) => ( +
  • {publishableApiKey.title}
  • + ) + )} +
+ )} +
+ ) +} + +export default PublishabelApiKeys +``` +
@@ -119,6 +157,28 @@ medusa.admin.publishableApiKeys.create({ }) ``` + + + +```tsx +import { useAdminCreatePublishableApiKey } from "medusa-react" + +const CreatePublishableApiKey = () => { + const createKey = useAdminCreatePublishableApiKey() + // ... + + const handleCreate = (title: string) => { + createKey.mutate({ + title, + }) + } + + // ... +} + +export default CreatePublishableApiKey +``` + @@ -176,6 +236,28 @@ medusa.admin.publishableApiKeys.update(publishableApiKeyId, { }) ``` + + + +```tsx +import { useAdminUpdatePublishableApiKey } from "medusa-react" + +const UpdatePublishableApiKey = () => { + const updateKey = useAdminUpdatePublishableApiKey(publishableApiKeyId) + // ... + + const handleUpdate = (title: string) => { + updateKey.mutate({ + title, + }) + } + + // ... +} + +export default UpdatePublishableApiKey +``` + @@ -233,6 +315,26 @@ medusa.admin.publishableApiKeys.revoke(publishableApiKeyId) }) ``` + + + +```tsx +import { useAdminRevokePublishableApiKey } from "medusa-react" + +const PublishableApiKey = () => { + const revokeKey = useAdminRevokePublishableApiKey(publishableApiKeyId) + // ... + + const handleRevoke = () => { + revokeKey.mutate() + } + + // ... +} + +export default PublishableApiKey +``` + @@ -279,6 +381,26 @@ medusa.admin.publishableApiKeys.delete(publishableApiKeyId) }) ``` + + + +```tsx +import { useAdminDeletePublishableApiKey } from "medusa-react" + +const PublishableApiKey = () => { + const deleteKey = useAdminDeletePublishableApiKey(publishableApiKeyId) + // ... + + const handleDelete = () => { + deleteKey.mutate() + } + + // ... +} + +export default PublishableApiKey +``` + @@ -332,6 +454,39 @@ medusa.admin.publishableApiKeys.listSalesChannels(publishableApiKeyId) }) ``` + + + +```tsx +import { SalesChannel } from "@medusajs/medusa" +import { useAdminPublishableApiKeySalesChannels } from "medusa-react" + +const SalesChannels = () => { + const { sales_channels, isLoading } = + useAdminPublishableApiKeySalesChannels( + publishableApiKeyId + ) + + return ( +
+ {isLoading && Loading...} + {sales_channels && !sales_channels.length && ( + No Sales Channels + )} + {sales_channels && sales_channels.length > 0 && ( +
    + {sales_channels.map((salesChannel: SalesChannel) => ( +
  • {salesChannel.name}
  • + ))} +
+ )} +
+ ) +} + +export default SalesChannels +``` +
@@ -388,6 +543,34 @@ medusa.admin.publishableApiKeys.addSalesChannelsBatch( }) ``` + + + +```tsx +import { useAdminAddPublishableKeySalesChannelsBatch } from "medusa-react" + +const PublishableApiKey = () => { + const addSalesChannels = useAdminAddPublishableKeySalesChannelsBatch( + publishableApiKeyId + ) + // ... + + const handleAdd = (salesChannelId: string) => { + addSalesChannels.mutate({ + sales_channel_ids: [ + { + id: salesChannelId, + }, + ], + }) + } + + // ... +} + +export default PublishableApiKey +``` + @@ -467,6 +650,37 @@ medusa.admin.publishableApiKeys.deleteSalesChannelsBatch( }) ``` + + + +```tsx +import { + useAdminRemovePublishableKeySalesChannelsBatch, +} from "medusa-react" + +const PublishableApiKey = () => { + const deleteSalesChannels = + useAdminRemovePublishableKeySalesChannelsBatch( + publishableApiKeyId + ) + // ... + + const handleDelete = (salesChannelId: string) => { + deleteSalesChannels.mutate({ + sales_channel_ids: [ + { + id: salesChannelId, + }, + ], + }) + } + + // ... +} + +export default PublishableApiKey +``` + diff --git a/docs/content/advanced/admin/manage-regions.mdx b/docs/content/advanced/admin/manage-regions.mdx index 52def1da8e..3884aed775 100644 --- a/docs/content/advanced/admin/manage-regions.mdx +++ b/docs/content/advanced/admin/manage-regions.mdx @@ -35,10 +35,16 @@ It is assumed that you already have a Medusa server installed and set up. If not ### JS Client -This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, JavaScript’s Fetch API, or cURL. +This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, among other methods. If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../js-client/overview.md) installed and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + ### Authenticated Admin User You must be an authenticated admin user before following along with the steps in the tutorial. @@ -54,7 +60,7 @@ You can retrieve regions available on your server using the [List Regions](/api/ -```tsx +```ts medusa.admin.regions.list() .then(({ regions, limit, offset, count }) => { console.log(regions.length) @@ -63,9 +69,37 @@ medusa.admin.regions.list() ``` - + ```tsx +import { Region } from "@medusajs/medusa" +import { useAdminRegions } from "medusa-react" + +const Regions = () => { + const { regions, isLoading } = useAdminRegions() + + return ( +
+ {isLoading && Loading...} + {regions && !regions.length && No Regions} + {regions && regions.length > 0 && ( +
    + {regions.map((region: Region) => ( +
  • {region.name}
  • + ))} +
+ )} +
+ ) +} + +export default Regions +``` + +
+ + +```ts fetch(`/admin/regions`, { credentials: "include", }) @@ -100,7 +134,7 @@ You can create a region by sending a request to the [Create a Region](/api/admin -```tsx +```ts medusa.admin.regions.create({ name: "Europe", currency_code: "eur", @@ -121,9 +155,42 @@ medusa.admin.regions.create({ ``` - + ```tsx +import { useAdminCreateRegion } from "medusa-react" + +const CreateRegion = () => { + const createRegion = useAdminCreateRegion() + // ... + + const handleCreate = () => { + createRegion.mutate({ + name: "Europe", + currency_code: "eur", + tax_rate: 0, + payment_providers: [ + "manual", + ], + fulfillment_providers: [ + "manual", + ], + countries: [ + "DK", + ], + }) + } + + // ... +} + +export default CreateRegion +``` + + + + +```ts fetch(`/admin/regions`, { credentials: "include", method: "POST", @@ -198,7 +265,7 @@ Alternatively, you can update the details of a region using the [Update a Region -```tsx +```ts medusa.admin.regions.update(regionId, { countries: [ "DK", @@ -211,9 +278,34 @@ medusa.admin.regions.update(regionId, { ``` - + ```tsx +import { useAdminUpdateRegion } from "medusa-react" + +const UpdateRegion = () => { + const updateRegion = useAdminUpdateRegion(regionId) + // ... + + const handleUpdate = () => { + updateRegion.mutate({ + countries: [ + "DK", + "DE", + ], + }) + } + + // ... +} + +export default UpdateRegion +``` + + + + +```ts fetch(`/admin/regions/${regionId}`, { credentials: "include", method: "POST", @@ -269,7 +361,7 @@ You can add a shipping option to a region by sending a request to the [Create Sh -```tsx +```ts medusa.admin.shippingOptions.create({ name: "PostFake", region_id: regionId, @@ -285,9 +377,37 @@ medusa.admin.shippingOptions.create({ ``` - + ```tsx +import { useAdminCreateShippingOption } from "medusa-react" + +const Region = () => { + const createShippingOption = useAdminCreateShippingOption() + // ... + + const handleCreate = () => { + createShippingOption.mutate({ + name: "PostFake", + region_id: regionId, + provider_id: "manual", + data: { + }, + price_type: "flat_rate", + amount: 1000, + }) + } + + // ... +} + +export default Region +``` + + + + +```ts fetch(`/admin/shipping-options`, { credentials: "include", method: "POST", @@ -357,7 +477,7 @@ You can delete a region by sending a request to the [Delete a Region](/api/admin -```tsx +```ts medusa.admin.regions.delete(regionId) .then(({ id, object, deleted }) => { console.log(id) @@ -365,9 +485,29 @@ medusa.admin.regions.delete(regionId) ``` - + ```tsx +import { useAdminDeleteRegion } from "medusa-react" + +const Region = () => { + const deleteRegion = useAdminDeleteRegion(regionId) + // ... + + const handleDelete = () => { + deleteRegion.mutate() + } + + // ... +} + +export default Region +``` + + + + +```ts fetch(`/admin/regions/${regionId}`, { credentials: "include", method: "DELETE", diff --git a/docs/content/advanced/admin/order-edit.mdx b/docs/content/advanced/admin/order-edit.mdx index 8267e834f4..deb00593c7 100644 --- a/docs/content/advanced/admin/order-edit.mdx +++ b/docs/content/advanced/admin/order-edit.mdx @@ -49,10 +49,16 @@ It is assumed that you already have a Medusa server installed and set up. If not ### JS Client -This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, JavaScript’s Fetch API, or cURL. +This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, among other methods. If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../js-client/overview.md) installed and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + ### Authenticated Admin User You must be an authenticated admin user before following along with the steps in the tutorial. @@ -83,6 +89,27 @@ medusa.admin.orderEdits.create({ }) ``` + + + +```tsx +import { useAdminCreateOrderEdit } from "medusa-react" + +const OrderEdit = () => { + const createOrderEdit = useAdminCreateOrderEdit() + + const handleCreateOrderEdit = (orderId: string) => { + createOrderEdit.mutate({ + order_id: orderId, + }) + } + + // ... +} + +export default OrderEdit +``` + @@ -157,6 +184,28 @@ medusa.admin.orderEdits.addLineItem(orderEditId, { }) ``` + + + +```tsx +import { useAdminOrderEditAddLineItem } from "medusa-react" + +const OrderEdit = () => { + const addLineItem = useAdminOrderEditAddLineItem(orderEditId) + + const handleAddLineItem = (quantity: number, variantId: string) => { + addLineItem.mutate({ + quantity, + variant_id: variantId, + }) + } + + // ... +} + +export default OrderEdit +``` + @@ -218,6 +267,30 @@ medusa.admin.orderEdits.updateLineItem(orderEditId, itemId, { }) ``` + + + +```tsx +import { useAdminOrderEditUpdateLineItem } from "medusa-react" + +const OrderEdit = () => { + const updateLineItem = useAdminOrderEditUpdateLineItem( + orderEditId, + itemId + ) + + const handleUpdateLineItem = (quantity: number) => { + updateLineItem.mutate({ + quantity, + }) + } + + // ... +} + +export default OrderEdit +``` + @@ -273,6 +346,28 @@ medusa.admin.orderEdits.removeLineItem(orderEditId, itemId) }) ``` + + + +```tsx +import { useAdminOrderEditDeleteLineItem } from "medusa-react" + +const OrderEdit = () => { + const removeLineItem = useAdminOrderEditDeleteLineItem( + orderEditId, + itemId + ) + + const handleRemoveLineItem = () => { + removeLineItem.mutate() + } + + // ... +} + +export default OrderEdit +``` + @@ -320,6 +415,28 @@ medusa.admin.orderEdits.deleteItemChange(orderEditId, changeId) }) ``` + + + +```tsx +import { useAdminDeleteOrderEditItemChange } from "medusa-react" + +const OrderEdit = () => { + const deleteItemChange = useAdminDeleteOrderEditItemChange( + orderEditId, + itemChangeId + ) + + const handleDeleteItemChange = () => { + deleteItemChange.mutate() + } + + // ... +} + +export default OrderEdit +``` + @@ -374,6 +491,28 @@ medusa.admin.orderEdits.requestConfirmation(orderEditId) }) ``` + + + +```tsx +import { useAdminRequestOrderEditConfirmation } from "medusa-react" + +const OrderEdit = () => { + const requestOrderConfirmation = + useAdminRequestOrderEditConfirmation( + orderEditId + ) + + const handleRequestConfirmation = () => { + requestOrderConfirmation.mutate() + } + + // ... +} + +export default OrderEdit +``` + @@ -441,6 +580,25 @@ medusa.admin.orderEdits.confirm(orderEditId) }) ``` + + + +```tsx +import { useAdminConfirmOrderEdit } from "medusa-react" + +const OrderEdit = () => { + const confirmOrderEdit = useAdminConfirmOrderEdit(orderEditId) + + const handleConfirmOrderEdit = () => { + confirmOrderEdit.mutate() + } + + // ... +} + +export default OrderEdit +``` + @@ -503,6 +661,25 @@ medusa.admin.payments.capturePayment(paymentId) }) ``` + + + +```tsx +import { useAdminPaymentsCapturePayment } from "medusa-react" + +const OrderEditPayment = () => { + const capturePayment = useAdminPaymentsCapturePayment(paymentId) + + const handleCapturePayment = () => { + capturePayment.mutate() + } + + // ... +} + +export default OrderEditPayment +``` + @@ -542,14 +719,41 @@ To refund the difference to the customer, send a request to the [Refund Payment] ```ts +import { RefundReason } from "@medusajs/medusa" +// ... + medusa.admin.payments.refundPayment(paymentId, { amount, + reason: RefundReason.DISCOUNT, // for example }) .then(({ refund }) => { console.log(refund.id) }) ``` + + + +```tsx +import { useAdminPaymentsRefundPayment } from "medusa-react" +import { RefundReason } from "@medusajs/medusa" + +const OrderEditPayment = () => { + const refundPayment = useAdminPaymentsRefundPayment(paymentId) + + const handleRefundPayment = (amount: number, reason: RefundReason) => { + refundPayment.mutate({ + amount, + reason, + }) + } + + // ... +} + +export default OrderEditPayment +``` + @@ -562,6 +766,7 @@ fetch(`/admin/payments/${paymentId}/refund`, { }, body: JSON.stringify({ amount, + reason: "discount", }), }) .then((response) => response.json()) @@ -578,7 +783,8 @@ curl -L -X POST '/admin/payments//refund' \ -H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ --data-raw '{ - "amount": 1000 + "amount": 1000, + "reason": "discount" }' ``` @@ -589,6 +795,14 @@ This request requires the ID of the payment as a path parameter. The payment can In the request’s body parameters, the `amount` field parameter is required. It is the amount to be refunded. +The `reason` request body parameter is also required. Its value is a string that can be one of the following: + +- `discount` +- `return` +- `swap` +- `claim` +- `other` + :::note Check out what other parameters can be sent in the [API reference](/api/admin/#tag/Payment/operation/PostPaymentsPaymentRefunds). diff --git a/docs/content/advanced/admin/use-customergroups-api.mdx b/docs/content/advanced/admin/use-customergroups-api.mdx index 346a1e0a08..e076a49593 100644 --- a/docs/content/advanced/admin/use-customergroups-api.mdx +++ b/docs/content/advanced/admin/use-customergroups-api.mdx @@ -23,10 +23,16 @@ It is assumed that you already have a Medusa server installed and set up. If not ### JS Client -This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, JavaScript’s Fetch API, or cURL. +This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, among other methods. If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../js-client/overview.md) installed and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + ### Authenticated Admin User You must be an authenticated admin user before following along with the steps in the tutorial. @@ -42,7 +48,7 @@ You can create a customer group by sending a request to the Create Customer Grou -```jsx +```ts medusa.admin.customerGroups.create({ name: "VIP", }) @@ -51,10 +57,38 @@ medusa.admin.customerGroups.create({ }) ``` + + + +```tsx +import { useAdminCreateCustomerGroup } from "medusa-react" + +const CreateCustomerGroup = () => { + const createCustomerGroup = useAdminCreateCustomerGroup() + // ... + + const handleCreate = () => { + createCustomerGroup.mutate({ + name, + }) + } + + // ... + + return ( +
+ {/* Render form */} +
+ ) +} + +export default CreateCustomerGroup +``` +
-```jsx +```ts fetch(`/admin/customer-groups`, { method: "POST", credentials: "include", @@ -97,17 +131,47 @@ You can get a list of all customer groups by sending a request to the List Custo -```jsx +```ts medusa.admin.customerGroups.list() .then(({ customer_groups, limit, offset, count }) => { console.log(customer_groups.length) }) ``` + + + +```tsx +import { CustomerGroup } from "@medusajs/medusa" +import { useAdminCustomerGroups } from "medusa-react" + +const CustomerGroups = () => { + const { customer_groups, isLoading } = useAdminCustomerGroups() + + return ( +
+ {isLoading && Loading...} + {customer_groups && !customer_groups.length && ( + No Customer Groups + )} + {customer_groups && customer_groups.length > 0 && ( +
    + {customer_groups.map((customerGroup: CustomerGroup) => ( +
  • {customerGroup.name}
  • + ))} +
+ )} +
+ ) +} + +export default CustomerGroups +``` +
-```jsx +```ts fetch(`/admin/customer-groups`, { credentials: "include", }) @@ -141,17 +205,39 @@ You can retrieve a single customer group by sending a request to the Get a Custo -```jsx +```ts medusa.admin.customerGroups.retrieve(customerGroupId) .then(({ customer_group }) => { console.log(customer_group.id) }) ``` + + + +```tsx +import { useAdminCustomerGroup } from "medusa-react" + +const CustomerGroup = () => { + const { customer_group, isLoading } = useAdminCustomerGroup( + customerGroupId + ) + + return ( +
+ {isLoading && Loading...} + {customer_group && {customer_group.name}} +
+ ) +} + +export default CustomerGroup +``` +
-```jsx +```ts fetch(`/admin/customer-groups/${customerGroupId}`, { credentials: "include", }) @@ -183,7 +269,7 @@ You can update a customer group’s data by sending a request to the Update Cust -```jsx +```ts medusa.admin.customerGroups.update(customerGroupId, { metadata: { is_seller: true, @@ -194,10 +280,38 @@ medusa.admin.customerGroups.update(customerGroupId, { }) ``` + + + +```tsx +import { useAdminUpdateCustomerGroup } from "medusa-react" + +const UpdateCustomerGroup = () => { + const updateCustomerGroup = useAdminUpdateCustomerGroup(customerGroupId) + // .. + + const handleUpdate = () => { + updateCustomerGroup.mutate({ + name, + }) + } + + // ... + + return ( +
+ {/* Render form */} +
+ ) +} + +export default UpdateCustomerGroup +``` +
-```jsx +```ts fetch(`/admin/customer-groups/${customerGroupId}`, { method: "POST", credentials: "include", @@ -244,17 +358,37 @@ You can delete a customer group by sending a request to the Delete a Customer Gr -```jsx +```ts medusa.admin.customerGroups.delete(customerGroupId) .then(({ id, object, deleted }) => { console.log(id) }) ``` + + + +```tsx +import { useAdminDeleteCustomerGroup } from "medusa-react" + +const CustomerGroup = () => { + const deleteCustomerGroup = useAdminDeleteCustomerGroup(customerGroupId) + // ... + + const handleDeleteCustomerGroup = () => { + deleteCustomerGroup.mutate() + } + + // ... +} + +export default CustomerGroup +``` + -```jsx +```ts fetch(`/admin/customer-groups/${customerGroupId}`, { method: "DELETE", credentials: "include", @@ -289,7 +423,7 @@ You can add a customer to a group by sending a request to the Customer Group’s -```jsx +```ts medusa.admin.customerGroups.addCustomers(customerGroupId, { customer_ids: [ { @@ -302,10 +436,36 @@ medusa.admin.customerGroups.addCustomers(customerGroupId, { }) ``` + + + +```tsx +import { useAdminAddCustomersToCustomerGroup } from "medusa-react" + +const CustomerGroup = () => { + const addCustomers = useAdminAddCustomersToCustomerGroup(customerGroupId) + // ... + + const handleAddCustomers= (customerId: string) => { + addCustomers.mutate({ + customer_ids: [ + { + id: customerId, + }, + ], + }) + } + + // ... +} + +export default CustomerGroup +``` + -```jsx +```ts fetch( `/admin/customer-groups/${customerGroupId}/customers/batch`, { @@ -357,17 +517,47 @@ You can retrieve a list of all customers in a customer group using the List Cust -```jsx +```ts medusa.admin.customerGroups.listCustomers(customerGroupId) .then(({ customers, count, offset, limit }) => { console.log(customers.length) }) ``` + + + +```tsx +import { Customer } from "@medusajs/medusa" +import { useAdminCustomerGroupCustomers } from "medusa-react" + +const CustomerGroup = () => { + const { customers, isLoading } = useAdminCustomerGroupCustomers( + customerGroupId + ) + + return ( +
+ {isLoading && Loading...} + {customers && !customers.length && No customers} + {customers && customers.length > 0 && ( +
    + {customers.map((customer: Customer) => ( +
  • {customer.first_name}
  • + ))} +
+ )} +
+ ) +} + +export default CustomerGroup +``` +
-```jsx +```ts fetch(`/admin/customer-groups/${customerGroupId}/customers`, { credentials: "include", }) @@ -403,7 +593,7 @@ You can remove customers from a customer group by sending a request to the Remov -```jsx +```ts medusa.admin.customerGroups.removeCustomers(customer_group_id, { customer_ids: [ { @@ -416,10 +606,39 @@ medusa.admin.customerGroups.removeCustomers(customer_group_id, { }) ``` + + + +```tsx +import { Customer } from "@medusajs/medusa" +import { useAdminRemoveCustomersFromCustomerGroup } from "medusa-react" + +const CustomerGroup = () => { + const removeCustomers = useAdminRemoveCustomersFromCustomerGroup( + customerGroupId + ) + // ... + + const handleRemoveCustomer = (customer_id: string) => { + removeCustomers.mutate({ + customer_ids: [ + { + id: customer_id, + }, + ], + }) + } + + // ... +} + +export default CustomerGroup +``` + -```jsx +```ts fetch( `/admin/customer-groups/${customerGroupId}/customers/batch`, { diff --git a/docs/content/advanced/backend/price-lists/use-api.mdx b/docs/content/advanced/backend/price-lists/use-api.mdx index 03b190f827..b471bb45eb 100644 --- a/docs/content/advanced/backend/price-lists/use-api.mdx +++ b/docs/content/advanced/backend/price-lists/use-api.mdx @@ -23,6 +23,12 @@ This guide includes code snippets to send requests to your Medusa server using M If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and [have created an instance of the client](../../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../../medusa-react/overview.md#usage). + ### Authenticated Admin User You must be an authenticated admin user before following along with the steps in the tutorial. @@ -69,13 +75,13 @@ For example, sending the following request creates a price list with two prices: ```jsx -import { PriceListType } from "@medusajs/medusa" +import { PriceListStatus, PriceListType } from "@medusajs/medusa" medusa.admin.priceLists.create({ name: "New Price List", description: "A new price list", type: PriceListType.SALE, - status: "active", + status: PriceListStatus.ACTIVE, prices: [ { amount: 1000, @@ -96,6 +102,46 @@ medusa.admin.priceLists.create({ }) ``` + + + +```tsx +import { PriceListStatus, PriceListType } from "@medusajs/medusa" +import { useAdminCreatePriceList } from "medusa-react" + +const CreatePriceList = () => { + const createPriceList = useAdminCreatePriceList() + // ... + + const handleCreate = () => { + createPriceList.mutate({ + name: "New Price List", + description: "A new price list", + type: PriceListType.SALE, + status: PriceListStatus.ACTIVE, + prices: [ + { + amount: 1000, + variant_id, + currency_code: "eur", + max_quantity: 3, + }, + { + amount: 1500, + variant_id, + currency_code: "eur", + min_quantity: 4, + }, + ], + }) + } + + // ... +} + +export default CreatePriceList +``` + @@ -185,6 +231,27 @@ medusa.admin.priceLists.retrieve(priceListId) }) ``` + + + +```tsx +import { CustomerGroup } from "@medusajs/medusa" +import { useAdminPriceList } from "medusa-react" + +const PriceList = () => { + const { price_list, isLoading } = useAdminPriceList(priceListId) + + return ( +
+ {isLoading && Loading...} + {price_list && {price_list.name}} +
+ ) +} + +export default PriceList +``` +
@@ -229,6 +296,29 @@ medusa.admin.priceLists.update(priceListId, { }) ``` + + + +```tsx +import { PriceListStatus, PriceListType } from "@medusajs/medusa" +import { useAdminUpdatePriceList } from "medusa-react" + +const CreatePriceList = () => { + const updatePriceList = useAdminUpdatePriceList(priceListId) + // ... + + const handleUpdate = () => { + updatePriceList.mutate({ + ends_at: "2022-10-11", + }) + } + + // ... +} + +export default CreatePriceList +``` + @@ -298,6 +388,34 @@ medusa.admin.priceLists.addPrices(priceListId, { }) ``` + + + +```tsx +import { useAdminCreatePriceListPrices } from "medusa-react" + +const PriceList = () => { + const addPrice = useAdminCreatePriceListPrices(priceListId) + // ... + + const handleAddPrice = () => { + addPrice.mutate({ + prices: [ + { + amount: 1200, + variant_id, + currency_code: "eur", + }, + ], + }) + } + + // ... +} + +export default PriceList +``` + @@ -363,6 +481,29 @@ medusa.admin.priceLists.deleteProductPrices(priceListId, productId) }) ``` + + + +```tsx +import { useAdminDeletePriceListProductPrices } from "medusa-react" + +const PriceList = () => { + const deletePrices = useAdminDeletePriceListProductPrices( + priceListId, + productId + ) + // ... + + const handleDeletePrices = () => { + deletePrices.mutate() + } + + // ... +} + +export default PriceList +``` + @@ -409,6 +550,29 @@ medusa.admin.priceLists.deleteVariantPrices(priceListId, variantId) }) ``` + + + +```tsx +import { useAdminDeletePriceListVariantPrices } from "medusa-react" + +const PriceList = () => { + const deleteVariantPrices = useAdminDeletePriceListVariantPrices( + priceListId, + variantId + ) + // ... + + const handleDeletePrices = () => { + deleteVariantPrices.mutate() + } + + // ... +} + +export default PriceList +``` + @@ -457,6 +621,26 @@ medusa.admin.priceLists.delete(priceListId) }) ``` + + + +```tsx +import { useAdminDeletePriceList } from "medusa-react" + +const PriceList = () => { + const deletePriceList = useAdminDeletePriceList(priceListId) + // ... + + const handleDeletePriceList = () => { + deletePriceList.mutate() + } + + // ... +} + +export default PriceList +``` + diff --git a/docs/content/advanced/backend/sales-channels/manage-admin.mdx b/docs/content/advanced/backend/sales-channels/manage-admin.mdx index 2cb813ee95..8018bfeaa5 100644 --- a/docs/content/advanced/backend/sales-channels/manage-admin.mdx +++ b/docs/content/advanced/backend/sales-channels/manage-admin.mdx @@ -25,21 +25,18 @@ This guide explains how to perform all these operations using the Admin APIs. It's assumed that you already have a Medusa server installed and set up. If not, you can follow our [quickstart guide](../../../quickstart/quick-start.mdx) to get started. -### Enabled Feature Flags - -The Sales Channels feature is currently in beta mode and guarded by a feature flag. To use sales channels either: - -1. Enable the `MEDUSA_FF_SALES_CHANNELS` environment variable; -2. Or enable the `sales_channels` key in the Medusa server's settings. - -You can learn more about enabling it in the [feature flags](../feature-flags/toggle.md) documentation. - ### JS Client -This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, JavaScript’s Fetch API, or cURL. +This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, among other methods. If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and [have created an instance of the client](../../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../../medusa-react/overview.md#usage). + ### Authenticated Admin User You must be an authenticated admin user before following along with the steps in this guide. @@ -55,7 +52,7 @@ You can create a sales channel by sending a request to the Create a Sales Channe -```jsx +```ts medusa.admin.salesChannels.create({ name: "App", description: "Mobile app", @@ -65,10 +62,33 @@ medusa.admin.salesChannels.create({ }) ``` + + + +```tsx +import { useAdminCreateSalesChannel } from "medusa-react" + +const CreateSalesChannel = () => { + const createSalesChannel = useAdminCreateSalesChannel() + // ... + + const handleCreate = (name: string, description: string) => { + createSalesChannel.mutate({ + name, + description, + }) + } + + // ... +} + +export default CreateSalesChannel +``` + -```jsx +```ts fetch(`/admin/sales-channels`, { method: "POST", credentials: "include", @@ -115,17 +135,47 @@ You can list all sales channels by sending a request to the List Sales Channels -```jsx +```ts medusa.admin.salesChannels.list() .then(({ sales_channels, limit, offset, count }) => { console.log(sales_channels.length) }) ``` + + + +```tsx +import { SalesChannel } from "@medusajs/medusa" +import { useAdminSalesChannels } from "medusa-react" + +const SalesChannels = () => { + const { sales_channels, isLoading } = useAdminSalesChannels() + + return ( +
+ {isLoading && Loading...} + {sales_channels && !sales_channels.length && ( + No Sales Channels + )} + {sales_channels && sales_channels.length > 0 && ( +
    + {sales_channels.map((salesChannel: SalesChannel) => ( +
  • {salesChannel.name}
  • + ))} +
+ )} +
+ ) +} + +export default SalesChannels +``` +
-```jsx +```ts fetch(`/admin/sales-channels`, { credentials: "include", }) @@ -157,17 +207,37 @@ You can retrieve a sales channel’s details by its ID using the Get Sales Chann -```jsx +```ts medusa.admin.salesChannels.retrieve(salesChannelId) .then(({ sales_channel }) => { console.log(sales_channel.id) }) ``` + + + +```tsx +import { useAdminSalesChannel } from "medusa-react" + +const SalesChannel = () => { + const { sales_channel, isLoading } = useAdminSalesChannel(salesChannelId) + + return ( +
+ {isLoading && Loading...} + {sales_channel && {sales_channel.name}} +
+ ) +} + +export default SalesChannel +``` +
-```jsx +```ts fetch(`/admin/sales-channels/${salesChannelId}`, { credentials: "include", }) @@ -199,7 +269,7 @@ You can update a Sales Channel’s details and attributes by sending a request t -```jsx +```ts medusa.admin.salesChannels.update(salesChannelId, { is_disabled: false, }) @@ -208,10 +278,32 @@ medusa.admin.salesChannels.update(salesChannelId, { }) ``` + + + +```tsx +import { useAdminUpdateSalesChannel } from "medusa-react" + +const UpdateSalesChannel = () => { + const updateSalesChannel = useAdminUpdateSalesChannel(salesChannelId) + // ... + + const handleUpdate = () => { + updateSalesChannel.mutate({ + is_disabled: false, + }) + } + + // ... +} + +export default UpdateSalesChannel +``` + -```jsx +```ts fetch(`/admin/sales-channels/${salesChannelId}`, { method: "POST", credentials: "include", @@ -258,17 +350,37 @@ You can delete a sales channel by sending a request to the Delete Sales Channel -```jsx +```ts medusa.admin.salesChannels.delete(salesChannelId) .then(({ id, object, deleted }) => { console.log(id) }) ``` + + + +```tsx +import { useAdminDeleteSalesChannel } from "medusa-react" + +const SalesChannel = () => { + const deleteSalesChannel = useAdminDeleteSalesChannel(salesChannelId) + // ... + + const handleDelete = () => { + deleteSalesChannel.mutate() + } + + // ... +} + +export default SalesChannel +``` + -```jsx +```ts fetch(`/admin/sales-channels/${salesChannelId}`, { method: "DELETE", credentials: "include", @@ -303,7 +415,7 @@ To add a product to a sales channel, send a request to the Sales Channel’s Add -```jsx +```ts medusa.admin.salesChannels.addProducts(salesChannelId, { product_ids: [ { @@ -316,10 +428,36 @@ medusa.admin.salesChannels.addProducts(salesChannelId, { }) ``` + + + +```tsx +import { useAdminAddProductsToSalesChannel } from "medusa-react" + +const SalesChannel = () => { + const addProducts = useAdminAddProductsToSalesChannel(salesChannelId) + // ... + + const handleAddProducts = (productId: string) => { + addProducts.mutate({ + product_ids: [ + { + id: productId, + }, + ], + }) + } + + // ... +} + +export default SalesChannel +``` + -```jsx +```ts fetch( `/admin/sales-channels/${salesChannelId}/products/batch`, { @@ -373,7 +511,7 @@ You can list the products available in a sales channel by sending a request to t -```jsx +```ts medusa.admin.products.list({ sales_channel_id: [ salesChannelId, @@ -384,10 +522,41 @@ medusa.admin.products.list({ }) ``` + + + +```tsx +import { Product } from "@medusajs/medusa" +import { PricedProduct } from "@medusajs/medusa/dist/types/pricing" +import { useAdminProducts } from "medusa-react" + +const SalesChannelProducts = () => { + const { products, isLoading } = useAdminProducts({ + sales_channel_id: [salesChannelId], + }) + + return ( +
+ {isLoading && Loading...} + {products && products.length > 0 && ( +
    + {products.map((product: (Product | PricedProduct)) => ( +
  • {product.title}
  • + ))} +
+ )} + {products && !products.length && No Products} +
+ ) +} + +export default SalesChannelProducts +``` +
-```jsx +```ts fetch( `/admin/products?sales_channel_id[0]=${salesChannelId}`, { @@ -426,7 +595,7 @@ You can delete a product from a sales channel by sending a request to the Sales -```jsx +```ts medusa.admin.salesChannels.removeProducts(salesChannelId, { product_ids: [ { @@ -439,10 +608,38 @@ medusa.admin.salesChannels.removeProducts(salesChannelId, { }) ``` + + + +```tsx +import { useAdminDeleteProductsFromSalesChannel } from "medusa-react" + +const SalesChannel = () => { + const deleteProducts = useAdminDeleteProductsFromSalesChannel( + salesChannelId + ) + // ... + + const handleDeleteProducts = (productId: string) => { + deleteProducts.mutate({ + product_ids: [ + { + id: productId, + }, + ], + }) + } + + // ... +} + +export default SalesChannel +``` + -```jsx +```ts fetch( `/admin/sales-channels/${salesChannelId}/products/batch`, { @@ -498,7 +695,7 @@ You can filter orders by a specific sales channel by sending a request to the Li -```jsx +```ts medusa.admin.orders.list({ sales_channel_id: [ salesChannelId, @@ -511,10 +708,42 @@ medusa.admin.orders.list({ }) ``` + + + +```tsx +import { Order } from "@medusajs/medusa" +import { useAdminOrders } from "medusa-react" + +const SalesChannelOrders = () => { + const { orders, isLoading } = useAdminOrders({ + sales_channel_id: [salesChannelId], + offset: 0, + limit: 50, + }) + + return ( +
+ {isLoading && Loading...} + {orders && orders.length > 0 && ( +
    + {orders.map((order: Order) => ( +
  • {order.display_id}
  • + ))} +
+ )} + {orders && !orders.length && No Orders} +
+ ) +} + +export default SalesChannelOrders +``` +
-```jsx +```ts fetch(`/admin/orders?sales_channel_id[0]=${salesChannelId}`, { credentials: "include", }) diff --git a/docs/content/advanced/storefront/customer-profiles.mdx b/docs/content/advanced/storefront/customer-profiles.mdx index 7eb1b5bbd2..1e7f4d8c55 100644 --- a/docs/content/advanced/storefront/customer-profiles.mdx +++ b/docs/content/advanced/storefront/customer-profiles.mdx @@ -37,10 +37,16 @@ It's also assumed you already have a storefront set up. It can be a custom store ### JS Client -This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client and JavaScript’s Fetch API. +This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, among other methods. If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../js-client/overview.md) and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + --- ## Register a Customer @@ -64,6 +70,38 @@ medusa.customers.create({ }) ``` + + + +```tsx +import { useCreateCustomer } from "medusa-react" + +const RegisterCustomer = () => { + const createCustomer = useCreateCustomer() + // ... + + const handleCreate = () => { + // ... + createCustomer.mutate({ + first_name, + last_name, + email, + password, + }) + } + + // ... + + return ( +
+ {/* Render form */} +
+ ) +} + +export default RegisterCustomer +``` +
@@ -321,6 +359,36 @@ medusa.customers.update({ }) ``` + + + +```tsx +import { useUpdateMe } from "medusa-react" + +const UpdateCustomer = () => { + const updateCustomer = useUpdateMe() + // ... + + const handleUpdate = () => { + // ... + updateCustomer.mutate({ + id: customer_id, + first_name, + }) + } + + // ... + + return ( +
+ {/* Render form */} +
+ ) +} + +export default UpdateCustomer +``` +
@@ -530,6 +598,35 @@ medusa.customers.listOrders() }) ``` + + + +```tsx +import { useCustomerOrders } from "medusa-react" +import { Order } from "@medusajs/medusa" + +const Orders = () => { + // refetch a function that can be used to + // re-retrieve orders after the customer logs in + const { orders, isLoading, refetch } = useCustomerOrders() + + return ( +
+ {isLoading && Loading orders...} + {orders?.length && ( +
    + {orders.map((order: Order) => ( +
  • {order.display_id}
  • + ))} +
+ )} +
+ ) +} + +export default Orders +``` +
diff --git a/docs/content/advanced/storefront/handle-order-edits.mdx b/docs/content/advanced/storefront/handle-order-edits.mdx index 40659c4071..47ecdc2019 100644 --- a/docs/content/advanced/storefront/handle-order-edits.mdx +++ b/docs/content/advanced/storefront/handle-order-edits.mdx @@ -51,6 +51,12 @@ This guide includes code snippets to send requests to your Medusa server using M If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../js-client/overview.md) and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + ### Previous Steps You must have an existing order edit in the “request” state. @@ -72,6 +78,21 @@ medusa.orderEdits.retrieve(orderEditId) }) ``` + + + +```ts +import { useOrderEdit } from "medusa-react" + +const OrderEdit = () => { + const { order_edit, isLoading } = useOrderEdit(orderEditId) + + // ... +} + +export default OrderEdit +``` + @@ -123,7 +144,7 @@ All data about changes to the original order’s items can be found in `order_ed Here’s an example of how you can use this data to show the customer the requested edits to the order: -```jsx +```tsx
    {orderEdit.changes.map((itemChange) => (
  • @@ -184,6 +205,28 @@ medusa.paymentCollections.managePaymentSession(paymentCollectionId, { }) ``` + + + +```ts +import { useManagePaymentSession } from "medusa-react" + +const OrderEditPayment = () => { + const managePaymentSession = useManagePaymentSession(paymentCollectionId) + // ... + + const handleAdditionalPayment = (provider_id: string) => { + managePaymentSession.mutate({ + provider_id, + }) + } + + // ... +} + +export default OrderEditPayment +``` + @@ -224,6 +267,28 @@ medusa.paymentCollection }) ``` + + + +```ts +import { useAuthorizePaymentSession } from "medusa-react" + +const OrderEditPayment = () => { + const authorizePaymentSession = useAuthorizePaymentSession( + paymentCollectionId + ) + // ... + + const handleAuthorizePayment = (paymentSessionId: string) => { + authorizePaymentSession.mutate(paymentSessionId) + } + + // ... +} + +export default OrderEditPayment +``` + @@ -263,6 +328,26 @@ medusa.orderEdits.complete(orderEditId) }) ``` + + + +```ts +import { useCompleteOrderEdit } from "medusa-react" + +const OrderEdit = () => { + const completeOrderEdit = useCompleteOrderEdit(orderEditId) + // ... + + const handleCompleteOrderEdit = () => { + completeOrderEdit.mutate() + } + + // ... +} + +export default OrderEdit +``` + @@ -310,6 +395,28 @@ medusa.orderEdits.decline(orderEditId, { }) ``` + + + +```ts +import { useDeclineOrderEdit } from "medusa-react" + +const OrderEdit = () => { + const declineOrderEdit = useDeclineOrderEdit(orderEditId) + // ... + + const handleDeclineOrderEdit = () => { + declineOrderEdit.mutate({ + declined_reason: "I am not satisfied", + }) + } + + // ... +} + +export default OrderEdit +``` + diff --git a/docs/content/advanced/storefront/how-to-implement-checkout-flow.mdx b/docs/content/advanced/storefront/how-to-implement-checkout-flow.mdx index 307d7c276b..b09637cd0d 100644 --- a/docs/content/advanced/storefront/how-to-implement-checkout-flow.mdx +++ b/docs/content/advanced/storefront/how-to-implement-checkout-flow.mdx @@ -33,6 +33,14 @@ This guide includes code snippets to send requests to your Medusa server using M If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../js-client/overview.md) and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + +It's also assumed you already have [used CartProvider higher in your component tree](../../medusa-react/overview.md#cartprovider). + ### Previous Steps This document assumes you’ve already taken care of the add-to-cart flow. So, you should have a [cart created](/api/store/#tag/Cart/operation/PostCart) for the customer with at least [one product in it](/api/store/#tag/Cart/operation/PostCartsCartLineItems). @@ -52,7 +60,7 @@ After the customer enters their shipping address information, you must send a `P -```jsx +```ts medusa.carts.update(cartId, { shipping_address: { company, @@ -72,10 +80,44 @@ medusa.carts.update(cartId, { }) ``` + + + +```tsx +import { useCart } from "medusa-react" + +const Cart = () => { + // ... + + const { updateCart } = useCart() + + const addShippingAddress = (address: Record) => { + updateCart.mutate({ + shipping_address: { + company: address.company, + first_name: address.first_name, + last_name: address.last_name, + address_1: address.address_1, + address_2: address.address_2, + city: address.city, + country_code: address.country_code, + province: address.province, + postal_code: address.postal_code, + phone: address.phone, + }, + }) + } + + // ... +} + +export default Cart +``` + -```jsx +```ts fetch(`/store/carts/${cartId}`, { method: "POST", credentials: "include", @@ -121,17 +163,51 @@ You can retrieve the list of shipping options by sending a `GET` request to the -```jsx +```ts medusa.shippingOptions.listCartOptions(cartId) .then(({ shipping_options }) => { console.log(shipping_options.length) }) ``` + + + +```tsx +import { ShippingOption } from "@medusajs/medusa" +import { useCartShippingOptions } from "medusa-react" + +type Props = { + cartId: string +} + +const ShippingOptions = ({ cartId }: Props) => { + const { shipping_options, isLoading } = useCartShippingOptions(cartId) + + return ( +
    + {isLoading && Loading...} + {shipping_options && !shipping_options.length && ( + No shipping options + )} + {shipping_options && ( +
      + {shipping_options.map((shipping_option: ShippingOption) => ( +
    • {shipping_option.name}
    • + ))} +
    + )} +
    + ) +} + +export default ShippingOptions +``` +
    -```jsx +```ts fetch(`/store/shipping-options/${cartId}`, { credentials: "include", }) @@ -153,7 +229,7 @@ Once the customer chooses one of the available shipping options, send a `POST` r -```jsx +```ts medusa.carts.addShippingMethod(cartId, { option_id: shippingOptionId, // the ID of the selected option }) @@ -162,10 +238,33 @@ medusa.carts.addShippingMethod(cartId, { }) ``` + + + +```tsx +import { useAddShippingMethodToCart } from "medusa-react" +// ... + +const ShippingOptions = ({ cartId }: Props) => { + // ... + const addShippingMethod = useAddShippingMethodToCart(cartId) + + const handleAddShippingMethod = (option_id: string) => { + addShippingMethod.mutate({ + option_id, + }) + } + + // ... +} + +export default ShippingOptions +``` + -```jsx +```ts fetch(`/store/carts/${cartId}/shipping-methods`, { method: "POST", credentials: "include", @@ -204,17 +303,47 @@ To initialize the payment sessions, send a `POST` request to the [Initialize Pay -```jsx +```ts medusa.carts.createPaymentSessions(cartId) .then(({ cart }) => { console.log(cart.payment_sessions) }) ``` + + + +```tsx +import { PaymentSession } from "@medusajs/medusa" +import { useCart } from "medusa-react" +import { useEffect } from "react" + +const PaymentProviders = () => { + const { cart, startCheckout } = useCart() + + useEffect(() => { + startCheckout.mutate() + }, []) + + return ( +
    + {!cart?.payment_sessions.length && No payment providers} +
      + {cart?.payment_sessions.map((paymentSession: PaymentSession) => ( +
    • {paymentSession.provider_id}
    • + ))} +
    +
    + ) +} + +export default PaymentProviders +``` +
    -```jsx +```ts fetch(`/store/carts/${cartId}/payment-sessions`, { method: "POST", credentials: "include", @@ -237,7 +366,7 @@ When the customer chooses the payment provider they want to complete purchase wi -```jsx +```ts medusa.carts.setPaymentSession(cartId, { // retrieved from the payment session selected by the customer provider_id: paymentProviderId, @@ -247,10 +376,32 @@ medusa.carts.setPaymentSession(cartId, { }) ``` + + + +```tsx +import { useCart } from "medusa-react" + +const PaymentProviders = () => { + const { cart, startCheckout, pay } = useCart() + // ... + + const handleSetPaymentSession = (provider_id: string) => { + pay.mutate({ + provider_id, + }) + } + + // ... +} + +export default PaymentProviders +``` + -```jsx +```ts fetch(`/store/carts/${cartId}/payment-session`, { method: "POST", credentials: "include", @@ -290,7 +441,7 @@ If you need to update that data at any point before the purchase is made, send a -```jsx +```ts medusa.carts.updatePaymentSession(cartId, paymentProviderId, { data: { // pass any data you want to add in the `data` attribute @@ -303,12 +454,40 @@ medusa.carts.updatePaymentSession(cartId, paymentProviderId, { }) ``` + + + +```tsx +import { useUpdatePaymentSession, useCart } from "medusa-react" +// ... + +const PaymentProviders = () => { + const { cart } = useCart() + const updatePaymentSession = useUpdatePaymentSession(cart.id) + // ... + + const handleUpdatePaymentSession = ( + provider_id: string, + data: Record + ) => { + updatePaymentSession.mutate({ + provider_id, + data, + }) + } + + // ... +} + +export default PaymentProviders +``` + -```jsx +```ts fetch( `/store/carts/${cartId}/payment-sessions/${paymentProviderId}`, { @@ -348,17 +527,38 @@ To complete a cart, send a `POST` request to the [Complete a Cart](/api/store/#t -```jsx +```ts medusa.carts.complete(cartId) .then(({ type, data }) => { console.log(type, data) }) ``` + + + +```tsx +import { useCart } from "medusa-react" +// ... + +const Cart = () => { + const { completeCheckout } = useCart() + // ... + + const handleStartCheckout = () => { + startCheckout.mutate() + } + + // ... +} + +export default Cart +``` + -```jsx +```ts fetch(`/store/carts/${cartId}/complete`, { method: "POST", credentials: "include", diff --git a/docs/content/advanced/storefront/implement-claim-order.mdx b/docs/content/advanced/storefront/implement-claim-order.mdx index 0d964128d5..db3496a08d 100644 --- a/docs/content/advanced/storefront/implement-claim-order.mdx +++ b/docs/content/advanced/storefront/implement-claim-order.mdx @@ -44,10 +44,16 @@ It is also assumed you already have a storefront set up. It can be a custom stor ### JS Client -This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client and JavaScript’s Fetch API. +This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, among other methods. If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../js-client/overview.md) and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + ### Handle Order Claim Request Event When the customer requests to claim the order, an event will be triggered. You should subscribe to this event to send a confirmation email to the customer when the event is triggered. @@ -71,7 +77,7 @@ To allow the customer to claim an order, send a request to the Claim an Order en -```tsx +```ts medusa.orders.claimOrders({ order_ids: [ order_id, @@ -88,7 +94,7 @@ medusa.orders.claimOrders({ -```tsx +```ts fetch(`/store/orders/batch/customer/token`, { method: "POST", credentials: "include", @@ -129,7 +135,7 @@ Then, you send a request to the Verify Claim Order endpoint: -```tsx +```ts medusa.orders.confirmRequest({ token, }) @@ -142,9 +148,31 @@ medusa.orders.confirmRequest({ ``` - + ```tsx +import { useGrantOrderAccess } from "medusa-react" + +const ClaimOrder = () => { + const grantOrderAccess = useGrantOrderAccess() + // ... + + const handleVerifyOrderClaim = (token: string) => { + grantOrderAccess.mutate(({ + token, + })) + } + + // ... +} + +export default ClaimOrder +``` + + + + +```ts fetch(`/store/orders/customer/confirm`, { method: "POST", credentials: "include", diff --git a/docs/content/advanced/storefront/use-discounts-in-checkout.mdx b/docs/content/advanced/storefront/use-discounts-in-checkout.mdx index b2a8273071..645df298ab 100644 --- a/docs/content/advanced/storefront/use-discounts-in-checkout.mdx +++ b/docs/content/advanced/storefront/use-discounts-in-checkout.mdx @@ -33,10 +33,18 @@ It is also assumed you already have a storefront set up. It can be a custom stor ### JS Client -This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client and JavaScript’s Fetch API. +This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, among other methods. If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../js-client/overview.md) and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + +It's also assumed you already have [used CartProvider higher in your component tree](../../medusa-react/overview.md#cartprovider). + ### Previous Steps This document assumes you’ve already taken care of the add-to-cart flow. So, you should have a [cart created](/api/store/#tag/Cart/operation/PostCart) for the customer with at least [one product in it](/api/store/#tag/Cart/operation/PostCartsCartLineItems). @@ -54,7 +62,7 @@ You can add a discount to a customer’s cart by sending the [Update Cart reques -```jsx +```ts medusa.carts.update(cartId, { discounts: [ { @@ -71,10 +79,37 @@ medusa.carts.update(cartId, { }) ``` + + + +```tsx +import { useCart } from "medusa-react" + +const Cart = () => { + // ... + + const { updateCart } = useCart() + + const addDiscount = (code: string) => { + updateCart.mutate({ + discounts: [ + { + code, + }, + ], + }) + } + + // ... +} + +export default Cart +``` + -```jsx +```ts fetch(`/store/carts/${cartId}`, { method: "POST", credentials: "include", @@ -218,7 +253,7 @@ You can remove a discount from a customer’s cart using the [Remove Discount re -```jsx +```ts medusa.carts.deleteDiscount(cartId, code) .then(({ cart }) => { console.log(cart.discounts) @@ -228,7 +263,7 @@ medusa.carts.deleteDiscount(cartId, code) -```jsx +```ts fetch(`/store/carts/${cartId}/discounts/${code}`, { method: "DELETE", credentials: "include", diff --git a/docs/content/advanced/storefront/use-gift-cards.mdx b/docs/content/advanced/storefront/use-gift-cards.mdx index 71b34f3965..df3566600d 100644 --- a/docs/content/advanced/storefront/use-gift-cards.mdx +++ b/docs/content/advanced/storefront/use-gift-cards.mdx @@ -29,10 +29,18 @@ It is also assumed you already have a storefront set up. It can be a custom stor ### JS Client -This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client and JavaScript’s Fetch API. +This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, among other methods. If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../js-client/overview.md) and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + +For requests that use the cart, it's also assumed you already have [used CartProvider higher in your component tree](../../medusa-react/overview.md#cartprovider). + ### Previous Steps To use gift cards, you must have a gift card created first. You can follow this documentation to learn how to do it using the admin APIs. @@ -64,6 +72,36 @@ medusa.products.list({ }) ``` + + + +```tsx +import { Product } from "@medusajs/medusa" +import { useProducts } from "medusa-react" + +const GiftCard = () => { + const { products, isLoading } = useProducts({ + is_giftcard: true, + }) + + return ( +
    + {isLoading && Loading...} + {products && products.length > 0 && ( +
      + {products.map((product: Product) => ( +
    • {product.title}
    • + ))} +
    + )} + {products && !products.length && No Gift Cards} +
    + ) +} + +export default GiftCard +``` +
    @@ -118,6 +156,27 @@ medusa.giftCards.retrieve(code) }) ``` + + + +```tsx +import { useGiftCard } from "medusa-react" + +const GiftCard = () => { + const { gift_card, isLoading, isError } = useGiftCard("code") + + return ( +
    + {isLoading && Loading...} + {gift_card && {gift_card.value}} + {isError && Gift Card does not exist} +
    + ) +} + +export default GiftCard +``` +
    @@ -178,6 +237,33 @@ medusa.carts.update(cartId, { }) ``` + + + +```tsx +import { useCart } from "medusa-react" + +const Cart = () => { + // ... + + const { updateCart } = useCart() + + const setGiftCard = (code: string) => { + updateCart.mutate({ + gift_cards: [ + { + code, + }, + ], + }) + } + + // ... +} + +export default Cart +``` + diff --git a/docs/content/advanced/storefront/use-regions.mdx b/docs/content/advanced/storefront/use-regions.mdx index 64f0be708f..9d1598e734 100644 --- a/docs/content/advanced/storefront/use-regions.mdx +++ b/docs/content/advanced/storefront/use-regions.mdx @@ -29,10 +29,18 @@ It is also assumed you already have a storefront set up. It can be a custom stor ### JS Client -This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client and JavaScript’s Fetch API. +This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, among other methods. If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../js-client/overview.md) and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + +For requests that use the cart, it's also assumed you already have [used CartProvider higher in your component tree](../../medusa-react/overview.md#cartprovider). + --- ## Show List of Regions @@ -44,7 +52,7 @@ You can retrieve available regions by sending a request to the [List Regions](/a -```tsx +```ts medusa.regions.list() .then(({ regions }) => { console.log(regions.length) @@ -53,9 +61,38 @@ medusa.regions.list() ``` - + ```tsx +import { Region } from "@medusajs/medusa" +import { useRegions } from "medusa-react" + +const Regions = () => { + const { regions, isLoading } = useRegions() + + return ( +
    + {isLoading && Loading...} + {regions?.length && ( +
      + {regions.map((region: Region) => ( +
    • + {region.name} +
    • + ))} +
    + )} +
    + ) +} + +export default Regions +``` + +
    + + +```ts fetch(`/store/regions`, { credentials: "include", }) @@ -84,7 +121,7 @@ For example: -```tsx +```ts medusa.products.list({ region_id: regionId, }) @@ -95,9 +132,32 @@ medusa.products.list({ ``` - + ```tsx +import { formatVariantPrice } from "medusa-react" + +const Product = () => { + // retrieve the region and variant(s) + // ... + + return ( + + {formatVariantPrice({ + variant, // ProductVariant + region, // Region + })} + + ) +} + +export default Product +``` + + + + +```ts fetch(`/store/products?region_id=${regionId}`, { credentials: "include", }) @@ -134,7 +194,7 @@ For example: -```tsx +```ts medusa.carts.update(cartId, { region_id: regionId, }) @@ -144,9 +204,32 @@ medusa.carts.update(cartId, { ``` - + ```tsx +import { useCart } from "medusa-react" + +const Cart = () => { + // ... + + const { updateCart } = useCart() + + const changeRegionId = (region_id: string) => { + updateCart.mutate({ + region_id, + }) + } + + // ... +} + +export default Cart +``` + + + + +```ts fetch(`/store/carts/${cartId}`, { method: "POST", credentials: "include", diff --git a/docs/content/advanced/storefront/use-sales-channels.mdx b/docs/content/advanced/storefront/use-sales-channels.mdx index 2b17601744..42e06becec 100644 --- a/docs/content/advanced/storefront/use-sales-channels.mdx +++ b/docs/content/advanced/storefront/use-sales-channels.mdx @@ -32,10 +32,18 @@ It is also assumed you already have a storefront set up. It can be a custom stor ### JS Client -This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client and JavaScript’s Fetch API. +This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, among other methods. If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../js-client/overview.md) and have [created an instance of the client](../../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../medusa-react/overview.md#usage). + +For requests that use the cart, it's also assumed you already have [used CartProvider higher in your component tree](../../medusa-react/overview.md#cartprovider). + --- ## Filter Products by Sales Channel @@ -45,7 +53,7 @@ To filter products by a specific sales channel, pass the `sales_channel_id` quer -```jsx +```ts medusa.products.list({ sales_channel_id: [ salesChannelId, @@ -56,10 +64,42 @@ medusa.products.list({ }) ``` + + + +```tsx +import { Product } from "@medusajs/medusa" +import { useProducts } from "medusa-react" + +const Products = () => { + const { products, isLoading } = useProducts({ + sales_channel_id: [ + salesChannelId, + ], + }) + + return ( +
    + {isLoading && Loading...} + {products && products.length > 0 && ( +
      + {products.map((product: Product) => ( +
    • {product.title}
    • + ))} +
    + )} + {products && !products.length && No Products} +
    + ) +} + +export default Products +``` +
    -```jsx +```ts fetch(`/store/products?sales_channel_id[0]=${salesChannelId}`) .then((response) => response.json()) .then(({ products, limit, offset, count }) => { @@ -86,7 +126,7 @@ To associate a sales channel with a cart while creating it, you can pass the `sa -```jsx +```ts medusa.carts.create({ sales_channel_id: salesChannelId, }) @@ -95,10 +135,36 @@ medusa.carts.create({ }) ``` + + + +```tsx +import { useCart } from "medusa-react" + +const Cart = () => { + const { cart, createCart } = useCart() + + const handleCreateCart = () => { + createCart.mutate( + { + sales_channel_id: salesChannelId, + }, + { + onSuccess: ({ cart }) => localStorage.setItem("cart_id", cart.id), + } + ) + } + + // ... +} + +export default Cart +``` + -```jsx +```ts fetch(`/store/carts`, { method: "POST", headers: { @@ -126,7 +192,7 @@ You can update the sales channel of an existing cart by passing the `sales_chann -```jsx +```ts medusa.carts.update(cartId, { sales_channel_id: salesChannelId, }) @@ -135,10 +201,33 @@ medusa.carts.update(cartId, { }) ``` + + + +```tsx +import { useCart } from "medusa-react" + +const Cart = () => { + // ... + + const { updateCart } = useCart() + + const changeSalesChannel = (salesChannelId: string) => { + updateCart.mutate({ + sales_channel_id: salesChannelId, + }) + } + + // ... +} + +export default Cart +``` + -```jsx +```ts fetch(`/store/carts/${cartId}`, { method: "POST", headers: { diff --git a/docs/content/guides/carts-in-medusa.mdx b/docs/content/guides/carts-in-medusa.mdx index 979a74e2c9..72739ab0b8 100644 --- a/docs/content/guides/carts-in-medusa.mdx +++ b/docs/content/guides/carts-in-medusa.mdx @@ -17,10 +17,6 @@ This document does not cover implementing the checkout flow. You can refer to [t ::: -### Glossary - -- **Line Item**: When products are added to the cart in Medusa, they are referred to as line items. Line items have, by default, the same properties and attributes as a product. However, you can customize line items specifically for a cart if necessary. - --- ## Prerequisites @@ -33,10 +29,18 @@ It is also assumed you already have a storefront set up. It can be a custom stor ### JS Client -This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client and JavaScript’s Fetch API. +This guide includes code snippets to send requests to your Medusa server using Medusa’s JS Client, among other methods. If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../js-client/overview.md) and have [created an instance of the client](../js-client/overview.md#configuration). +### Medusa React + +This guide also includes code snippets to send requests to your Medusa server using Medusa React, among other methods. + +If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../medusa-react/overview.md#usage). + +It's also assumed you already have [used CartProvider higher in your component tree](../medusa-react/overview.md#cartprovider). + --- ## Create a Cart @@ -46,7 +50,7 @@ You can create a cart with the following code snippet: -```jsx +```ts medusa.carts.create() .then(({ cart }) => { localStorage.setItem("cart_id", cart.id) @@ -55,10 +59,34 @@ medusa.carts.create() }) ``` + + + +```tsx +import { useCart } from "medusa-react" + +const Cart = () => { + const { cart, createCart } = useCart() + + const handleCreateCart = () => { + createCart.mutate( + {}, // create an empty cart + { + onSuccess: ({ cart }) => localStorage.setItem("cart_id", cart.id), + } + ) + } + + // ... +} + +export default Cart +``` + -```jsx +```ts fetch(`/store/carts`, { method: "POST", credentials: "include", @@ -94,6 +122,32 @@ medusa.carts.create({ }) ``` + + + +```tsx +import { useCart } from "medusa-react" + +const Cart = () => { + const { cart, createCart } = useCart() + + const handleCreateCart = () => { + createCart.mutate( + { + region_id, + }, + { + onSuccess: ({ cart }) => localStorage.setItem("cart_id", cart.id), + } + ) + } + + // ... +} + +export default Cart +``` + @@ -138,7 +192,7 @@ You can retrieve the cart at any given point using its ID with the following cod -```jsx +```ts const id = localStorage.getItem("cart_id") if (id) { @@ -147,10 +201,25 @@ if (id) { } ``` + + + +```tsx +import { useGetCart } from "medusa-react" + +const Cart = () => { + const { cart, isLoading } = useGetCart(cart_id) + + // ... +} + +export default Cart +``` + -```jsx +```ts const id = localStorage.getItem("cart_id") if (id) { @@ -186,17 +255,40 @@ You can use the following snippet to update any of the cart’s data: -```jsx +```ts medusa.carts.update(cartId, { region_id, }) .then(({ cart }) => setCart(cart)) ``` + + + +```tsx +import { useCart } from "medusa-react" + +const Cart = () => { + // ... + + const { updateCart } = useCart() + + const changeRegionId = (region_id: string) => { + updateCart.mutate({ + region_id, + }) + } + + // ... +} + +export default Cart +``` + -```jsx +```ts fetch(`/store/carts/${cartId}`, { method: "POST", credentials: "include", @@ -229,17 +321,40 @@ You can do that using the same update operation: -```jsx +```ts medusa.carts.update(cartId, { customer_id, }) .then(({ cart }) => setCart(cart)) ``` + + + +```tsx +import { useCart } from "medusa-react" + +const Cart = () => { + // ... + + const { updateCart } = useCart() + + const changeCustomerId = (customer_id: string) => { + updateCart.mutate({ + customer_id, + }) + } + + // ... +} + +export default Cart +``` + -```jsx +```ts fetch(`/store/carts/${cartId}`, { method: "POST", credentials: "include", @@ -268,17 +383,40 @@ You can do that using the same update operation: -```jsx +```ts medusa.carts.update(cartId, { email: "user@example.com", }) .then(({ cart }) => setCart(cart)) ``` + + + +```tsx +import { useCart } from "medusa-react" + +const Cart = () => { + // ... + + const { updateCart } = useCart() + + const changeEmail = (email: string) => { + updateCart.mutate({ + email, + }) + } + + // ... +} + +export default Cart +``` + -```jsx +```ts fetch(`/store/carts/${cartId}`, { method: "POST", credentials: "include", @@ -313,6 +451,30 @@ medusa.carts.lineItems.create(cartId, { .then(({ cart }) => setCart(cart)) ``` + + + +```tsx +import { useCreateLineItem } from "medusa-react" + +const Cart = () => { + // ... + + const createLineItem = useCreateLineItem(cart_id) + + const handleAddItem = () => { + createLineItem.mutate({ + variant_id, + quantity, + }) + } + + // ... +} + +export default Cart +``` + @@ -356,17 +518,41 @@ To update a line item's quantity in the cart, you can use the following code sni -```jsx +```ts medusa.carts.lineItems.update(cartId, lineItemId, { quantity: 3, }) .then(({ cart }) => setCart(cart)) ``` + + + +```tsx +import { useUpdateLineItem } from "medusa-react" + +const Cart = () => { + // ... + + const updateLineItem = useUpdateLineItem(cart_id) + + const handleUpdateItem = () => { + updateLineItem.mutate({ + lineId, + quantity: 3, + }) + } + + // ... +} + +export default Cart +``` + -```jsx +```ts fetch(`/store/carts/${cartId}/line-items/${lineItemId}`, { method: "POST", credentials: "include", @@ -397,15 +583,38 @@ To delete a line item from the cart, you can use the following code snippet: -```jsx +```ts medusa.carts.lineItems.delete(cartId, lineItemId) .then(({ cart }) => setCart(cart)) ``` + + + +```tsx +import { useDeleteLineItem } from "medusa-react" + +const Cart = () => { + // ... + + const deleteLineItem = useDeleteLineItem(cart_id) + + const handleDeleteItem = () => { + deleteLineItem.mutate({ + lineId, + }) + } + + // ... +} + +export default Cart +``` + -```jsx +```ts fetch(`/store/carts/${cartId}/line-items/${lineItemId}`, { method: "DELETE", credentials: "include", diff --git a/docs/content/js-client/overview.md b/docs/content/js-client/overview.md index e365be4f2d..81277d018b 100644 --- a/docs/content/js-client/overview.md +++ b/docs/content/js-client/overview.md @@ -84,5 +84,5 @@ const medusa = new Medusa({ | ------------------- | ------------------------- | --------------------------------------------------------- | | `maxRetries` | `0` | The amount of times a request is retried. | | `baseUrl` | `'http://localhost:9000'` | The url to which requests are made to. | -| `apiKey` | `''` | Optional api key used for authenticating admin requests . | +| `apiKey` | `''` | Optional API key used for authenticating admin requests. | | `publishableApiKey` | `''` | Optional publishable API key used for storefront requests.| \ No newline at end of file diff --git a/docs/content/medusa-react/overview.md b/docs/content/medusa-react/overview.md index b4863eb5a1..f783e0411e 100644 --- a/docs/content/medusa-react/overview.md +++ b/docs/content/medusa-react/overview.md @@ -55,7 +55,7 @@ import React from "react" const queryClient = new QueryClient() -function App() { +const App = () => { return ( { @@ -451,7 +456,7 @@ import React from "react" const queryClient = new QueryClient() -function App() { +const App = () => { return ( Date: Tue, 24 Jan 2023 07:55:24 -0500 Subject: [PATCH 05/17] hotfix(medusa-react): Invalidate query keys on successful mutations (#3099) **What** - Fixes an issue where query keys weren't invalidated on successful mutations. **How** - Update `buildOptions` function to be called per `QueryKey` instead of passing them all as a single query key, resulting in no matches found. - Fixes imports that aren't compatible with ESM modules. --- .changeset/smooth-knives-stare.md | 5 +++++ packages/medusa-react/src/hooks/admin/auth/mutations.ts | 2 +- .../medusa-react/src/hooks/admin/collections/mutations.ts | 2 +- .../medusa-react/src/hooks/admin/currencies/mutations.ts | 2 +- .../medusa-react/src/hooks/admin/gift-cards/mutations.ts | 2 +- packages/medusa-react/src/hooks/admin/notes/mutations.ts | 2 +- .../medusa-react/src/hooks/admin/order-edits/mutations.ts | 2 +- .../src/hooks/admin/payment-collections/mutations.ts | 2 +- packages/medusa-react/src/hooks/admin/payments/mutations.ts | 2 +- .../src/hooks/admin/publishable-api-keys/mutations.ts | 2 +- .../medusa-react/src/hooks/admin/return-reasons/mutations.ts | 2 +- .../medusa-react/src/hooks/store/order-edits/mutations.ts | 2 +- packages/medusa-react/src/hooks/store/orders/mutations.ts | 2 +- .../src/hooks/store/payment-collections/mutations.ts | 2 +- packages/medusa-react/src/hooks/utils/buildOptions.ts | 4 +++- 15 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 .changeset/smooth-knives-stare.md diff --git a/.changeset/smooth-knives-stare.md b/.changeset/smooth-knives-stare.md new file mode 100644 index 0000000000..3926a32107 --- /dev/null +++ b/.changeset/smooth-knives-stare.md @@ -0,0 +1,5 @@ +--- +"medusa-react": patch +--- + +hotfix(medusa-react): Fixes an issue where queries weren't properly invalidated on successful mutations diff --git a/packages/medusa-react/src/hooks/admin/auth/mutations.ts b/packages/medusa-react/src/hooks/admin/auth/mutations.ts index 404b5d5ab0..ea7255691d 100644 --- a/packages/medusa-react/src/hooks/admin/auth/mutations.ts +++ b/packages/medusa-react/src/hooks/admin/auth/mutations.ts @@ -5,9 +5,9 @@ import { UseMutationOptions, useQueryClient, } from "@tanstack/react-query" -import { adminAuthKeys } from "." import { useMedusa } from "../../../contexts/medusa" import { buildOptions } from "../../utils/buildOptions" +import { adminAuthKeys } from "./queries" export const useAdminLogin = ( options?: UseMutationOptions, Error, AdminPostAuthReq> diff --git a/packages/medusa-react/src/hooks/admin/collections/mutations.ts b/packages/medusa-react/src/hooks/admin/collections/mutations.ts index b1fea2b23e..0bd2d1bf8f 100644 --- a/packages/medusa-react/src/hooks/admin/collections/mutations.ts +++ b/packages/medusa-react/src/hooks/admin/collections/mutations.ts @@ -12,9 +12,9 @@ import { UseMutationOptions, useQueryClient, } from "@tanstack/react-query" -import { adminCollectionKeys } from "." import { useMedusa } from "../../../contexts/medusa" import { buildOptions } from "../../utils/buildOptions" +import { adminCollectionKeys } from "./queries" export const useAdminCreateCollection = ( options?: UseMutationOptions< diff --git a/packages/medusa-react/src/hooks/admin/currencies/mutations.ts b/packages/medusa-react/src/hooks/admin/currencies/mutations.ts index a8712837ed..857db90a03 100644 --- a/packages/medusa-react/src/hooks/admin/currencies/mutations.ts +++ b/packages/medusa-react/src/hooks/admin/currencies/mutations.ts @@ -8,9 +8,9 @@ import { UseMutationOptions, useQueryClient, } from "@tanstack/react-query" -import { adminCurrenciesKeys } from "." import { useMedusa } from "../../../contexts/medusa" import { buildOptions } from "../../utils/buildOptions" +import { adminCurrenciesKeys } from "./queries" export const useAdminUpdateCurrency = ( code: string, diff --git a/packages/medusa-react/src/hooks/admin/gift-cards/mutations.ts b/packages/medusa-react/src/hooks/admin/gift-cards/mutations.ts index 98889f5ad0..da1673b4a2 100644 --- a/packages/medusa-react/src/hooks/admin/gift-cards/mutations.ts +++ b/packages/medusa-react/src/hooks/admin/gift-cards/mutations.ts @@ -9,9 +9,9 @@ import { UseMutationOptions, useQueryClient, } from "@tanstack/react-query" -import { adminGiftCardKeys } from "." import { useMedusa } from "../../../contexts/medusa" import { buildOptions } from "../../utils/buildOptions" +import { adminGiftCardKeys } from "./queries" export const useAdminCreateGiftCard = ( options?: UseMutationOptions< diff --git a/packages/medusa-react/src/hooks/admin/notes/mutations.ts b/packages/medusa-react/src/hooks/admin/notes/mutations.ts index 2a8cd3fa7d..1f452b78c4 100644 --- a/packages/medusa-react/src/hooks/admin/notes/mutations.ts +++ b/packages/medusa-react/src/hooks/admin/notes/mutations.ts @@ -10,9 +10,9 @@ import { UseMutationOptions, useQueryClient, } from "@tanstack/react-query" -import { adminNoteKeys } from "." import { useMedusa } from "../../../contexts/medusa" import { buildOptions } from "../../utils/buildOptions" +import { adminNoteKeys } from "./queries" export const useAdminCreateNote = ( options?: UseMutationOptions< diff --git a/packages/medusa-react/src/hooks/admin/order-edits/mutations.ts b/packages/medusa-react/src/hooks/admin/order-edits/mutations.ts index 71e584b99f..67e24a6774 100644 --- a/packages/medusa-react/src/hooks/admin/order-edits/mutations.ts +++ b/packages/medusa-react/src/hooks/admin/order-edits/mutations.ts @@ -15,10 +15,10 @@ import { AdminPostOrderEditsReq, } from "@medusajs/medusa" -import { adminOrderEditsKeys } from "." import { useMedusa } from "../../../contexts" import { buildOptions } from "../../utils/buildOptions" import { adminOrderKeys } from "../orders" +import { adminOrderEditsKeys } from "./queries" export const useAdminCreateOrderEdit = ( options?: UseMutationOptions< diff --git a/packages/medusa-react/src/hooks/admin/payment-collections/mutations.ts b/packages/medusa-react/src/hooks/admin/payment-collections/mutations.ts index 6bcf9ecc54..fe0b1bdcbd 100644 --- a/packages/medusa-react/src/hooks/admin/payment-collections/mutations.ts +++ b/packages/medusa-react/src/hooks/admin/payment-collections/mutations.ts @@ -11,9 +11,9 @@ import { AdminUpdatePaymentCollectionsReq, } from "@medusajs/medusa" -import { adminPaymentCollectionQueryKeys } from "." import { useMedusa } from "../../../contexts" import { buildOptions } from "../../utils/buildOptions" +import { adminPaymentCollectionQueryKeys } from "./queries" export const useAdminDeletePaymentCollection = ( id: string, diff --git a/packages/medusa-react/src/hooks/admin/payments/mutations.ts b/packages/medusa-react/src/hooks/admin/payments/mutations.ts index e04b31ebb7..cc799c55af 100644 --- a/packages/medusa-react/src/hooks/admin/payments/mutations.ts +++ b/packages/medusa-react/src/hooks/admin/payments/mutations.ts @@ -11,9 +11,9 @@ import { AdminRefundRes, } from "@medusajs/medusa" -import { adminPaymentQueryKeys } from "." import { useMedusa } from "../../../contexts" import { buildOptions } from "../../utils/buildOptions" +import { adminPaymentQueryKeys } from "./queries" export const useAdminPaymentsCapturePayment = ( id: string, diff --git a/packages/medusa-react/src/hooks/admin/publishable-api-keys/mutations.ts b/packages/medusa-react/src/hooks/admin/publishable-api-keys/mutations.ts index 679663255a..129728e756 100644 --- a/packages/medusa-react/src/hooks/admin/publishable-api-keys/mutations.ts +++ b/packages/medusa-react/src/hooks/admin/publishable-api-keys/mutations.ts @@ -13,9 +13,9 @@ import { AdminPublishableApiKeysRes, } from "@medusajs/medusa" -import { adminPublishableApiKeysKeys } from "." import { useMedusa } from "../../../contexts" import { buildOptions } from "../../utils/buildOptions" +import { adminPublishableApiKeysKeys } from "./queries" export const useAdminCreatePublishableApiKey = ( options?: UseMutationOptions< diff --git a/packages/medusa-react/src/hooks/admin/return-reasons/mutations.ts b/packages/medusa-react/src/hooks/admin/return-reasons/mutations.ts index 36d6d14e8f..0b4a42fd54 100644 --- a/packages/medusa-react/src/hooks/admin/return-reasons/mutations.ts +++ b/packages/medusa-react/src/hooks/admin/return-reasons/mutations.ts @@ -9,9 +9,9 @@ import { UseMutationOptions, useQueryClient, } from "@tanstack/react-query" -import { adminReturnReasonKeys } from "." import { useMedusa } from "../../../contexts/medusa" import { buildOptions } from "../../utils/buildOptions" +import { adminReturnReasonKeys } from "./queries" export const useAdminCreateReturnReason = ( options?: UseMutationOptions< diff --git a/packages/medusa-react/src/hooks/store/order-edits/mutations.ts b/packages/medusa-react/src/hooks/store/order-edits/mutations.ts index b034bec494..ae87869e7f 100644 --- a/packages/medusa-react/src/hooks/store/order-edits/mutations.ts +++ b/packages/medusa-react/src/hooks/store/order-edits/mutations.ts @@ -10,9 +10,9 @@ import { StorePostOrderEditsOrderEditDecline, } from "@medusajs/medusa" -import { orderEditQueryKeys } from "." import { useMedusa } from "../../../contexts" import { buildOptions } from "../../utils/buildOptions" +import { orderEditQueryKeys } from "./queries" export const useDeclineOrderEdit = ( id: string, diff --git a/packages/medusa-react/src/hooks/store/orders/mutations.ts b/packages/medusa-react/src/hooks/store/orders/mutations.ts index a453c0dd89..58518c8b79 100644 --- a/packages/medusa-react/src/hooks/store/orders/mutations.ts +++ b/packages/medusa-react/src/hooks/store/orders/mutations.ts @@ -10,9 +10,9 @@ import { StorePostCustomersCustomerOrderClaimReq, } from "@medusajs/medusa" -import { orderKeys } from "." import { useMedusa } from "../../../contexts" import { buildOptions } from "../../utils/buildOptions" +import { orderKeys } from "./queries" export const useRequestOrderAccess = ( options?: UseMutationOptions< diff --git a/packages/medusa-react/src/hooks/store/payment-collections/mutations.ts b/packages/medusa-react/src/hooks/store/payment-collections/mutations.ts index 495f05a319..decd273ca3 100644 --- a/packages/medusa-react/src/hooks/store/payment-collections/mutations.ts +++ b/packages/medusa-react/src/hooks/store/payment-collections/mutations.ts @@ -13,9 +13,9 @@ import { StorePostPaymentCollectionsBatchSessionsReq, } from "@medusajs/medusa" -import { paymentCollectionQueryKeys } from "." import { useMedusa } from "../../../contexts" import { buildOptions } from "../../utils/buildOptions" +import { paymentCollectionQueryKeys } from "./queries" export const useManageMultiplePaymentSessions = ( id: string, diff --git a/packages/medusa-react/src/hooks/utils/buildOptions.ts b/packages/medusa-react/src/hooks/utils/buildOptions.ts index d593b587e3..dd39bb21fc 100644 --- a/packages/medusa-react/src/hooks/utils/buildOptions.ts +++ b/packages/medusa-react/src/hooks/utils/buildOptions.ts @@ -23,7 +23,9 @@ export const buildOptions = < } if (queryKey !== undefined) { - queryClient.invalidateQueries(queryKey) + queryKey.forEach((key) => { + queryClient.invalidateQueries({ queryKey: key as QueryKey }) + }) } }, } From 8f07738d888a748cf13c450cca054199753e018f Mon Sep 17 00:00:00 2001 From: olivermrbl Date: Tue, 24 Jan 2023 13:58:41 +0100 Subject: [PATCH 06/17] chore(release): Publish --- .changeset/smooth-knives-stare.md | 5 ----- packages/medusa-react/CHANGELOG.md | 6 ++++++ packages/medusa-react/package.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) delete mode 100644 .changeset/smooth-knives-stare.md diff --git a/.changeset/smooth-knives-stare.md b/.changeset/smooth-knives-stare.md deleted file mode 100644 index 3926a32107..0000000000 --- a/.changeset/smooth-knives-stare.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"medusa-react": patch ---- - -hotfix(medusa-react): Fixes an issue where queries weren't properly invalidated on successful mutations diff --git a/packages/medusa-react/CHANGELOG.md b/packages/medusa-react/CHANGELOG.md index 0829a1bf61..cad5384187 100644 --- a/packages/medusa-react/CHANGELOG.md +++ b/packages/medusa-react/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 4.0.3 + +### Patch Changes + +- [#3099](https://github.com/medusajs/medusa/pull/3099) [`6293fccc6`](https://github.com/medusajs/medusa/commit/6293fccc650411d27a9823a5f63f286d08ff2174) Thanks [@kasperkristensen](https://github.com/kasperkristensen)! - hotfix(medusa-react): Fixes an issue where queries weren't properly invalidated on successful mutations + ## 4.0.2 ### Patch Changes diff --git a/packages/medusa-react/package.json b/packages/medusa-react/package.json index 60ac6ac60d..e6b2651f79 100644 --- a/packages/medusa-react/package.json +++ b/packages/medusa-react/package.json @@ -1,5 +1,5 @@ { - "version": "4.0.2", + "version": "4.0.3", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", From 0312eceda7020d7cfd3dabcf890477d4d0b8657b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 25 Jan 2023 10:07:20 +0200 Subject: [PATCH 07/17] chore(docs): Removed Docs Announcement Bar (automated) (#3106) Co-authored-by: shahednasser --- www/docs/announcement.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/docs/announcement.json b/www/docs/announcement.json index 15289f12a5..9e26dfeeb6 100644 --- a/www/docs/announcement.json +++ b/www/docs/announcement.json @@ -1 +1 @@ -{"id":"https://github.com/medusajs/medusa/releases/tag/v1.7.5","content":"v1.7.5 is out","isCloseable":true} \ No newline at end of file +{} \ No newline at end of file From 4e82ec07347cef7214978a6a088f9df78824ec92 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 25 Jan 2023 10:28:11 +0200 Subject: [PATCH 08/17] chore(docs): Updated API Reference (#3107) * chore(docs): Generated API Reference * small fix Co-authored-by: olivermrbl Co-authored-by: Shahed Nasser --- docs/api/admin-spec3.json | 21 +++++++++++++++++---- docs/api/admin-spec3.yaml | 21 +++++++++++++++++---- docs/api/admin/openapi.yaml | 21 +++++++++++++++++---- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/docs/api/admin-spec3.json b/docs/api/admin-spec3.json index f6e41e681d..da98f41bb2 100644 --- a/docs/api/admin-spec3.json +++ b/docs/api/admin-spec3.json @@ -18648,17 +18648,30 @@ components: of `{api_token}`. This is where you must pass the API token. - If you're alternatively following along with the JS Client request - samples, you must provide the `apiKey` option when creating the Medusa - client: + If you're following along with the JS Client request samples, you must + provide the `apiKey` option when creating the Medusa client: - ```js + ```ts const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3, apiKey: '{api_token}' }) ``` + + + If you're using Medusa React, you can pass the `apiKey` prop to + `MedusaProvider`: + + + ```tsx + + + + ``` scheme: bearer cookie_auth: type: apiKey diff --git a/docs/api/admin-spec3.yaml b/docs/api/admin-spec3.yaml index f6e41e681d..da98f41bb2 100644 --- a/docs/api/admin-spec3.yaml +++ b/docs/api/admin-spec3.yaml @@ -18648,17 +18648,30 @@ components: of `{api_token}`. This is where you must pass the API token. - If you're alternatively following along with the JS Client request - samples, you must provide the `apiKey` option when creating the Medusa - client: + If you're following along with the JS Client request samples, you must + provide the `apiKey` option when creating the Medusa client: - ```js + ```ts const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3, apiKey: '{api_token}' }) ``` + + + If you're using Medusa React, you can pass the `apiKey` prop to + `MedusaProvider`: + + + ```tsx + + + + ``` scheme: bearer cookie_auth: type: apiKey diff --git a/docs/api/admin/openapi.yaml b/docs/api/admin/openapi.yaml index 5492810a7e..4c2251095a 100644 --- a/docs/api/admin/openapi.yaml +++ b/docs/api/admin/openapi.yaml @@ -543,17 +543,30 @@ components: of `{api_token}`. This is where you must pass the API token. - If you're alternatively following along with the JS Client request - samples, you must provide the `apiKey` option when creating the Medusa - client: + If you're following along with the JS Client request samples, you must + provide the `apiKey` option when creating the Medusa client: - ```js + ```ts const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3, apiKey: '{api_token}' }) ``` + + + If you're using Medusa React, you can pass the `apiKey` prop to + `MedusaProvider`: + + + ```tsx + + + + ``` scheme: bearer cookie_auth: type: apiKey From 589cb18f98f7ca83c6a103851dcc93ac29ebaf52 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 26 Jan 2023 15:58:33 +0200 Subject: [PATCH 09/17] docs: improved SEO of documentation (#3117) * docs: added description to documentation pages * docs: added more descriptions * docs: finished improving meta description * docs: added searchbox structured data * docs: added breadcrumbs structured data * docs: added how to structured data * docs: improved 404 page * docs: added how-to frontmatter option --- docs/content/add-plugins/algolia.md | 5 ++ .../contentful/customize-contentful.md | 5 ++ docs/content/add-plugins/contentful/index.md | 5 ++ docs/content/add-plugins/klarna.md | 5 ++ docs/content/add-plugins/mailchimp.md | 5 ++ docs/content/add-plugins/meilisearch.md | 5 ++ docs/content/add-plugins/minio.md | 5 ++ docs/content/add-plugins/paypal.md | 5 ++ docs/content/add-plugins/s3.md | 5 ++ docs/content/add-plugins/segment.md | 5 ++ docs/content/add-plugins/sendgrid.mdx | 5 ++ docs/content/add-plugins/slack.md | 5 ++ docs/content/add-plugins/spaces.md | 5 ++ docs/content/add-plugins/strapi.md | 5 ++ docs/content/add-plugins/stripe.md | 5 ++ docs/content/add-plugins/twilio-sms.md | 5 ++ docs/content/admin/development.md | 5 ++ docs/content/admin/quickstart.mdx | 5 ++ docs/content/advanced/admin/import-prices.mdx | 5 ++ .../advanced/admin/import-products.mdx | 5 ++ .../advanced/admin/manage-customers.mdx | 5 ++ .../advanced/admin/manage-discounts.mdx | 5 ++ .../advanced/admin/manage-gift-cards.mdx | 5 ++ .../admin/manage-publishable-api-keys.mdx | 7 +- .../content/advanced/admin/manage-regions.mdx | 5 ++ docs/content/advanced/admin/order-edit.mdx | 5 ++ .../advanced/admin/use-customergroups-api.mdx | 5 ++ .../batch-jobs/{create.md => create.mdx} | 5 ++ .../backend/batch-jobs/customize-import.md | 17 +++-- .../advanced/backend/batch-jobs/index.md | 4 ++ .../advanced/backend/customer-groups/index.md | 4 ++ .../advanced/backend/customers/index.md | 4 ++ .../backend/dependency-container/index.md | 4 ++ .../advanced/backend/discounts/index.md | 4 ++ .../backend/endpoints/add-middleware.md | 5 ++ .../content/advanced/backend/endpoints/add.md | 5 ++ .../advanced/backend/entities/index.md | 5 ++ .../advanced/backend/entities/overview.md | 4 ++ .../advanced/backend/events/architecture.md | 4 ++ .../advanced/backend/feature-flags/toggle.md | 7 +- .../advanced/backend/gift-cards/index.md | 4 ++ .../advanced/backend/migrations/index.md | 5 ++ .../advanced/backend/migrations/overview.md | 4 ++ .../how-to-create-notification-provider.md | 5 ++ .../advanced/backend/notification/overview.md | 4 ++ .../payment/how-to-create-payment-provider.md | 5 ++ .../advanced/backend/payment/overview.md | 4 ++ .../advanced/backend/plugins/create.md | 7 +- .../advanced/backend/plugins/overview.md | 4 ++ .../advanced/backend/price-lists/index.md | 4 ++ .../advanced/backend/price-lists/use-api.mdx | 7 +- .../backend/price-selection-strategy/index.md | 4 ++ .../price-selection-strategy/override.md | 7 +- .../backend/publishable-api-keys/index.md | 4 ++ .../advanced/backend/regions/overview.md | 4 ++ .../advanced/backend/sales-channels/index.md | 4 ++ .../backend/sales-channels/manage-admin.mdx | 5 ++ .../advanced/backend/scheduled-jobs/create.md | 5 ++ .../backend/services/create-service.md | 5 ++ .../advanced/backend/services/overview.md | 4 ++ .../shipping/add-fulfillment-provider.md | 5 ++ .../advanced/backend/shipping/overview.md | 4 ++ .../backend/subscribers/create-subscriber.md | 7 +- .../backend/subscribers/events-list.md | 4 ++ .../advanced/backend/subscribers/overview.md | 4 ++ .../backend/taxes/inclusive-pricing.md | 4 ++ .../backend/taxes/manual-calculation.md | 5 ++ .../advanced/backend/upgrade-guides/index.mdx | 1 + .../ecommerce/handle-order-claim-event.md | 5 ++ .../ecommerce/send-gift-card-to-customer.md | 7 +- .../advanced/storefront/customer-profiles.mdx | 5 ++ .../storefront/handle-order-edits.mdx | 7 +- .../how-to-implement-checkout-flow.mdx | 5 ++ .../storefront/implement-claim-order.mdx | 7 +- .../storefront/use-discounts-in-checkout.mdx | 5 ++ .../advanced/storefront/use-gift-cards.mdx | 5 ++ .../advanced/storefront/use-regions.mdx | 5 ++ .../storefront/use-sales-channels.mdx | 5 ++ docs/content/cli/reference.md | 4 ++ .../deployments/admin/deploying-on-netlify.md | 1 + docs/content/deployments/admin/index.mdx | 1 + .../server/deploying-on-digital-ocean.md | 1 + .../server/deploying-on-heroku.mdx | 1 + .../deployments/server/deploying-on-qovery.md | 1 + .../server/deploying-on-railway.md | 1 + docs/content/deployments/server/index.mdx | 1 + .../storefront/deploying-gatsby-on-netlify.md | 1 + docs/content/deployments/storefront/index.mdx | 1 + docs/content/guides/carts-in-medusa.mdx | 5 ++ docs/content/homepage.mdx | 2 +- docs/content/introduction.md | 6 +- docs/content/js-client/overview.md | 6 +- docs/content/medusa-react/overview.md | 4 ++ .../content/quickstart/quick-start-docker.mdx | 7 +- docs/content/quickstart/quick-start.mdx | 7 +- .../starters/gatsby-medusa-starter.mdx | 4 ++ .../starters/nextjs-medusa-starter.mdx | 4 ++ .../0-set-up-your-development-environment.mdx | 6 +- docs/content/usage/configurations.md | 6 +- docs/content/usage/create-medusa-app.mdx | 5 ++ docs/content/usage/local-development.md | 4 ++ docs/content/user-guide/customers/groups.mdx | 2 + docs/content/user-guide/customers/index.md | 1 + docs/content/user-guide/customers/manage.mdx | 2 + docs/content/user-guide/discounts/create.mdx | 2 + docs/content/user-guide/discounts/index.md | 1 + docs/content/user-guide/discounts/manage.mdx | 2 + docs/content/user-guide/gift-cards/custom.mdx | 2 + docs/content/user-guide/gift-cards/index.md | 1 + docs/content/user-guide/gift-cards/manage.mdx | 2 + docs/content/user-guide/index.mdx | 1 + docs/content/user-guide/lists.mdx | 1 + docs/content/user-guide/orders/claims.mdx | 2 + docs/content/user-guide/orders/drafts.mdx | 2 + docs/content/user-guide/orders/exchange.mdx | 2 + docs/content/user-guide/orders/export.mdx | 2 + .../user-guide/orders/fulfillments.mdx | 2 + docs/content/user-guide/orders/index.md | 1 + docs/content/user-guide/orders/manage.mdx | 2 + docs/content/user-guide/orders/payments.md | 1 + docs/content/user-guide/orders/returns.mdx | 2 + .../content/user-guide/price-lists/import.mdx | 2 + docs/content/user-guide/price-lists/index.md | 1 + .../content/user-guide/price-lists/manage.mdx | 2 + .../user-guide/products/collections.mdx | 2 + docs/content/user-guide/products/export.mdx | 2 + docs/content/user-guide/products/import.mdx | 2 + docs/content/user-guide/products/index.mdx | 1 + docs/content/user-guide/products/manage.mdx | 2 + docs/content/user-guide/regions/index.md | 1 + docs/content/user-guide/regions/manage.mdx | 2 + docs/content/user-guide/regions/providers.mdx | 4 +- .../user-guide/regions/shipping-options.mdx | 5 +- .../user-guide/sales-channels/index.md | 7 +- .../user-guide/sales-channels/manage.mdx | 2 + .../user-guide/sales-channels/products.mdx | 2 + .../content/user-guide/settings/currencies.md | 2 + .../settings/publishable-api-keys.mdx | 2 + .../user-guide/settings/return-reasons.mdx | 2 + docs/content/user-guide/settings/store.md | 1 + docs/content/user-guide/taxes/index.md | 1 + docs/content/user-guide/taxes/manage.md | 2 + .../user-guide/taxes/tax-inclusive.mdx | 2 + .../user-guide/taxes/tax-overrides.mdx | 2 + docs/content/user-guide/taxes/tax-rates.mdx | 2 + docs/content/user-guide/users/index.md | 1 + docs/content/user-guide/users/profile.md | 4 +- docs/content/user-guide/users/team.mdx | 10 ++- www/docs/docusaurus.config.js | 2 +- www/docs/sidebars.js | 9 +-- www/docs/src/components/Feedback/index.js | 8 --- www/docs/src/css/_docspage.css | 4 ++ www/docs/src/theme/Layout/index.js | 4 +- www/docs/src/theme/NotFound.js | 72 +++++++++++++++++++ .../src/theme/StructuredData/HowTo/index.js | 31 ++++++++ .../theme/StructuredData/Searchbox/index.tsx | 27 +++++++ www/docs/src/theme/TOCItems/index.js | 15 ++++ www/docs/src/utils/filterListItems.ts | 1 - 158 files changed, 699 insertions(+), 48 deletions(-) rename docs/content/advanced/backend/batch-jobs/{create.md => create.mdx} (98%) create mode 100644 www/docs/src/theme/NotFound.js create mode 100644 www/docs/src/theme/StructuredData/HowTo/index.js create mode 100644 www/docs/src/theme/StructuredData/Searchbox/index.tsx create mode 100644 www/docs/src/theme/TOCItems/index.js diff --git a/docs/content/add-plugins/algolia.md b/docs/content/add-plugins/algolia.md index 7efc23734c..713bcf9e3b 100644 --- a/docs/content/add-plugins/algolia.md +++ b/docs/content/add-plugins/algolia.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to integrate Algolia with the Medusa server. Learn how to install the Algolia plugin into the Medusa server and how to integrate it into a storefront.' +addHowToData: true +--- + # Algolia In this document, you’ll learn how to install the [Algolia plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-plugin-algolia) and use it on both your Medusa Server and your storefront. diff --git a/docs/content/add-plugins/contentful/customize-contentful.md b/docs/content/add-plugins/contentful/customize-contentful.md index cfcbad213b..15967dda4f 100644 --- a/docs/content/add-plugins/contentful/customize-contentful.md +++ b/docs/content/add-plugins/contentful/customize-contentful.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to customize the Contentful integration with Medusa and how to customize the Gatsby storefront that is connected to Contentful.' +addHowToData: true +--- + # Customize your Medusa and Contentful Integration In this document, you’ll learn how to customize the Contentful integration with Medusa and how to customize the Gatsby storefront that is connected to Contentful. diff --git a/docs/content/add-plugins/contentful/index.md b/docs/content/add-plugins/contentful/index.md index 1a709a91d5..295ffa8560 100644 --- a/docs/content/add-plugins/contentful/index.md +++ b/docs/content/add-plugins/contentful/index.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to integrate Contentful with the Medusa server and a Gatsby storefront. Contentful is a headless CMS server that provides rich CMS functionalities.' +addHowToData: true +--- + # Contentful In this document, you’ll learn how to integrate a Medusa server with Contentful to add rich Content Management System (CMS) functionalities diff --git a/docs/content/add-plugins/klarna.md b/docs/content/add-plugins/klarna.md index fae6242abb..d6d0e9e88b 100644 --- a/docs/content/add-plugins/klarna.md +++ b/docs/content/add-plugins/klarna.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to integrate Klarna as a payment provider with the Medusa server. Learn how to install Klarna and enable the payment provider in a region.' +addHowToData: true +--- + # Klarna In this document, you’ll learn how to integrate Klarna as a payment provider in Medusa. diff --git a/docs/content/add-plugins/mailchimp.md b/docs/content/add-plugins/mailchimp.md index b1858aab23..7a867c2b22 100644 --- a/docs/content/add-plugins/mailchimp.md +++ b/docs/content/add-plugins/mailchimp.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to integrate Mailchimp with the Medusa server. Learn how to install the plugin on the Medusa server and how to add a subscription form.' +addHowToData: true +--- + # Mailchimp In this document, you’ll learn about the Mailchimp plugin, what it does, and how to use it. diff --git a/docs/content/add-plugins/meilisearch.md b/docs/content/add-plugins/meilisearch.md index c788813a94..6b3651b704 100644 --- a/docs/content/add-plugins/meilisearch.md +++ b/docs/content/add-plugins/meilisearch.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to integrate MeiliSearch with the Medusa server. Learn how to install the MeiliSearch plugin on the Medusa server and integrate it into the storefront.' +addHowToData: true +--- + # MeiliSearch In this document, you’ll learn how to install the [MeiliSearch plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-plugin-meilisearch) and use it on both your Medusa Server and your storefront. diff --git a/docs/content/add-plugins/minio.md b/docs/content/add-plugins/minio.md index c66c61ed38..ed5ac5fd9b 100644 --- a/docs/content/add-plugins/minio.md +++ b/docs/content/add-plugins/minio.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to integrate MinIO with the Medusa server. Learn how to install the MinIO plugin on the Medusa server and configure it.' +addHowToData: true +--- + # MinIO This document will guide you through installing the MinIO file service plugin on your Medusa server. diff --git a/docs/content/add-plugins/paypal.md b/docs/content/add-plugins/paypal.md index 3586825d6f..78126d7fbd 100644 --- a/docs/content/add-plugins/paypal.md +++ b/docs/content/add-plugins/paypal.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to integrate PayPal with the Medusa server. Learn how to install the PayPal plugin on the Medusa server and integrate into a storefront.' +addHowToData: true +--- + # PayPal This document guides you through setting up PayPal as a payment provider in your Medusa server, admin, and storefront using the [PayPal plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-payment-paypal). diff --git a/docs/content/add-plugins/s3.md b/docs/content/add-plugins/s3.md index 943d92f606..0350ad172e 100644 --- a/docs/content/add-plugins/s3.md +++ b/docs/content/add-plugins/s3.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to integrate the S3 plugin with the Medusa server. Learn how to configure and use S3 to store images related to the Medusa server.' +addHowToData: true +--- + # S3 In this document, you’ll learn how to install the [S3 plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-file-s3) on your Medusa server and use it for storage. diff --git a/docs/content/add-plugins/segment.md b/docs/content/add-plugins/segment.md index ff4ed78ae6..028e297483 100644 --- a/docs/content/add-plugins/segment.md +++ b/docs/content/add-plugins/segment.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to integrate Segment with the Medusa server. Learn how to add custom tracking with Segment and Medusa.' +addHowToData: true +--- + # Segment In this document, you’ll learn about the [Segment plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-plugin-segment), what it does, and how to install and use it. diff --git a/docs/content/add-plugins/sendgrid.mdx b/docs/content/add-plugins/sendgrid.mdx index 0951af214f..f216d68267 100644 --- a/docs/content/add-plugins/sendgrid.mdx +++ b/docs/content/add-plugins/sendgrid.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to integrate SendGrid with the Medusa server. Learn how to install the SendGrid plugin and test it out.' +addHowToData: true +--- + # SendGrid In this document, you’ll learn about the [SendGrid plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-plugin-sendgrid), what it does, and how to use it. diff --git a/docs/content/add-plugins/slack.md b/docs/content/add-plugins/slack.md index 316d57926c..4ebf2881ec 100644 --- a/docs/content/add-plugins/slack.md +++ b/docs/content/add-plugins/slack.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to integrate Slack with the Medusa server. Learn how to create and configure a Slack app and install the Slack plugin on the Medusa server.' +addHowToData: true +--- + # Slack In this documentation, you'll learn how to add the [Slack plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-plugin-slack-notification) to your Medusa server to start receiving order notifications. diff --git a/docs/content/add-plugins/spaces.md b/docs/content/add-plugins/spaces.md index 7f31d81587..b5d59a273b 100644 --- a/docs/content/add-plugins/spaces.md +++ b/docs/content/add-plugins/spaces.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to integrate Spaces with the Medusa server. Learn how to install and configure the Spaces plugin on the Medusa server.' +addHowToData: true +--- + # Spaces In this document, you’ll learn how to install the [Spaces plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-file-spaces) on your Medusa server and use it for storage. diff --git a/docs/content/add-plugins/strapi.md b/docs/content/add-plugins/strapi.md index b957616476..9c9b2f57b4 100644 --- a/docs/content/add-plugins/strapi.md +++ b/docs/content/add-plugins/strapi.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to integrate Strapi with the Medusa server. Learn how to install the plugin and test two-way sync between the ecommerce and CMS services.' +addHowToData: true +--- + # Strapi In this document, you’ll learn how to integrate Strapi with Medusa to add rich Content Management System (CMS) functionalities. diff --git a/docs/content/add-plugins/stripe.md b/docs/content/add-plugins/stripe.md index d657377050..6d986d0643 100644 --- a/docs/content/add-plugins/stripe.md +++ b/docs/content/add-plugins/stripe.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to integrate Stripe with the Medusa server. Learn how to install the Stripe plugin on the Medusa server and integrate it into a storefront.' +addHowToData: true +--- + # Stripe This document guides you through setting up Stripe payments in your Medusa server, admin, and storefront using the [Stripe Plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-payment-stripe). diff --git a/docs/content/add-plugins/twilio-sms.md b/docs/content/add-plugins/twilio-sms.md index 368c4c48df..f09b03f15f 100644 --- a/docs/content/add-plugins/twilio-sms.md +++ b/docs/content/add-plugins/twilio-sms.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to integrate Twilio SMS with the Medusa server. Learn how to install the Twilio SMS plugin and test it out.' +addHowToData: true +--- + # Twilio SMS In this document, you’ll learn about the Twilio SMS Plugin, what it does, and how to use it in Medusa. diff --git a/docs/content/admin/development.md b/docs/content/admin/development.md index 21e10cebdc..5e11740947 100644 --- a/docs/content/admin/development.md +++ b/docs/content/admin/development.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to set up the Medusa Admin repository for local development and customization. This includes cloning the GitHub repository and adding an upstream repository.' +addHowToData: true +--- + # Customize Medusa Admin In this document, you’ll learn how to customize the Medusa admin by forking it, and how to keep it updated with changes from the main repository. diff --git a/docs/content/admin/quickstart.mdx b/docs/content/admin/quickstart.mdx index ccfd938266..b1f4df545a 100644 --- a/docs/content/admin/quickstart.mdx +++ b/docs/content/admin/quickstart.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to install the Medusa admin. The Medusa admin gives merchants an easy-to-use interface to manage their data such as orders, products, regions, and more.' +addHowToData: true +--- + import Feedback from '@site/src/components/Feedback'; # Medusa Admin Quickstart diff --git a/docs/content/advanced/admin/import-prices.mdx b/docs/content/advanced/admin/import-prices.mdx index 8345426968..8c0f6b3221 100644 --- a/docs/content/advanced/admin/import-prices.mdx +++ b/docs/content/advanced/admin/import-prices.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to bulk-import prices into Medusa using the Admin REST APIs. The steps include uploading a CSV file, creating a batch job for the import, and confirming the batch job.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/advanced/admin/import-products.mdx b/docs/content/advanced/admin/import-products.mdx index 8b93dbea5c..02a37597e7 100644 --- a/docs/content/advanced/admin/import-products.mdx +++ b/docs/content/advanced/admin/import-products.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to import products into Medusa using the Admin REST APIs. The steps include uploading a CSV file, creating a batch job for the import, and confirming the batch job.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/advanced/admin/manage-customers.mdx b/docs/content/advanced/admin/manage-customers.mdx index de5beedd17..3c4cb10665 100644 --- a/docs/content/advanced/admin/manage-customers.mdx +++ b/docs/content/advanced/admin/manage-customers.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to implement customer-related functionalities for admins using the REST APIs. This includes how to list customers, add a new customer and edit the details of a customer.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/advanced/admin/manage-discounts.mdx b/docs/content/advanced/admin/manage-discounts.mdx index 56f72570fc..9b02a7911b 100644 --- a/docs/content/advanced/admin/manage-discounts.mdx +++ b/docs/content/advanced/admin/manage-discounts.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to implement discount functionalities for admins in Medusa using the REST APIs. This includes creating, updating, and deleting discounts, and managing conditions of discounts.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/advanced/admin/manage-gift-cards.mdx b/docs/content/advanced/admin/manage-gift-cards.mdx index 389ceebe4a..c90930c2bc 100644 --- a/docs/content/advanced/admin/manage-gift-cards.mdx +++ b/docs/content/advanced/admin/manage-gift-cards.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to implement gift card functionalities for admins using the REST APIs. This includes how to create, update, and delete gift cards, as well as custom gift cards.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/advanced/admin/manage-publishable-api-keys.mdx b/docs/content/advanced/admin/manage-publishable-api-keys.mdx index ceab6d2cd6..bbfb3e006b 100644 --- a/docs/content/advanced/admin/manage-publishable-api-keys.mdx +++ b/docs/content/advanced/admin/manage-publishable-api-keys.mdx @@ -1,7 +1,12 @@ +--- +description: 'Learn how to implement publishable API key functionalities for admins in Medusa using the REST APIs. This includes how to list, create, update, and delete a publishable API key.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -# Manage Publishable API Keys +# How to Manage Publishable API Keys In this document, you’ll learn how to manage the publishable API keys using the admin APIs. diff --git a/docs/content/advanced/admin/manage-regions.mdx b/docs/content/advanced/admin/manage-regions.mdx index 3884aed775..2e217e1594 100644 --- a/docs/content/advanced/admin/manage-regions.mdx +++ b/docs/content/advanced/admin/manage-regions.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to implement region-related functionalities for admins using the REST APIs. This includes how to list regions, and create, update, and delete regions.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/advanced/admin/order-edit.mdx b/docs/content/advanced/admin/order-edit.mdx index deb00593c7..f5048ceaaf 100644 --- a/docs/content/advanced/admin/order-edit.mdx +++ b/docs/content/advanced/admin/order-edit.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to implement order-editing features for admins using the REST APIs. This guide includes how to create an order edit and move order edit to request state, and more.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/advanced/admin/use-customergroups-api.mdx b/docs/content/advanced/admin/use-customergroups-api.mdx index e076a49593..d528d35188 100644 --- a/docs/content/advanced/admin/use-customergroups-api.mdx +++ b/docs/content/advanced/admin/use-customergroups-api.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to implement customer group functionalities for admins using the REST APIs. This includes listing customer groups, creating a customer group, managing customers in the group, and more.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/advanced/backend/batch-jobs/create.md b/docs/content/advanced/backend/batch-jobs/create.mdx similarity index 98% rename from docs/content/advanced/backend/batch-jobs/create.md rename to docs/content/advanced/backend/batch-jobs/create.mdx index 3cfc6d829a..9bddb1f4ec 100644 --- a/docs/content/advanced/backend/batch-jobs/create.md +++ b/docs/content/advanced/backend/batch-jobs/create.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to create a batch job strategy in the Medusa server. This guide also includes how to test your batch job strategy.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/advanced/backend/batch-jobs/customize-import.md b/docs/content/advanced/backend/batch-jobs/customize-import.md index c8ed6a2793..74ca818110 100644 --- a/docs/content/advanced/backend/batch-jobs/customize-import.md +++ b/docs/content/advanced/backend/batch-jobs/customize-import.md @@ -1,4 +1,9 @@ -# Customize Import Strategy +--- +description: 'Learn how to customize the import strategy in Medusa. The import strategy can be used to import entities such as products, prices in a price list, orders, or other entities.' +addHowToData: true +--- + +# How to Customize Import Strategy In this document, you’ll learn how to create a custom product import strategy either by overwriting the default strategy or creating your own. @@ -30,7 +35,7 @@ If you use SQLite during your development, it’s highly recommended that you us The steps required for overwriting a batch job strategy are essentially the same steps required to create a batch job strategy with a minor difference. For that reason, this documentation does not cover the basics of a batch job strategy. -If you’re interested to learn more about batch job strategies and how they work, please check out the [Create Batch Job Strategy documentation](./create.md). +If you’re interested to learn more about batch job strategies and how they work, please check out the [Create Batch Job Strategy documentation](./create.mdx). ### 1. Create a File @@ -69,7 +74,7 @@ export default MyImportStrategy :::note -This is the base implementation of a batch job strategy. You can learn about all the different methods and properties in [this documentation](./create.md#3-define-required-properties). +This is the base implementation of a batch job strategy. You can learn about all the different methods and properties in [this documentation](./create.mdx#3-define-required-properties). ::: @@ -92,7 +97,7 @@ class MyImportStrategy extends AbstractBatchJobStrategy { You can now define your custom functionality in your batch job strategy. For example, you can create custom import logic to import products. -Refer to the [Create a Batch Job documentation](./create.md#3-define-required-properties) to understand what properties and methods are required in your batch job strategy and how you can use them to implement your custom functionality. +Refer to the [Create a Batch Job documentation](./create.mdx#3-define-required-properties) to understand what properties and methods are required in your batch job strategy and how you can use them to implement your custom functionality. ### 5. Run Build Command @@ -104,7 +109,7 @@ npm run build ### 6. Test your Functionality -Since you didn’t create a new batch job type and overwrote the functionality of the strategy, you can test out your functionality using the [same steps used with the default strategy](./create.md#test-your-batch-job-strategy). +Since you didn’t create a new batch job type and overwrote the functionality of the strategy, you can test out your functionality using the [same steps used with the default strategy](./create.mdx#test-your-batch-job-strategy). Specifically, since you create batch jobs using the [Create Batch Job](https://docs.medusajs.com/api/admin/#tag/Batch-Job/operation/PostBatchJobs) endpoint which accepts the batch job type as a body parameter, you just need to send the same type you used for this field. In the example of this documentation, the `type` would be `product-import`. @@ -116,7 +121,7 @@ If you overwrote the import functionality, you can follow [these steps to learn If you don’t want to overwrite Medusa’s batch job strategy, you can create a custom batch job strategy with a different `batchType` value. Then, use that type when you send a request to [Create a Batch Job](https://docs.medusajs.com/api/admin/#tag/Batch-Job). -For more details on creating custom batch job strategies, please check out the [Create Batch Job Strategy documentation](create.md). +For more details on creating custom batch job strategies, please check out the [Create Batch Job Strategy documentation](create.mdx). --- diff --git a/docs/content/advanced/backend/batch-jobs/index.md b/docs/content/advanced/backend/batch-jobs/index.md index caf20ccd22..88b61e4cd2 100644 --- a/docs/content/advanced/backend/batch-jobs/index.md +++ b/docs/content/advanced/backend/batch-jobs/index.md @@ -1,3 +1,7 @@ +--- +description: 'Learn what batch jobs in the Medusa server are and their flow. Batch jobs are tasks that can be performed asynchronously and iteratively in the Medusa server.' +--- + # Batch Jobs In this document, you’ll learn what Batch Jobs are and how they work in Medusa. diff --git a/docs/content/advanced/backend/customer-groups/index.md b/docs/content/advanced/backend/customer-groups/index.md index 6823503e2e..194040eb31 100644 --- a/docs/content/advanced/backend/customer-groups/index.md +++ b/docs/content/advanced/backend/customer-groups/index.md @@ -1,3 +1,7 @@ +--- +description: 'Learn what Customer Groups are and how they can be used in the Medusa server. Customer Groups allow to combine customers with similar attributes into a single group.' +--- + # Customer Groups In this document, you’ll learn about Customer Groups and how they can be used in Medusa. diff --git a/docs/content/advanced/backend/customers/index.md b/docs/content/advanced/backend/customers/index.md index 1f5d6cb104..cd2cbcc641 100644 --- a/docs/content/advanced/backend/customers/index.md +++ b/docs/content/advanced/backend/customers/index.md @@ -1,3 +1,7 @@ +--- +description: 'Learn about what Customers are in Medusa and how they are implemented. Customers are individuals that make purchases in your store.' +--- + # Customers In this document, you’ll learn about Customers and their relation to other entities in Medusa. diff --git a/docs/content/advanced/backend/dependency-container/index.md b/docs/content/advanced/backend/dependency-container/index.md index ea28a8462d..379821d342 100644 --- a/docs/content/advanced/backend/dependency-container/index.md +++ b/docs/content/advanced/backend/dependency-container/index.md @@ -1,3 +1,7 @@ +--- +description: 'Learn what the dependency container is and how to use it in Medusa. Learn also what dependency injection is, and what the resources regsitered and their names are.' +--- + # Dependency Container In this document, you’ll learn what the dependency container is and how you can use it in Medusa. diff --git a/docs/content/advanced/backend/discounts/index.md b/docs/content/advanced/backend/discounts/index.md index 094f96c43e..66867c16ca 100644 --- a/docs/content/advanced/backend/discounts/index.md +++ b/docs/content/advanced/backend/discounts/index.md @@ -1,3 +1,7 @@ +--- +description: 'Learn about the discount architecture in the Medusa server. Discounts are used to offer promotions to the user for marketing purposes.' +--- + # Discounts Architecture In this document, you’ll learn about Discounts architecture and how it works. diff --git a/docs/content/advanced/backend/endpoints/add-middleware.md b/docs/content/advanced/backend/endpoints/add-middleware.md index 0049545e67..f4fc992b7a 100644 --- a/docs/content/advanced/backend/endpoints/add-middleware.md +++ b/docs/content/advanced/backend/endpoints/add-middleware.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to add a middleware in Medusa. A middleware is a function that has access to the request and response objects and can be used to perform actions around an endpoint.' +addHowToData: true +--- + # How to Add a Middleware In this document, you’ll learn how to add a middleware to an existing or custom route in Medusa. diff --git a/docs/content/advanced/backend/endpoints/add.md b/docs/content/advanced/backend/endpoints/add.md index 34c5b1a195..5bd826f027 100644 --- a/docs/content/advanced/backend/endpoints/add.md +++ b/docs/content/advanced/backend/endpoints/add.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to create endpoints in the Medusa server. This guide also includes how to add CORS configurations, creating multiple endpoints, adding protected routes, and more.' +addHowToData: true +--- + # How to Create Endpoints In this document, you’ll learn how to create endpoints in your Medusa server. diff --git a/docs/content/advanced/backend/entities/index.md b/docs/content/advanced/backend/entities/index.md index c7abea1ea1..2aaf8bf238 100644 --- a/docs/content/advanced/backend/entities/index.md +++ b/docs/content/advanced/backend/entities/index.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to create an entity in the Medusa server. This guide also explains how to create a repository and access and delete the entity.' +addHowToData: true +--- + # Create an Entity In this document, you’ll learn how you can create an [Entity](overview.md). diff --git a/docs/content/advanced/backend/entities/overview.md b/docs/content/advanced/backend/entities/overview.md index 550e80da20..e606715e0c 100644 --- a/docs/content/advanced/backend/entities/overview.md +++ b/docs/content/advanced/backend/entities/overview.md @@ -1,3 +1,7 @@ +--- +description: 'Learn what entities are in the Medusa server. There are entities in the Medusa server, and developers can create custom entities.' +--- + # Entities In this document, you'll learn what Entities are in Medusa. diff --git a/docs/content/advanced/backend/events/architecture.md b/docs/content/advanced/backend/events/architecture.md index aa3ade0329..8714d1a0f5 100644 --- a/docs/content/advanced/backend/events/architecture.md +++ b/docs/content/advanced/backend/events/architecture.md @@ -1,3 +1,7 @@ +--- +description: 'Learn how the events system is implemented in Medusa. It is built on a publish-subscribe architecture. The Medusa core publishes events when certain actions take place.' +--- + # Events Architecture In this document, you'll learn how the events system is implemented in Medusa. diff --git a/docs/content/advanced/backend/feature-flags/toggle.md b/docs/content/advanced/backend/feature-flags/toggle.md index 69cebd2c62..ea371b9a78 100644 --- a/docs/content/advanced/backend/feature-flags/toggle.md +++ b/docs/content/advanced/backend/feature-flags/toggle.md @@ -1,4 +1,9 @@ -# Toggle Feature Flags +--- +description: 'Learn how to toggle feature flags in the Medusa server. This guide explains the steps required to toggle a feature flag.' +addHowToData: true +--- + +# How to Toggle Feature Flags In this document, you’ll learn about what feature flags are and how to toggle them. diff --git a/docs/content/advanced/backend/gift-cards/index.md b/docs/content/advanced/backend/gift-cards/index.md index 6fe7773089..7d213ec70c 100644 --- a/docs/content/advanced/backend/gift-cards/index.md +++ b/docs/content/advanced/backend/gift-cards/index.md @@ -1,3 +1,7 @@ +--- +description: 'Learn what gift cards are and how they work in the Medusa server. Learn about the relations between Gift Cards and other entities.' +--- + # Gift Cards In this document, you’ll learn about Gift Cards and how they work in Medusa. diff --git a/docs/content/advanced/backend/migrations/index.md b/docs/content/advanced/backend/migrations/index.md index 784bb8a317..7f2ad29417 100644 --- a/docs/content/advanced/backend/migrations/index.md +++ b/docs/content/advanced/backend/migrations/index.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to create a migration in the Medusa server. This guide explains how to write and run migrations.' +addHowToData: true +--- + # How to Create Migrations In this document, you’ll learn how to create a [Migration](overview.md) using [Typeorm](https://typeorm.io) on your Medusa server. diff --git a/docs/content/advanced/backend/migrations/overview.md b/docs/content/advanced/backend/migrations/overview.md index 743991da6d..1d60316be4 100644 --- a/docs/content/advanced/backend/migrations/overview.md +++ b/docs/content/advanced/backend/migrations/overview.md @@ -1,3 +1,7 @@ +--- +description: 'Learn what Migrations are in the Medusa server and how to run them. Migrations are used to make changes to the database schema the Medusa server is linked to.' +--- + # Migrations In this document, you'll learn what Migrations are in Medusa. diff --git a/docs/content/advanced/backend/notification/how-to-create-notification-provider.md b/docs/content/advanced/backend/notification/how-to-create-notification-provider.md index ede8131a57..fc0c51d303 100644 --- a/docs/content/advanced/backend/notification/how-to-create-notification-provider.md +++ b/docs/content/advanced/backend/notification/how-to-create-notification-provider.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to create a notification provider in the Medusa server. This guide explains the different methods available in a Notification provider.' +addHowToData: true +--- + # How to Create a Notification Provider In this document, you’ll learn how to add a Notification Provider to your Medusa server. diff --git a/docs/content/advanced/backend/notification/overview.md b/docs/content/advanced/backend/notification/overview.md index 44b8261d7c..3481c19ed8 100644 --- a/docs/content/advanced/backend/notification/overview.md +++ b/docs/content/advanced/backend/notification/overview.md @@ -1,3 +1,7 @@ +--- +description: 'Learn about the Notificaiton architecture in Medusa and the automation flow. The Notification Architecture is made up of the Notification Provider and Notification.' +--- + # Notification Architecture Overview This document gives an overview of the notification architecture and how it works. diff --git a/docs/content/advanced/backend/payment/how-to-create-payment-provider.md b/docs/content/advanced/backend/payment/how-to-create-payment-provider.md index c204a1690d..46406c3618 100644 --- a/docs/content/advanced/backend/payment/how-to-create-payment-provider.md +++ b/docs/content/advanced/backend/payment/how-to-create-payment-provider.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to create a payment provider in the Medusa server. This guide explains the different methods available in a fulfillment provider.' +addHowToData: true +--- + # How to Create a Payment Provider In this document, you’ll learn how to add a Payment Provider to your Medusa server. If you’re unfamiliar with the Payment architecture in Medusa, make sure to check out the [overview](./overview.md) first. diff --git a/docs/content/advanced/backend/payment/overview.md b/docs/content/advanced/backend/payment/overview.md index cfea8ef5b9..f146244bdc 100644 --- a/docs/content/advanced/backend/payment/overview.md +++ b/docs/content/advanced/backend/payment/overview.md @@ -1,3 +1,7 @@ +--- +description: 'Learn about the payment architecture in the Medusa server. The payment architecture refers to all operations in the ecommerce store related to processing payments.' +--- + # Payment Architecture Overview In this document, you’ll learn about the payment architecture in Medusa, specifically its 3 main components and the idempotency key. diff --git a/docs/content/advanced/backend/plugins/create.md b/docs/content/advanced/backend/plugins/create.md index 00b160a80d..3f8b8a57b5 100644 --- a/docs/content/advanced/backend/plugins/create.md +++ b/docs/content/advanced/backend/plugins/create.md @@ -1,4 +1,9 @@ -# Create a Plugin +--- +description: 'Learn how to create a plugin in Medusa. This guide explains how to develop, configure, test, and publish the plugins.' +addHowToData: true +--- + +# How to Create a Plugin In this document, you’ll learn how to create a plugin and publish it. If you’re interested to learn more about what plugins are and where to find available official and community plugins, check out the [overview document](overview.md). diff --git a/docs/content/advanced/backend/plugins/overview.md b/docs/content/advanced/backend/plugins/overview.md index 2a3b68f267..ddf8bf2698 100644 --- a/docs/content/advanced/backend/plugins/overview.md +++ b/docs/content/advanced/backend/plugins/overview.md @@ -1,3 +1,7 @@ +--- +description: 'Learn what Plugins are and how they are used in Medusa. Plugins are re-usable customizations that can be added to a Medusa server.' +--- + # Plugins In this document, you’ll get an overview of plugins in Medusa, where to find them, and how to install them. If you want to learn how to create a plugin, check out [this guide](create.md) instead. diff --git a/docs/content/advanced/backend/price-lists/index.md b/docs/content/advanced/backend/price-lists/index.md index f8b10cdba4..1e29901a1e 100644 --- a/docs/content/advanced/backend/price-lists/index.md +++ b/docs/content/advanced/backend/price-lists/index.md @@ -1,3 +1,7 @@ +--- +description: 'Learn what price lists are and how they work in a Medusa server. Price Lists can be used to override product prices based on different conditions.' +--- + # Price Lists In this document, you’ll learn what price lists are and how they work. diff --git a/docs/content/advanced/backend/price-lists/use-api.mdx b/docs/content/advanced/backend/price-lists/use-api.mdx index b471bb45eb..85c2141af2 100644 --- a/docs/content/advanced/backend/price-lists/use-api.mdx +++ b/docs/content/advanced/backend/price-lists/use-api.mdx @@ -1,7 +1,12 @@ +--- +description: 'Learn how to implement price list functionalities for admins using the REST APIs. This includes how to create a price list, retriving price list details, managing prices in the price list, and more.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -# How to Use PriceList APIs +# How to Manage PriceLists In this document, you’ll learn how to use the PriceList Admin APIs to create, update, and manage prices in a price list. diff --git a/docs/content/advanced/backend/price-selection-strategy/index.md b/docs/content/advanced/backend/price-selection-strategy/index.md index 1d4adcc7a7..d8f15eac9d 100644 --- a/docs/content/advanced/backend/price-selection-strategy/index.md +++ b/docs/content/advanced/backend/price-selection-strategy/index.md @@ -1,3 +1,7 @@ +--- +description: 'Learn what the price selection strategy is in the Medusa server. The price selection strategy retrieves the best price for a product variant for a specific context.' +--- + # Price Selection Strategy In this document, you’ll learn what a price selection strategy is. diff --git a/docs/content/advanced/backend/price-selection-strategy/override.md b/docs/content/advanced/backend/price-selection-strategy/override.md index dc4b93bf90..2fa519151a 100644 --- a/docs/content/advanced/backend/price-selection-strategy/override.md +++ b/docs/content/advanced/backend/price-selection-strategy/override.md @@ -1,4 +1,9 @@ -# Override Price Selection Strategy +--- +description: 'Learn how to override the price selection strategy. The price selection strategy is used to determine the best price based on a specific context.' +addHowToData: true +--- + +# How to Override Price Selection Strategy In this document, you’ll learn how to override Medusa’s price selection strategy to create a custom pricing strategy. diff --git a/docs/content/advanced/backend/publishable-api-keys/index.md b/docs/content/advanced/backend/publishable-api-keys/index.md index 5cdd03abb9..b88e2cb616 100644 --- a/docs/content/advanced/backend/publishable-api-keys/index.md +++ b/docs/content/advanced/backend/publishable-api-keys/index.md @@ -1,3 +1,7 @@ +--- +description: 'Learn what publishable API keys are and how they can be used in the Medusa server. Publishable API keys can be used to scope API calls with an API key.' +--- + # Publishable API Keys Overview In this document, you’ll learn about Publishable API Keys and their usage. diff --git a/docs/content/advanced/backend/regions/overview.md b/docs/content/advanced/backend/regions/overview.md index 5bf329ba4c..798108f402 100644 --- a/docs/content/advanced/backend/regions/overview.md +++ b/docs/content/advanced/backend/regions/overview.md @@ -1,3 +1,7 @@ +--- +description: 'Learn about what Regions are and how they are used in a Medusa server. Regions represent at least one country on the Medusa server.' +--- + # Regions Overview In this document, you’ll learn about Regions and their importance in your Medusa server. diff --git a/docs/content/advanced/backend/sales-channels/index.md b/docs/content/advanced/backend/sales-channels/index.md index 69702035f9..f4d4f07d0f 100644 --- a/docs/content/advanced/backend/sales-channels/index.md +++ b/docs/content/advanced/backend/sales-channels/index.md @@ -1,3 +1,7 @@ +--- +description: 'Learn what Sales Channels are and how they can be used in Medusa. Sales Channels allow merchants to separate between the different channels products are sold in.' +--- + # Sales Channels In this document, you’ll learn about Sales Channels and how they can be used in Medusa. diff --git a/docs/content/advanced/backend/sales-channels/manage-admin.mdx b/docs/content/advanced/backend/sales-channels/manage-admin.mdx index 8018bfeaa5..0a4df8d6ef 100644 --- a/docs/content/advanced/backend/sales-channels/manage-admin.mdx +++ b/docs/content/advanced/backend/sales-channels/manage-admin.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to implement sales channels features for admins in Medusa using the REST APIs. This includes how to list sales channels, and create, retrieve, update and delete a sales channel. This also includes how to manage products in a sales channel.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/advanced/backend/scheduled-jobs/create.md b/docs/content/advanced/backend/scheduled-jobs/create.md index 86fcf8e7e8..f7c0438a6f 100644 --- a/docs/content/advanced/backend/scheduled-jobs/create.md +++ b/docs/content/advanced/backend/scheduled-jobs/create.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to create a scheduled job in the Medusa server. The scheduled job in this example will simply change the status of draft products to published.' +addHowToData: true +--- + # How to Create a Scheduled Job In this document, you’ll learn how to create a scheduled job in Medusa. diff --git a/docs/content/advanced/backend/services/create-service.md b/docs/content/advanced/backend/services/create-service.md index 5180c6adaa..7dfeabfd6d 100644 --- a/docs/content/advanced/backend/services/create-service.md +++ b/docs/content/advanced/backend/services/create-service.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to create a service in Medusa. This guide also includes how to use services in other services, subscribers, and endpoints.' +addHowToData: true +--- + # Create a Service In this document, you’ll learn how you can create a [Service](./overview.md) and use it across your Medusa server just like any of the core services. diff --git a/docs/content/advanced/backend/services/overview.md b/docs/content/advanced/backend/services/overview.md index 6d4209f895..f1ed4b8175 100644 --- a/docs/content/advanced/backend/services/overview.md +++ b/docs/content/advanced/backend/services/overview.md @@ -1,3 +1,7 @@ +--- +description: 'Learn what Services are in the Medusa server. Services represent bundled helper methods that you want to use across the server.' +--- + # Services In this document, you'll learn about what Services are in Medusa. diff --git a/docs/content/advanced/backend/shipping/add-fulfillment-provider.md b/docs/content/advanced/backend/shipping/add-fulfillment-provider.md index 3d41fa456c..a451aafc83 100644 --- a/docs/content/advanced/backend/shipping/add-fulfillment-provider.md +++ b/docs/content/advanced/backend/shipping/add-fulfillment-provider.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to create a fulfillment provider in the Medusa server. This guide explains the different methods in the fulfillment provider.' +addHowToData: true +--- + # How to Add a Fulfillment Provider In this document, you’ll learn how to add a fulfillment provider to a Medusa server. If you’re unfamiliar with the Shipping architecture in Medusa, make sure to [check out the overview first](overview.md). diff --git a/docs/content/advanced/backend/shipping/overview.md b/docs/content/advanced/backend/shipping/overview.md index e5c9f1384e..a12fb128d7 100644 --- a/docs/content/advanced/backend/shipping/overview.md +++ b/docs/content/advanced/backend/shipping/overview.md @@ -1,3 +1,7 @@ +--- +description: 'Learn how the shipping architecture is implemented in the Medusa server. This includes an overview of what the Fulfillment Provider, Shipping Profile, Shipping Option, and Shipping Methods.' +--- + # Shipping Architecture Overview This document gives an overview of the shipping architecture and its four most important components. diff --git a/docs/content/advanced/backend/subscribers/create-subscriber.md b/docs/content/advanced/backend/subscribers/create-subscriber.md index 75dc810e03..0dc3e6d8b9 100644 --- a/docs/content/advanced/backend/subscribers/create-subscriber.md +++ b/docs/content/advanced/backend/subscribers/create-subscriber.md @@ -1,4 +1,9 @@ -# Create a Subscriber +--- +description: 'Learn how to create a subscriber in the Medusa server. You can use subscribers to implement functionalities like sending an order confirmation email.' +addHowToData: true +--- + +# How to Create a Subscriber In this document, you’ll learn how to create a [Subscriber](overview.md) in your Medusa server that listens to events to perform an action. diff --git a/docs/content/advanced/backend/subscribers/events-list.md b/docs/content/advanced/backend/subscribers/events-list.md index 9428717f39..ad60827158 100644 --- a/docs/content/advanced/backend/subscribers/events-list.md +++ b/docs/content/advanced/backend/subscribers/events-list.md @@ -1,3 +1,7 @@ +--- +description: 'Learn about the available events and their data payloads in Medusa. Events can be used to perform an action when the events are triggered.' +--- + # Events Reference This document details all events in Medusa, when they are triggered, and what data your handler method will receive when the event is triggered. diff --git a/docs/content/advanced/backend/subscribers/overview.md b/docs/content/advanced/backend/subscribers/overview.md index c61fa9171e..97b4355981 100644 --- a/docs/content/advanced/backend/subscribers/overview.md +++ b/docs/content/advanced/backend/subscribers/overview.md @@ -1,3 +1,7 @@ +--- +description: 'Learn what subscribers are in the Medusa server. Subscribers are used to listen to triggered events to perform an action.' +--- + # Subscribers In this document, you'll learn what Subscribers are in Medusa. diff --git a/docs/content/advanced/backend/taxes/inclusive-pricing.md b/docs/content/advanced/backend/taxes/inclusive-pricing.md index a106fea87b..3941226103 100644 --- a/docs/content/advanced/backend/taxes/inclusive-pricing.md +++ b/docs/content/advanced/backend/taxes/inclusive-pricing.md @@ -1,3 +1,7 @@ +--- +description: 'Learn what tax-inclusive pricing is and how it works in Medusa. Tax-inclusive pricing allows merchants to set the final prices for products and shipping options regardless of what tax rate is applicable for the customer.' +--- + # Tax Inclusive Pricing In this document, you’ll learn how tax-inclusive pricing works in Medusa. diff --git a/docs/content/advanced/backend/taxes/manual-calculation.md b/docs/content/advanced/backend/taxes/manual-calculation.md index a73d5e6712..0e8b246a46 100644 --- a/docs/content/advanced/backend/taxes/manual-calculation.md +++ b/docs/content/advanced/backend/taxes/manual-calculation.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to manually calculate taxes during checkout in the Medusa server. There are different methods including using endpoints or services.' +addHowToData: true +--- + # Calculate Taxes Manually in Checkout In this document, you’ll learn how to manually calculate taxes during checkout if you have automatic tax calculation disabled in a region. diff --git a/docs/content/advanced/backend/upgrade-guides/index.mdx b/docs/content/advanced/backend/upgrade-guides/index.mdx index 8f74590bc2..219502a8f5 100644 --- a/docs/content/advanced/backend/upgrade-guides/index.mdx +++ b/docs/content/advanced/backend/upgrade-guides/index.mdx @@ -1,5 +1,6 @@ --- hide_table_of_contents: true +description: 'Upgrade guides on how to update the Medusa server along with other Medusa components to the latest version.' --- import DocCardList from '@theme/DocCardList'; diff --git a/docs/content/advanced/ecommerce/handle-order-claim-event.md b/docs/content/advanced/ecommerce/handle-order-claim-event.md index c2d18c7be0..c067c70a9a 100644 --- a/docs/content/advanced/ecommerce/handle-order-claim-event.md +++ b/docs/content/advanced/ecommerce/handle-order-claim-event.md @@ -1,3 +1,8 @@ +--- +description: 'Learn how to handle the order claim event in the Medusa server. When the event is triggered, you can send an email to the customer to inform them about it.' +addHowToData: true +--- + # How to Handle Order Claim Event In this document, you’ll learn how to handle the order claim event and send a confirmation email when the event is triggered. diff --git a/docs/content/advanced/ecommerce/send-gift-card-to-customer.md b/docs/content/advanced/ecommerce/send-gift-card-to-customer.md index d2b11bcc94..f76d7a6e57 100644 --- a/docs/content/advanced/ecommerce/send-gift-card-to-customer.md +++ b/docs/content/advanced/ecommerce/send-gift-card-to-customer.md @@ -1,4 +1,9 @@ -# Send Gift Card Code to Customer +--- +description: 'Learn how to send a gift card code to the customer. Once the customer purchases a gift card, an email can be sent with the code so that they can redeem the gift card.' +addHowToData: true +--- + +# How to Send Gift Card Code to Customer In this document, you’ll learn how to send a customer the gift card code they purchased. diff --git a/docs/content/advanced/storefront/customer-profiles.mdx b/docs/content/advanced/storefront/customer-profiles.mdx index 1e7f4d8c55..7f6e23620f 100644 --- a/docs/content/advanced/storefront/customer-profiles.mdx +++ b/docs/content/advanced/storefront/customer-profiles.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to implement customer account functionalities in your storefront using the REST APIs. This includes implementing customer registration, login, edit profile, and more.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/advanced/storefront/handle-order-edits.mdx b/docs/content/advanced/storefront/handle-order-edits.mdx index 47ecdc2019..69a2034cc9 100644 --- a/docs/content/advanced/storefront/handle-order-edits.mdx +++ b/docs/content/advanced/storefront/handle-order-edits.mdx @@ -1,7 +1,12 @@ +--- +description: 'Learn how to implement order-edit related features in the storefront using REST APIs. This includes showing the customer order-edit requests, authorizing additional payments, and confirming or declining order edits.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -# How to Handle an Order Edit +# How to Handle an Order Edit in Storefront In this document, you’ll learn how to allow a customer to confirm or decline an Order Edit. diff --git a/docs/content/advanced/storefront/how-to-implement-checkout-flow.mdx b/docs/content/advanced/storefront/how-to-implement-checkout-flow.mdx index b09637cd0d..22d66d070f 100644 --- a/docs/content/advanced/storefront/how-to-implement-checkout-flow.mdx +++ b/docs/content/advanced/storefront/how-to-implement-checkout-flow.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to implement the checkout flow in your storefront using the REST APIs. This includes adding steps related to shipping and payment, then placing the order.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/advanced/storefront/implement-claim-order.mdx b/docs/content/advanced/storefront/implement-claim-order.mdx index db3496a08d..7ff038a86a 100644 --- a/docs/content/advanced/storefront/implement-claim-order.mdx +++ b/docs/content/advanced/storefront/implement-claim-order.mdx @@ -1,7 +1,12 @@ +--- +description: 'Learn how to implement the order-claim flow in the storefront. This includes allowing customers to claim their orders, and verify a claim to an order.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -# How to Implement Claim Order Flow +# How to Implement Claim Order Flow in Storefront In this document, you’ll learn how to implement the claim order flow in a storefront to allow customers to claim their orders. diff --git a/docs/content/advanced/storefront/use-discounts-in-checkout.mdx b/docs/content/advanced/storefront/use-discounts-in-checkout.mdx index 645df298ab..19ed4c9242 100644 --- a/docs/content/advanced/storefront/use-discounts-in-checkout.mdx +++ b/docs/content/advanced/storefront/use-discounts-in-checkout.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to implement discount functionalities in your storefront using the REST APIs. This includes adding a discount to the cart, showing the discount details, and removing the discount from the cart.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/advanced/storefront/use-gift-cards.mdx b/docs/content/advanced/storefront/use-gift-cards.mdx index df3566600d..81c346d016 100644 --- a/docs/content/advanced/storefront/use-gift-cards.mdx +++ b/docs/content/advanced/storefront/use-gift-cards.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to implement gift-card related functionalities in your storefront using the REST APIs. This includes showing the gift card to customers and redeeming the gift card during checkout.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/advanced/storefront/use-regions.mdx b/docs/content/advanced/storefront/use-regions.mdx index 9d1598e734..6b16b7b2ff 100644 --- a/docs/content/advanced/storefront/use-regions.mdx +++ b/docs/content/advanced/storefront/use-regions.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to implement region-related functionalities on your storefront using the REST APIs. This includes showing the customer available regions, showing product prices, and setting the region of a cart.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/advanced/storefront/use-sales-channels.mdx b/docs/content/advanced/storefront/use-sales-channels.mdx index 42e06becec..55a37e047d 100644 --- a/docs/content/advanced/storefront/use-sales-channels.mdx +++ b/docs/content/advanced/storefront/use-sales-channels.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to implement sales channel functionalities in the storefront using REST APIs. This includes filtering products by Sales Channel and associating a cart with a sales channel.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/cli/reference.md b/docs/content/cli/reference.md index be638b79e3..f272fddd1e 100644 --- a/docs/content/cli/reference.md +++ b/docs/content/cli/reference.md @@ -1,3 +1,7 @@ +--- +description: 'Learn how to install the Medusa CLI Tool. Medusa CLI Tool can be used to perform actions such as create a new Medusa server, run migrations, create a new admin user, and more.' +--- + # CLI Reference This document serves as a reference to the Medusa CLI tool including how to install it and what commands are available. diff --git a/docs/content/deployments/admin/deploying-on-netlify.md b/docs/content/deployments/admin/deploying-on-netlify.md index 975c442e3f..9b22413470 100644 --- a/docs/content/deployments/admin/deploying-on-netlify.md +++ b/docs/content/deployments/admin/deploying-on-netlify.md @@ -1,5 +1,6 @@ --- description: 'Learn step-by-step.' +addHowToData: true --- # Deploy Medusa Admin on Netlify diff --git a/docs/content/deployments/admin/index.mdx b/docs/content/deployments/admin/index.mdx index 43bdb54b52..23fccb107e 100644 --- a/docs/content/deployments/admin/index.mdx +++ b/docs/content/deployments/admin/index.mdx @@ -1,5 +1,6 @@ --- hide_table_of_contents: true +description: 'Learn how to deploy the Medusa Admin to different hosting providers to be used with a deployed Medusa server.' --- import DocCardList from '@theme/DocCardList'; diff --git a/docs/content/deployments/server/deploying-on-digital-ocean.md b/docs/content/deployments/server/deploying-on-digital-ocean.md index dffef96150..438609b194 100644 --- a/docs/content/deployments/server/deploying-on-digital-ocean.md +++ b/docs/content/deployments/server/deploying-on-digital-ocean.md @@ -1,5 +1,6 @@ --- description: 'Learn step-by-step.' +addHowToData: true --- # Deploy Your Medusa Server to DigitalOcean Apps diff --git a/docs/content/deployments/server/deploying-on-heroku.mdx b/docs/content/deployments/server/deploying-on-heroku.mdx index 57df2d8de9..6869074a6c 100644 --- a/docs/content/deployments/server/deploying-on-heroku.mdx +++ b/docs/content/deployments/server/deploying-on-heroku.mdx @@ -1,5 +1,6 @@ --- description: 'Learn step-by-step.' +addHowToData: true --- import styles from '../deployment.module.css'; diff --git a/docs/content/deployments/server/deploying-on-qovery.md b/docs/content/deployments/server/deploying-on-qovery.md index 20e094a7fc..ac046b8fdd 100644 --- a/docs/content/deployments/server/deploying-on-qovery.md +++ b/docs/content/deployments/server/deploying-on-qovery.md @@ -1,5 +1,6 @@ --- description: 'Learn step-by-step.' +addHowToData: true --- # Deploy Your Medusa Server on Qovery diff --git a/docs/content/deployments/server/deploying-on-railway.md b/docs/content/deployments/server/deploying-on-railway.md index 65305be3e4..96b1146bf2 100644 --- a/docs/content/deployments/server/deploying-on-railway.md +++ b/docs/content/deployments/server/deploying-on-railway.md @@ -1,5 +1,6 @@ --- description: 'Learn step-by-step.' +addHowToData: true --- # Deploy Your Medusa Server to Railway diff --git a/docs/content/deployments/server/index.mdx b/docs/content/deployments/server/index.mdx index 8bbea14e77..c7f653ffa0 100644 --- a/docs/content/deployments/server/index.mdx +++ b/docs/content/deployments/server/index.mdx @@ -1,5 +1,6 @@ --- hide_table_of_contents: true +description: 'Learn how to deploy your Medusa server to different hosting providers including DigitalOcean, Heroku, Railway, and more.' --- import DocCardList from '@theme/DocCardList'; diff --git a/docs/content/deployments/storefront/deploying-gatsby-on-netlify.md b/docs/content/deployments/storefront/deploying-gatsby-on-netlify.md index 4c2905868e..6480cd02bd 100644 --- a/docs/content/deployments/storefront/deploying-gatsby-on-netlify.md +++ b/docs/content/deployments/storefront/deploying-gatsby-on-netlify.md @@ -1,5 +1,6 @@ --- description: 'Learn step-by-step.' +addHowToData: true --- # Deploy Gatsby Storefront on Netlify diff --git a/docs/content/deployments/storefront/index.mdx b/docs/content/deployments/storefront/index.mdx index 78a07d184e..2c683ece38 100644 --- a/docs/content/deployments/storefront/index.mdx +++ b/docs/content/deployments/storefront/index.mdx @@ -1,5 +1,6 @@ --- hide_table_of_contents: true +description: 'Learn how to deploy your storefronts to different hosting providers to be used with a deployed Medusa server.' --- import DocCardList from '@theme/DocCardList'; diff --git a/docs/content/guides/carts-in-medusa.mdx b/docs/content/guides/carts-in-medusa.mdx index 72739ab0b8..5e3357024b 100644 --- a/docs/content/guides/carts-in-medusa.mdx +++ b/docs/content/guides/carts-in-medusa.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to implement the cart functionality in your storefront using the REST APIs. This includes creating a cart, updating a cart, adding products to the cart, and more.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/docs/content/homepage.mdx b/docs/content/homepage.mdx index ee030460b4..af9d5428c5 100644 --- a/docs/content/homepage.mdx +++ b/docs/content/homepage.mdx @@ -1,7 +1,7 @@ --- id: homepage title: Medusa Documentation -description: "Get an overview of Medusa's features, integrations, and how to use them." +description: "Medusa is an open source composable commerce platform. Learn about its features and how to use it." slug: / hide_table_of_contents: true hide_footer: true diff --git a/docs/content/introduction.md b/docs/content/introduction.md index 41783cfde4..b203ed7381 100644 --- a/docs/content/introduction.md +++ b/docs/content/introduction.md @@ -1,3 +1,7 @@ +--- +description: 'Medusa is composed of three architectures: Medusa server, admin dashboard, and storefront. It also provides advanced ecommerce features such as order management and automated RMA flows.' +--- + # Overview ## Architecture @@ -38,7 +42,7 @@ Your customers use the Storefront to view products and make orders. Medusa provi - [Sales Channels](./user-guide/sales-channels/index.md): Create multiple sales channels and control which sales channels products are available in. - [Bulk Import](./user-guide/products/import.mdx): Bulk import strategies for different entities including [products](./advanced/admin/import-products.mdx) and [price lists](./advanced/admin/import-prices.mdx). - [Bulk Export](./user-guide/products/export.mdx): Bulk export strategies for different entities including [products](./user-guide/products/export.mdx) and [orders](./user-guide/orders/export.mdx). -- Complete Customization Capabilities: Aside from all the features that Medusa provides, it is completely customizable providing capabilities to create custom [endpoints](./advanced/backend/endpoints/add.md), [services](./advanced/backend/services/create-service.md), [subscribers](./advanced/backend/subscribers/create-subscriber.md), [batch job strategies](./advanced/backend/batch-jobs/create.md), and much more! +- Complete Customization Capabilities: Aside from all the features that Medusa provides, it is completely customizable providing capabilities to create custom [endpoints](./advanced/backend/endpoints/add.md), [services](./advanced/backend/services/create-service.md), [subscribers](./advanced/backend/subscribers/create-subscriber.md), [batch job strategies](./advanced/backend/batch-jobs/create.mdx), and much more! --- diff --git a/docs/content/js-client/overview.md b/docs/content/js-client/overview.md index 81277d018b..375053c6fa 100644 --- a/docs/content/js-client/overview.md +++ b/docs/content/js-client/overview.md @@ -1,6 +1,10 @@ +--- +description: 'Learn how to install the Medusa JS Client in a storefront. Medusa JS Client provides easy access to the Medusa API from a client written in TypeScript.' +--- + # Medusa JS Client -The [Medusa JS Client](https://www.npmjs.com/package/@medusajs/medusa-js) provides easy access to the Medusa API from a client written in Typescript. This reference guides you to learn what methods the client has and how you can use them. +The [Medusa JS Client](https://www.npmjs.com/package/@medusajs/medusa-js) provides easy access to the Medusa API from a client written in TypeScript. This reference guides you to learn what methods the client has and how you can use them. This client can be use as an alternative to directly interacting with the [REST APIs](https://docs.medusajs.com/api/store). diff --git a/docs/content/medusa-react/overview.md b/docs/content/medusa-react/overview.md index f783e0411e..254895487e 100644 --- a/docs/content/medusa-react/overview.md +++ b/docs/content/medusa-react/overview.md @@ -1,3 +1,7 @@ +--- +description: 'Learn how to install Medusa React in a React storefront. Medusa React is a React library that provides a set of utilities and hooks for interactive with the Medusa server.' +--- + # Medusa React [Medusa React](https://www.npmjs.com/package/medusa-react) is a React library that provides a set of utilities and hooks for interacting seamlessly with the Medusa server. It can be used to build custom React-based storefronts or admin dashboards. diff --git a/docs/content/quickstart/quick-start-docker.mdx b/docs/content/quickstart/quick-start-docker.mdx index c4d38500f8..208b58bcf2 100644 --- a/docs/content/quickstart/quick-start-docker.mdx +++ b/docs/content/quickstart/quick-start-docker.mdx @@ -1,6 +1,11 @@ +--- +description: 'Learn how to create a composable commerce platform using Medusa. This quickstart guide will help you set up your Medusa server using Docker. ' +addHowToData: true +--- + import Feedback from '@site/src/components/Feedback'; -# Quickstart using Docker +# Quickstart using Docker: Medusa Server In this document, you will learn how to make a container of Medusa's app on Docker. Docker is an open source platform for building, deploying, and managing containerized applications. diff --git a/docs/content/quickstart/quick-start.mdx b/docs/content/quickstart/quick-start.mdx index e74085631b..5ff329817c 100644 --- a/docs/content/quickstart/quick-start.mdx +++ b/docs/content/quickstart/quick-start.mdx @@ -1,6 +1,11 @@ +--- +description: 'Learn how to create a composable commerce platform using Medusa. This quickstart guide will help you set up your Medusa server in three steps.' +addHowToData: true +--- + import Feedback from '@site/src/components/Feedback'; -# Quickstart +# Quickstart: Medusa Server This document will guide you through setting up your Medusa server in a few minutes. diff --git a/docs/content/starters/gatsby-medusa-starter.mdx b/docs/content/starters/gatsby-medusa-starter.mdx index 4c892c8f8f..b87ca55c0c 100644 --- a/docs/content/starters/gatsby-medusa-starter.mdx +++ b/docs/content/starters/gatsby-medusa-starter.mdx @@ -1,3 +1,7 @@ +--- +description: 'Learn how to install the Gatsby starter storefront to use with the Medusa Server. The Gatsby storefront includes features related to customer profiles, order returns and exchanges, and more.' +--- + import Feedback from '@site/src/components/Feedback'; # Gatsby Storefront Quickstart diff --git a/docs/content/starters/nextjs-medusa-starter.mdx b/docs/content/starters/nextjs-medusa-starter.mdx index 56947a6e60..4781075ffd 100644 --- a/docs/content/starters/nextjs-medusa-starter.mdx +++ b/docs/content/starters/nextjs-medusa-starter.mdx @@ -1,3 +1,7 @@ +--- +description: 'Learn how to install the Next.js starter storefront to use with Medusa. The Next.js storefront includes ready-integrations with plugins like Stripe and Algolia. It offers features like customer accounts, cart and checkout flows, and more.' +--- + import Feedback from '@site/src/components/Feedback'; # Next.js Storefront Quickstart diff --git a/docs/content/tutorial/0-set-up-your-development-environment.mdx b/docs/content/tutorial/0-set-up-your-development-environment.mdx index 0ef044ca8f..b4987fd38b 100644 --- a/docs/content/tutorial/0-set-up-your-development-environment.mdx +++ b/docs/content/tutorial/0-set-up-your-development-environment.mdx @@ -1,8 +1,12 @@ +--- +description: 'Learn how to set up your development environment while using Medusa. This guide includes how to install Node.js, Git, Medusa CLI tool, PostgreSQL, and Redis.' +--- + import styles from './development.module.css'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -# Set up your development environment +# Set up Development Environment This document will guide you to set up your development environment to efficiently and properly use Medusa. diff --git a/docs/content/usage/configurations.md b/docs/content/usage/configurations.md index ff0ba2a998..9bf320cf0d 100644 --- a/docs/content/usage/configurations.md +++ b/docs/content/usage/configurations.md @@ -1,4 +1,8 @@ -# Configure your Server +--- +description: 'Learn about the different configurations available in a Medusa server. This includes configurations related to the database, CORS, plugins, redis, and more.' +--- + +# Configure Medusa Server In this document, you’ll learn what configurations you can add to your Medusa server and how to add them. diff --git a/docs/content/usage/create-medusa-app.mdx b/docs/content/usage/create-medusa-app.mdx index 64e02e5161..b4a34714dc 100644 --- a/docs/content/usage/create-medusa-app.mdx +++ b/docs/content/usage/create-medusa-app.mdx @@ -1,3 +1,8 @@ +--- +description: 'Learn how to create a composable commerce platform using Medusa. This quickstart guide will help you set up your Medusa server, admin, and storefront all at once.' +addHowToData: true +--- + import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import Feedback from '@site/src/components/Feedback'; diff --git a/docs/content/usage/local-development.md b/docs/content/usage/local-development.md index 7ef4fe5be5..f47a2b2551 100644 --- a/docs/content/usage/local-development.md +++ b/docs/content/usage/local-development.md @@ -1,3 +1,7 @@ +--- +description: 'Learn how to perform local development in the Medusa monorepo. This includes how to use the dev CLI tool and perform unit, integration, and plugin tests.' +--- + # Local Development of Medusa Server and Monorepo In this document, you’ll learn how to customize Medusa’s core and run tests. diff --git a/docs/content/user-guide/customers/groups.mdx b/docs/content/user-guide/customers/groups.mdx index 815ea93b6e..4ead55e79b 100644 --- a/docs/content/user-guide/customers/groups.mdx +++ b/docs/content/user-guide/customers/groups.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 3 +description: 'This user guide explains how to manage customer groups on the Medusa admin. Learn how to create and edit customer groups.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/customers/index.md b/docs/content/user-guide/customers/index.md index ba782a1b0e..c194773077 100644 --- a/docs/content/user-guide/customers/index.md +++ b/docs/content/user-guide/customers/index.md @@ -1,5 +1,6 @@ --- sidebar_position: 1 +description: 'Medusa admin allows merchants to manage customers and customer groups.' --- # Customers Overview diff --git a/docs/content/user-guide/customers/manage.mdx b/docs/content/user-guide/customers/manage.mdx index 9bf1d9a27d..7f57c1659c 100644 --- a/docs/content/user-guide/customers/manage.mdx +++ b/docs/content/user-guide/customers/manage.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 2 +description: 'This user guide explains how to manage customers on the Medusa admin. Learn how to view and edit customers.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/discounts/create.mdx b/docs/content/user-guide/discounts/create.mdx index b74f01f50c..7f5245f7cb 100644 --- a/docs/content/user-guide/discounts/create.mdx +++ b/docs/content/user-guide/discounts/create.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 2 +description: 'This user guide explains how to create a discount on the Medusa admin.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/discounts/index.md b/docs/content/user-guide/discounts/index.md index fab52777c2..4ef56fafc8 100644 --- a/docs/content/user-guide/discounts/index.md +++ b/docs/content/user-guide/discounts/index.md @@ -1,5 +1,6 @@ --- sidebar_position: 1 +description: 'Medusa admin allows merchants to manage discounts. Merchants can create discounts and manage their conditions.' --- # Discounts Overview diff --git a/docs/content/user-guide/discounts/manage.mdx b/docs/content/user-guide/discounts/manage.mdx index 4b63802f5b..b6b1ced784 100644 --- a/docs/content/user-guide/discounts/manage.mdx +++ b/docs/content/user-guide/discounts/manage.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 3 +description: 'This user guide explains how to manage discounts on the Medusa admin. Learn how to edit and delete discounts' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/gift-cards/custom.mdx b/docs/content/user-guide/gift-cards/custom.mdx index d3660ded43..33a0e7bb3e 100644 --- a/docs/content/user-guide/gift-cards/custom.mdx +++ b/docs/content/user-guide/gift-cards/custom.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 3 +description: 'This user guide explains how to manage custom gift cards on the Medusa admin. Learn how to create and edit custom gift cards.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/gift-cards/index.md b/docs/content/user-guide/gift-cards/index.md index 70f0cf46c0..9604793abb 100644 --- a/docs/content/user-guide/gift-cards/index.md +++ b/docs/content/user-guide/gift-cards/index.md @@ -1,5 +1,6 @@ --- sidebar_position: 1 +description: 'Medusa admin allows merchants to manage gift cards. Merchants can manage main and custom gift cards.' --- # Gift Cards Overview diff --git a/docs/content/user-guide/gift-cards/manage.mdx b/docs/content/user-guide/gift-cards/manage.mdx index 66f1faae1c..701fdea273 100644 --- a/docs/content/user-guide/gift-cards/manage.mdx +++ b/docs/content/user-guide/gift-cards/manage.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 2 +description: 'This user guide explains how to manage the main gift card on the Medusa admin. Learn how to create, edit, and delete a gift card.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/index.mdx b/docs/content/user-guide/index.mdx index d906804b6c..e62f5d6c55 100644 --- a/docs/content/user-guide/index.mdx +++ b/docs/content/user-guide/index.mdx @@ -1,6 +1,7 @@ --- sidebar_position: 1 sidebar_label: Introduction +description: 'The user guide explains how to use the Medusa Admin for non technical users. Learn through easy steps how to use the Medusa admin to perform different operations and ecommerce tasks.' --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/lists.mdx b/docs/content/user-guide/lists.mdx index 5b6e8113d4..e931712605 100644 --- a/docs/content/user-guide/lists.mdx +++ b/docs/content/user-guide/lists.mdx @@ -1,5 +1,6 @@ --- sidebar_position: 2 +description: 'Learn how to use utility features in the Medusa Admin including lists, quick and advanced filters, pagination, and search functionalities. You can also customize quick features.' --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/orders/claims.mdx b/docs/content/user-guide/orders/claims.mdx index 521791bde8..a5a4514404 100644 --- a/docs/content/user-guide/orders/claims.mdx +++ b/docs/content/user-guide/orders/claims.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 8 +description: 'This user guide explains how to manage order claims on the Medusa Admin. Learn how to create claims, manage their returns and fulfillments, and more.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/orders/drafts.mdx b/docs/content/user-guide/orders/drafts.mdx index 90d0690c48..ddcde29fb4 100644 --- a/docs/content/user-guide/orders/drafts.mdx +++ b/docs/content/user-guide/orders/drafts.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 5 +description: 'This user guide explains how to manage draft orders on the Medusa Admin. Learn how to create a draft order, view its details, edit a draft order, cancel a draft order, and more.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/orders/exchange.mdx b/docs/content/user-guide/orders/exchange.mdx index b5d1a65854..8c280f83b1 100644 --- a/docs/content/user-guide/orders/exchange.mdx +++ b/docs/content/user-guide/orders/exchange.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 7 +description: 'This user guide explains how to manage exchanges in the Medusa Admin. Learn how to create an order exchange, create an order exchange, mark an order exchange return as received, and cancel an exchange.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/orders/export.mdx b/docs/content/user-guide/orders/export.mdx index 1b21345a78..7e1d2d5972 100644 --- a/docs/content/user-guide/orders/export.mdx +++ b/docs/content/user-guide/orders/export.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 9 +description: 'This user guide explains how to export a list of orders on the Medusa admin.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/orders/fulfillments.mdx b/docs/content/user-guide/orders/fulfillments.mdx index 6cbbd72d93..380e3c80e1 100644 --- a/docs/content/user-guide/orders/fulfillments.mdx +++ b/docs/content/user-guide/orders/fulfillments.mdx @@ -1,6 +1,8 @@ --- sidebar_position: 4 sidebar_label: Manage Fulfillments +description: 'This user guide explains how to manage order fulfillments in the Medusa Admin. Learn how to create fulfillments, mark fulfillments as shipped, and cancel fulfillments.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/orders/index.md b/docs/content/user-guide/orders/index.md index 1f54612e26..0a1bdbcfb0 100644 --- a/docs/content/user-guide/orders/index.md +++ b/docs/content/user-guide/orders/index.md @@ -1,6 +1,7 @@ --- sidebar_position: 1 sidebar_label: Overview +description: 'Medusa Admin allows merchants to manage orders. Merchants can view order information, capture payment, create shipments and fulfillments, and more.' --- # Orders Overview diff --git a/docs/content/user-guide/orders/manage.mdx b/docs/content/user-guide/orders/manage.mdx index c2a9340326..7677025bd1 100644 --- a/docs/content/user-guide/orders/manage.mdx +++ b/docs/content/user-guide/orders/manage.mdx @@ -1,6 +1,8 @@ --- sidebar_position: 2 sidebar_label: Manage Details +description: 'Learn in this user guide how to manage orders on the Medusa Admin. Learn how to find the order details page, what information can be found on that page, and how to manage the order details such as shipping address or email.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/orders/payments.md b/docs/content/user-guide/orders/payments.md index 542dcd1b97..6b9ce852b3 100644 --- a/docs/content/user-guide/orders/payments.md +++ b/docs/content/user-guide/orders/payments.md @@ -1,6 +1,7 @@ --- sidebar_position: 3 sidebar_label: Manage Payments +addHowToData: true --- # Manage Order's Payments diff --git a/docs/content/user-guide/orders/returns.mdx b/docs/content/user-guide/orders/returns.mdx index b808fb9cc3..0c32c0d67f 100644 --- a/docs/content/user-guide/orders/returns.mdx +++ b/docs/content/user-guide/orders/returns.mdx @@ -1,6 +1,8 @@ --- sidebar_position: 6 sidebar_label: Manage Returns +description: 'This user guide explains how to manage order returns on the Medusa Admin. Learn how to request a return for an order, mark a return as received, and cancel a return.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/price-lists/import.mdx b/docs/content/user-guide/price-lists/import.mdx index f1f9a85b47..fc72f9aeb3 100644 --- a/docs/content/user-guide/price-lists/import.mdx +++ b/docs/content/user-guide/price-lists/import.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 3 +description: 'This user guide explains how to import prices to a price list on the Medusa admin.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/price-lists/index.md b/docs/content/user-guide/price-lists/index.md index 5de7df3827..1a0dbf386e 100644 --- a/docs/content/user-guide/price-lists/index.md +++ b/docs/content/user-guide/price-lists/index.md @@ -1,5 +1,6 @@ --- sidebar_position: 1 +description: 'Medusa admin allows merchants to manage their price lists. Merchants can override prices or create sales using price lists.' --- # Price Lists Overview diff --git a/docs/content/user-guide/price-lists/manage.mdx b/docs/content/user-guide/price-lists/manage.mdx index 036dfe3841..23b27fc4df 100644 --- a/docs/content/user-guide/price-lists/manage.mdx +++ b/docs/content/user-guide/price-lists/manage.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 2 +description: 'This user guide explains how to manage price lists on the Medusa admin. Learn how to create, edit, and delete price lists.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/products/collections.mdx b/docs/content/user-guide/products/collections.mdx index 981b7f915a..177f12c825 100644 --- a/docs/content/user-guide/products/collections.mdx +++ b/docs/content/user-guide/products/collections.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 3 +description: 'This user guide explains how to manage collections on the Medusa admin. Learn how to create, edit, and delete collections.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/products/export.mdx b/docs/content/user-guide/products/export.mdx index d4dfe90b90..4c4f57f58a 100644 --- a/docs/content/user-guide/products/export.mdx +++ b/docs/content/user-guide/products/export.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 4 +description: 'This user guide explains how to export a list of products on the Medusa admin.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/products/import.mdx b/docs/content/user-guide/products/import.mdx index a9d644e1d7..b092a49500 100644 --- a/docs/content/user-guide/products/import.mdx +++ b/docs/content/user-guide/products/import.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 5 +description: 'This user guide explains how to import a list of products into Medusa using the admin.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/products/index.mdx b/docs/content/user-guide/products/index.mdx index 74cbb0e81e..378dcec3c5 100644 --- a/docs/content/user-guide/products/index.mdx +++ b/docs/content/user-guide/products/index.mdx @@ -1,5 +1,6 @@ --- sidebar_position: 1 +description: 'Medusa admin allows merchants to manage products. Merchants can view products and collections, edit them, and more.' --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/products/manage.mdx b/docs/content/user-guide/products/manage.mdx index 45d761a131..334f9d2a80 100644 --- a/docs/content/user-guide/products/manage.mdx +++ b/docs/content/user-guide/products/manage.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 2 +description: 'This user guide explains how to manage products on the Medusa admin. Learn how to create a product, edit a product, and more.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/regions/index.md b/docs/content/user-guide/regions/index.md index 9877469309..f2632552e3 100644 --- a/docs/content/user-guide/regions/index.md +++ b/docs/content/user-guide/regions/index.md @@ -1,5 +1,6 @@ --- sidebar_position: 1 +description: 'Medusa admin allows merchants to manage regions. Regions represent different countries within an ecommerce store.' --- # Regions Overview diff --git a/docs/content/user-guide/regions/manage.mdx b/docs/content/user-guide/regions/manage.mdx index 0bf73a0e03..571611918f 100644 --- a/docs/content/user-guide/regions/manage.mdx +++ b/docs/content/user-guide/regions/manage.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 2 +description: 'This user guide explains how to manage regions on the Medusa admin. Learn how to create and edit regions.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/regions/providers.mdx b/docs/content/user-guide/regions/providers.mdx index f1246427d5..38c15d4d8b 100644 --- a/docs/content/user-guide/regions/providers.mdx +++ b/docs/content/user-guide/regions/providers.mdx @@ -1,11 +1,13 @@ --- sidebar_position: 3 sidebar_label: Manage Providers +description: 'This user guide explains how to manage payment and fulfillment providers in a region on the Medusa admin.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; -# Manage Payment and Fulfillment Providers +# Manage Payment and Fulfillment Providers in a Region In this document, you’ll learn how to manage a region’s payment and fulfillment providers in your Medusa Admin. diff --git a/docs/content/user-guide/regions/shipping-options.mdx b/docs/content/user-guide/regions/shipping-options.mdx index da97383cb6..63fcb338b5 100644 --- a/docs/content/user-guide/regions/shipping-options.mdx +++ b/docs/content/user-guide/regions/shipping-options.mdx @@ -1,10 +1,13 @@ --- sidebar_position: 4 +sidebar_label: Manage Shipping Options +description: 'This user guide explains how to manage shipping options in a region on the Medusa admin.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; -# Manage Shipping Options +# Manage Shipping Options in a Region In this document, you’ll learn how to manage a region’s shipping options in your Medusa Admin. diff --git a/docs/content/user-guide/sales-channels/index.md b/docs/content/user-guide/sales-channels/index.md index f3e5c006e4..00d9aab361 100644 --- a/docs/content/user-guide/sales-channels/index.md +++ b/docs/content/user-guide/sales-channels/index.md @@ -1,17 +1,12 @@ --- sidebar_position: 1 +description: 'Medusa admin allows merchants to manage their sales channels. Merchants can separate products into multiple sales channels.' --- # Sales Channels Overview In this document, you’ll get an overview of sales channels in Medusa and learn about their importance in your ecommerce store. -:::note - -Sales Channels are currently in beta mode and need to be [manually enabled in your store using feature flags](../../advanced/backend/feature-flags/toggle.md). If you’re unsure how that works, please contact your technical team. - -::: - ## Overview Sales Channels are multiple channels that you can sell your products through. For example, you can have a sales channel for the web storefront, another for the mobile app, and another for selling across social media platforms. diff --git a/docs/content/user-guide/sales-channels/manage.mdx b/docs/content/user-guide/sales-channels/manage.mdx index 18d7fea59d..9e9e203838 100644 --- a/docs/content/user-guide/sales-channels/manage.mdx +++ b/docs/content/user-guide/sales-channels/manage.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 2 +description: 'This user guide explains how to manage sales channels on the Medusa admin. Learn how to create, edit, and delete sales channels.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/sales-channels/products.mdx b/docs/content/user-guide/sales-channels/products.mdx index 41c8b3a6d7..dd9fa00414 100644 --- a/docs/content/user-guide/sales-channels/products.mdx +++ b/docs/content/user-guide/sales-channels/products.mdx @@ -1,6 +1,8 @@ --- sidebar_position: 3 sidebar_label: Manage Products +description: 'This user guide explains how to manage products in sales channels on the Medusa admin.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/settings/currencies.md b/docs/content/user-guide/settings/currencies.md index 0c896befd4..53d4d419b3 100644 --- a/docs/content/user-guide/settings/currencies.md +++ b/docs/content/user-guide/settings/currencies.md @@ -1,5 +1,7 @@ --- sidebar_position: 2 +description: 'This user guide explains how to manage currencies on the Medusa admin. Learn how to add currencies and set default currency.' +addHowToData: true --- # Manage Currencies diff --git a/docs/content/user-guide/settings/publishable-api-keys.mdx b/docs/content/user-guide/settings/publishable-api-keys.mdx index ccb49e4bbd..d118b479cc 100644 --- a/docs/content/user-guide/settings/publishable-api-keys.mdx +++ b/docs/content/user-guide/settings/publishable-api-keys.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 4 +description: 'This user guide explains how to manage publishable API keys on the Medusa admin. Learn how to create, edit, copy, and revoke publishable API keys.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/settings/return-reasons.mdx b/docs/content/user-guide/settings/return-reasons.mdx index 42a0877399..6e4887eaf8 100644 --- a/docs/content/user-guide/settings/return-reasons.mdx +++ b/docs/content/user-guide/settings/return-reasons.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 3 +description: 'This user guide explains how to manage return reasons on the Medusa admin. Learn how to add, edit, and remove return reasons.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/settings/store.md b/docs/content/user-guide/settings/store.md index d3775c4161..c5bd14c5b0 100644 --- a/docs/content/user-guide/settings/store.md +++ b/docs/content/user-guide/settings/store.md @@ -1,5 +1,6 @@ --- sidebar_position: 1 +description: 'This user guide explains how to manage the store details on the Medusa admin.' --- # Manage Store Details diff --git a/docs/content/user-guide/taxes/index.md b/docs/content/user-guide/taxes/index.md index 898f234bde..3e42b2c2e0 100644 --- a/docs/content/user-guide/taxes/index.md +++ b/docs/content/user-guide/taxes/index.md @@ -1,5 +1,6 @@ --- sidebar_position: 1 +description: 'Medusa admin allows merchants to manage their taxes. Merchants can specify and configure taxes per region.' --- # Taxes Overview diff --git a/docs/content/user-guide/taxes/manage.md b/docs/content/user-guide/taxes/manage.md index 198162a422..d6d0b47d87 100644 --- a/docs/content/user-guide/taxes/manage.md +++ b/docs/content/user-guide/taxes/manage.md @@ -1,5 +1,7 @@ --- sidebar_position: 2 +description: 'This user guide explains how to manage taxes on the Medusa admin. Learn how to edit their configurations.' +addHowToData: true --- # Manage Taxes diff --git a/docs/content/user-guide/taxes/tax-inclusive.mdx b/docs/content/user-guide/taxes/tax-inclusive.mdx index 4f3c621eb0..10bd287844 100644 --- a/docs/content/user-guide/taxes/tax-inclusive.mdx +++ b/docs/content/user-guide/taxes/tax-inclusive.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 5 +description: 'This user guide explains how to manage tax inclusive pricing on the Medusa admin.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/taxes/tax-overrides.mdx b/docs/content/user-guide/taxes/tax-overrides.mdx index 86ff054f60..5f92608553 100644 --- a/docs/content/user-guide/taxes/tax-overrides.mdx +++ b/docs/content/user-guide/taxes/tax-overrides.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 4 +description: 'This user guide explains how to manage tax overrides on the Medusa admin. Learn how to add, edit, and delete overrides.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/taxes/tax-rates.mdx b/docs/content/user-guide/taxes/tax-rates.mdx index 4e535158fc..2a56f6b75e 100644 --- a/docs/content/user-guide/taxes/tax-rates.mdx +++ b/docs/content/user-guide/taxes/tax-rates.mdx @@ -1,5 +1,7 @@ --- sidebar_position: 3 +description: 'This user guide explains how to manage tax rates on the Medusa admin. Learn how to create, edit, and delete tax rates.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; diff --git a/docs/content/user-guide/users/index.md b/docs/content/user-guide/users/index.md index 0b423b9fdf..1688355f5c 100644 --- a/docs/content/user-guide/users/index.md +++ b/docs/content/user-guide/users/index.md @@ -1,5 +1,6 @@ --- sidebar_position: 1 +description: 'Medusa admin can be accessed more than one user. Merchants can have users added into their team to use the Medusa admin.' --- # Users Overview diff --git a/docs/content/user-guide/users/profile.md b/docs/content/user-guide/users/profile.md index f7dc5633d9..c2ef1293aa 100644 --- a/docs/content/user-guide/users/profile.md +++ b/docs/content/user-guide/users/profile.md @@ -1,5 +1,7 @@ --- -sidebar_position: 1 +sidebar_position: 2 +description: 'This user guide explains how to manage user profile on the Medusa admin. Learn how to edit a user profile and reset user password.' +addHowToData: true --- # Manage Profile diff --git a/docs/content/user-guide/users/team.mdx b/docs/content/user-guide/users/team.mdx index 4565624b8d..bce8b11b1f 100644 --- a/docs/content/user-guide/users/team.mdx +++ b/docs/content/user-guide/users/team.mdx @@ -1,5 +1,7 @@ --- -sidebar_position: 2 +sidebar_position: 3 +description: 'This user guide explains how to manage the team on the Medusa admin. Learn how to invite users to your team and edit their details.' +addHowToData: true --- import UiIcon from '@site/src/components/UiIcon'; @@ -12,6 +14,8 @@ In this document, you’ll learn how to invite new users, edit other users’ in You can view your team by going to Settings → The Team. +--- + ## Manage Invites To add a new user to your team, you must invite them. Invites are sent by email, but you can also copy the invite link and send it personally to the user. @@ -60,6 +64,8 @@ To remove an invite: 3. Click on “Remove invitation” from the dropdown. 4. Confirm removing the invitation by clicking the “Yes, remove” button in the pop-up. +--- + ## Edit a User’s Details To edit a user’s details in your team: @@ -69,6 +75,8 @@ To edit a user’s details in your team: 3. In the new form, edit any of the user’s information. 4. Once done, click on the Save button. +--- + ## Remove a User :::warning diff --git a/www/docs/docusaurus.config.js b/www/docs/docusaurus.config.js index 2b0873de38..724b733417 100644 --- a/www/docs/docusaurus.config.js +++ b/www/docs/docusaurus.config.js @@ -210,7 +210,7 @@ const config = { [require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}], ], showLastUpdateTime: true, - breadcrumbs: false, + // breadcrumbs: false, async sidebarItemsGenerator({defaultSidebarItemsGenerator, ...args}) { const sidebarItems = await defaultSidebarItemsGenerator(args); return reverseSidebar(sidebarItems); diff --git a/www/docs/sidebars.js b/www/docs/sidebars.js index 1ea583f512..1678897c08 100644 --- a/www/docs/sidebars.js +++ b/www/docs/sidebars.js @@ -32,17 +32,18 @@ module.exports = { items: [ { type: "doc", - id: "quickstart/quick-start", - label: "Quickstart Guide", + id: "usage/create-medusa-app", + label: 'create-medusa-app' }, { type: "doc", - id: "usage/create-medusa-app", - label: 'Use create-medusa-app' + id: "quickstart/quick-start", + label: "Server Quickstart", }, { type:"doc", id: "quickstart/quick-start-docker", + label: "Server Quickstart: Docker", }, ] }, diff --git a/www/docs/src/components/Feedback/index.js b/www/docs/src/components/Feedback/index.js index ead2a3c2b5..6129c48867 100644 --- a/www/docs/src/components/Feedback/index.js +++ b/www/docs/src/components/Feedback/index.js @@ -38,15 +38,11 @@ export default function Feedback ({ } function submitFeedback (e, feedback = null) { - console.log(id, feedback, (feedback !== null && feedback) || (feedback === null && positiveFeedback) ? 'yes' : 'no') if (isBrowser) { - console.log("here1"); if (window.analytics) { - console.log("here3"); if (showForm) { setLoading(true); } - console.log("here4"); window.analytics.track(event, { url: location.pathname, label: document.title, @@ -54,17 +50,13 @@ export default function Feedback ({ message, uuid: id }, function () { - console.log("here5"); if (showForm) { setLoading(false); - console.log("here6"); resetForm(); } }) } else { - console.log("here7"); if (showForm) { - console.log("here8"); resetForm(); } } diff --git a/www/docs/src/css/_docspage.css b/www/docs/src/css/_docspage.css index deb48dfd4c..3196e2df36 100644 --- a/www/docs/src/css/_docspage.css +++ b/www/docs/src/css/_docspage.css @@ -1,3 +1,7 @@ +.theme-doc-breadcrumbs { + display: none; +} + article { max-width: var(--ifm-docs-page-max-width); } diff --git a/www/docs/src/theme/Layout/index.js b/www/docs/src/theme/Layout/index.js index d0271ba021..9b0465017b 100644 --- a/www/docs/src/theme/Layout/index.js +++ b/www/docs/src/theme/Layout/index.js @@ -15,6 +15,7 @@ import ErrorPageContent from '@theme/ErrorPageContent'; import styles from './styles.module.css'; import useIsBrowser from '@docusaurus/useIsBrowser'; import {useLocation} from '@docusaurus/router'; +import StructuredDataSearchbox from '../StructuredData/Searchbox'; export default function Layout(props) { const { @@ -49,12 +50,11 @@ export default function Layout(props) { } }, [isBrowser, location.pathname]); - useKeyboardNavigation(); return ( - + {isBrowser && location.pathname === '/' && } diff --git a/www/docs/src/theme/NotFound.js b/www/docs/src/theme/NotFound.js new file mode 100644 index 0000000000..6d5fdebf29 --- /dev/null +++ b/www/docs/src/theme/NotFound.js @@ -0,0 +1,72 @@ +import React from 'react'; +import Translate, {translate} from '@docusaurus/Translate'; +import {PageMetadata} from '@docusaurus/theme-common'; +import Layout from '@theme/Layout'; +import useBaseUrl from '@docusaurus/useBaseUrl' + +export default function NotFound() { + return ( + <> + + +
    +
    +
    +

    + + Page Not Found + +

    +

    + + Looks like the page you're looking for has either changed into a different + location or isn't in our documentation anymore. + +

    +

    + If you think this is a mistake, please + report this issue on GitHub + +

    +

    Some popular links

    + +
    +
    +
    +
    + + ); +} diff --git a/www/docs/src/theme/StructuredData/HowTo/index.js b/www/docs/src/theme/StructuredData/HowTo/index.js new file mode 100644 index 0000000000..a42a21eae6 --- /dev/null +++ b/www/docs/src/theme/StructuredData/HowTo/index.js @@ -0,0 +1,31 @@ +import React from "react" +import Head from '@docusaurus/Head' +import {useLocation} from '@docusaurus/router'; +import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; + +export default function StructuredDataHowTo ({ toc, title }) { + const location = useLocation(); + const { siteConfig: { url } } = useDocusaurusContext() + const mainUrl = `${url}/${location.pathname}` + + return ( + + + + ) +} \ No newline at end of file diff --git a/www/docs/src/theme/StructuredData/Searchbox/index.tsx b/www/docs/src/theme/StructuredData/Searchbox/index.tsx new file mode 100644 index 0000000000..61735c3014 --- /dev/null +++ b/www/docs/src/theme/StructuredData/Searchbox/index.tsx @@ -0,0 +1,27 @@ +import React from 'react'; +import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; +import Head from '@docusaurus/Head'; + +export default function StructuredDataSearchbox () { + const { siteConfig: { url } } = useDocusaurusContext() + + return ( + + + + ) +} \ No newline at end of file diff --git a/www/docs/src/theme/TOCItems/index.js b/www/docs/src/theme/TOCItems/index.js new file mode 100644 index 0000000000..8e64bd71ae --- /dev/null +++ b/www/docs/src/theme/TOCItems/index.js @@ -0,0 +1,15 @@ +import React from 'react'; +import TOCItems from '@theme-original/TOCItems'; +import StructuredDataHowTo from '../StructuredData/HowTo'; +import { useDoc } from '@docusaurus/theme-common/internal' + +export default function TOCItemsWrapper(props) { + const { frontMatter, contentTitle } = useDoc() + + return ( + <> + + {frontMatter?.addHowToData && } + + ); +} diff --git a/www/docs/src/utils/filterListItems.ts b/www/docs/src/utils/filterListItems.ts index e0c70cae3c..b78026f27f 100644 --- a/www/docs/src/utils/filterListItems.ts +++ b/www/docs/src/utils/filterListItems.ts @@ -1,7 +1,6 @@ import { PropSidebarItem, PropSidebarItemLink } from '@docusaurus/plugin-content-docs' export default function filterListItems (items: PropSidebarItemLink[], pathPattern: string | RegExp): PropSidebarItemLink[] { - console.log(items) if (!items.length) { return items } From 5af39e7beba1eecff4750aa470d9aa4135112923 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 26 Jan 2023 16:54:27 +0200 Subject: [PATCH 10/17] docs: added product category events to reference (#3118) --- .../backend/subscribers/events-list.md | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/docs/content/advanced/backend/subscribers/events-list.md b/docs/content/advanced/backend/subscribers/events-list.md index ad60827158..db9f845be5 100644 --- a/docs/content/advanced/backend/subscribers/events-list.md +++ b/docs/content/advanced/backend/subscribers/events-list.md @@ -2072,6 +2072,102 @@ Object of the following format: --- +## Product Category Events + +This section holds all events related to product categories. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Event Name + +Description + +Event Data Payload +
    + +`product-category.created` + + + +Triggered when a product category is created. + + + +Object of the following format: + +```js noReport noCopy +{ + id, // string ID of category +} +``` + +
    + +`product-category.updated` + + + +Triggered when a product category is updated. + + + +Object of the following format: + +```js noReport noCopy +{ + id, // string ID of category +} +``` + +
    + +`product-category.deleted` + + + +Triggered when a product category is deleted. + + + +Object of the following format: + +```js noReport noCopy +{ + id, // string ID of category +} +``` + +
    + +--- + ## Product Variant Events This section holds all events related to product variants. From a65e115844494bf0944afa64386dc93ef4d74fd6 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 26 Jan 2023 19:30:17 +0200 Subject: [PATCH 11/17] docs: added user guide for order editing (#3120) --- docs/content/user-guide/orders/claims.mdx | 2 +- docs/content/user-guide/orders/drafts.mdx | 2 +- docs/content/user-guide/orders/edit.mdx | 89 +++++++++++++++++++++ docs/content/user-guide/orders/exchange.mdx | 2 +- docs/content/user-guide/orders/export.mdx | 2 +- docs/content/user-guide/orders/manage.mdx | 26 ++++++ docs/content/user-guide/orders/payments.md | 3 +- docs/content/user-guide/orders/returns.mdx | 2 +- 8 files changed, 122 insertions(+), 6 deletions(-) create mode 100644 docs/content/user-guide/orders/edit.mdx diff --git a/docs/content/user-guide/orders/claims.mdx b/docs/content/user-guide/orders/claims.mdx index a5a4514404..842b9eb02a 100644 --- a/docs/content/user-guide/orders/claims.mdx +++ b/docs/content/user-guide/orders/claims.mdx @@ -1,5 +1,5 @@ --- -sidebar_position: 8 +sidebar_position: 9 description: 'This user guide explains how to manage order claims on the Medusa Admin. Learn how to create claims, manage their returns and fulfillments, and more.' addHowToData: true --- diff --git a/docs/content/user-guide/orders/drafts.mdx b/docs/content/user-guide/orders/drafts.mdx index ddcde29fb4..8ee9e71405 100644 --- a/docs/content/user-guide/orders/drafts.mdx +++ b/docs/content/user-guide/orders/drafts.mdx @@ -1,5 +1,5 @@ --- -sidebar_position: 5 +sidebar_position: 6 description: 'This user guide explains how to manage draft orders on the Medusa Admin. Learn how to create a draft order, view its details, edit a draft order, cancel a draft order, and more.' addHowToData: true --- diff --git a/docs/content/user-guide/orders/edit.mdx b/docs/content/user-guide/orders/edit.mdx new file mode 100644 index 0000000000..5a33ddbd35 --- /dev/null +++ b/docs/content/user-guide/orders/edit.mdx @@ -0,0 +1,89 @@ +--- +sidebar_position: 5 +description: 'This user guide explains how to edit the items in an order in the Medusa admin. You can add, update, replace, duplicate, and delete items.' +addHowToData: true +--- + +import UiIcon from '@site/src/components/UiIcon'; + +# Edit an Order’s Items + +In this document, you’ll learn how to edit items in an order. This includes adding, updating, or deleting items. + +## Overview + +Using the Medusa Admin, you can edit the items in an order. You can perform the following edits: + +- Add a new item to the order. +- Edit the quantity of an existing item in the order. +- Delete an item from the order. + +When you request an order edit, the changes aren’t actually saved and reflected on the order until the order edit is confirmed. + +There are two ways to confirm an order edit request: + +1. The customer reviews the order edit. If they accept the order edit and an additional payment is required, then they’ll have to authorize that payment. The customer can also reject the order edit; +2. Or you force-confirm the order edit. In this case, the order edit is reflected on the original order. If there are any additional payment required, you would have to handle that manually with the customer. + +--- + +## Request an Order Edit + +:::info + +You can’t request an order edit if another order edit is already requested. + +::: + +To request an order edit: + +1. Open the order details page. +2. Click on the “Edit Order” button at the top right of the Summary section. +3. In the new window that opens: + 1. To add an item: + 1. Click on the “Add items” button. + 2. Click on the checkbox next to the items you want to add. + 3. Once done, click on the “Save and go back” button. + 2. To update an item’s quantity: + 1. Click on the or icons next to the quantity of the item you want to edit. + 3. To replace an item: + 1. Click on the icon next to the item. + 2. Click on “Replace with other item” from the dropdown. + 3. Choose the replacement by clicking on the radio button next to the new item. + 4. Once done, click on the “Save and go back” button. + 4. To duplicate an item: + 1. Click on the icon next to the item. + 2. Click on “Duplicate item” from the dropdown. + 5. To delete an item: + 1. Click on the icon next to the item. + 2. Click on “Remove item” from the dropdown. + 6. You can optionally enter a note for the customer to see in the Note field. +4. Once done, click on the “Save and close” button. + +--- + +## Force Confirm an Order + +:::warning + +When you force confirm an order edit, the changes will be reflected on the order. If the order edit requires additional payment, you’ll have to manually receive that payment from the customer. + +::: + +To force confirm an order: + +1. Open the order details page. +2. Find the order edit in the Timeline section. +3. Click on the “Force Confirm” button. +4. Confirm your action by clicking the “Yes, Force Confirm” button in the pop-up. + +--- + +## Cancel an Order Edit Request + +To cancel an order-edit request: + +1. Open the order details page. +2. Find the order edit in the Timeline section. +3. Click on the “Cancel Order Edit” button. +4. Click the button again to confirm canceling the order. \ No newline at end of file diff --git a/docs/content/user-guide/orders/exchange.mdx b/docs/content/user-guide/orders/exchange.mdx index 8c280f83b1..04c28c5f89 100644 --- a/docs/content/user-guide/orders/exchange.mdx +++ b/docs/content/user-guide/orders/exchange.mdx @@ -1,5 +1,5 @@ --- -sidebar_position: 7 +sidebar_position: 8 description: 'This user guide explains how to manage exchanges in the Medusa Admin. Learn how to create an order exchange, create an order exchange, mark an order exchange return as received, and cancel an exchange.' addHowToData: true --- diff --git a/docs/content/user-guide/orders/export.mdx b/docs/content/user-guide/orders/export.mdx index 7e1d2d5972..d70965427c 100644 --- a/docs/content/user-guide/orders/export.mdx +++ b/docs/content/user-guide/orders/export.mdx @@ -1,5 +1,5 @@ --- -sidebar_position: 9 +sidebar_position: 10 description: 'This user guide explains how to export a list of orders on the Medusa admin.' addHowToData: true --- diff --git a/docs/content/user-guide/orders/manage.mdx b/docs/content/user-guide/orders/manage.mdx index 7677025bd1..32b0b0fc91 100644 --- a/docs/content/user-guide/orders/manage.mdx +++ b/docs/content/user-guide/orders/manage.mdx @@ -63,6 +63,19 @@ To edit the shipping address used for an order: --- +## Edit the Billing Address + +To edit the billing address used for an order: + +1. Open the order details page. +2. Scroll down to the Customer section. +3. Click on the icon. +4. Click on Edit Billing Address from the dropdown. +5. This opens a new window to edit the billing address. +6. Once you’re done, click on the Save button. + +--- + ## Edit Email Address To edit the email address associated with an order: @@ -76,6 +89,19 @@ To edit the email address associated with an order: --- +## Transfer Customer Ownership + +To change the customer that placed this order: + +1. Open the order details page. +2. Scroll down to the Customer section. +3. Click on the icon. +4. Click on "Transfer ownership" from the dropdown. +5. In the new window that opens choose the new customer to own this order. +6. Once done, click on the Confirm button. + +--- + ## Add a Note To add a note to an order: diff --git a/docs/content/user-guide/orders/payments.md b/docs/content/user-guide/orders/payments.md index 6b9ce852b3..a518eed97f 100644 --- a/docs/content/user-guide/orders/payments.md +++ b/docs/content/user-guide/orders/payments.md @@ -47,7 +47,8 @@ To refund an order’s payment: 3. Click on the Refund button. 4. In the new window that opens: - Enter the Refund amount. It must be less than the Total Paid amount specified in the Payment section. - - Choose a reason for the refund and optionally provide a note. + - Choose a reason for the refund. + - Optionally provide a note for the customer to see. - If you don’t want the customer to receive an email that the refund has been made, uncheck the “Send notifications” checkbox. 5. Once you’re done, click on the Complete button. diff --git a/docs/content/user-guide/orders/returns.mdx b/docs/content/user-guide/orders/returns.mdx index 0c32c0d67f..cada6cfe4a 100644 --- a/docs/content/user-guide/orders/returns.mdx +++ b/docs/content/user-guide/orders/returns.mdx @@ -1,5 +1,5 @@ --- -sidebar_position: 6 +sidebar_position: 7 sidebar_label: Manage Returns description: 'This user guide explains how to manage order returns on the Medusa Admin. Learn how to request a return for an order, mark a return as received, and cancel a return.' addHowToData: true From cf89624747b0544b8147991f0c5c245e24d13437 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Fri, 27 Jan 2023 11:05:57 +0200 Subject: [PATCH 12/17] docs: fixed mobile usability of tooltips (#3124) --- www/docs/package.json | 1 + www/docs/src/css/_code.css | 4 ++ www/docs/src/css/_tooltip.css | 52 +++++-------------- www/docs/src/css/_variables.css | 3 ++ .../src/theme/CodeBlock/Content/String.js | 2 +- www/docs/src/theme/CopyButton/index.js | 13 +++-- www/docs/src/theme/Tooltip/index.js | 30 ++++++----- www/docs/yarn.lock | 32 +++++++++++- 8 files changed, 81 insertions(+), 56 deletions(-) diff --git a/www/docs/package.json b/www/docs/package.json index 5f35efa9f1..70ecb285ca 100644 --- a/www/docs/package.json +++ b/www/docs/package.json @@ -31,6 +31,7 @@ "prism-react-renderer": "^1.3.1", "react": "^17.0.1", "react-dom": "^17.0.1", + "react-tooltip": "^5.7.0", "react-transition-group": "^4.4.5", "react-uuid": "^2.0.0", "redocusaurus": "^1.4.0", diff --git a/www/docs/src/css/_code.css b/www/docs/src/css/_code.css index 04d104721f..5e36501b68 100644 --- a/www/docs/src/css/_code.css +++ b/www/docs/src/css/_code.css @@ -98,6 +98,10 @@ html[data-theme="dark"] .docusaurus-highlight-code-line { border-radius: var(--ifm-code-border-radius); } +.code-action-copy { + display: flex; +} + .code-action { background-color: transparent; border: none; diff --git a/www/docs/src/css/_tooltip.css b/www/docs/src/css/_tooltip.css index 35c6ab9e95..5dd33d6f99 100644 --- a/www/docs/src/css/_tooltip.css +++ b/www/docs/src/css/_tooltip.css @@ -1,45 +1,19 @@ -.tooltip-container { - position: relative; +.react-tooltip { + border: 1px solid var(--ifm-tooltip-border-color) !important; + border-radius: 8px !important; + font-size: 12px !important; + font-weight: 500 !important; + line-height: 20px !important; + box-shadow: 0px 2px 16px var(--ifm-tooltip-box-shadow-color) !important; + padding: 8px 16px !important; } -.tooltip-box { - position: absolute; - top: calc(-100% - 17px); - z-index: 100000; - padding: 8px 16px; - max-width: 170px; - width: max-content; - text-align: center; - - background-color: var(--ifm-tooltip-background-color); - border: 1px solid var(--ifm-tooltip-border-color); - border-radius: 8px; - color: var(--ifm-color-content); - font-size: 12px; - font-weight: 500; - line-height: 20px; - box-shadow: 0px 2px 16px var(--ifm-tooltip-box-shadow-color); - - opacity: 0; - transition: all .1s; -} - -.tooltip-box:not(.visible) { +.react-tooltip-arrow { display: none; } -.tooltip-box.visible { - opacity: 1; -} - -.inline-tooltip { - display: inline-block; -} - -.tooltip-container:not(.inline-tooltip) .tooltip-box { - left: calc(-50% - 30px); -} - -.inline-tooltip .tooltip-box { - left: 0; +@media screen and (max-width: 875px) { + .react-tooltip { + display: none; + } } \ No newline at end of file diff --git a/www/docs/src/css/_variables.css b/www/docs/src/css/_variables.css index 01c1bfe1a4..57a9045c70 100644 --- a/www/docs/src/css/_variables.css +++ b/www/docs/src/css/_variables.css @@ -95,6 +95,9 @@ --ifm-tooltip-background-color: #fff; --ifm-tooltip-border-color: #E5E7EB; --ifm-tooltip-box-shadow-color: rgba(17, 24, 39, 0.08); + --rt-opacity: 1 !important; + --rt-color-dark: var(--ifm-tooltip-background-color) !important; + --rt-color-white: var(--ifm-color-content) !important; /* Buttons */ --ifm-primary-btn-background-color: #fff; diff --git a/www/docs/src/theme/CodeBlock/Content/String.js b/www/docs/src/theme/CodeBlock/Content/String.js index 48e918776e..5b6799793d 100644 --- a/www/docs/src/theme/CodeBlock/Content/String.js +++ b/www/docs/src/theme/CodeBlock/Content/String.js @@ -103,7 +103,7 @@ export default function CodeBlockString({ )} {!noCopy && ( - + () => window.clearTimeout(copyTimeout.current), []); return ( - - + ) } \ No newline at end of file diff --git a/www/docs/src/theme/Tooltip/index.js b/www/docs/src/theme/Tooltip/index.js index 8445a36f4b..4d8c6f2015 100644 --- a/www/docs/src/theme/Tooltip/index.js +++ b/www/docs/src/theme/Tooltip/index.js @@ -1,20 +1,26 @@ -import React from 'react'; +import React, { useState, useEffect } from 'react'; +import { Tooltip as ReactTooltip } from 'react-tooltip' +import uuid from 'react-uuid'; +import 'react-tooltip/dist/react-tooltip.css' -export default function Tooltip ({ children, text, tooltipClassName, ...rest }) { - const [show, setShow] = React.useState(false); +export default function Tooltip ({ children, text, tooltipClassName }) { + const [elementId, setElementId] = useState(null) + + useEffect(() => { + if (!elementId) { + setElementId(uuid()) + } + }, [elementId]) return ( - - - {text} - - setShow(true)} - onMouseLeave={() => setShow(false)} - {...rest} + <> + {children} - + + ); }; \ No newline at end of file diff --git a/www/docs/yarn.lock b/www/docs/yarn.lock index 3090bd6535..d02a2472a9 100644 --- a/www/docs/yarn.lock +++ b/www/docs/yarn.lock @@ -2574,6 +2574,22 @@ __metadata: languageName: node linkType: hard +"@floating-ui/core@npm:^1.0.5": + version: 1.1.0 + resolution: "@floating-ui/core@npm:1.1.0" + checksum: 427c95953f99c58647c3eee50d75770fddc19416cea152403010527135e8c88479352a8cbb4aeb09949cf283522861d815bf77dff5207b64dc8dd3b623bf57a3 + languageName: node + linkType: hard + +"@floating-ui/dom@npm:^1.0.4": + version: 1.1.0 + resolution: "@floating-ui/dom@npm:1.1.0" + dependencies: + "@floating-ui/core": ^1.0.5 + checksum: 8cae2d59f32bce8d742a414477ee62854affbcb7ae318598adebadec36d43c01dccaf5004d73a9dd26683d393bb69fb1e8181970b8d7939f529512ab1ad672d2 + languageName: node + linkType: hard + "@gar/promisify@npm:^1.1.3": version: 1.1.3 resolution: "@gar/promisify@npm:1.1.3" @@ -4641,7 +4657,7 @@ __metadata: languageName: node linkType: hard -"classnames@npm:^2.3.1": +"classnames@npm:^2.3.1, classnames@npm:^2.3.2": version: 2.3.2 resolution: "classnames@npm:2.3.2" checksum: cd50ead57b4f97436aaa9f9885c6926323efc7c2bea8e3d4eb10e4e972aa6a1cfca1c7a0e06f8a199ca7498d4339e30bb6002e589e61c9f21248cbf3e8b0b18d @@ -5527,6 +5543,7 @@ __metadata: prism-react-renderer: ^1.3.1 react: ^17.0.1 react-dom: ^17.0.1 + react-tooltip: ^5.7.0 react-transition-group: ^4.4.5 react-uuid: ^2.0.0 redocusaurus: ^1.4.0 @@ -9878,6 +9895,19 @@ __metadata: languageName: node linkType: hard +"react-tooltip@npm:^5.7.0": + version: 5.7.0 + resolution: "react-tooltip@npm:5.7.0" + dependencies: + "@floating-ui/dom": ^1.0.4 + classnames: ^2.3.2 + peerDependencies: + react: ">=16.14.0" + react-dom: ">=16.14.0" + checksum: b9bbf50fe227ef478d98512f075b5dabc02f020256dcb825a36b8b7aa905764ce838f0dc382ca7f16279ab99327f8106fc38c14e619db07d937a5f0c37bc83fe + languageName: node + linkType: hard + "react-transition-group@npm:^4.4.5": version: 4.4.5 resolution: "react-transition-group@npm:4.4.5" From 3566bccb765c901c620006c649ab897bcbca0ce0 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Mon, 30 Jan 2023 14:11:00 +0200 Subject: [PATCH 13/17] docs: added publish plugin documentation (#3137) --- .../advanced/backend/plugins/create.md | 183 ++---------------- .../advanced/backend/plugins/overview.md | 3 +- .../advanced/backend/plugins/publish.md | 160 +++++++++++++++ www/docs/sidebars.js | 5 + 4 files changed, 185 insertions(+), 166 deletions(-) create mode 100644 docs/content/advanced/backend/plugins/publish.md diff --git a/docs/content/advanced/backend/plugins/create.md b/docs/content/advanced/backend/plugins/create.md index 3f8b8a57b5..f70ff779a6 100644 --- a/docs/content/advanced/backend/plugins/create.md +++ b/docs/content/advanced/backend/plugins/create.md @@ -1,11 +1,11 @@ --- -description: 'Learn how to create a plugin in Medusa. This guide explains how to develop, configure, test, and publish the plugins.' +description: 'Learn how to create a plugin in Medusa. This guide explains how to develop, configure, and test a plugin.' addHowToData: true --- # How to Create a Plugin -In this document, you’ll learn how to create a plugin and publish it. If you’re interested to learn more about what plugins are and where to find available official and community plugins, check out the [overview document](overview.md). +In this document, you’ll learn how to create a plugin and some tips for develoment. If you’re interested to learn more about what plugins are and where to find available official and community plugins, check out the [overview document](overview.md). ## Prerequisites @@ -39,10 +39,6 @@ By convention, all plugin names start with `medusa` followed by a descriptive na ## Changes to package.json -### Rename Project Name - -Update the `name` field in the `package.json` file to the name of your plugin. This should be the same name that you chose when running the `medusa new` command. - ### Change Dependencies A basic Medusa server installed with the `medusa new` command has dependencies similar to this: @@ -67,7 +63,7 @@ A basic Medusa server installed with the `medusa new` command has dependencies s For a plugin, some dependencies are not necessary. You can remove the packages `medusa-fulfillment-manual`, `medusa-payment-manual`, and `medusa-payment-stripe` as they are fulfillment and payment plugins necessary for a Medusa server, but not for a plugin. -Additionally, you remove `@medusajs/medusa-cli` as you don’t need to use the Medusa CLI while developing a plugin. +Additionally, you can remove `@medusajs/medusa-cli` as you don’t need to use the Medusa CLI while developing a plugin. Once you’re done making these changes, re-run the install command to update your `node_modules` directory: @@ -75,65 +71,27 @@ Once you’re done making these changes, re-run the install command to update yo npm install ``` -This section includes recommended changes to your `package.json`. You can skip any of these changes if you don’t find them necessary to your plugin. - ### Recommended: Change scripts +It's recommended to remove the `seed` and `start` scripts from your `package.json` as they aren't necessary for plugin development. + +Furthermore, it's recommended to change the `build` command and add a new `watch` command: + +```json title=package.json +"scripts": { + "build": "babel src --out-dir . --ignore **/__tests__ --extensions \".ts,.js\"", + "watch": "babel -w src --out-dir . --ignore **/__tests__ --extensions \".ts,.js\"" +} +``` + +The change to the `build` command ensures that the built files are placed as explained in the [plugin structure section](#plugin-structure). The `watch` command makes the [testing of the plugin](#test-your-plugin) easier. + :::caution If you don't make changes to the `build` and `watch` commands, please be aware of the [expected plugin structure](#plugin-structure). ::: -A basic Medusa installation comes with the following scripts: - -```json title=package.json -"scripts": { - "seed": "medusa seed -f ./data/seed.json", - "build": "babel src --out-dir . --ignore **/__tests__ --extensions \".ts,.js\"", - "start": "medusa develop" -} -``` - -The `seed` and `start` scripts aren't necessary for plugin development so you can remove them. - -It’s also recommended to add the `watch` script that automatically compiles your files if they are changed: - -```json title=package.json -"watch": "babel -w src --out-dir . --ignore **/__tests__ --extensions \".ts,.js\"" -``` - -This is helpful when testing the plugin. - -:::note - -Testing the plugin is covered in a [later section](#test-your-plugin). - -::: - -Another recommended script is the `prepare` script that builds your files under a “production” environment: - -```json title=package.json -"prepare": "cross-env NODE_ENV=production npm run build" -``` - -You would typically run this script before publishing your plugin. - -This script requires installing the package `cross-env` as a development dependency: - -```bash npm2yarn -npm install --save-dev cross-env -``` - -### Recommended: Change Basic Info - -`package.json` holds information that further describes the package or the author that created the package. It is recommended to make the following changes: - -- `description`: Change this to a sentence that describes what your plugin does. -- `author`: Your name and email. -- `repository`: The repository that holds your plugin’s codebase. -- `keywords`: This should hold the keywords that are related to your plugin. It’s recommended that all plugins use the keywords `medusa-plugin` or `medusa`. - --- ## Develop your Plugin @@ -355,116 +313,11 @@ It is safe to ignore any `cross-env: command not found` error you may receive. --- -## NPM Ignore File - -Not all files that you use while developing your plugin are necessary to be published. - -For example, the files you add in the `src` directory are compiled to the root of the plugin directory before publishing. Then, when a developer installs your plugin, they’ll just be using the files in the root. - -So, you can ignore files and directories like `src` from the final published NPM package. - -To do that, create the file `.npmignore` with the following content: - -```bash title=.npmignore -/lib -node_modules -.DS_store -.env* -/*.js -!index.js -yarn.lock -src -.gitignore -.eslintrc -.babelrc -.prettierrc - -#These are files that are included in a -#Medusa project and can be removed from a -#plugin project -medusa-config.js -Dockerfile -medusa-db.sql -develop.sh -``` - ---- - ## Publish Plugin -Once you’re done developing your plugin you can publish the package on NPM’s registry so that other developers can benefit from it and use it. +Once you're done with the development of the plugin, you can publish it to NPM so that other Medusa developers and users can use it. -Before you publish a plugin, you must [create an account on NPM](https://www.npmjs.com/signup). - -### Prepare Plugin - -Before you publish or update your plugin, make sure to run the `prepare` command [defined earlier](#recommended-change-scripts): - -```bash npm2yarn -npm run prepare -``` - -### Login - -In your terminal, log in with your NPM account: - -```bash -npm login -``` - -You’ll be asked to enter your NPM email and password. - -### Publish Plugin Package - -Once you’re logged in, you can publish your package with the following command: - -```bash -npm publish -``` - -Your package is then published on NPM and everyone can use it and install it. - -### Update Plugin - -To update your plugin at a later point, you can run the following command to change the NPM version: - -```bash -npm version -``` - -Where `` indicates the type of version update you’re publishing. For example, it can be `major` or `minor`. - -You can see the [full list of types in NPM’s documentation](https://docs.npmjs.com/cli/v8/commands/npm-version). - -Then, publish the new update: - -```bash -npm publish -``` - ---- - -## Add Plugin to Medusa’s Repository - -All officially-supported plugins are available in the [`packages` directory of the Medusa GitHub repository](https://github.com/medusajs/medusa/tree/master/packages). - -If you’re interested in adding your plugin, you need to create a new pull request (PR) where you add your plugin inside the `packages` directory. Our team will then review your plugin, and if it’s approved the PR will be merged and your plugin will be available on Medusa’s repository. - -:::note - -Before contributing to the Medusa repository, please check out the [contribution guidelines](https://github.com/medusajs/medusa/blob/master/CONTRIBUTING.md). - -::: - ---- - -## Install a Plugin - -To install any published plugin, you can run the following command on any Medusa server project: - -```bash npm2yarn -npm install medusa-plugin-custom -``` +Please refer to [this guide on required steps to publish a plugin](./publish.md). --- diff --git a/docs/content/advanced/backend/plugins/overview.md b/docs/content/advanced/backend/plugins/overview.md index ddf8bf2698..74b430230a 100644 --- a/docs/content/advanced/backend/plugins/overview.md +++ b/docs/content/advanced/backend/plugins/overview.md @@ -58,5 +58,6 @@ For community plugins, please refer to the installation instructions of that plu ## See Also -- [Create your own plugin](create.md) +- [Create a plugin](create.md) +- [Publish a plugin](publish.md) - [Create a fulfillment provider](../shipping/add-fulfillment-provider.md) or a [payment provider](../payment/how-to-create-payment-provider.md) diff --git a/docs/content/advanced/backend/plugins/publish.md b/docs/content/advanced/backend/plugins/publish.md new file mode 100644 index 0000000000..aca5129095 --- /dev/null +++ b/docs/content/advanced/backend/plugins/publish.md @@ -0,0 +1,160 @@ +--- +description: 'Learn how to publish a Medusa plugin to NPM. This guide lists some check lists to ensure you have implemented before publishing, as well as required steps.' +addHowToData: true +--- + +# How to Publish a Plugin + +In this document, you'll learn how to publish a Medusa plugin to NPM and what are some requirements to keep in mind before publishing. + +## Prerequisites + +If you haven't created a plugin yet, please check [this guide to learn how to create a plugin](./create.md). + +--- + +## Prepare the Plugin + +### package.json Checklist + +Before publishing your plugin, make sure you've set the following fields in your plugin's package.json: + +- `name`: The name of your plugin. By convention, all plugin names start with `medusa` followed by a descriptive name of what the plugin does. For example, `medusa-payment-stripe`. +- `description`: A short description of what the plugin does. +- `author`: Your name or your company's name. +- `repository`: This includes details about the repository that holds the source code of the plugin. It's an object that holds the following properties: + - `type`: Should be `git`. + - `url`: The URL to the repository (for example, the GitHub repository holding the code of your plugin). +- `keywords`: An array of keywords that are related to the plugin. It's required for all Medusa plugins to use the keywords `medusa-plugin`. Other recommended keywords are: + - `medusa-plugin-analytics`: For plugins that add analytics functionalities or integrations. + - `medusa-plugin-cms`: For plugins that add CMS functionalities or integrations. + - `medusa-plugin-notification`: For plugins that add notification functionalities or integrations. + - `medusa-plugin-payment`: For plugins that add payment functionalities or integrations. + - `medusa-plugin-search`: For plugins that add search functionalities or integrations. + - `medusa-plugin-shipping`: For plugins that add shipping functionalities or integrations. + - `medusa-plugin-storage`: For plugins that add a file service or storage integration. + - `medusa-plugin-source`: For plugins that help migrate or import data into Medusa from another platform. + - `medusa-plugin-storefront`: For storefronts that can be integrated with a Medusa server. + - `medusa-plugin-other`: For any other type of plugin. + +### Scripts in package.json + +Make sure you add the `publish` command to your `scripts` field and make the following change to the `build` command: + +```json title=package.json +"build": "babel src --out-dir . --ignore **/__tests__ --extensions \".ts,.js\"", +"prepare": "cross-env NODE_ENV=production npm run build" +``` + +The `build` command ensures that the plugin's built files are placed as explained in the [plugin structure](./create.md#plugin-structure) section of the Create Plugin documentation. + +The `prepare` command facilitates your publishing process. You would typically run this script before publishing your plugin. + +This new script requires installing the package `cross-env` as a development dependency: + +```bash npm2yarn +npm install --save-dev cross-env +``` + +### Plugin Structure + +Make sure your plugin's structure is as described in the [Create Plugin](./create.md#plugin-structure) documentation. If you've made the changes mentioned in [the above section to the scripts](#scripts-in-packagejson) in `package.json`, you should have the correct structure when you run the `prepare` command. + +### NPM Ignore File + +Not all files that you use while developing your plugin are necessary to be published. + +For example, the files you add in the `src` directory are compiled to the root of the plugin directory before publishing. Then, when a developer installs your plugin, they’ll just be using the files in the root. + +So, you can ignore files and directories like `src` from the final published NPM package. + +To do that, create the file `.npmignore` with the following content: + +```bash title=.npmignore +/lib +node_modules +.DS_store +.env* +/*.js +!index.js +yarn.lock +src +.gitignore +.eslintrc +.babelrc +.prettierrc + +# These are files that are included in a +# Medusa project and can be removed from a +# plugin project +medusa-config.js +Dockerfile +medusa-db.sql +develop.sh +``` + +--- + +## Publish Plugin + +This section explains how to publish your plugin to NPM. + +Before you publish a plugin, you must [create an account on NPM](https://www.npmjs.com/signup). + +### Prepare Plugin + +Before you publish or update your plugin, make sure to run the `prepare` command [defined earlier](#packagejson-checklist): + +```bash npm2yarn +npm run prepare +``` + +### Login + +In your terminal, log in with your NPM account: + +```bash +npm login +``` + +You’ll be asked to enter your NPM email and password. + +### Publish Plugin Package + +Once you’re logged in, you can publish your package with the following command: + +```bash +npm publish +``` + +Your package is then published on NPM and everyone can use it and install it. + +### Install Plugin + +To install your published plugin, you can run the following command on any Medusa server project: + +```bash npm2yarn +npm install medusa-plugin-custom +``` + +### Update Plugin + +To update your plugin at a later point, you can run the following command to change the NPM version: + +```bash +npm version +``` + +Where `` indicates the type of version update you’re publishing. For example, it can be `major` or `minor`. You can see the [full list of types in NPM’s documentation](https://docs.npmjs.com/cli/v8/commands/npm-version). + +Then, publish the new update: + +```bash +npm publish +``` + +--- + +## See Also + +- [Available official plugins](https://github.com/medusajs/medusa/tree/master/packages) \ No newline at end of file diff --git a/www/docs/sidebars.js b/www/docs/sidebars.js index 1678897c08..ed5af1c12f 100644 --- a/www/docs/sidebars.js +++ b/www/docs/sidebars.js @@ -399,6 +399,11 @@ module.exports = { id: "advanced/backend/plugins/create", label: "Create a Plugin" }, + { + type: "doc", + id: "advanced/backend/plugins/publish", + label: "Publish a Plugin" + }, { type: "doc", id: "advanced/backend/migrations/index", From 771c54952a3c54a199558a40032f25db67a8c0da Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Mon, 30 Jan 2023 15:24:26 +0200 Subject: [PATCH 14/17] chore: fixed OAS using incorrect store resource (#3138) (#3140) --- .../src/api/routes/store/product-tags/list-product-tags.ts | 2 +- .../src/api/routes/store/product-types/list-product-types.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/medusa/src/api/routes/store/product-tags/list-product-tags.ts b/packages/medusa/src/api/routes/store/product-tags/list-product-tags.ts index 379268bb92..50a9769902 100644 --- a/packages/medusa/src/api/routes/store/product-tags/list-product-tags.ts +++ b/packages/medusa/src/api/routes/store/product-tags/list-product-tags.ts @@ -89,7 +89,7 @@ import { IsType } from "../../../../utils/validators/is-type" * source: | * import Medusa from "@medusajs/medusa-js" * const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) - * medusa.store.productTags.list() + * medusa.productTags.list() * .then(({ product_tags }) => { * console.log(product_tags.length); * }); diff --git a/packages/medusa/src/api/routes/store/product-types/list-product-types.ts b/packages/medusa/src/api/routes/store/product-types/list-product-types.ts index a7451dcc2e..3716134495 100644 --- a/packages/medusa/src/api/routes/store/product-types/list-product-types.ts +++ b/packages/medusa/src/api/routes/store/product-types/list-product-types.ts @@ -89,7 +89,7 @@ import ProductTypeService from "../../../../services/product-type" * import Medusa from "@medusajs/medusa-js" * const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) * // must be previously logged in or use api token - * medusa.store.productTypes.list() + * medusa.productTypes.list() * .then(({ product_types }) => { * console.log(product_types.length); * }); From 6f058b389be34591ee6b7a32a4302187129269a5 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Mon, 30 Jan 2023 15:24:44 +0200 Subject: [PATCH 15/17] docs: added information about metadata attribute (#3139) * docs: added information about metdata fields * docs: changed a subheader to avoid confusion * added acronym expanding for jsonb --- .../advanced/backend/entities/overview.md | 41 +++++++++++++++++++ .../advanced/backend/plugins/publish.md | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/docs/content/advanced/backend/entities/overview.md b/docs/content/advanced/backend/entities/overview.md index e606715e0c..48c7f9f746 100644 --- a/docs/content/advanced/backend/entities/overview.md +++ b/docs/content/advanced/backend/entities/overview.md @@ -24,6 +24,47 @@ The `SoftDeletableEntity` class extends the `BaseEntity` class and adds another --- +## metadata Attribute + +Most entities in Medusa have a `metadata` attribute. This attribute is an object that can be used to store custom data related to that entity. In the database, this attribute is stored as a [JSON Binary (JSONB)](https://www.postgresql.org/docs/current/datatype-json.html#JSON-CONTAINMENT) column. On retrieval, the attribute is parsed into an object. + +Some example use cases for the `metadata` attribute include: + +- Store an external ID of an entity related to a third-party integartion. +- Store product customization such as personalization options. + +### Add and Update Metadata + +You can add or update metadata entities either through the REST APIs or through create and update methods in the entity's respective service. + +In the [admin REST APIs](/api/admin), you'll find that in create or update requests of some entities you can also set the `metadata`. + +In services, there are typically `create` or `update` methods that allow you to set or update the metadata. + +If you want to add a property to the `metadata` object or update a property in the `metadata` object, you can pass the `metadata` object with the properties you want to add or update in it. For example: + +```json +{ + // other data + "metadata": { + "is_b2b": true + } +} +``` + +If you want to remove a property from the `metadata` object, you can pass the `metadata` object with the property you want to delete. The property should have an empty string value. For example: + +```json +{ + // other data + "metadata": { + "is_b2b": "" // this deletes the `is_b2b` property from `metadata` + } +} +``` + +--- + ## See Also - [Create an entity](./index.md) diff --git a/docs/content/advanced/backend/plugins/publish.md b/docs/content/advanced/backend/plugins/publish.md index aca5129095..c8af392320 100644 --- a/docs/content/advanced/backend/plugins/publish.md +++ b/docs/content/advanced/backend/plugins/publish.md @@ -101,7 +101,7 @@ This section explains how to publish your plugin to NPM. Before you publish a plugin, you must [create an account on NPM](https://www.npmjs.com/signup). -### Prepare Plugin +### Run Prepare Command Before you publish or update your plugin, make sure to run the `prepare` command [defined earlier](#packagejson-checklist): From 061a0a37fa21574f7951d9f5b335b99bd33b7cb1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 15:37:43 +0200 Subject: [PATCH 16/17] chore(docs): Updated API Reference (#3142) * chore(docs): Generated API Reference * Update admin-spec3.json * Update admin-spec3.yaml * Update openapi.yaml --------- Co-authored-by: shahednasser Co-authored-by: Shahed Nasser --- docs/api/store-spec3.json | 4 ++-- docs/api/store-spec3.yaml | 4 ++-- .../store/code_samples/JavaScript/product-tags/getundefined | 2 +- .../store/code_samples/JavaScript/product-types/getundefined | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/api/store-spec3.json b/docs/api/store-spec3.json index 78ce2600e0..61259dedfb 100644 --- a/docs/api/store-spec3.json +++ b/docs/api/store-spec3.json @@ -3313,7 +3313,7 @@ paths: const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) - medusa.store.productTags.list() + medusa.productTags.list() .then(({ product_tags }) => { console.log(product_tags.length); @@ -3463,7 +3463,7 @@ paths: // must be previously logged in or use api token - medusa.store.productTypes.list() + medusa.productTypes.list() .then(({ product_types }) => { console.log(product_types.length); diff --git a/docs/api/store-spec3.yaml b/docs/api/store-spec3.yaml index 78ce2600e0..61259dedfb 100644 --- a/docs/api/store-spec3.yaml +++ b/docs/api/store-spec3.yaml @@ -3313,7 +3313,7 @@ paths: const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) - medusa.store.productTags.list() + medusa.productTags.list() .then(({ product_tags }) => { console.log(product_tags.length); @@ -3463,7 +3463,7 @@ paths: // must be previously logged in or use api token - medusa.store.productTypes.list() + medusa.productTypes.list() .then(({ product_types }) => { console.log(product_types.length); diff --git a/docs/api/store/code_samples/JavaScript/product-tags/getundefined b/docs/api/store/code_samples/JavaScript/product-tags/getundefined index 7d0a963010..4cb9290fe8 100644 --- a/docs/api/store/code_samples/JavaScript/product-tags/getundefined +++ b/docs/api/store/code_samples/JavaScript/product-tags/getundefined @@ -1,6 +1,6 @@ import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) -medusa.store.productTags.list() +medusa.productTags.list() .then(({ product_tags }) => { console.log(product_tags.length); }); diff --git a/docs/api/store/code_samples/JavaScript/product-types/getundefined b/docs/api/store/code_samples/JavaScript/product-types/getundefined index 355ccb321a..448cefcb2a 100644 --- a/docs/api/store/code_samples/JavaScript/product-types/getundefined +++ b/docs/api/store/code_samples/JavaScript/product-types/getundefined @@ -1,7 +1,7 @@ import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token -medusa.store.productTypes.list() +medusa.productTypes.list() .then(({ product_types }) => { console.log(product_types.length); }); From 15a7ba2914417b2894c4a8564389318b2d346df2 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Mon, 30 Jan 2023 16:41:02 +0200 Subject: [PATCH 17/17] chore(docs): updated docusaurus to v2.3.0 (#3145) --- www/docs/docusaurus.config.js | 10 +- www/docs/package.json | 4 +- www/docs/src/theme/Tabs/index.js | 217 ++++++---------- www/docs/yarn.lock | 419 ++++++++++++++++--------------- 4 files changed, 297 insertions(+), 353 deletions(-) diff --git a/www/docs/docusaurus.config.js b/www/docs/docusaurus.config.js index 724b733417..55db151320 100644 --- a/www/docs/docusaurus.config.js +++ b/www/docs/docusaurus.config.js @@ -1,3 +1,4 @@ +require('dotenv').config(); const path = require("path") const fs = require("fs") const docsPath = path.join(__dirname, "../../docs/content") @@ -16,18 +17,11 @@ const config = { url: "https://docs.medusajs.com", baseUrl: "/", onBrokenLinks: "throw", - onBrokenMarkdownLinks: "warn", + onBrokenMarkdownLinks: "throw", favicon: "img/favicon.ico", organizationName: "medusajs", projectName: "medusajs/www", plugins: [ - [ - "docusaurus2-dotenv", - { - path: "./.env", // The path to your environment variables. - systemvars: true, // Set to true if you would rather load all system variables as well (useful for CI purposes) - }, - ], [ "docusaurus-plugin-segment", { diff --git a/www/docs/package.json b/www/docs/package.json index 70ecb285ca..2a2bdba430 100644 --- a/www/docs/package.json +++ b/www/docs/package.json @@ -21,11 +21,11 @@ "@docusaurus/preset-classic": "latest", "@docusaurus/remark-plugin-npm2yarn": "latest", "@svgr/webpack": "6.2.1", - "algoliasearch-helper": "^3.8.2", + "algoliasearch-helper": "^3.11.3", "clsx": "^1.1.1", "docusaurus-plugin-image-zoom": "^0.1.1", "docusaurus-plugin-segment": "^1.0.3", - "docusaurus2-dotenv": "^1.4.0", + "dotenv": "^16.0.3", "file-loader": "^6.2.0", "lodash": "^4.17.21", "prism-react-renderer": "^1.3.1", diff --git a/www/docs/src/theme/Tabs/index.js b/www/docs/src/theme/Tabs/index.js index 4c3edb4df0..7ec11e0944 100644 --- a/www/docs/src/theme/Tabs/index.js +++ b/www/docs/src/theme/Tabs/index.js @@ -1,105 +1,33 @@ -import React, {cloneElement, isValidElement, useEffect, useState} from 'react'; +import React, {cloneElement, useEffect} from 'react'; +import clsx from 'clsx'; import { useScrollPositionBlocker, - useTabGroupChoice, + useTabs, } from '@docusaurus/theme-common/internal'; - -import clsx from 'clsx'; -import {duplicates} from '@docusaurus/theme-common'; -import styles from './styles.module.css'; import useIsBrowser from '@docusaurus/useIsBrowser'; +import styles from './styles.module.css'; -// A very rough duck type, but good enough to guard against mistakes while -// allowing customization -function isTabItem(comp) { - return 'value' in comp.props; -} -function TabsComponent(props) { - const { - lazy, - block, - defaultValue: defaultValueProp, - values: valuesProp, - groupId, - className, - isCodeTabs = false, - codeTitle - } = props; - const children = React.Children.map(props.children, (child) => { - if (isValidElement(child) && isTabItem(child)) { - return child; - } - // child.type.name will give non-sensical values in prod because of - // minification, but we assume it won't throw in prod. - throw new Error( - `Docusaurus error: Bad child <${ - // @ts-expect-error: guarding against unexpected cases - typeof child.type === 'string' ? child.type : child.type.name - }>: all children of the component should be , and every should have a unique "value" prop.`, - ); - }); - const values = - valuesProp ?? - // Only pick keys that we recognize. MDX would inject some keys by default - children.map(({props: {value, label, attributes}}) => ({ - value, - label, - attributes, - })); - const dup = duplicates(values, (a, b) => a.value === b.value); - if (dup.length > 0) { - throw new Error( - `Docusaurus error: Duplicate values "${dup - .map((a) => a.value) - .join(', ')}" found in . Every value needs to be unique.`, - ); - } - // When defaultValueProp is null, don't show a default tab - const defaultValue = - defaultValueProp === null - ? defaultValueProp - : defaultValueProp ?? - children.find((child) => child.props.default)?.props.value ?? - children[0].props.value; - if (defaultValue !== null && !values.some((a) => a.value === defaultValue)) { - throw new Error( - `Docusaurus error: The has a defaultValue "${defaultValue}" but none of its children has the corresponding value. Available values are: ${values - .map((a) => a.value) - .join( - ', ', - )}. If you intend to show no default tab, use defaultValue={null} instead.`, - ); - } - const {tabGroupChoices, setTabGroupChoices} = useTabGroupChoice(); - const [selectedValue, setSelectedValue] = useState(defaultValue); +//ADDED: isCodeTabs and codeTitle props +function TabList({className, block, selectedValue, selectValue, tabValues, isCodeTabs = false, codeTitle}) { const tabRefs = []; const {blockElementScrollPositionUntilNextRender} = useScrollPositionBlocker(); - if (groupId != null) { - const relevantTabGroupChoice = tabGroupChoices[groupId]; - if ( - relevantTabGroupChoice != null && - relevantTabGroupChoice !== selectedValue && - values.some((value) => value.value === relevantTabGroupChoice) - ) { - setSelectedValue(relevantTabGroupChoice); - } - } const handleTabChange = (event) => { const newTab = event.currentTarget; const newTabIndex = tabRefs.indexOf(newTab); - const newTabValue = values[newTabIndex].value; + const newTabValue = tabValues[newTabIndex].value; if (newTabValue !== selectedValue) { blockElementScrollPositionUntilNextRender(newTab); - setSelectedValue(newTabValue); - if (groupId != null) { - setTabGroupChoices(groupId, String(newTabValue)); - } + selectValue(newTabValue); } }; const handleKeydown = (event) => { let focusElement = null; switch (event.key) { + case 'Enter': { + handleTabChange(event); + break; + } case 'ArrowRight': { const nextTab = tabRefs.indexOf(event.currentTarget) + 1; focusElement = tabRefs[nextTab] ?? tabRefs[0]; @@ -115,65 +43,77 @@ function TabsComponent(props) { } focusElement?.focus(); }; - return ( -
    -
    - {isCodeTabs && {codeTitle}} -
      - {values.map(({value, label, attributes}) => ( -
    • tabRefs.push(tabControl)} - onKeyDown={handleKeydown} - onFocus={handleTabChange} - onClick={handleTabChange} - {...attributes} - className={clsx( - 'tabs__item', - styles.tabItem, - attributes?.className, - { - 'tabs__item--active': selectedValue === value, - }, - )}> - {label ?? value} -
    • - ))} -
    -
    - {lazy ? ( - cloneElement( - children.filter( - (tabItem) => tabItem.props.value === selectedValue, - )[0], - ) - ) : ( -
    - {children.map((tabItem, i) => - cloneElement(tabItem, { - key: i, - hidden: tabItem.props.value !== selectedValue, - }), - )} -
    + //ADDED: div wrapper to ul + //ADDED: span with code-title class + return ( +
    + {isCodeTabs && {codeTitle}} +
      + {tabValues.map(({value, label, attributes}) => ( +
    • tabRefs.push(tabControl)} + onKeyDown={handleKeydown} + onClick={handleTabChange} + {...attributes} + className={clsx('tabs__item', styles.tabItem, attributes?.className, { + 'tabs__item--active': selectedValue === value, + })}> + {label ?? value} +
    • + ))} +
    +
    + ); +} + +//CHANGED: Removed margin-top--md class +function TabContent({lazy, children, selectedValue}) { + if (lazy) { + const selectedTabItem = children.find( + (tabItem) => tabItem.props.value === selectedValue, + ); + if (!selectedTabItem) { + // fail-safe or fail-fast? not sure what's best here + return null; + } + return cloneElement(selectedTabItem); + } + return ( +
    + {children.map((tabItem, i) => + cloneElement(tabItem, { + key: i, + hidden: tabItem.props.value !== selectedValue, + }), )}
    ); } +function TabsComponent(props) { + const tabs = useTabs(props); + return ( +
    + + +
    + ); +} export default function Tabs(props) { const isBrowser = useIsBrowser(); @@ -182,8 +122,9 @@ export default function Tabs(props) { //set the default window.localStorage.setItem('docusaurus.tab.npm2yarn', 'yarn') } - }, []) + }, []); + // ADDED: wrapper div + isCodeTabs prop return (
    = 3.1 < 6" + checksum: 544b6b73eaa4788d9082b2760b15c1e5ad59f1174eecf1535ea074bf3c4b019f5234c37cd1659ee6704fac46d681ebf9754259d66a40944fa5a33ee2db0a8182 + languageName: node + linkType: hard + "algoliasearch@npm:^4.0.0, algoliasearch@npm:^4.13.1": version: 4.14.2 resolution: "algoliasearch@npm:4.14.2" @@ -5532,11 +5561,11 @@ __metadata: "@docusaurus/preset-classic": latest "@docusaurus/remark-plugin-npm2yarn": latest "@svgr/webpack": 6.2.1 - algoliasearch-helper: ^3.8.2 + algoliasearch-helper: ^3.11.3 clsx: ^1.1.1 docusaurus-plugin-image-zoom: ^0.1.1 docusaurus-plugin-segment: ^1.0.3 - docusaurus2-dotenv: ^1.4.0 + dotenv: ^16.0.3 file-loader: ^6.2.0 lodash: ^4.17.21 prettier: ^2.3.2 @@ -5598,15 +5627,6 @@ __metadata: languageName: node linkType: hard -"docusaurus2-dotenv@npm:^1.4.0": - version: 1.4.0 - resolution: "docusaurus2-dotenv@npm:1.4.0" - dependencies: - dotenv-webpack: 1.7.0 - checksum: 694b88296685673f85b3a6864c3ce9dd19041bdfcfd2cc48d1099ca3fd3303160ae31d0bcedc41f67cb2f2eaa9837845236ed7922d7cc6a9b857bf3fd71d21ef - languageName: node - linkType: hard - "dom-converter@npm:^0.2.0": version: 0.2.0 resolution: "dom-converter@npm:0.2.0" @@ -5721,30 +5741,10 @@ __metadata: languageName: node linkType: hard -"dotenv-defaults@npm:^1.0.2": - version: 1.1.1 - resolution: "dotenv-defaults@npm:1.1.1" - dependencies: - dotenv: ^6.2.0 - checksum: c1304b7c83cbc310b0fa2a9256cf60caa0221d8b240b9e520f59bcdf3dfcfcf6a6d322250e787b6b770e21a17e7fdf56b6371e0b9a515d58d1159e7042a7caef - languageName: node - linkType: hard - -"dotenv-webpack@npm:1.7.0": - version: 1.7.0 - resolution: "dotenv-webpack@npm:1.7.0" - dependencies: - dotenv-defaults: ^1.0.2 - peerDependencies: - webpack: ^1 || ^2 || ^3 || ^4 - checksum: 65ec0ccf2f8ab8db43040d66765a264d8fea2c779402495f01870cf93b73a31d01d7cfc3632341706e8e3a300553c4f84251b0319df01adaba9d2539406c9a2e - languageName: node - linkType: hard - -"dotenv@npm:^6.2.0": - version: 6.2.0 - resolution: "dotenv@npm:6.2.0" - checksum: 56886938622c34255c89ec24d584460668a5ca035afe37da7b16bfbac36f8b352d20a6dde51000b30db04fa5cac7b03caf165919fe5e9bd8c91a2735fd61c649 +"dotenv@npm:^16.0.3": + version: 16.0.3 + resolution: "dotenv@npm:16.0.3" + checksum: 109457ac5f9e930ca8066ea33887b6f839ab24d647a7a8b49ddcd1f32662e2c35591c5e5b9819063e430148a664d0927f0cbe60cf9575d89bc524f47ff7e78f0 languageName: node linkType: hard @@ -11745,6 +11745,15 @@ __metadata: languageName: node linkType: hard +"use-sync-external-store@npm:^1.2.0": + version: 1.2.0 + resolution: "use-sync-external-store@npm:1.2.0" + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + checksum: ac4814e5592524f242921157e791b022efe36e451fe0d4fd4d204322d5433a4fc300d63b0ade5185f8e0735ded044c70bcf6d2352db0f74d097a238cebd2da02 + languageName: node + linkType: hard + "util-deprecate@npm:^1.0.1, util-deprecate@npm:^1.0.2, util-deprecate@npm:~1.0.1": version: 1.0.2 resolution: "util-deprecate@npm:1.0.2"