feat(cards): refine controls and modal transitions
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import dayjs from "dayjs";
|
||||
import { z } from "zod";
|
||||
import { bankMonth } from "./form-validation";
|
||||
|
||||
const calendarDate = z.string().date();
|
||||
function bankPeriod(params: URLSearchParams) {
|
||||
const month = bankMonth(params.get("month"));
|
||||
const from = params.get("from");
|
||||
const to = params.get("to");
|
||||
return from &&
|
||||
to &&
|
||||
calendarDate.safeParse(from).success &&
|
||||
calendarDate.safeParse(to).success &&
|
||||
from >= "0001-01-01" &&
|
||||
from <= to
|
||||
? { from, to }
|
||||
: {
|
||||
from: `${month}-01`,
|
||||
to: dayjs(`${month}-01`).endOf("month").format("YYYY-MM-DD"),
|
||||
};
|
||||
}
|
||||
|
||||
export { bankPeriod };
|
||||
Reference in New Issue
Block a user