import preview from "../../.storybook/preview.tsx"; import { Failure, Success } from "../async-op.ts"; import { SyncLogList } from "./SyncLog.tsx"; const meta = preview.meta({ title: "Components/SyncLogList", component: SyncLogList, }); export const Inactive = meta.story({ args: { syncState: "INACTIVE", lastSuccessfulSyncTs: null, syncLog: [], }, }); export const Syncing = meta.story({ args: { syncState: "SYNCING", lastSuccessfulSyncTs: 1773753718052, syncLog: [ { startedTs: 1773753718052, pull: null, push: new Success({ pushed: [ { id: "123", name: "Test Item", updatedTs: 1773753718052, deleted: false, }, ], pulled: [], }), }, ], }, }); export const Idle = meta.story({ args: { syncState: "IDLE", lastSuccessfulSyncTs: 1773753718052, syncLog: [], }, }); export const Waiting = meta.story({ args: { syncState: "WAITING", lastSuccessfulSyncTs: 1773753718052, syncLog: [], }, }); export const Authenticating = meta.story({ args: { syncState: "AUTHENTICATING", lastSuccessfulSyncTs: null, syncLog: [], }, }); export const Error = meta.story({ args: { syncState: "ERROR", lastSuccessfulSyncTs: 1773753718052, syncLog: [ { startedTs: 1773753718052, pull: null, push: new Failure({ type: "API_ERROR" as const, code: 500 }), }, ], }, }); export const SuccessfulPullAndPush = meta.story({ args: { syncState: "IDLE", lastSuccessfulSyncTs: 1773753718052, syncLog: [ { startedTs: 1773753718052, pull: new Success({ pulled: [ { id: "p1", name: "Pulled Item", updatedTs: 1773753718052, deleted: false, }, ], }), push: new Success({ pushed: [ { id: "s1", name: "Pushed Item", updatedTs: 1773753718052, deleted: false, }, ], pulled: [ { id: "s2", name: "Patch Item", updatedTs: 1773753718052, deleted: false, }, ], }), }, ], }, }); export const AllUpToDate = meta.story({ args: { syncState: "IDLE", lastSuccessfulSyncTs: 1773753718052, syncLog: [ { startedTs: 1773753718052, pull: new Success({ pulled: [] }), push: new Success({ pushed: [], pulled: [] }), }, ], }, }); export const PullFailure = meta.story({ args: { syncState: "ERROR", lastSuccessfulSyncTs: 1773753718052, syncLog: [ { startedTs: 1773753718052, pull: new Failure({ type: "NETWORK_ERROR" as const }), push: null, }, ], }, }); export const DeletedAndUnnamedItems = meta.story({ args: { syncState: "IDLE", lastSuccessfulSyncTs: 1773753718052, syncLog: [ { startedTs: 1773753718052, pull: null, push: new Success({ pushed: [ { id: "d1", name: "Removed Campaign", updatedTs: 1773753718052, deleted: true, }, { id: "d2", name: "", updatedTs: 1773753718052, deleted: false, }, ], pulled: [], }), }, ], }, }); export const MultipleSyncEntries = meta.story({ args: { syncState: "IDLE", lastSuccessfulSyncTs: 1773753718052, syncLog: [ { startedTs: 1773753718052, pull: new Success({ pulled: [] }), push: new Success({ pushed: [], pulled: [] }), }, { startedTs: 1773753608052, pull: new Success({ pulled: [ { id: "m1", name: "Synced Item", updatedTs: 1773753608052, deleted: false, }, ], }), push: new Success({ pushed: [ { id: "m2", name: "Pushed Item", updatedTs: 1773753608052, deleted: false, }, ], pulled: [], }), }, { startedTs: 1773753508052, pull: new Failure({ type: "NETWORK_ERROR" as const }), push: null, }, ], }, });