import { useReducer } from 'react'
interface FormState {
values: Record<string, any>
errors: Record<string, string>
touched: Record<string, boolean>
export const initialCart = { items: {} };
export function cartReducer(state, action) {
switch (action.type) {
case 'ADD_ITEM': {
const { product, qty = 1 } = action;
import { useCallback, useEffect, useReducer } from "react";
type State = { secondsLeft: number; isRunning: boolean };
type Action =
| { type: "start"; seconds: number }
| { type: "tick" }
export const MAX_VISIBLE = 4;
const DEFAULTS = {
variant: "info",
duration: 4000,
};
export interface Todo {
id: string;
title: string;
done: boolean;
pending: boolean;
}
export interface CartItem {
sku: string;
name: string;
unitPrice: number; // cents
qty: number;
}
import { useReducer, useCallback } from 'react';
const initialState = (present) => ({ past: [], present, future: [] });
function historyReducer(state, action) {
const { past, present, future } = state;
export const initialState = (steps, initialData = {}) => ({
steps,
stepIndex: 0,
data: initialData,
errors: {},
});
export interface Todo {
id: string;
title: string;
done: boolean;
}
import React from 'react';
export function UndoSnackbar({ pending, onUndo }) {
if (!pending) return null;
return (
export const TOTAL_STEPS = 3;
export interface WizardData {
email: string;
password: string;
fullName: string;
export interface CartItem {
id: string;
name: string;
price: number;
quantity: number;
}