API reference
Business modules
Data and actions of orders, products, customers, invoices, learning, account and help center.
Orders, products, customers, invoices and learning load their data through a provider (options.provider, a mock by default) and return ready, a promise to await before reading a record at setup (if (!loaded.value) await ready; create every useId() above that line, because on the server the ids made after an await differ from the browser's). The account and the help center read their mocks directly. See Connect your API.
useProviderState()
Shared state loaded once per visit from a provider; the server waits for it before rendering. It also returns error (the message of a failed load), refresh() (loads the provider again) and sync, which runs a provider call in the background and, when it fails, shows a toast and reloads the data so the screen never keeps a change the backend rejected.
useProviderState(key: string, load: () => Promise<T>, empty: () => T): { state: any; ready: any; loaded: any; error: any; refresh: () => Promise<void | undefined>; sync: (task: Promise<unknown>) => void; }statereadyloadederrorrefreshsyncuseProviderSync()
Runs a provider call in the background and shows a toast if it fails; pass a function (such as refresh) to run after the failure. Module composables use the sync that useProviderState() returns, already wired to refresh.
useProviderSync(onFailure?: () => Promise<unknown>): (task: Promise<unknown>) => void
useOrders()
Orders with lookups and status actions: advance, cancel and refund.
useOrders(options: UseOrdersOptions = {}): { orders: any; ready: any; loaded: any; error: any; refresh: any; findOrder: (id: string) => any; findProduct: (code: string) => Product | undefined; ordersOf: (customerId: string…ordersreadyloadederrorrefreshfindOrderfindProductordersOfadvancecancelrefundmarkPaidaddCommentorderTotals()
Subtotal, discount, shipping, tax and total of an order.
orderTotals(order: Order): OrderTotals
subtotaltaxshippingdiscounttotalunitsorderLines()
The lines of an order with their products and category icons.
orderLines(order: Order): OrderLine[]
nextOrderStatus()
The status that follows the current one.
nextOrderStatus(status: OrderStatus): "processing" | "shipped" | "delivered" | "cancelled" | "refunded" | undefined
useProducts()
Products: save, duplicate, restock, change status and remove.
useProducts(options: UseProductsOptions = {}): { products: any; ready: any; loaded: any; error: any; refresh: any; findProduct: (code: string) => any; nextCode: () => string; save: (product: Product) => void; setStatus: (codes…productsreadyloadederrorrefreshfindProductnextCodesavesetStatusremoveduplicaterestockuseProductForm()
The create/edit form of a product with its sections and code generation.
useProductForm(items: MaybeRefOrGetter<Product[]>): { isOpen: any; isSaving: any; editing: any; values: any; sections: any; title: any; create: () => void; edit: (product: Product) => void; nextCode: () => string; toProduct: (submi…isOpenisSavingeditingvaluessectionstitlecreateeditnextCodetoProductuseCustomers()
Customers: save, remove and manage notes.
useCustomers(options: UseCustomersOptions = {}): { customers: any; ready: any; loaded: any; error: any; refresh: any; findCustomer: (id: string) => any; save: (customer: Customer) => void; remove: (ids: string[]) => void; addNot…customersreadyloadederrorrefreshfindCustomersaveremoveaddNoteremoveNotenextIduseInvoices()
Invoices and clients: save, send, remind, record payments, mark paid, duplicate and remove.
useInvoices(options: UseInvoicesOptions = {}): { invoices: any; ready: any; loaded: any; error: any; refresh: any; clients: any; find: (id: string) => any; nextId: (issued?: string) => string; save: (invoice: Invoice) => void;…invoicesreadyloadederrorrefreshclientsfindnextIdsavesetStateremindrecordPaymentmarkPaidduplicateremoveuseLearning()
Courses, students and instructors with every lookup and action of the learning module.
useLearning(options: UseLearningOptions = {}): { state: any; ready: any; loaded: any; error: any; refresh: any; coursesById: any; findCourse: (id: string) => any; studentsOf: (courseId: string) => any; setCourseStatus: (id: st…statereadyloadederrorrefreshcoursesByIdfindCoursestudentsOfsetCourseStatusinstructorOfstatsOffindInstructorcoursesOfsaveInstructorremoveInstructorstudentSummaryenrollmentOffindStudentlessonOfenrollsaveCourseduplicateCourseremoveCoursesaveStudentremoveStudentsuseCourseDuration()
Formats course minutes as hours and minutes.
useCourseDuration(): { duration: (minutes: number) => any; }durationuseInstructorTiles()
The five stat tiles of an instructor profile.
useInstructorTiles(): { tiles: (instructor: Instructor, stats: ReturnType<typeof instructorStats>) => ({ label: any; value: any; hint: any; hintClass: string | undefined; icon?: undefined; iconColor?: …tilesuseStudentTimeline()
The activity of a student as timeline items.
useStudentTimeline(): { timeline: (student: Student, limit?: number) => TimelineItem[]; }timelineuseCourseForm()
The create/edit form of a course.
useCourseForm(): { panel: any; title: any; sections: any; create: () => void; edit: (course: Course) => void; submit: (values: FormValues) => Course; }paneltitlesectionscreateeditsubmituseStudentForm()
The student form and the enrol form.
useStudentForm(): { panel: any; title: any; fields: any; create: () => void; edit: (student: Student) => void; submit: (values: FormValues) => void; enrollPanel: any; enrollStudent: any; enrollFiel…paneltitlefieldscreateeditsubmitenrollPanelenrollStudentenrollFieldsopenEnrollsubmitEnrolluseInstructorForm()
The invite/edit form of an instructor.
useInstructorForm(): { panel: any; isEditing: any; title: any; fields: any; create: () => void; edit: (instructor: Instructor) => void; submit: (values: FormValues) => void; }panelisEditingtitlefieldscreateeditsubmituseAccount()
Profile, sessions, notifications, security, preferences, billing and subscription of the account area.
useAccount(): { profile: any; sessions: any; notifications: any; digest: any; quietHours: any; billingDetails: any; subscription: any; security: any; preferences: any; billingHistory: any; upda…profilesessionsnotificationsdigestquietHoursbillingDetailssubscriptionsecuritypreferencesbillingHistoryupdateSecurityupdatePreferencesupdateProfileplansplanFeaturesrevokeSessionrevokeOtherSessionssetNotificationplanPriceuseHelpCenter()
Articles, categories, FAQ, search, related articles and suggestions of the help center.
useHelpCenter(): { allArticles: any; categories: any; faq: any; popularSearches: any; updates: any; tickets: any; search: (query: string, category?: HelpCategoryId) => any; findArticle: (slug: str…allArticlescategoriesfaqpopularSearchesupdatesticketssearchfindArticlerelatedTosuggest