第3项:旧界面与 React 共用对账、回收及基础业务规则
This commit is contained in:
1 parent
54c05879d5
commit
389952f31c
65 files changed
+2265
-3800
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import type { LedgerClient } from '../../lib/api';
|
||||
import { Model, type LedgerState } from '../../shared';
|
||||
import { Model, Values, type LedgerState } from '../../shared';
|
||||
|
||||
export interface Props {
|
||||
client: LedgerClient;
|
||||
@@ -161,8 +161,7 @@ export function time(value: string) {
|
||||
}
|
||||
export const snapshotLabel = (s: Snapshot) =>
|
||||
s.source === 'automatic' ? '系统自动保存' : !s.source || s.source === 'manual' ? '店主复核' : '已保存';
|
||||
export const dateValid = (s: string) =>
|
||||
/^\d{4}-\d{2}-\d{2}$/.test(s) && !Number.isNaN(+new Date(s)) && new Date(s).toISOString().slice(0, 10) === s;
|
||||
export const dateValid = Values.validDate;
|
||||
export function useRead<T>(client: LedgerClient, url: string | null, version: number, validate?: (value: T) => void) {
|
||||
const [response, setResponse] = useState<{ url: string; version: number; value?: T; error?: string }>();
|
||||
useEffect(() => {
|
||||
|
||||
Reference in new issue
Block a user