class Document < ApplicationRecord
belongs_to :account
enum status: { pending: 0, processing: 1, ready: 2, failed: 3 }
after_create_commit :broadcast_badge
export type CircuitState = "closed" | "open" | "half-open";
export interface CircuitBreakerOptions {
failureThreshold: number;
resetTimeout: number; // ms to wait in "open" before probing
onStateChange?: (from: CircuitState, to: CircuitState) => void;
export const initialState = (steps, initialData = {}) => ({
steps,
stepIndex: 0,
data: initialData,
errors: {},
});
export const wizardMachine = {
initial: 'account',
states: {
account: {
next: 'profile',
canLeave: (data) => Boolean(data.email && data.password),
<?php
namespace App\Orders;
enum OrderStatus: string
{
import React from 'react';
export function UndoSnackbar({ pending, onUndo }) {
if (!pending) return null;
return (
use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OrderState {
Pending,
Paid,
<%= form_with url: bulk_update_orders_path, method: :patch, data: { turbo_confirm: "Update selected orders?" } do %>
<div class="batch-toolbar">
<%= select_tag :status,
options_for_select(Order.statuses.keys.map { |s| [s.humanize, s] }),
prompt: "Set status to\u2026" %>
<%= submit_tag "Apply to selected", class: "btn" %>
export const TOTAL_STEPS = 3;
export interface WizardData {
email: string;
password: string;
fullName: string;
framework:
workflows:
order:
type: state_machine
marking_store:
type: method
<?php
namespace App\Http\Requests\Wizard;
use Illuminate\Foundation\Http\FormRequest;
export type FetchState<T> =
| { status: 'idle' }
| { status: 'loading' }
| { status: 'success'; data: T }
| { status: 'error'; error: Error };