function toPascal(name: string): string {
  return name.charAt(0).toUpperCase() + name.slice(1);
}

export function renderResolverStub(name: string): string {
  return `import { createResolver, t } from "@tailor-platform/sdk";
import { createContext } from "@tailor-platform/erp-kit/app";
import { getDB } from "@/generated/kysely-tailordb";

export default createResolver({
  name: "${name}",
  operation: "mutation",
  input: {
    // TODO: define input fields
  },
  body: async (context) => {
    const db = getDB("main-db");
    return db.transaction().execute(async (trx) => {
      // TODO: implement
      return {};
    });
  },
  output: t
    .object({
      // TODO: define output fields
    })
    .description("${toPascal(name)} response"),
});
`;
}

export function renderStoryTestStub(name: string, testCases: string[]): string {
  const its = testCases
    .map((tc) => `  it("${tc}", async () => {\n    // TODO: implement\n  });`)
    .join("\n\n");
  return `import { describe, expect, inject, it } from "vitest";
import { createGraphQLClient } from "@/tests/utils/graphql-client";

describe("${name}", () => {
  const graphQLClient = createGraphQLClient(inject("url"), inject("token"));

${its}
});
`;
}
