docs: generate medusa-react reference (#6004)

* add new plugin for better organization

* added handling in theme for mutations and query types

* added tsdoc to hooks

* added tsdocs to utility functions

* added tsdoc to providers

* generated reference

* general fixes for generated reference

* generated api reference specs + general fixes

* add missing import react

* split utilities into different directories

* added overview page

* added link to customer authentication section

* fix lint errors

* added changeset

* fix readme

* fixed build error

* added expand fields + other sections to overview

* updated what's new section

* general refactoring

* remove unnecessary query field

* fix links

* added ignoreApi option
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-01-05 17:03:38 +02:00
1 parent 6fc6a9de6a
commit 7d650771d1
2811 files changed
+231856 -455063

No files matched your search

@@ -34,6 +34,31 @@ import { validator } from "../../../../utils/validator"
* .then(({ user }) => {
* console.log(user.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminLogin } from "medusa-react"
*
* const Login = () => {
* const adminLogin = useAdminLogin()
* // ...
*
* const handleLogin = () => {
* adminLogin.mutate({
* email: "user@example.com",
* password: "supersecret",
* }, {
* onSuccess: ({ user }) => {
* console.log(user)
* }
* })
* }
*
* // ...
* }
*
* export default Login
* - lang: Shell
* label: cURL
* source: |
@@ -91,6 +116,7 @@ export default async (req, res) => {
/**
* @schema AdminPostAuthReq
* type: object
* description: The admin's credentials used to log in.
* required:
* - email
* - password
@@ -15,6 +15,28 @@
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in
* medusa.admin.auth.deleteSession()
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDeleteSession } from "medusa-react"
*
* const Logout = () => {
* const adminLogout = useAdminDeleteSession()
* // ...
*
* const handleLogout = () => {
* adminLogout.mutate(undefined, {
* onSuccess: () => {
* // user logged out.
* }
* })
* }
*
* // ...
* }
*
* export default Logout
* - lang: Shell
* label: cURL
* source: |
@@ -20,6 +20,24 @@ import _ from "lodash"
* .then(({ user }) => {
* console.log(user.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminGetSession } from "medusa-react"
*
* const Profile = () => {
* const { user, isLoading } = useAdminGetSession()
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {user && <span>{user.email}</span>}
* </div>
* )
* }
*
* export default Profile
* - lang: Shell
* label: cURL
* source: |
@@ -22,6 +22,32 @@ import { EntityManager } from "typeorm"
* .then(({ batch_job }) => {
* console.log(batch_job.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCancelBatchJob } from "medusa-react"
*
* type Props = {
* batchJobId: string
* }
*
* const BatchJob = ({ batchJobId }: Props) => {
* const cancelBatchJob = useAdminCancelBatchJob(batchJobId)
* // ...
*
* const handleCancel = () => {
* cancelBatchJob.mutate(undefined, {
* onSuccess: ({ batch_job }) => {
* console.log(batch_job)
* }
* })
* }
*
* // ...
* }
*
* export default BatchJob
* - lang: Shell
* label: cURL
* source: |
@@ -22,6 +22,32 @@ import { EntityManager } from "typeorm"
* .then(({ batch_job }) => {
* console.log(batch_job.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminConfirmBatchJob } from "medusa-react"
*
* type Props = {
* batchJobId: string
* }
*
* const BatchJob = ({ batchJobId }: Props) => {
* const confirmBatchJob = useAdminConfirmBatchJob(batchJobId)
* // ...
*
* const handleConfirm = () => {
* confirmBatchJob.mutate(undefined, {
* onSuccess: ({ batch_job }) => {
* console.log(batch_job)
* }
* })
* }
*
* // ...
* }
*
* export default BatchJob
* - lang: Shell
* label: cURL
* source: |
@@ -36,6 +36,32 @@ import { validator } from "../../../../utils/validator"
* }).then((({ batch_job }) => {
* console.log(batch_job.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCreateBatchJob } from "medusa-react"
*
* const CreateBatchJob = () => {
* const createBatchJob = useAdminCreateBatchJob()
* // ...
*
* const handleCreateBatchJob = () => {
* createBatchJob.mutate({
* type: "publish-products",
* context: {},
* dry_run: true
* }, {
* onSuccess: ({ batch_job }) => {
* console.log(batch_job)
* }
* })
* }
*
* // ...
* }
*
* export default CreateBatchJob
* - lang: Shell
* label: cURL
* source: |
@@ -96,6 +122,7 @@ export default async (req, res) => {
/**
* @schema AdminPostBatchesReq
* type: object
* description: The details of the batch job to create.
* required:
* - type
* - context
@@ -19,6 +19,28 @@
* .then(({ batch_job }) => {
* console.log(batch_job.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminBatchJob } from "medusa-react"
*
* type Props = {
* batchJobId: string
* }
*
* const BatchJob = ({ batchJobId }: Props) => {
* const { batch_job, isLoading } = useAdminBatchJob(batchJobId)
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {batch_job && <span>{batch_job.created_by}</span>}
* </div>
* )
* }
*
* export default BatchJob
* - lang: Shell
* label: cURL
* source: |
@@ -224,6 +224,38 @@ import { isDefined } from "medusa-core-utils"
* .then(({ batch_jobs, limit, offset, count }) => {
* console.log(batch_jobs.length)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminBatchJobs } from "medusa-react"
*
* const BatchJobs = () => {
* const {
* batch_jobs,
* limit,
* offset,
* count,
* isLoading
* } = useAdminBatchJobs()
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {batch_jobs?.length && (
* <ul>
* {batch_jobs.map((batchJob) => (
* <li key={batchJob.id}>
* {batchJob.id}
* </li>
* ))}
* </ul>
* )}
* </div>
* )
* }
*
* export default BatchJobs
* - lang: Shell
* label: cURL
* source: |
@@ -36,6 +36,34 @@ import { defaultAdminCollectionsRelations } from "./index"
* .then(({ collection }) => {
* console.log(collection.products)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminAddProductsToCollection } from "medusa-react"
*
* type Props = {
* collectionId: string
* }
*
* const Collection = ({ collectionId }: Props) => {
* const addProducts = useAdminAddProductsToCollection(collectionId)
* // ...
*
* const handleAddProducts = (productIds: string[]) => {
* addProducts.mutate({
* product_ids: productIds
* }, {
* onSuccess: ({ collection }) => {
* console.log(collection.products)
* }
* })
* }
*
* // ...
* }
*
* export default Collection
* - lang: Shell
* label: cURL
* source: |
@@ -100,6 +128,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminPostProductsToCollectionReq
* type: object
* description: "The details of the products to add to the collection."
* required:
* - product_ids
* properties:
@@ -30,6 +30,30 @@ import { defaultAdminCollectionsRelations } from "."
* .then(({ collection }) => {
* console.log(collection.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCreateCollection } from "medusa-react"
*
* const CreateCollection = () => {
* const createCollection = useAdminCreateCollection()
* // ...
*
* const handleCreate = (title: string) => {
* createCollection.mutate({
* title
* }, {
* onSuccess: ({ collection }) => {
* console.log(collection.id)
* }
* })
* }
*
* // ...
* }
*
* export default CreateCollection
* - lang: Shell
* label: cURL
* source: |
@@ -89,6 +113,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminPostCollectionsReq
* type: object
* description: The product collection's details.
* required:
* - title
* properties:
@@ -24,6 +24,32 @@ import ProductCollectionService from "../../../../services/product-collection"
* .then(({ id, object, deleted }) => {
* console.log(id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDeleteCollection } from "medusa-react"
*
* type Props = {
* collectionId: string
* }
*
* const Collection = ({ collectionId }: Props) => {
* const deleteCollection = useAdminDeleteCollection(collectionId)
* // ...
*
* const handleDelete = (title: string) => {
* deleteCollection.mutate(void 0, {
* onSuccess: ({ id, object, deleted }) => {
* console.log(id)
* }
* })
* }
*
* // ...
* }
*
* export default Collection
* - lang: Shell
* label: cURL
* source: |
@@ -24,6 +24,28 @@ import { defaultAdminCollectionsRelations } from "."
* .then(({ collection }) => {
* console.log(collection.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCollection } from "medusa-react"
*
* type Props = {
* collectionId: string
* }
*
* const Collection = ({ collectionId }: Props) => {
* const { collection, isLoading } = useAdminCollection(collectionId)
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {collection && <span>{collection.title}</span>}
* </div>
* )
* }
*
* export default Collection
* - lang: Shell
* label: cURL
* source: |
@@ -98,6 +98,33 @@ import { Type } from "class-transformer"
* .then(({ collections, limit, offset, count }) => {
* console.log(collections.length);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCollections } from "medusa-react"
*
* const Collections = () => {
* const { collections, isLoading } = useAdminCollections()
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {collections && !collections.length && <span>
* No Product Collections
* </span>}
* {collections && collections.length > 0 && (
* <ul>
* {collections.map((collection) => (
* <li key={collection.id}>{collection.title}</li>
* ))}
* </ul>
* )}
* </div>
* )
* }
*
* export default Collections
* - lang: Shell
* label: cURL
* source: |
@@ -35,6 +35,34 @@ import ProductCollectionService from "../../../../services/product-collection"
* .then(({ id, object, removed_products }) => {
* console.log(removed_products)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminRemoveProductsFromCollection } from "medusa-react"
*
* type Props = {
* collectionId: string
* }
*
* const Collection = ({ collectionId }: Props) => {
* const removeProducts = useAdminRemoveProductsFromCollection(collectionId)
* // ...
*
* const handleRemoveProducts = (productIds: string[]) => {
* removeProducts.mutate({
* product_ids: productIds
* }, {
* onSuccess: ({ id, object, removed_products }) => {
* console.log(removed_products)
* }
* })
* }
*
* // ...
* }
*
* export default Collection
* - lang: Shell
* label: cURL
* source: |
@@ -99,6 +127,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminDeleteProductsFromCollectionReq
* type: object
* description: "The details of the products to remove from the collection."
* required:
* - product_ids
* properties:
@@ -32,6 +32,34 @@ import { defaultAdminCollectionsRelations } from "."
* .then(({ collection }) => {
* console.log(collection.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminUpdateCollection } from "medusa-react"
*
* type Props = {
* collectionId: string
* }
*
* const Collection = ({ collectionId }: Props) => {
* const updateCollection = useAdminUpdateCollection(collectionId)
* // ...
*
* const handleUpdate = (title: string) => {
* updateCollection.mutate({
* title
* }, {
* onSuccess: ({ collection }) => {
* console.log(collection.id)
* }
* })
* }
*
* // ...
* }
*
* export default Collection
* - lang: Shell
* label: cURL
* source: |
@@ -94,6 +122,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminPostCollectionsCollectionReq
* type: object
* description: The product collection's details to update.
* properties:
* title:
* type: string
@@ -37,6 +37,33 @@ import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators
* .then(({ currencies, count, offset, limit }) => {
* console.log(currencies.length);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCurrencies } from "medusa-react"
*
* const Currencies = () => {
* const { currencies, isLoading } = useAdminCurrencies()
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {currencies && !currencies.length && (
* <span>No Currencies</span>
* )}
* {currencies && currencies.length > 0 && (
* <ul>
* {currencies.map((currency) => (
* <li key={currency.code}>{currency.name}</li>
* ))}
* </ul>
* )}
* </div>
* )
* }
*
* export default Currencies
* - lang: Shell
* label: cURL
* source: |
@@ -34,6 +34,34 @@ import { EntityManager } from "typeorm"
* .then(({ currency }) => {
* console.log(currency.code);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminUpdateCurrency } from "medusa-react"
*
* type Props = {
* currencyCode: string
* }
*
* const Currency = ({ currencyCode }: Props) => {
* const updateCurrency = useAdminUpdateCurrency(currencyCode)
* // ...
*
* const handleUpdate = (includes_tax: boolean) => {
* updateCurrency.mutate({
* includes_tax,
* }, {
* onSuccess: ({ currency }) => {
* console.log(currency)
* }
* })
* }
*
* // ...
* }
*
* export default Currency
* - lang: Shell
* label: cURL
* source: |
@@ -87,6 +115,7 @@ export default async (req: ExtendedRequest<Currency>, res) => {
/**
* @schema AdminPostCurrenciesCurrencyReq
* type: object
* description: "The details to update in the currency"
* properties:
* includes_tax:
* type: boolean
@@ -39,6 +39,38 @@ import { validator } from "../../../../utils/validator"
* .then(({ customer_group }) => {
* console.log(customer_group.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import {
* useAdminAddCustomersToCustomerGroup,
* } from "medusa-react"
*
* type Props = {
* customerGroupId: string
* }
*
* const CustomerGroup = ({ customerGroupId }: Props) => {
* const addCustomers = useAdminAddCustomersToCustomerGroup(
* customerGroupId
* )
* // ...
*
* const handleAddCustomers= (customerId: string) => {
* addCustomers.mutate({
* customer_ids: [
* {
* id: customerId,
* },
* ],
* })
* }
*
* // ...
* }
*
* export default CustomerGroup
* - lang: Shell
* label: cURL
* source: |
@@ -108,6 +140,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminPostCustomerGroupsGroupCustomersBatchReq
* type: object
* description: "The customers to add to the customer group."
* required:
* - customer_ids
* properties:
@@ -31,6 +31,26 @@ import { validator } from "../../../../utils/validator"
* .then(({ customer_group }) => {
* console.log(customer_group.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCreateCustomerGroup } from "medusa-react"
*
* const CreateCustomerGroup = () => {
* const createCustomerGroup = useAdminCreateCustomerGroup()
* // ...
*
* const handleCreate = (name: string) => {
* createCustomerGroup.mutate({
* name,
* })
* }
*
* // ...
* }
*
* export default CreateCustomerGroup
* - lang: Shell
* label: cURL
* source: |
@@ -89,6 +109,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminPostCustomerGroupsReq
* type: object
* description: "The details of the customer group to create."
* required:
* - name
* properties:
@@ -24,6 +24,30 @@ import { EntityManager } from "typeorm"
* .then(({ id, object, deleted }) => {
* console.log(id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDeleteCustomerGroup } from "medusa-react"
*
* type Props = {
* customerGroupId: string
* }
*
* const CustomerGroup = ({ customerGroupId }: Props) => {
* const deleteCustomerGroup = useAdminDeleteCustomerGroup(
* customerGroupId
* )
* // ...
*
* const handleDeleteCustomerGroup = () => {
* deleteCustomerGroup.mutate()
* }
*
* // ...
* }
*
* export default CustomerGroup
* - lang: Shell
* label: cURL
* source: |
@@ -39,6 +39,39 @@ import { validator } from "../../../../utils/validator"
* .then(({ customer_group }) => {
* console.log(customer_group.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import {
* useAdminRemoveCustomersFromCustomerGroup,
* } from "medusa-react"
*
* type Props = {
* customerGroupId: string
* }
*
* const CustomerGroup = ({ customerGroupId }: Props) => {
* const removeCustomers =
* useAdminRemoveCustomersFromCustomerGroup(
* customerGroupId
* )
* // ...
*
* const handleRemoveCustomer = (customerId: string) => {
* removeCustomers.mutate({
* customer_ids: [
* {
* id: customerId,
* },
* ],
* })
* }
*
* // ...
* }
*
* export default CustomerGroup
* - lang: Shell
* label: cURL
* source: |
@@ -108,6 +141,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminDeleteCustomerGroupsGroupCustomerBatchReq
* type: object
* description: "The customers to remove from the customer group."
* required:
* - customer_ids
* properties:
@@ -30,6 +30,42 @@ import { Type } from "class-transformer"
* .then(({ customers }) => {
* console.log(customers.length);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCustomerGroupCustomers } from "medusa-react"
*
* type Props = {
* customerGroupId: string
* }
*
* const CustomerGroup = ({ customerGroupId }: Props) => {
* const {
* customers,
* isLoading,
* } = useAdminCustomerGroupCustomers(
* customerGroupId
* )
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {customers && !customers.length && (
* <span>No customers</span>
* )}
* {customers && customers.length > 0 && (
* <ul>
* {customers.map((customer) => (
* <li key={customer.id}>{customer.first_name}</li>
* ))}
* </ul>
* )}
* </div>
* )
* }
*
* export default CustomerGroup
* - lang: Shell
* label: cURL
* source: |
@@ -27,6 +27,30 @@ import { FindParams } from "../../../../types/common"
* .then(({ customer_group }) => {
* console.log(customer_group.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCustomerGroup } from "medusa-react"
*
* type Props = {
* customerGroupId: string
* }
*
* const CustomerGroup = ({ customerGroupId }: Props) => {
* const { customer_group, isLoading } = useAdminCustomerGroup(
* customerGroupId
* )
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {customer_group && <span>{customer_group.name}</span>}
* </div>
* )
* }
*
* export default CustomerGroup
* - lang: Shell
* label: cURL
* source: |
@@ -114,6 +114,40 @@ import { Type } from "class-transformer"
* .then(({ customer_groups, limit, offset, count }) => {
* console.log(customer_groups.length);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCustomerGroups } from "medusa-react"
*
* const CustomerGroups = () => {
* const {
* customer_groups,
* isLoading,
* } = useAdminCustomerGroups()
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {customer_groups && !customer_groups.length && (
* <span>No Customer Groups</span>
* )}
* {customer_groups && customer_groups.length > 0 && (
* <ul>
* {customer_groups.map(
* (customerGroup) => (
* <li key={customerGroup.id}>
* {customerGroup.name}
* </li>
* )
* )}
* </ul>
* )}
* </div>
* )
* }
*
* export default CustomerGroups
* - lang: Shell
* label: cURL
* source: |
@@ -35,6 +35,32 @@ import { validator } from "../../../../utils/validator"
* .then(({ customer_group }) => {
* console.log(customer_group.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminUpdateCustomerGroup } from "medusa-react"
*
* type Props = {
* customerGroupId: string
* }
*
* const CustomerGroup = ({ customerGroupId }: Props) => {
* const updateCustomerGroup = useAdminUpdateCustomerGroup(
* customerGroupId
* )
* // ..
*
* const handleUpdate = (name: string) => {
* updateCustomerGroup.mutate({
* name,
* })
* }
*
* // ...
* }
*
* export default CustomerGroup
* - lang: Shell
* label: cURL
* source: |
@@ -110,6 +136,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminPostCustomerGroupsGroupReq
* type: object
* description: "The details to update in the customer group."
* properties:
* name:
* description: "Name of the customer group"
@@ -33,6 +33,35 @@ import { EntityManager } from "typeorm"
* .then(({ customer }) => {
* console.log(customer.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCreateCustomer } from "medusa-react"
*
* type CustomerData = {
* first_name: string
* last_name: string
* email: string
* password: string
* }
*
* const CreateCustomer = () => {
* const createCustomer = useAdminCreateCustomer()
* // ...
*
* const handleCreate = (customerData: CustomerData) => {
* createCustomer.mutate(customerData, {
* onSuccess: ({ customer }) => {
* console.log(customer.id)
* }
* })
* }
*
* // ...
* }
*
* export default CreateCustomer
* - lang: Shell
* label: cURL
* source: |
@@ -87,6 +116,7 @@ export default async (req, res) => {
/**
* @schema AdminPostCustomersReq
* type: object
* description: "The details of the customer to create."
* required:
* - email
* - first_name
@@ -26,6 +26,30 @@ import { validator } from "../../../../utils/validator"
* .then(({ customer }) => {
* console.log(customer.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCustomer } from "medusa-react"
*
* type Props = {
* customerId: string
* }
*
* const Customer = ({ customerId }: Props) => {
* const { customer, isLoading } = useAdminCustomer(
* customerId
* )
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {customer && <span>{customer.first_name}</span>}
* </div>
* )
* }
*
* export default Customer
* - lang: Shell
* label: cURL
* source: |
@@ -38,6 +38,33 @@ import customerController from "../../../../controllers/customers"
* .then(({ customers, limit, offset, count }) => {
* console.log(customers.length);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCustomers } from "medusa-react"
*
* const Customers = () => {
* const { customers, isLoading } = useAdminCustomers()
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {customers && !customers.length && (
* <span>No customers</span>
* )}
* {customers && customers.length > 0 && (
* <ul>
* {customers.map((customer) => (
* <li key={customer.id}>{customer.first_name}</li>
* ))}
* </ul>
* )}
* </div>
* )
* }
*
* export default Customers
* - lang: Shell
* label: cURL
* source: |
@@ -45,6 +45,35 @@ import { validator } from "../../../../utils/validator"
* .then(({ customer }) => {
* console.log(customer.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminUpdateCustomer } from "medusa-react"
*
* type CustomerData = {
* first_name: string
* last_name: string
* email: string
* password: string
* }
*
* type Props = {
* customerId: string
* }
*
* const Customer = ({ customerId }: Props) => {
* const updateCustomer = useAdminUpdateCustomer(customerId)
* // ...
*
* const handleUpdate = (customerData: CustomerData) => {
* updateCustomer.mutate(customerData)
* }
*
* // ...
* }
*
* export default Customer
* - lang: Shell
* label: cURL
* source: |
@@ -128,6 +157,7 @@ class Group {
/**
* @schema AdminPostCustomersCustomerReq
* type: object
* description: "The details of the customer to update."
* properties:
* email:
* type: string
@@ -26,6 +26,32 @@ import { EntityManager } from "typeorm"
* .then(({ discount }) => {
* console.log(discount.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDiscountAddRegion } from "medusa-react"
*
* type Props = {
* discountId: string
* }
*
* const Discount = ({ discountId }: Props) => {
* const addRegion = useAdminDiscountAddRegion(discountId)
* // ...
*
* const handleAdd = (regionId: string) => {
* addRegion.mutate(regionId, {
* onSuccess: ({ discount }) => {
* console.log(discount.regions)
* }
* })
* }
*
* // ...
* }
*
* export default Discount
* - lang: Shell
* label: cURL
* source: |
@@ -42,6 +42,47 @@ import { FindParams } from "../../../../types/common"
* .then(({ discount }) => {
* console.log(discount.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import {
* useAdminAddDiscountConditionResourceBatch
* } from "medusa-react"
*
* type Props = {
* discountId: string
* conditionId: string
* }
*
* const DiscountCondition = ({
* discountId,
* conditionId
* }: Props) => {
* const addConditionResources = useAdminAddDiscountConditionResourceBatch(
* discountId,
* conditionId
* )
* // ...
*
* const handleAdd = (itemId: string) => {
* addConditionResources.mutate({
* resources: [
* {
* id: itemId
* }
* ]
* }, {
* onSuccess: ({ discount }) => {
* console.log(discount.id)
* }
* })
* }
*
* // ...
* }
*
* export default DiscountCondition
* - lang: Shell
* label: cURL
* source: |
@@ -116,6 +157,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminPostDiscountsDiscountConditionsConditionBatchReq
* type: object
* description: "The details of the resources to add."
* required:
* - resources
* properties:
@@ -42,6 +42,39 @@ import { FindParams } from "../../../../types/common"
* .then(({ discount }) => {
* console.log(discount.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { DiscountConditionOperator } from "@medusajs/medusa"
* import { useAdminDiscountCreateCondition } from "medusa-react"
*
* type Props = {
* discountId: string
* }
*
* const Discount = ({ discountId }: Props) => {
* const createCondition = useAdminDiscountCreateCondition(discountId)
* // ...
*
* const handleCreateCondition = (
* operator: DiscountConditionOperator,
* products: string[]
* ) => {
* createCondition.mutate({
* operator,
* products
* }, {
* onSuccess: ({ discount }) => {
* console.log(discount.id)
* }
* })
* }
*
* // ...
* }
*
* export default Discount
* - lang: Shell
* label: cURL
* source: |
@@ -64,6 +64,46 @@ import { FindParams } from "../../../../types/common"
* .then(({ discount }) => {
* console.log(discount.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import {
* useAdminCreateDiscount,
* } from "medusa-react"
* import {
* AllocationType,
* DiscountRuleType,
* } from "@medusajs/medusa"
*
* const CreateDiscount = () => {
* const createDiscount = useAdminCreateDiscount()
* // ...
*
* const handleCreate = (
* currencyCode: string,
* regionId: string
* ) => {
* // ...
* createDiscount.mutate({
* code: currencyCode,
* rule: {
* type: DiscountRuleType.FIXED,
* value: 10,
* allocation: AllocationType.ITEM,
* },
* regions: [
* regionId,
* ],
* is_dynamic: false,
* is_disabled: false,
* })
* }
*
* // ...
* }
*
* export default CreateDiscount
* - lang: Shell
* label: cURL
* source: |
@@ -127,6 +167,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminPostDiscountsReq
* type: object
* description: "The details of the discount to create."
* required:
* - code
* - rule
@@ -40,6 +40,38 @@ import { EntityManager } from "typeorm"
* .then(({ discount }) => {
* console.log(discount.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCreateDynamicDiscountCode } from "medusa-react"
*
* type Props = {
* discountId: string
* }
*
* const Discount = ({ discountId }: Props) => {
* const createDynamicDiscount = useAdminCreateDynamicDiscountCode(discountId)
* // ...
*
* const handleCreate = (
* code: string,
* usageLimit: number
* ) => {
* createDynamicDiscount.mutate({
* code,
* usage_limit: usageLimit
* }, {
* onSuccess: ({ discount }) => {
* console.log(discount.is_dynamic)
* }
* })
* }
*
* // ...
* }
*
* export default Discount
* - lang: Shell
* label: cURL
* source: |
@@ -100,6 +132,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminPostDiscountsDiscountDynamicCodesReq
* type: object
* description: "The details of the dynamic discount to create."
* required:
* - code
* properties:
@@ -29,6 +29,38 @@ import { FindParams } from "../../../../types/common"
* .then(({ id, object, deleted }) => {
* console.log(id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import {
* useAdminDiscountRemoveCondition
* } from "medusa-react"
*
* type Props = {
* discountId: string
* }
*
* const Discount = ({ discountId }: Props) => {
* const deleteCondition = useAdminDiscountRemoveCondition(
* discountId
* )
* // ...
*
* const handleDelete = (
* conditionId: string
* ) => {
* deleteCondition.mutate(conditionId, {
* onSuccess: ({ id, object, deleted }) => {
* console.log(deleted)
* }
* })
* }
*
* // ...
* }
*
* export default Discount
* - lang: Shell
* label: cURL
* source: |
@@ -22,6 +22,24 @@ import { EntityManager } from "typeorm"
* .then(({ id, object, deleted }) => {
* console.log(id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDeleteDiscount } from "medusa-react"
*
* const Discount = () => {
* const deleteDiscount = useAdminDeleteDiscount(discount_id)
* // ...
*
* const handleDelete = () => {
* deleteDiscount.mutate()
* }
*
* // ...
* }
*
* export default Discount
* - lang: Shell
* label: cURL
* source: |
@@ -25,6 +25,32 @@ import { EntityManager } from "typeorm"
* .then(({ discount }) => {
* console.log(discount.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDeleteDynamicDiscountCode } from "medusa-react"
*
* type Props = {
* discountId: string
* }
*
* const Discount = ({ discountId }: Props) => {
* const deleteDynamicDiscount = useAdminDeleteDynamicDiscountCode(discountId)
* // ...
*
* const handleDelete = (code: string) => {
* deleteDynamicDiscount.mutate(code, {
* onSuccess: ({ discount }) => {
* console.log(discount.is_dynamic)
* }
* })
* }
*
* // ...
* }
*
* export default Discount
* - lang: Shell
* label: cURL
* source: |
@@ -39,6 +39,47 @@ import { FindParams } from "../../../../types/common"
* .then(({ discount }) => {
* console.log(discount.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import {
* useAdminDeleteDiscountConditionResourceBatch
* } from "medusa-react"
*
* type Props = {
* discountId: string
* conditionId: string
* }
*
* const DiscountCondition = ({
* discountId,
* conditionId
* }: Props) => {
* const deleteConditionResource = useAdminDeleteDiscountConditionResourceBatch(
* discountId,
* conditionId,
* )
* // ...
*
* const handleDelete = (itemId: string) => {
* deleteConditionResource.mutate({
* resources: [
* {
* id: itemId
* }
* ]
* }, {
* onSuccess: ({ discount }) => {
* console.log(discount.id)
* }
* })
* }
*
* // ...
* }
*
* export default DiscountCondition
* - lang: Shell
* label: cURL
* source: |
@@ -27,6 +27,40 @@ import { FindParams } from "../../../../types/common"
* .then(({ discount_condition }) => {
* console.log(discount_condition.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminGetDiscountCondition } from "medusa-react"
*
* type Props = {
* discountId: string
* discountConditionId: string
* }
*
* const DiscountCondition = ({
* discountId,
* discountConditionId
* }: Props) => {
* const {
* discount_condition,
* isLoading
* } = useAdminGetDiscountCondition(
* discountId,
* discountConditionId
* )
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {discount_condition && (
* <span>{discount_condition.type}</span>
* )}
* </div>
* )
* }
*
* export default DiscountCondition
* - lang: Shell
* label: cURL
* source: |
@@ -26,6 +26,30 @@ import { FindParams } from "../../../../types/common"
* .then(({ discount }) => {
* console.log(discount.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminGetDiscountByCode } from "medusa-react"
*
* type Props = {
* discountCode: string
* }
*
* const Discount = ({ discountCode }: Props) => {
* const { discount, isLoading } = useAdminGetDiscountByCode(
* discountCode
* )
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {discount && <span>{discount.code}</span>}
* </div>
* )
* }
*
* export default Discount
* - lang: Shell
* label: cURL
* source: |
@@ -26,6 +26,30 @@ import { FindParams } from "../../../../types/common"
* .then(({ discount }) => {
* console.log(discount.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDiscount } from "medusa-react"
*
* type Props = {
* discountId: string
* }
*
* const Discount = ({ discountId }: Props) => {
* const { discount, isLoading } = useAdminDiscount(
* discountId
* )
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {discount && <span>{discount.code}</span>}
* </div>
* )
* }
*
* export default Discount
* - lang: Shell
* label: cURL
* source: |
@@ -53,6 +53,33 @@ import { optionalBooleanMapper } from "../../../../utils/validators/is-boolean"
* .then(({ discounts, limit, offset, count }) => {
* console.log(discounts.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDiscounts } from "medusa-react"
*
* const Discounts = () => {
* const { discounts, isLoading } = useAdminDiscounts()
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {discounts && !discounts.length && (
* <span>No customers</span>
* )}
* {discounts && discounts.length > 0 && (
* <ul>
* {discounts.map((discount) => (
* <li key={discount.id}>{discount.code}</li>
* ))}
* </ul>
* )}
* </div>
* )
* }
*
* export default Discounts
* - lang: Shell
* label: cURL
* source: |
@@ -25,6 +25,32 @@ import { EntityManager } from "typeorm"
* .then(({ discount }) => {
* console.log(discount.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDiscountRemoveRegion } from "medusa-react"
*
* type Props = {
* discountId: string
* }
*
* const Discount = ({ discountId }: Props) => {
* const deleteRegion = useAdminDiscountRemoveRegion(discountId)
* // ...
*
* const handleDelete = (regionId: string) => {
* deleteRegion.mutate(regionId, {
* onSuccess: ({ discount }) => {
* console.log(discount.regions)
* }
* })
* }
*
* // ...
* }
*
* export default Discount
* - lang: Shell
* label: cURL
* source: |
@@ -40,6 +40,43 @@ import { FindParams } from "../../../../types/common"
* .then(({ discount }) => {
* console.log(discount.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDiscountUpdateCondition } from "medusa-react"
*
* type Props = {
* discountId: string
* conditionId: string
* }
*
* const DiscountCondition = ({
* discountId,
* conditionId
* }: Props) => {
* const update = useAdminDiscountUpdateCondition(
* discountId,
* conditionId
* )
* // ...
*
* const handleUpdate = (
* products: string[]
* ) => {
* update.mutate({
* products
* }, {
* onSuccess: ({ discount }) => {
* console.log(discount.id)
* }
* })
* }
*
* // ...
* }
*
* export default DiscountCondition
* - lang: Shell
* label: cURL
* source: |
@@ -53,6 +53,30 @@ import { FindParams } from "../../../../types/common"
* .then(({ discount }) => {
* console.log(discount.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminUpdateDiscount } from "medusa-react"
*
* type Props = {
* discountId: string
* }
*
* const Discount = ({ discountId }: Props) => {
* const updateDiscount = useAdminUpdateDiscount(discountId)
* // ...
*
* const handleUpdate = (isDisabled: boolean) => {
* updateDiscount.mutate({
* is_disabled: isDisabled,
* })
* }
*
* // ...
* }
*
* export default Discount
* - lang: Shell
* label: cURL
* source: |
@@ -111,6 +135,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminPostDiscountsDiscountReq
* type: object
* description: "The details of the discount to update."
* properties:
* code:
* type: string
@@ -64,6 +64,41 @@ import { cleanResponseData } from "../../../../utils/clean-response-data"
* .then(({ draft_order }) => {
* console.log(draft_order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCreateDraftOrder } from "medusa-react"
*
* type DraftOrderData = {
* email: string
* region_id: string
* items: {
* quantity: number,
* variant_id: string
* }[]
* shipping_methods: {
* option_id: string
* price: number
* }[]
* }
*
* const CreateDraftOrder = () => {
* const createDraftOrder = useAdminCreateDraftOrder()
* // ...
*
* const handleCreate = (data: DraftOrderData) => {
* createDraftOrder.mutate(data, {
* onSuccess: ({ draft_order }) => {
* console.log(draft_order.id)
* }
* })
* }
*
* // ...
* }
*
* export default CreateDraftOrder
* - lang: Shell
* label: cURL
* source: |
@@ -167,6 +202,7 @@ enum Status {
/**
* @schema AdminPostDraftOrdersReq
* type: object
* description: "The details of the draft order to create."
* required:
* - email
* - region_id
@@ -49,6 +49,36 @@ import { validator } from "../../../../utils/validator"
* .then(({ draft_order }) => {
* console.log(draft_order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDraftOrderAddLineItem } from "medusa-react"
*
* type Props = {
* draftOrderId: string
* }
*
* const DraftOrder = ({ draftOrderId }: Props) => {
* const addLineItem = useAdminDraftOrderAddLineItem(
* draftOrderId
* )
* // ...
*
* const handleAdd = (quantity: number) => {
* addLineItem.mutate({
* quantity,
* }, {
* onSuccess: ({ draft_order }) => {
* console.log(draft_order.cart)
* }
* })
* }
*
* // ...
* }
*
* export default DraftOrder
* - lang: Shell
* label: cURL
* source: |
@@ -161,6 +191,7 @@ export default async (req, res) => {
/**
* @schema AdminPostDraftOrdersDraftOrderLineItemsReq
* type: object
* description: "The details of the line item to create."
* required:
* - quantity
* properties:
@@ -22,6 +22,34 @@ import { EntityManager } from "typeorm"
* .then(({ id, object, deleted }) => {
* console.log(id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDeleteDraftOrder } from "medusa-react"
*
* type Props = {
* draftOrderId: string
* }
*
* const DraftOrder = ({ draftOrderId }: Props) => {
* const deleteDraftOrder = useAdminDeleteDraftOrder(
* draftOrderId
* )
* // ...
*
* const handleDelete = () => {
* deleteDraftOrder.mutate(void 0, {
* onSuccess: ({ id, object, deleted }) => {
* console.log(id)
* }
* })
* }
*
* // ...
* }
*
* export default DraftOrder
* - lang: Shell
* label: cURL
* source: |
@@ -32,6 +32,34 @@ import { cleanResponseData } from "../../../../utils/clean-response-data"
* .then(({ draft_order }) => {
* console.log(draft_order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDraftOrderRemoveLineItem } from "medusa-react"
*
* type Props = {
* draftOrderId: string
* }
*
* const DraftOrder = ({ draftOrderId }: Props) => {
* const deleteLineItem = useAdminDraftOrderRemoveLineItem(
* draftOrderId
* )
* // ...
*
* const handleDelete = (itemId: string) => {
* deleteLineItem.mutate(itemId, {
* onSuccess: ({ draft_order }) => {
* console.log(draft_order.cart)
* }
* })
* }
*
* // ...
* }
*
* export default DraftOrder
* - lang: Shell
* label: cURL
* source: |
@@ -30,6 +30,32 @@ import { cleanResponseData } from "../../../../utils/clean-response-data"
* .then(({ draft_order }) => {
* console.log(draft_order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDraftOrder } from "medusa-react"
*
* type Props = {
* draftOrderId: string
* }
*
* const DraftOrder = ({ draftOrderId }: Props) => {
* const {
* draft_order,
* isLoading,
* } = useAdminDraftOrder(draftOrderId)
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {draft_order && <span>{draft_order.display_id}</span>}
*
* </div>
* )
* }
*
* export default DraftOrder
* - lang: Shell
* label: cURL
* source: |
@@ -35,6 +35,33 @@ import { validator } from "../../../../utils/validator"
* .then(({ draft_orders, limit, offset, count }) => {
* console.log(draft_orders.length);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDraftOrders } from "medusa-react"
*
* const DraftOrders = () => {
* const { draft_orders, isLoading } = useAdminDraftOrders()
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {draft_orders && !draft_orders.length && (
* <span>No Draft Orders</span>
* )}
* {draft_orders && draft_orders.length > 0 && (
* <ul>
* {draft_orders.map((order) => (
* <li key={order.id}>{order.display_id}</li>
* ))}
* </ul>
* )}
* </div>
* )
* }
*
* export default DraftOrders
* - lang: Shell
* label: cURL
* source: |
@@ -38,6 +38,34 @@ import { promiseAll } from "@medusajs/utils"
* .then(({ order }) => {
* console.log(order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDraftOrderRegisterPayment } from "medusa-react"
*
* type Props = {
* draftOrderId: string
* }
*
* const DraftOrder = ({ draftOrderId }: Props) => {
* const registerPayment = useAdminDraftOrderRegisterPayment(
* draftOrderId
* )
* // ...
*
* const handlePayment = () => {
* registerPayment.mutate(void 0, {
* onSuccess: ({ order }) => {
* console.log(order.id)
* }
* })
* }
*
* // ...
* }
*
* export default DraftOrder
* - lang: Shell
* label: cURL
* source: |
@@ -49,6 +49,36 @@ import { cleanResponseData } from "../../../../utils/clean-response-data"
* .then(({ draft_order }) => {
* console.log(draft_order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminUpdateDraftOrder } from "medusa-react"
*
* type Props = {
* draftOrderId: string
* }
*
* const DraftOrder = ({ draftOrderId }: Props) => {
* const updateDraftOrder = useAdminUpdateDraftOrder(
* draftOrderId
* )
* // ...
*
* const handleUpdate = (email: string) => {
* updateDraftOrder.mutate({
* email,
* }, {
* onSuccess: ({ draft_order }) => {
* console.log(draft_order.id)
* }
* })
* }
*
* // ...
* }
*
* export default DraftOrder
* - lang: Shell
* label: cURL
* source: |
@@ -145,6 +175,7 @@ export default async (req, res) => {
/**
* @schema AdminPostDraftOrdersDraftOrderReq
* type: object
* description: "The details of the draft order to update."
* properties:
* region_id:
* type: string
@@ -42,6 +42,36 @@ import { cleanResponseData } from "../../../../utils/clean-response-data"
* .then(({ draft_order }) => {
* console.log(draft_order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDraftOrderUpdateLineItem } from "medusa-react"
*
* type Props = {
* draftOrderId: string
* }
*
* const DraftOrder = ({ draftOrderId }: Props) => {
* const updateLineItem = useAdminDraftOrderUpdateLineItem(
* draftOrderId
* )
* // ...
*
* const handleUpdate = (
* itemId: string,
* quantity: number
* ) => {
* updateLineItem.mutate({
* item_id: itemId,
* quantity,
* })
* }
*
* // ...
* }
*
* export default DraftOrder
* - lang: Shell
* label: cURL
* source: |
@@ -150,6 +180,7 @@ export default async (req, res) => {
/**
* @schema AdminPostDraftOrdersDraftOrderLineItemsItemReq
* type: object
* description: "The details to update of the line item."
* properties:
* unit_price:
* description: The custom price of the line item. If a `variant_id` is supplied, the price provided here will override the variant's price.
@@ -31,6 +31,34 @@ import { EntityManager } from "typeorm"
* .then(({ gift_card }) => {
* console.log(gift_card.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCreateGiftCard } from "medusa-react"
*
* const CreateCustomGiftCards = () => {
* const createGiftCard = useAdminCreateGiftCard()
* // ...
*
* const handleCreate = (
* regionId: string,
* value: number
* ) => {
* createGiftCard.mutate({
* region_id: regionId,
* value,
* }, {
* onSuccess: ({ gift_card }) => {
* console.log(gift_card.id)
* }
* })
* }
*
* // ...
* }
*
* export default CreateCustomGiftCards
* - lang: Shell
* label: cURL
* source: |
@@ -90,6 +118,7 @@ export default async (req, res) => {
/**
* @schema AdminPostGiftCardsReq
* type: object
* description: "The details of the gift card to create."
* required:
* - region_id
* properties:
@@ -21,6 +21,34 @@ import { EntityManager } from "typeorm"
* .then(({ id, object, deleted }) => {
* console.log(id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDeleteGiftCard } from "medusa-react"
*
* type Props = {
* customGiftCardId: string
* }
*
* const CustomGiftCard = ({ customGiftCardId }: Props) => {
* const deleteGiftCard = useAdminDeleteGiftCard(
* customGiftCardId
* )
* // ...
*
* const handleDelete = () => {
* deleteGiftCard.mutate(void 0, {
* onSuccess: ({ id, object, deleted}) => {
* console.log(id)
* }
* })
* }
*
* // ...
* }
*
* export default CustomGiftCard
* - lang: Shell
* label: cURL
* source: |
@@ -21,6 +21,28 @@ import { defaultAdminGiftCardFields, defaultAdminGiftCardRelations } from "./"
* .then(({ gift_card }) => {
* console.log(gift_card.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminGiftCard } from "medusa-react"
*
* type Props = {
* giftCardId: string
* }
*
* const CustomGiftCard = ({ giftCardId }: Props) => {
* const { gift_card, isLoading } = useAdminGiftCard(giftCardId)
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {gift_card && <span>{gift_card.code}</span>}
* </div>
* )
* }
*
* export default CustomGiftCard
* - lang: Shell
* label: cURL
* source: |
@@ -30,6 +30,34 @@ import { isDefined } from "medusa-core-utils"
* .then(({ gift_cards, limit, offset, count }) => {
* console.log(gift_cards.length);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { GiftCard } from "@medusajs/medusa"
* import { useAdminGiftCards } from "medusa-react"
*
* const CustomGiftCards = () => {
* const { gift_cards, isLoading } = useAdminGiftCards()
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {gift_cards && !gift_cards.length && (
* <span>No custom gift cards...</span>
* )}
* {gift_cards && gift_cards.length > 0 && (
* <ul>
* {gift_cards.map((giftCard: GiftCard) => (
* <li key={giftCard.id}>{giftCard.code}</li>
* ))}
* </ul>
* )}
* </div>
* )
* }
*
* export default CustomGiftCards
* - lang: Shell
* label: cURL
* source: |
@@ -34,6 +34,36 @@ import { validator } from "../../../../utils/validator"
* .then(({ gift_card }) => {
* console.log(gift_card.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminUpdateGiftCard } from "medusa-react"
*
* type Props = {
* customGiftCardId: string
* }
*
* const CustomGiftCard = ({ customGiftCardId }: Props) => {
* const updateGiftCard = useAdminUpdateGiftCard(
* customGiftCardId
* )
* // ...
*
* const handleUpdate = (regionId: string) => {
* updateGiftCard.mutate({
* region_id: regionId,
* }, {
* onSuccess: ({ gift_card }) => {
* console.log(gift_card.id)
* }
* })
* }
*
* // ...
* }
*
* export default CustomGiftCard
* - lang: Shell
* label: cURL
* source: |
@@ -94,6 +124,7 @@ export default async (req, res) => {
/**
* @schema AdminPostGiftCardsGiftCardReq
* type: object
* description: "The details to update of the gift card."
* properties:
* balance:
* type: integer
@@ -43,6 +43,30 @@ import { FindParams } from "../../../../types/common"
* .then(({ inventory_item }) => {
* console.log(inventory_item.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCreateInventoryItem } from "medusa-react"
*
* const CreateInventoryItem = () => {
* const createInventoryItem = useAdminCreateInventoryItem()
* // ...
*
* const handleCreate = (variantId: string) => {
* createInventoryItem.mutate({
* variant_id: variantId,
* }, {
* onSuccess: ({ inventory_item }) => {
* console.log(inventory_item.id)
* }
* })
* }
*
* // ...
* }
*
* export default CreateInventoryItem
* - lang: Shell
* label: cURL
* source: |
@@ -185,6 +209,7 @@ function generateAttachInventoryToVariantHandler(
/**
* @schema AdminPostInventoryItemsReq
* type: object
* description: "The details of the inventory item to create."
* required:
* - variant_id
* properties:
@@ -35,6 +35,40 @@ import { FindParams } from "../../../../types/common"
* .then(({ inventory_item }) => {
* console.log(inventory_item.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCreateLocationLevel } from "medusa-react"
*
* type Props = {
* inventoryItemId: string
* }
*
* const InventoryItem = ({ inventoryItemId }: Props) => {
* const createLocationLevel = useAdminCreateLocationLevel(
* inventoryItemId
* )
* // ...
*
* const handleCreateLocationLevel = (
* locationId: string,
* stockedQuantity: number
* ) => {
* createLocationLevel.mutate({
* location_id: locationId,
* stocked_quantity: stockedQuantity,
* }, {
* onSuccess: ({ inventory_item }) => {
* console.log(inventory_item.id)
* }
* })
* }
*
* // ...
* }
*
* export default InventoryItem
* - lang: Shell
* label: cURL
* source: |
@@ -107,6 +141,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminPostInventoryItemsItemLocationLevelsReq
* type: object
* description: "The details of the location level to create."
* required:
* - location_id
* - stocked_quantity
@@ -24,6 +24,30 @@ import { ProductVariantInventoryService } from "../../../../services"
* .then(({ id, object, deleted }) => {
* console.log(id)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDeleteInventoryItem } from "medusa-react"
*
* type Props = {
* inventoryItemId: string
* }
*
* const InventoryItem = ({ inventoryItemId }: Props) => {
* const deleteInventoryItem = useAdminDeleteInventoryItem(
* inventoryItemId
* )
* // ...
*
* const handleDelete = () => {
* deleteInventoryItem.mutate()
* }
*
* // ...
* }
*
* export default InventoryItem
* - lang: Shell
* label: cURL
* source: |
@@ -25,6 +25,32 @@ import { EntityManager } from "typeorm"
* .then(({ inventory_item }) => {
* console.log(inventory_item.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDeleteLocationLevel } from "medusa-react"
*
* type Props = {
* inventoryItemId: string
* }
*
* const InventoryItem = ({ inventoryItemId }: Props) => {
* const deleteLocationLevel = useAdminDeleteLocationLevel(
* inventoryItemId
* )
* // ...
*
* const handleDelete = (
* locationId: string
* ) => {
* deleteLocationLevel.mutate(locationId)
* }
*
* // ...
* }
*
* export default InventoryItem
* - lang: Shell
* label: cURL
* source: |
@@ -27,6 +27,33 @@ import { joinLevels } from "./utils/join-levels"
* .then(({ inventory_item }) => {
* console.log(inventory_item.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminInventoryItem } from "medusa-react"
*
* type Props = {
* inventoryItemId: string
* }
*
* const InventoryItem = ({ inventoryItemId }: Props) => {
* const {
* inventory_item,
* isLoading
* } = useAdminInventoryItem(inventoryItemId)
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {inventory_item && (
* <span>{inventory_item.sku}</span>
* )}
* </div>
* )
* }
*
* export default InventoryItem
* - lang: Shell
* label: cURL
* source: |
@@ -77,6 +77,38 @@ import { Transform } from "class-transformer"
* .then(({ inventory_items, count, offset, limit }) => {
* console.log(inventory_items.length);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminInventoryItems } from "medusa-react"
*
* function InventoryItems() {
* const {
* inventory_items,
* isLoading
* } = useAdminInventoryItems()
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {inventory_items && !inventory_items.length && (
* <span>No Items</span>
* )}
* {inventory_items && inventory_items.length > 0 && (
* <ul>
* {inventory_items.map(
* (item) => (
* <li key={item.id}>{item.id}</li>
* )
* )}
* </ul>
* )}
* </div>
* )
* }
*
* export default InventoryItems
* - lang: Shell
* label: cURL
* source: |
@@ -38,6 +38,39 @@ import { IsType } from "../../../../utils/validators/is-type"
* .then(({ inventory_item }) => {
* console.log(inventory_item.location_levels);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import {
* useAdminInventoryItemLocationLevels,
* } from "medusa-react"
*
* type Props = {
* inventoryItemId: string
* }
*
* const InventoryItem = ({ inventoryItemId }: Props) => {
* const {
* inventory_item,
* isLoading,
* } = useAdminInventoryItemLocationLevels(inventoryItemId)
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {inventory_item && (
* <ul>
* {inventory_item.location_levels.map((level) => (
* <span key={level.id}>{level.stocked_quantity}</span>
* ))}
* </ul>
* )}
* </div>
* )
* }
*
* export default InventoryItem
* - lang: Shell
* label: cURL
* source: |
@@ -36,6 +36,36 @@ import { IInventoryService } from "@medusajs/types"
* .then(({ inventory_item }) => {
* console.log(inventory_item.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminUpdateInventoryItem } from "medusa-react"
*
* type Props = {
* inventoryItemId: string
* }
*
* const InventoryItem = ({ inventoryItemId }: Props) => {
* const updateInventoryItem = useAdminUpdateInventoryItem(
* inventoryItemId
* )
* // ...
*
* const handleUpdate = (origin_country: string) => {
* updateInventoryItem.mutate({
* origin_country,
* }, {
* onSuccess: ({ inventory_item }) => {
* console.log(inventory_item.origin_country)
* }
* })
* }
*
* // ...
* }
*
* export default InventoryItem
* - lang: Shell
* label: cURL
* source: |
@@ -36,6 +36,40 @@ import { FindParams } from "../../../../types/common"
* .then(({ inventory_item }) => {
* console.log(inventory_item.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminUpdateLocationLevel } from "medusa-react"
*
* type Props = {
* inventoryItemId: string
* }
*
* const InventoryItem = ({ inventoryItemId }: Props) => {
* const updateLocationLevel = useAdminUpdateLocationLevel(
* inventoryItemId
* )
* // ...
*
* const handleUpdate = (
* stockLocationId: string,
* stocked_quantity: number
* ) => {
* updateLocationLevel.mutate({
* stockLocationId,
* stocked_quantity,
* }, {
* onSuccess: ({ inventory_item }) => {
* console.log(inventory_item.id)
* }
* })
* }
*
* // ...
* }
*
* export default InventoryItem
* - lang: Shell
* label: cURL
* source: |
@@ -44,6 +44,40 @@ import { EntityManager } from "typeorm"
* .catch(() => {
* // an error occurred
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminAcceptInvite } from "medusa-react"
*
* const AcceptInvite = () => {
* const acceptInvite = useAdminAcceptInvite()
* // ...
*
* const handleAccept = (
* token: string,
* firstName: string,
* lastName: string,
* password: string
* ) => {
* acceptInvite.mutate({
* token,
* user: {
* first_name: firstName,
* last_name: lastName,
* password,
* },
* }, {
* onSuccess: () => {
* // invite accepted successfully.
* }
* })
* }
*
* // ...
* }
*
* export default AcceptInvite
* - lang: Shell
* label: cURL
* source: |
@@ -22,6 +22,32 @@ import InviteService from "../../../../services/invite"
* .then(({ id, object, deleted }) => {
* console.log(id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDeleteInvite } from "medusa-react"
*
* type Props = {
* inviteId: string
* }
*
* const DeleteInvite = ({ inviteId }: Props) => {
* const deleteInvite = useAdminDeleteInvite(inviteId)
* // ...
*
* const handleDelete = () => {
* deleteInvite.mutate(void 0, {
* onSuccess: ({ id, object, deleted }) => {
* console.log(id)
* }
* })
* }
*
* // ...
* }
*
* export default Invite
* - lang: Shell
* label: cURL
* source: |
@@ -26,6 +26,32 @@ import { EntityManager } from "typeorm"
* .catch(() => {
* // an error occurred
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminResendInvite } from "medusa-react"
*
* type Props = {
* inviteId: string
* }
*
* const ResendInvite = ({ inviteId }: Props) => {
* const resendInvite = useAdminResendInvite(inviteId)
* // ...
*
* const handleResend = () => {
* resendInvite.mutate(void 0, {
* onSuccess: () => {
* // invite resent successfully
* }
* })
* }
*
* // ...
* }
*
* export default ResendInvite
* - lang: Shell
* label: cURL
* source: |
@@ -32,6 +32,32 @@ import { EntityManager } from "typeorm"
* .then(({ note }) => {
* console.log(note.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCreateNote } from "medusa-react"
*
* const CreateNote = () => {
* const createNote = useAdminCreateNote()
* // ...
*
* const handleCreate = () => {
* createNote.mutate({
* resource_id: "order_123",
* resource_type: "order",
* value: "We delivered this order"
* }, {
* onSuccess: ({ note }) => {
* console.log(note.id)
* }
* })
* }
*
* // ...
* }
*
* export default CreateNote
* - lang: Shell
* label: cURL
* source: |
@@ -93,6 +119,7 @@ export default async (req, res) => {
/**
* @schema AdminPostNotesReq
* type: object
* description: "The details of the note to be created."
* required:
* - resource_id
* - resource_type
@@ -22,6 +22,28 @@ import NoteService from "../../../../services/note"
* .then(({ id, object, deleted }) => {
* console.log(id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDeleteNote } from "medusa-react"
*
* type Props = {
* noteId: string
* }
*
* const Note = ({ noteId }: Props) => {
* const deleteNote = useAdminDeleteNote(noteId)
* // ...
*
* const handleDelete = () => {
* deleteNote.mutate()
* }
*
* // ...
* }
*
* export default Note
* - lang: Shell
* label: cURL
* source: |
@@ -21,6 +21,28 @@ import NoteService from "../../../../services/note"
* .then(({ note }) => {
* console.log(note.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminNote } from "medusa-react"
*
* type Props = {
* noteId: string
* }
*
* const Note = ({ noteId }: Props) => {
* const { note, isLoading } = useAdminNote(noteId)
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {note && <span>{note.resource_type}</span>}
* </div>
* )
* }
*
* export default Note
* - lang: Shell
* label: cURL
* source: |
@@ -29,6 +29,31 @@ import { validator } from "../../../../utils/validator"
* .then(({ notes, limit, offset, count }) => {
* console.log(notes.length);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminNotes } from "medusa-react"
*
* const Notes = () => {
* const { notes, isLoading } = useAdminNotes()
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {notes && !notes.length && <span>No Notes</span>}
* {notes && notes.length > 0 && (
* <ul>
* {notes.map((note) => (
* <li key={note.id}>{note.resource_type}</li>
* ))}
* </ul>
* )}
* </div>
* )
* }
*
* export default Notes
* - lang: Shell
* label: cURL
* source: |
@@ -31,6 +31,36 @@ import { EntityManager } from "typeorm"
* .then(({ note }) => {
* console.log(note.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminUpdateNote } from "medusa-react"
*
* type Props = {
* noteId: string
* }
*
* const Note = ({ noteId }: Props) => {
* const updateNote = useAdminUpdateNote(noteId)
* // ...
*
* const handleUpdate = (
* value: string
* ) => {
* updateNote.mutate({
* value
* }, {
* onSuccess: ({ note }) => {
* console.log(note.value)
* }
* })
* }
*
* // ...
* }
*
* export default Note
* - lang: Shell
* label: cURL
* source: |
@@ -85,6 +115,7 @@ export default async (req, res) => {
/**
* @schema AdminPostNotesNoteReq
* type: object
* description: "The details to update of the note."
* required:
* - value
* properties:
@@ -41,6 +41,33 @@ import { validator } from "../../../../utils/validator"
* .then(({ notifications }) => {
* console.log(notifications.length);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminNotifications } from "medusa-react"
*
* const Notifications = () => {
* const { notifications, isLoading } = useAdminNotifications()
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {notifications && !notifications.length && (
* <span>No Notifications</span>
* )}
* {notifications && notifications.length > 0 && (
* <ul>
* {notifications.map((notification) => (
* <li key={notification.id}>{notification.to}</li>
* ))}
* </ul>
* )}
* </div>
* )
* }
*
* export default Notifications
* - lang: Shell
* label: cURL
* source: |
@@ -35,6 +35,34 @@ import { validator } from "../../../../utils/validator"
* .then(({ notification }) => {
* console.log(notification.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminResendNotification } from "medusa-react"
*
* type Props = {
* notificationId: string
* }
*
* const Notification = ({ notificationId }: Props) => {
* const resendNotification = useAdminResendNotification(
* notificationId
* )
* // ...
*
* const handleResend = () => {
* resendNotification.mutate({}, {
* onSuccess: ({ notification }) => {
* console.log(notification.id)
* }
* })
* }
*
* // ...
* }
*
* export default Notification
* - lang: Shell
* label: cURL
* source: |
@@ -102,6 +130,7 @@ export default async (req, res) => {
/**
* @schema AdminPostNotificationsNotificationResendReq
* type: object
* description: "The resend details."
* properties:
* to:
* description: >-
@@ -38,6 +38,37 @@ import {
* .then(({ order_edit }) => {
* console.log(order_edit.id)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminOrderEditAddLineItem } from "medusa-react"
*
* type Props = {
* orderEditId: string
* }
*
* const OrderEdit = ({ orderEditId }: Props) => {
* const addLineItem = useAdminOrderEditAddLineItem(
* orderEditId
* )
*
* const handleAddLineItem =
* (quantity: number, variantId: string) => {
* addLineItem.mutate({
* quantity,
* variant_id: variantId,
* }, {
* onSuccess: ({ order_edit }) => {
* console.log(order_edit.changes)
* }
* })
* }
*
* // ...
* }
*
* export default OrderEdit
* - lang: Shell
* label: cURL
* source: |
@@ -103,6 +134,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminPostOrderEditsEditLineItemsReq
* type: object
* description: "The details of the line item change to create."
* required:
* - variant_id
* - quantity
@@ -27,6 +27,38 @@ import {
* .then(({ order_edit }) => {
* console.log(order_edit.id)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import {
* useAdminCancelOrderEdit
* } from "medusa-react"
*
* type Props = {
* orderEditId: string
* }
*
* const OrderEdit = ({ orderEditId }: Props) => {
* const cancelOrderEdit =
* useAdminCancelOrderEdit(
* orderEditId
* )
*
* const handleCancel = () => {
* cancelOrderEdit.mutate(void 0, {
* onSuccess: ({ order_edit }) => {
* console.log(
* order_edit.id
* )
* }
* })
* }
*
* // ...
* }
*
* export default OrderEdit
* - lang: Shell
* label: cURL
* source: |
@@ -27,6 +27,36 @@ import {
* .then(({ order_edit }) => {
* console.log(order_edit.id)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminConfirmOrderEdit } from "medusa-react"
*
* type Props = {
* orderEditId: string
* }
*
* const OrderEdit = ({ orderEditId }: Props) => {
* const confirmOrderEdit = useAdminConfirmOrderEdit(
* orderEditId
* )
*
* const handleConfirmOrderEdit = () => {
* confirmOrderEdit.mutate(void 0, {
* onSuccess: ({ order_edit }) => {
* console.log(
* order_edit.confirmed_at,
* order_edit.confirmed_by
* )
* }
* })
* }
*
* // ...
* }
*
* export default OrderEdit
* - lang: Shell
* label: cURL
* source: |
@@ -31,6 +31,29 @@ import {
* .then(({ order_edit }) => {
* console.log(order_edit.id)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCreateOrderEdit } from "medusa-react"
*
* const CreateOrderEdit = () => {
* const createOrderEdit = useAdminCreateOrderEdit()
*
* const handleCreateOrderEdit = (orderId: string) => {
* createOrderEdit.mutate({
* order_id: orderId,
* }, {
* onSuccess: ({ order_edit }) => {
* console.log(order_edit.id)
* }
* })
* }
*
* // ...
* }
*
* export default CreateOrderEdit
* - lang: Shell
* label: cURL
* source: |
@@ -93,6 +116,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminPostOrderEditsReq
* type: object
* description: "The details of the order edit to create."
* required:
* - order_id
* properties:
@@ -29,6 +29,38 @@ import {
* .then(({ order_edit }) => {
* console.log(order_edit.id)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminOrderEditDeleteLineItem } from "medusa-react"
*
* type Props = {
* orderEditId: string
* itemId: string
* }
*
* const OrderEditLineItem = ({
* orderEditId,
* itemId
* }: Props) => {
* const removeLineItem = useAdminOrderEditDeleteLineItem(
* orderEditId,
* itemId
* )
*
* const handleRemoveLineItem = () => {
* removeLineItem.mutate(void 0, {
* onSuccess: ({ order_edit }) => {
* console.log(order_edit.changes)
* }
* })
* }
*
* // ...
* }
*
* export default OrderEditLineItem
* - lang: Shell
* label: cURL
* source: |
@@ -23,6 +23,38 @@ import { OrderEditService } from "../../../../services"
* .then(({ id, object, deleted }) => {
* console.log(id)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDeleteOrderEditItemChange } from "medusa-react"
*
* type Props = {
* orderEditId: string
* itemChangeId: string
* }
*
* const OrderEditItemChange = ({
* orderEditId,
* itemChangeId
* }: Props) => {
* const deleteItemChange = useAdminDeleteOrderEditItemChange(
* orderEditId,
* itemChangeId
* )
*
* const handleDeleteItemChange = () => {
* deleteItemChange.mutate(void 0, {
* onSuccess: ({ id, object, deleted }) => {
* console.log(id)
* }
* })
* }
*
* // ...
* }
*
* export default OrderEditItemChange
* - lang: Shell
* label: cURL
* source: |
@@ -22,6 +22,33 @@ import { OrderEditService } from "../../../../services"
* .then(({ id, object, deleted }) => {
* console.log(id)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminDeleteOrderEdit } from "medusa-react"
*
* type Props = {
* orderEditId: string
* }
*
* const OrderEdit = ({ orderEditId }: Props) => {
* const deleteOrderEdit = useAdminDeleteOrderEdit(
* orderEditId
* )
*
* const handleDelete = () => {
* deleteOrderEdit.mutate(void 0, {
* onSuccess: ({ id, object, deleted }) => {
* console.log(id)
* }
* })
* }
*
* // ...
* }
*
* export default OrderEdit
* - lang: Shell
* label: cURL
* source: |
@@ -26,6 +26,31 @@ import { FindParams } from "../../../../types/common"
* .then(({ order_edit }) => {
* console.log(order_edit.id)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminOrderEdit } from "medusa-react"
*
* type Props = {
* orderEditId: string
* }
*
* const OrderEdit = ({ orderEditId }: Props) => {
* const {
* order_edit,
* isLoading,
* } = useAdminOrderEdit(orderEditId)
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {order_edit && <span>{order_edit.status}</span>}
* </div>
* )
* }
*
* export default OrderEdit
* - lang: Shell
* label: cURL
* source: |
@@ -30,6 +30,35 @@ import { IsOptional, IsString } from "class-validator"
* .then(({ order_edits, count, limit, offset }) => {
* console.log(order_edits.length)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminOrderEdits } from "medusa-react"
*
* const OrderEdits = () => {
* const { order_edits, isLoading } = useAdminOrderEdits()
*
* return (
* <div>
* {isLoading && <span>Loading...</span>}
* {order_edits && !order_edits.length && (
* <span>No Order Edits</span>
* )}
* {order_edits && order_edits.length > 0 && (
* <ul>
* {order_edits.map((orderEdit) => (
* <li key={orderEdit.id}>
* {orderEdit.status}
* </li>
* ))}
* </ul>
* )}
* </div>
* )
* }
*
* export default OrderEdits
* - lang: Shell
* label: cURL
* source: |
@@ -33,6 +33,39 @@ import {
* .then({ order_edit }) => {
* console.log(order_edit.id)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import {
* useAdminRequestOrderEditConfirmation,
* } from "medusa-react"
*
* type Props = {
* orderEditId: string
* }
*
* const OrderEdit = ({ orderEditId }: Props) => {
* const requestOrderConfirmation =
* useAdminRequestOrderEditConfirmation(
* orderEditId
* )
*
* const handleRequestConfirmation = () => {
* requestOrderConfirmation.mutate(void 0, {
* onSuccess: ({ order_edit }) => {
* console.log(
* order_edit.requested_at,
* order_edit.requested_by
* )
* }
* })
* }
*
* // ...
* }
*
* export default OrderEdit
* - lang: Shell
* label: cURL
* source: |
@@ -37,6 +37,40 @@ import {
* .then(({ order_edit }) => {
* console.log(order_edit.id)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminOrderEditUpdateLineItem } from "medusa-react"
*
* type Props = {
* orderEditId: string
* itemId: string
* }
*
* const OrderEditItemChange = ({
* orderEditId,
* itemId
* }: Props) => {
* const updateLineItem = useAdminOrderEditUpdateLineItem(
* orderEditId,
* itemId
* )
*
* const handleUpdateLineItem = (quantity: number) => {
* updateLineItem.mutate({
* quantity,
* }, {
* onSuccess: ({ order_edit }) => {
* console.log(order_edit.items)
* }
* })
* }
*
* // ...
* }
*
* export default OrderEditItemChange
* - lang: Shell
* label: cURL
* source: |
@@ -106,6 +140,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminPostOrderEditsEditLineItemsLineItemReq
* type: object
* description: "The details to create or update of the line item change."
* required:
* - quantity
* properties:
@@ -36,6 +36,37 @@ import {
* .then(({ order_edit }) => {
* console.log(order_edit.id)
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminUpdateOrderEdit } from "medusa-react"
*
* type Props = {
* orderEditId: string
* }
*
* const OrderEdit = ({ orderEditId }: Props) => {
* const updateOrderEdit = useAdminUpdateOrderEdit(
* orderEditId,
* )
*
* const handleUpdate = (
* internalNote: string
* ) => {
* updateOrderEdit.mutate({
* internal_note: internalNote
* }, {
* onSuccess: ({ order_edit }) => {
* console.log(order_edit.internal_note)
* }
* })
* }
*
* // ...
* }
*
* export default OrderEdit
* - lang: Shell
* label: cURL
* source: |
@@ -102,6 +133,7 @@ export default async (req: Request, res: Response) => {
/**
* @schema AdminPostOrderEditsOrderEditReq
* type: object
* description: "The details to update of the order edit."
* properties:
* internal_note:
* description: An optional note to create or update in the order edit.
@@ -43,6 +43,40 @@ import { cleanResponseData } from "../../../../utils/clean-response-data"
* .then(({ order }) => {
* console.log(order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminAddShippingMethod } from "medusa-react"
*
* type Props = {
* orderId: string
* }
*
* const Order = ({ orderId }: Props) => {
* const addShippingMethod = useAdminAddShippingMethod(
* orderId
* )
* // ...
*
* const handleAddShippingMethod = (
* optionId: string,
* price: number
* ) => {
* addShippingMethod.mutate({
* option_id: optionId,
* price
* }, {
* onSuccess: ({ order }) => {
* console.log(order.shipping_methods)
* }
* })
* }
*
* // ...
* }
*
* export default Order
* - lang: Shell
* label: cURL
* source: |
@@ -27,6 +27,34 @@ import { cleanResponseData } from "../../../../utils/clean-response-data"
* .then(({ order }) => {
* console.log(order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminArchiveOrder } from "medusa-react"
*
* type Props = {
* orderId: string
* }
*
* const Order = ({ orderId }: Props) => {
* const archiveOrder = useAdminArchiveOrder(
* orderId
* )
* // ...
*
* const handleArchivingOrder = () => {
* archiveOrder.mutate(void 0, {
* onSuccess: ({ order }) => {
* console.log(order.status)
* }
* })
* }
*
* // ...
* }
*
* export default Order
* - lang: Shell
* label: cURL
* source: |
@@ -33,6 +33,29 @@ import { cleanResponseData } from "../../../../utils/clean-response-data"
* .then(({ order }) => {
* console.log(order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCancelClaim } from "medusa-react"
*
* type Props = {
* orderId: string
* claimId: string
* }
*
* const Claim = ({ orderId, claimId }: Props) => {
* const cancelClaim = useAdminCancelClaim(orderId)
* // ...
*
* const handleCancel = () => {
* cancelClaim.mutate(claimId)
* }
*
* // ...
* }
*
* export default Claim
* - lang: Shell
* label: cURL
* source: |
@@ -35,6 +35,38 @@ import { cleanResponseData } from "../../../../utils/clean-response-data"
* .then(({ order }) => {
* console.log(order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCancelClaimFulfillment } from "medusa-react"
*
* type Props = {
* orderId: string
* claimId: string
* }
*
* const Claim = ({ orderId, claimId }: Props) => {
* const cancelFulfillment = useAdminCancelClaimFulfillment(
* orderId
* )
* // ...
*
* const handleCancel = (fulfillmentId: string) => {
* cancelFulfillment.mutate({
* claim_id: claimId,
* fulfillment_id: fulfillmentId,
* }, {
* onSuccess: ({ order }) => {
* console.log(order.claims)
* }
* })
* }
*
* // ...
* }
*
* export default Claim
* - lang: Shell
* label: cURL
* source: |
@@ -35,6 +35,39 @@ import { cleanResponseData } from "../../../../utils/clean-response-data"
* .then(({ order }) => {
* console.log(order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCancelSwapFulfillment } from "medusa-react"
*
* type Props = {
* orderId: string,
* swapId: string
* }
*
* const Swap = ({
* orderId,
* swapId
* }: Props) => {
* const cancelFulfillment = useAdminCancelSwapFulfillment(
* orderId
* )
* // ...
*
* const handleCancelFulfillment = (
* fulfillmentId: string
* ) => {
* cancelFulfillment.mutate({
* swap_id: swapId,
* fulfillment_id: fulfillmentId,
* })
* }
*
* // ...
* }
*
* export default Swap
* - lang: Shell
* label: cURL
* source: |
@@ -37,6 +37,36 @@ import { promiseAll } from "@medusajs/utils"
* .then(({ order }) => {
* console.log(order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCancelFulfillment } from "medusa-react"
*
* type Props = {
* orderId: string
* }
*
* const Order = ({ orderId }: Props) => {
* const cancelFulfillment = useAdminCancelFulfillment(
* orderId
* )
* // ...
*
* const handleCancel = (
* fulfillmentId: string
* ) => {
* cancelFulfillment.mutate(fulfillmentId, {
* onSuccess: ({ order }) => {
* console.log(order.fulfillments)
* }
* })
* }
*
* // ...
* }
*
* export default Order
* - lang: Shell
* label: cURL
* source: |
@@ -27,6 +27,34 @@ import { cleanResponseData } from "../../../../utils/clean-response-data"
* .then(({ order }) => {
* console.log(order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCancelOrder } from "medusa-react"
*
* type Props = {
* orderId: string
* }
*
* const Order = ({ orderId }: Props) => {
* const cancelOrder = useAdminCancelOrder(
* orderId
* )
* // ...
*
* const handleCancel = () => {
* cancelOrder.mutate(void 0, {
* onSuccess: ({ order }) => {
* console.log(order.status)
* }
* })
* }
*
* // ...
* }
*
* export default Order
* - lang: Shell
* label: cURL
* source: |
@@ -33,6 +33,38 @@ import { cleanResponseData } from "../../../../utils/clean-response-data"
* .then(({ order }) => {
* console.log(order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCancelSwap } from "medusa-react"
*
* type Props = {
* orderId: string,
* swapId: string
* }
*
* const Swap = ({
* orderId,
* swapId
* }: Props) => {
* const cancelSwap = useAdminCancelSwap(
* orderId
* )
* // ...
*
* const handleCancel = () => {
* cancelSwap.mutate(swapId, {
* onSuccess: ({ order }) => {
* console.log(order.swaps)
* }
* })
* }
*
* // ...
* }
*
* export default Swap
* - lang: Shell
* label: cURL
* source: |
@@ -27,6 +27,34 @@ import { cleanResponseData } from "../../../../utils/clean-response-data"
* .then(({ order }) => {
* console.log(order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCapturePayment } from "medusa-react"
*
* type Props = {
* orderId: string
* }
*
* const Order = ({ orderId }: Props) => {
* const capturePayment = useAdminCapturePayment(
* orderId
* )
* // ...
*
* const handleCapture = () => {
* capturePayment.mutate(void 0, {
* onSuccess: ({ order }) => {
* console.log(order.status)
* }
* })
* }
*
* // ...
* }
*
* export default Order
* - lang: Shell
* label: cURL
* source: |
@@ -27,6 +27,34 @@ import { cleanResponseData } from "../../../../utils/clean-response-data"
* .then(({ order }) => {
* console.log(order.id);
* })
* - lang: tsx
* label: Medusa React
* source: |
* import React from "react"
* import { useAdminCompleteOrder } from "medusa-react"
*
* type Props = {
* orderId: string
* }
*
* const Order = ({ orderId }: Props) => {
* const completeOrder = useAdminCompleteOrder(
* orderId
* )
* // ...
*
* const handleComplete = () => {
* completeOrder.mutate(void 0, {
* onSuccess: ({ order }) => {
* console.log(order.status)
* }
* })
* }
*
* // ...
* }
*
* export default Order
* - lang: Shell
* label: cURL
* source: |
Loaded 100 of 2811 files, more files were not shown because too many files have changed in this diff. Show more