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:
@@ -78,7 +78,9 @@ You can list invites by sending a request to the [List Invite API Route](https:/
|
||||
return (
|
||||
<div>
|
||||
{isLoading && <span>Loading...</span>}
|
||||
{invites && !invites.length && <span>No Invites</span>}
|
||||
{invites && !invites.length && (
|
||||
<span>No Invites</span>
|
||||
)}
|
||||
{invites && invites.length > 0 && (
|
||||
<ul>
|
||||
{invites.map((invite) => (
|
||||
@@ -242,13 +244,18 @@ You can accept an invite by sending a request to the [Accept Invite API Route](h
|
||||
const acceptInvite = useAdminAcceptInvite()
|
||||
// ...
|
||||
|
||||
const handleAccept = () => {
|
||||
const handleAccept = (
|
||||
token: string,
|
||||
firstName: string,
|
||||
lastName: string,
|
||||
password: string
|
||||
) => {
|
||||
acceptInvite.mutate({
|
||||
token,
|
||||
user: {
|
||||
first_name: "Brigitte",
|
||||
last_name: "Collier",
|
||||
password: "supersecret",
|
||||
first_name: firstName,
|
||||
last_name: lastName,
|
||||
password,
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -335,7 +342,11 @@ You can resend an invite if it’s not accepted yet. To resend an invite, send a
|
||||
```tsx
|
||||
import { useAdminResendInvite } from "medusa-react"
|
||||
|
||||
const ResendInvite = () => {
|
||||
type Props = {
|
||||
inviteId: string
|
||||
}
|
||||
|
||||
const ResendInvite = ({ inviteId }: Props) => {
|
||||
const resendInvite = useAdminResendInvite(inviteId)
|
||||
// ...
|
||||
|
||||
@@ -400,18 +411,26 @@ You can delete an invite by sending a request to the [Delete Invite API Route](h
|
||||
```tsx
|
||||
import { useAdminDeleteInvite } from "medusa-react"
|
||||
|
||||
const DeleteInvite = () => {
|
||||
type Props = {
|
||||
inviteId: string
|
||||
}
|
||||
|
||||
const DeleteInvite = ({ inviteId }: Props) => {
|
||||
const deleteInvite = useAdminDeleteInvite(inviteId)
|
||||
// ...
|
||||
|
||||
const handleDelete = () => {
|
||||
deleteInvite.mutate()
|
||||
deleteInvite.mutate(void 0, {
|
||||
onSuccess: ({ id, object, deleted }) => {
|
||||
console.log(id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
export default DeleteInvite
|
||||
export default Invite
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
@@ -283,17 +283,24 @@ You can update a user’s details in their profile by sending a request to the [
|
||||
|
||||
```tsx
|
||||
import {
|
||||
useAdminDeleteSession,
|
||||
useAdminUpdateUser,
|
||||
} from "medusa-react"
|
||||
|
||||
const Profile = () => {
|
||||
type Props = {
|
||||
userId: string
|
||||
}
|
||||
|
||||
const Profile = ({ userId }: Props) => {
|
||||
const updateUser = useAdminUpdateUser(userId)
|
||||
// ...
|
||||
|
||||
const handleUpdate = () => {
|
||||
const handleUpdate = (firstName: string) => {
|
||||
updateUser.mutate({
|
||||
first_name: "Marcellus",
|
||||
first_name: firstName,
|
||||
}, {
|
||||
onSuccess: ({ user }) => {
|
||||
console.log(user.first_name)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -384,9 +391,15 @@ You can request a password reset by sending a request to the [Request Password R
|
||||
const requestPasswordReset = useAdminSendResetPasswordToken()
|
||||
// ...
|
||||
|
||||
const handleResetPassword = () => {
|
||||
const handleResetPassword = (
|
||||
email: string
|
||||
) => {
|
||||
requestPasswordReset.mutate({
|
||||
email: "user@example.com",
|
||||
email
|
||||
}, {
|
||||
onSuccess: () => {
|
||||
// successful
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -463,10 +476,17 @@ You can reset the password by sending a request to the [Reset Password API Route
|
||||
const resetPassword = useAdminResetPassword()
|
||||
// ...
|
||||
|
||||
const handleResetPassword = () => {
|
||||
const handleResetPassword = (
|
||||
token: string,
|
||||
password: string
|
||||
) => {
|
||||
resetPassword.mutate({
|
||||
token: "supersecrettoken",
|
||||
password: "supersecret",
|
||||
token,
|
||||
password,
|
||||
}, {
|
||||
onSuccess: ({ user }) => {
|
||||
console.log(user.id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -153,6 +153,10 @@ You can create a user by sending a request to the [Create User API Route](https:
|
||||
createUser.mutate({
|
||||
email: "user@example.com",
|
||||
password: "supersecret",
|
||||
}, {
|
||||
onSuccess: ({ user }) => {
|
||||
console.log(user.id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -232,20 +236,30 @@ You can update a user’s details by sending a request to the [Update User API R
|
||||
```tsx
|
||||
import { useAdminUpdateUser } from "medusa-react"
|
||||
|
||||
const UpdateUser = () => {
|
||||
type Props = {
|
||||
userId: string
|
||||
}
|
||||
|
||||
const User = ({ userId }: Props) => {
|
||||
const updateUser = useAdminUpdateUser(userId)
|
||||
// ...
|
||||
|
||||
const handleUpdateUser = () => {
|
||||
const handleUpdateUser = (
|
||||
firstName: string
|
||||
) => {
|
||||
updateUser.mutate({
|
||||
first_name: "Marcellus",
|
||||
first_name: firstName,
|
||||
}, {
|
||||
onSuccess: ({ user }) => {
|
||||
console.log(user.first_name)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
export default UpdateUser
|
||||
export default User
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -311,18 +325,26 @@ You can delete a user by sending a request to the [Delete User API Route](https:
|
||||
```tsx
|
||||
import { useAdminDeleteUser } from "medusa-react"
|
||||
|
||||
const DeleteUser = () => {
|
||||
type Props = {
|
||||
userId: string
|
||||
}
|
||||
|
||||
const User = ({ userId }: Props) => {
|
||||
const deleteUser = useAdminDeleteUser(userId)
|
||||
// ...
|
||||
|
||||
const handleDeleteUser = () => {
|
||||
deleteUser.mutate()
|
||||
deleteUser.mutate(void 0, {
|
||||
onSuccess: ({ id, object, deleted }) => {
|
||||
console.log(id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
export default DeleteUser
|
||||
export default User
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
Reference in New Issue
Block a user