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:
@@ -0,0 +1,19 @@
|
||||
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
|
||||
@@ -0,0 +1,15 @@
|
||||
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
|
||||
@@ -0,0 +1,22 @@
|
||||
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
|
||||
@@ -0,0 +1,29 @@
|
||||
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
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
@@ -0,0 +1,19 @@
|
||||
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
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
@@ -0,0 +1,24 @@
|
||||
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
|
||||
@@ -0,0 +1,21 @@
|
||||
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
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
@@ -0,0 +1,19 @@
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
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
|
||||
@@ -0,0 +1,24 @@
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
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
|
||||
@@ -0,0 +1,31 @@
|
||||
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
|
||||
@@ -0,0 +1,17 @@
|
||||
import React from "react"
|
||||
import { useAdminCreateCustomerGroup } from "medusa-react"
|
||||
|
||||
const CreateCustomerGroup = () => {
|
||||
const createCustomerGroup = useAdminCreateCustomerGroup()
|
||||
// ...
|
||||
|
||||
const handleCreate = (name: string) => {
|
||||
createCustomerGroup.mutate({
|
||||
name,
|
||||
})
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
export default CreateCustomerGroup
|
||||
@@ -0,0 +1,21 @@
|
||||
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
|
||||
@@ -0,0 +1,21 @@
|
||||
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
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
@@ -0,0 +1,33 @@
|
||||
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
|
||||
@@ -0,0 +1,30 @@
|
||||
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
|
||||
@@ -0,0 +1,29 @@
|
||||
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
|
||||
@@ -0,0 +1,24 @@
|
||||
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
|
||||
@@ -0,0 +1,26 @@
|
||||
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
|
||||
@@ -0,0 +1,21 @@
|
||||
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
|
||||
@@ -0,0 +1,26 @@
|
||||
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
|
||||
@@ -0,0 +1,24 @@
|
||||
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
|
||||
@@ -0,0 +1,37 @@
|
||||
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
|
||||
@@ -0,0 +1,21 @@
|
||||
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
|
||||
@@ -0,0 +1,30 @@
|
||||
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
|
||||
@@ -0,0 +1,29 @@
|
||||
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
|
||||
@@ -0,0 +1,31 @@
|
||||
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
|
||||
@@ -0,0 +1,34 @@
|
||||
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
|
||||
@@ -0,0 +1,38 @@
|
||||
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
|
||||
@@ -0,0 +1,38 @@
|
||||
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
|
||||
@@ -0,0 +1,15 @@
|
||||
import React from "react"
|
||||
import { useAdminDeleteDiscount } from "medusa-react"
|
||||
|
||||
const Discount = () => {
|
||||
const deleteDiscount = useAdminDeleteDiscount(discount_id)
|
||||
// ...
|
||||
|
||||
const handleDelete = () => {
|
||||
deleteDiscount.mutate()
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
export default Discount
|
||||
@@ -0,0 +1,21 @@
|
||||
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
|
||||
@@ -0,0 +1,21 @@
|
||||
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
|
||||
@@ -0,0 +1,29 @@
|
||||
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
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
@@ -0,0 +1,24 @@
|
||||
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
|
||||
@@ -0,0 +1,32 @@
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
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
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
@@ -0,0 +1,27 @@
|
||||
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
|
||||
@@ -0,0 +1,27 @@
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
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
|
||||
@@ -0,0 +1,27 @@
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
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
|
||||
@@ -0,0 +1,19 @@
|
||||
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
|
||||
@@ -0,0 +1,27 @@
|
||||
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
|
||||
@@ -0,0 +1,29 @@
|
||||
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
|
||||
@@ -0,0 +1,21 @@
|
||||
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
|
||||
@@ -0,0 +1,21 @@
|
||||
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
|
||||
@@ -0,0 +1,24 @@
|
||||
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
|
||||
@@ -0,0 +1,27 @@
|
||||
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
|
||||
@@ -0,0 +1,30 @@
|
||||
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
|
||||
@@ -0,0 +1,31 @@
|
||||
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
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
@@ -0,0 +1,31 @@
|
||||
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
|
||||
@@ -0,0 +1,31 @@
|
||||
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
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
@@ -0,0 +1,22 @@
|
||||
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
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
@@ -0,0 +1,19 @@
|
||||
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
|
||||
@@ -0,0 +1,19 @@
|
||||
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
|
||||
@@ -0,0 +1,27 @@
|
||||
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
|
||||
@@ -0,0 +1,24 @@
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
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
|
||||
@@ -0,0 +1,26 @@
|
||||
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
|
||||
@@ -0,0 +1,20 @@
|
||||
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
|
||||
@@ -0,0 +1,24 @@
|
||||
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
|
||||
@@ -0,0 +1,22 @@
|
||||
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
|
||||
@@ -0,0 +1,28 @@
|
||||
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
|
||||
@@ -0,0 +1,29 @@
|
||||
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
|
||||
@@ -0,0 +1,29 @@
|
||||
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
|
||||
@@ -0,0 +1,27 @@
|
||||
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
|
||||
@@ -0,0 +1,28 @@
|
||||
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
|
||||
@@ -0,0 +1,29 @@
|
||||
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
|
||||
@@ -0,0 +1,31 @@
|
||||
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
|
||||
@@ -0,0 +1,30 @@
|
||||
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
|
||||
@@ -0,0 +1,22 @@
|
||||
import React from "react"
|
||||
import { useAdminOrders } from "medusa-react"
|
||||
|
||||
const Orders = () => {
|
||||
const { orders, isLoading } = useAdminOrders()
|
||||
|
||||
return (
|
||||
<div>
|
||||
{isLoading && <span>Loading...</span>}
|
||||
{orders && !orders.length && <span>No Orders</span>}
|
||||
{orders && orders.length > 0 && (
|
||||
<ul>
|
||||
{orders.map((order) => (
|
||||
<li key={order.id}>{order.display_id}</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Orders
|
||||
@@ -0,0 +1,23 @@
|
||||
import React from "react"
|
||||
import { useAdminOrder } from "medusa-react"
|
||||
|
||||
type Props = {
|
||||
orderId: string
|
||||
}
|
||||
|
||||
const Order = ({ orderId }: Props) => {
|
||||
const {
|
||||
order,
|
||||
isLoading,
|
||||
} = useAdminOrder(orderId)
|
||||
|
||||
return (
|
||||
<div>
|
||||
{isLoading && <span>Loading...</span>}
|
||||
{order && <span>{order.display_id}</span>}
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Order
|
||||
@@ -0,0 +1,28 @@
|
||||
import React from "react"
|
||||
import { useAdminUpdateOrder } from "medusa-react"
|
||||
|
||||
type Props = {
|
||||
orderId: string
|
||||
}
|
||||
|
||||
const Order = ({ orderId }: Props) => {
|
||||
const updateOrder = useAdminUpdateOrder(
|
||||
orderId
|
||||
)
|
||||
|
||||
const handleUpdate = (
|
||||
email: string
|
||||
) => {
|
||||
updateOrder.mutate({
|
||||
email,
|
||||
}, {
|
||||
onSuccess: ({ order }) => {
|
||||
console.log(order.email)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
export default Order
|
||||
@@ -0,0 +1,25 @@
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
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
|
||||
@@ -0,0 +1,33 @@
|
||||
import React from "react"
|
||||
import { useAdminCreateClaim } from "medusa-react"
|
||||
|
||||
type Props = {
|
||||
orderId: string
|
||||
}
|
||||
|
||||
const CreateClaim = ({ orderId }: Props) => {
|
||||
|
||||
const CreateClaim = (orderId: string) => {
|
||||
const createClaim = useAdminCreateClaim(orderId)
|
||||
// ...
|
||||
|
||||
const handleCreate = (itemId: string) => {
|
||||
createClaim.mutate({
|
||||
type: "refund",
|
||||
claim_items: [
|
||||
{
|
||||
item_id: itemId,
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
}, {
|
||||
onSuccess: ({ order }) => {
|
||||
console.log(order.claims)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
export default CreateClaim
|
||||
@@ -0,0 +1,27 @@
|
||||
import React from "react"
|
||||
import { useAdminUpdateClaim } from "medusa-react"
|
||||
|
||||
type Props = {
|
||||
orderId: string
|
||||
claimId: string
|
||||
}
|
||||
|
||||
const Claim = ({ orderId, claimId }: Props) => {
|
||||
const updateClaim = useAdminUpdateClaim(orderId)
|
||||
// ...
|
||||
|
||||
const handleUpdate = () => {
|
||||
updateClaim.mutate({
|
||||
claim_id: claimId,
|
||||
no_notification: false
|
||||
}, {
|
||||
onSuccess: ({ order }) => {
|
||||
console.log(order.claims)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
export default Claim
|
||||
@@ -0,0 +1,20 @@
|
||||
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
|
||||
@@ -0,0 +1,26 @@
|
||||
import React from "react"
|
||||
import { useAdminFulfillClaim } from "medusa-react"
|
||||
|
||||
type Props = {
|
||||
orderId: string
|
||||
claimId: string
|
||||
}
|
||||
|
||||
const Claim = ({ orderId, claimId }: Props) => {
|
||||
const fulfillClaim = useAdminFulfillClaim(orderId)
|
||||
// ...
|
||||
|
||||
const handleFulfill = () => {
|
||||
fulfillClaim.mutate({
|
||||
claim_id: claimId,
|
||||
}, {
|
||||
onSuccess: ({ order }) => {
|
||||
console.log(order.claims)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
export default Claim
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user