feat: rubgram manual submission creation
Build and Push Image / docker (push) Successful in 5m49s

This commit is contained in:
2026-06-02 23:43:00 +07:00 Unverified
parent 809bb8d09c
commit 5d9b75aa9b
43 changed files with 1354 additions and 381 deletions
+15 -6
View File
@@ -9,6 +9,7 @@ import type {
import { cn } from "@/lib/utils";
import { DialogClose } from "./ui/dialog";
import { Label } from "./ui/label";
import { Divide } from "lucide-react";
const AUTOSAVE_TTL_MS = 10 * 60 * 1000;
const STORAGE_PREFIX = "form:autosave:";
@@ -28,7 +29,7 @@ type FormContextValue = {
const FormContext = React.createContext<FormContextValue | null>(null);
function useFormContext() {
export function useFormContext() {
const ctx = React.useContext(FormContext);
if (!ctx) throw new Error("FormInput/FormAction must be inside FormProvider");
return ctx;
@@ -153,9 +154,13 @@ export function FormProvider<T extends TypedFormDataShape>({
React.useEffect(() => {
const stored = safeParseAutosave(localStorage.getItem(storageKey(id)));
if (!stored) return;
if (!stored) {
setStorageLock(null);
return;
}
if (Date.now() - stored.savedAt > AUTOSAVE_TTL_MS) {
localStorage.removeItem(storageKey(id));
setStorageLock(null);
return;
}
setValues(stored.values || {});
@@ -282,8 +287,8 @@ export function FormInput({
className,
}: FormInputProps) {
const { values, setValue, updateValues } = useFormContext();
const childProps = children.props as Record<string, unknown>;
const value = (values[name] ?? childProps.defaultValue) || "";
const childProps = (children.props ?? {}) as Record<string, unknown>;
const value = values[name] ?? childProps?.defaultValue ?? "";
const nextProps: Record<string, unknown> = { name, defaultValue: undefined };
const applyValue = React.useCallback(
(nextValue: unknown) => {
@@ -336,6 +341,10 @@ export function FormInput({
nextProps.id = `forminput-${name}`;
}
if (children.$$typeof === Symbol.for("react.lazy")) {
children = React.use((children as any)._payload);
}
return (
<>
{label ? (
@@ -346,10 +355,10 @@ export function FormInput({
<span className="font-normal opacity-70">{subLabel}</span>
)}
</Label>
{React.cloneElement(children, nextProps)}
{React.cloneElement(children || Divide, nextProps)}
</div>
) : (
React.cloneElement(children, nextProps)
React.cloneElement(children || Divide, nextProps)
)}
</>
);