Broadleaf Microservices
  • v1.0.0-latest-prod

Commerce Quote Hooks

useFetchQuotes

Hook to use to make a request to fetch a list of quotes.

Props

quoteClient

Client for making requests. From @broadleaf/commerce-cart.

searchParam

(Optional) Query param to include in the request in the cq. Filters by Quote name. Type: string.

sort

Sort param to include, e.g., name,asc. Type: string.

fromDate

Date to use as the starting point for filtering quotes by create date. Type: string.

toDate

Date to use as the ending point for filtering quotes by create date. Type: string.

pagination

Additional pagination props. Type: CartPaginationProps.

Response

isFetching

Whether the request is in progress. Type: boolean.

error

Any error produced by the request. Type: ApiError | unknown.

carts

The page of quote type carts if no error was encountered. Type: Page<Cart>.

refetch

Method to resend the request. Type: () ⇒ Promise<void>.

useFetchQuoteById

Hook to use to make a request to fetch a quote by id.

Props

quoteClient

The client used to make the request. This comes from the @broadleaf/commerce-cart SDK.

quoteId

Id of the parent quote. Type: string.

Response

isFetching

Whether the request is in progress. Type: boolean.

error

Any error produced by the request. Type: ApiError | unknown.

quote

The quote if no error was encountered. Type: Cart.

refetch

Method to resend the request. Type: () ⇒ Promise<void>.

Quote Actions & Modification

useUpdateQuoteInfo

Hook to use to make a request to update a quote’s name or expiration date. Only sellers can set the latter field.

Props

quoteClient

The client used to make the request. This comes from the @broadleaf/commerce-cart SDK.

Response

updateQuoteInfo

Function to make the request. Type: (quote: Cart, request: UpdateCartInfoRequest) ⇒ Promise<Cart | undefined>. See UpdateCartInfoRequest.

quote

The updated quote. Type: Cart.

error

Any error produced by the request. Type: ApiError | unknown.

useChangeQuoteStatus

Hook to use to make a request to change a quote’s status.

Props

quoteClient

The client used to make the request. This comes from the @broadleaf/commerce-cart SDK.

Response

changeQuoteStatus

Function to make the request. Type: (selectedQuote: Cart, status: string) ⇒ Promise<void>.

error

Any error produced by the request. Type: ApiError | unknown.

useDeleteQuote

Hook to use to make a request to delete a quote by id. Only for sellers.

Props

quoteClient

The client used to make the request. This comes from the @broadleaf/commerce-cart SDK.

Response

deleteQuote

Function to make the request. Type: (selectedQuote: Cart) ⇒ Promise<void>.

error

Any error produced by the request. Type: ApiError | unknown.

useMakeQuoteActive

Hook to use to make a request to set a quote as active. This will make the quote active in the app’s state and change the quote’s status to EDITING if not already one of the following statuses:

  • DRAFTING

  • EDITING

  • PUBLISHED

  • ASSIGNED

Props

quoteClient

The client used to make the request. This comes from the @broadleaf/commerce-cart SDK.

setCart

The callback needed to handle setting the app’s cart state. Type: (cart: Cart | null) ⇒ void.

Response

makeQuoteActive

Method to send the request. Takes the quote type cart to make active. Type: (selectedQuote: Cart) ⇒ Promise<void>.

error

Any error produced by the request. Type: ApiError | unknown.

useConvertExpiredToCart

Hook to use to make a request to convert an expired Quote into a regular Cart. This hook provides a callback method and an API error if any.

Props

quoteClient

The client used to make the request. This comes from the @broadleaf/commerce-cart SDK.

setCart

The callback needed to handle setting the app’s cart state. Type: (cart: Cart | null) ⇒ void.

Response

convertToCart

Callback function to send the request. Type: (selectedQuote: Cart, type?: string) ⇒ void. type is the Cart#type, default is STANDARD.

Notes & History

useFetchNotes

Hook to use to make a request to fetch a list of notes for a quote.

Props

quoteClient

The client used to make the request. This comes from the @broadleaf/commerce-cart SDK.

quoteId

Id of the parent quote. Type: string.

quoteItemId

(Optional) Id of the parent quote item. Type: string.

Response

fetchNotes

Function to make the request. Type: () ⇒ Promise<void>.

notes

Page of notes. Type: Page of CartNote.

error

Any error produced by the request. Type: ApiError | unknown.

useFetchChangeHistory

Hook to use to make a request to fetch a list of CartActionAudits for a quote.

Props

quoteClient

The client used to make the request. This comes from the @broadleaf/commerce-cart SDK.

quoteId

Id of the parent quote. Type: string.

Response

fetchChangeHistory

Function to make the request. Type: () ⇒ Promise<void>.

changeHistory

Page of audits. Type: Page of CartActionAudit.

error

Any error produced by the request. Type: ApiError | unknown.

Context & Authorization

useConfigContext

Hook to use to access the ConfigContext.

Props

None.

Response

ConfigContext

The ConfigContext.

useIsSeller

Hook to use to make a check if the currently authenticated user is a seller (CSR).

Props

None.

Response

isSeller

Boolean indicating if the current user is a seller. Type: boolean.

useGetCustomerAccessToken

Hook to use to make a request to fetch an access token for the customer or CSR.

Props

None.

Response

getCustomerAccessToken

A function to use to fetch the access token. Type: (options?: GetAccessTokenOptions) ⇒ Promise<string | undefined>. See GetAccessTokenOptions.