Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python
675 B
Raw Blame
import { nanoid } from "nanoid";
import {
  AiCreateCommit,
  AiEditCommit,
  CodeCreateCommit,
  Commit,
} from "./types";

export function createCommit(
  commit:
    | Omit<
        AiCreateCommit,
        "hash" | "dateCreated" | "selectedVariantIndex" | "isCommitted"
      >
    | Omit<
        AiEditCommit,
        "hash" | "dateCreated" | "selectedVariantIndex" | "isCommitted"
      >
    | Omit<
        CodeCreateCommit,
        "hash" | "dateCreated" | "selectedVariantIndex" | "isCommitted"
      >
): Commit {
  const hash = nanoid();
  return {
    ...commit,
    hash,
    isCommitted: false,
    dateCreated: new Date(),
    selectedVariantIndex: 0,
  };
}