Repository: rahulc0dy/retreat-of-code
Pull request #8: feat(input submission): add input submission route
Author: login: rahulc0dy
Labels: name: enhancement
description: New feature or request
Created: 2025-04-01T13:33:10Z | Merged: 2025-04-11T06:24:09Z

## Description

<!--
Provide a concise description of the changes introduced by this PR.
Explain the problem this PR addresses and how the changes resolve it.
-->
This PR adds input submission and checking logic to the app.

### Related Issue

<!--
If this PR addresses an existing issue, please link to it.
Example: Closes #123
-->
Closes None

## Checklist

- [x] I have followed the coding guidelines for this project.
- [x] I have performed a self-review of my code.
- [x] I have commented my code where necessary.
- [ ] I have added tests that prove my fix is effective or that my feature works.
- [x] New and existing unit tests pass locally with my changes.

## Screenshots (if applicable)
![image](https://github.com/user-attachments/assets/44e73c1c-938d-45b8-8653-a71e25769684)

<!--
Include screenshots to help explain the changes made in this PR.
-->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

## Summary by CodeRabbit

- **New Features**
  - Added an interactive answer submission form on question pages, allowing you to input answers with real-time feedback.
  - Introduced a “Back to Home” link on question listings, making navigation smoother across the site.
  - New component for answer input has been implemented, enhancing user interaction with displayed questions.
  - Introduced a new API endpoint for submitting answers, improving backend functionality for handling user inputs. 
  - Added environment variable management for better configuration in the application.

- **Bug Fixes**
  - Updated environment variable imports to ensure proper configuration across the application.

- **Chores**
  - Updated project dependencies to enhance performance and maintainability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->


Diff:
diff --git a/app/(root)/questions/[year]/[day]/page.tsx b/app/(root)/questions/[year]/[day]/page.tsx
index f5722e1..526bfbf 100644
--- a/app/(root)/questions/[year]/[day]/page.tsx
+++ b/app/(root)/questions/[year]/[day]/page.tsx
@@ -2,6 +2,7 @@ import { getQuestionData } from "@/lib/questions";
 import Link from "next/link";
 import ReactMarkdown from "react-markdown";
 import { z } from "zod";
+import AnswerInput from "@/components/AnswerInput";
 
 interface QuestionPageProps {
   params: Promise<{ year: string; day: string }>;
@@ -41,6 +42,10 @@ export default async function QuestionPage({ params }: QuestionPageProps) {
       <article className="max-w-prose font-thin">
         <ReactMarkdown>{questionData.content}</ReactMarkdown>
       </article>
+
+      <Link href={"#"}>Get your input</Link>
+      <AnswerInput questionId={`${year}-${day}`} />
+
       <Link
         href={`/questions/${year}`}
         className="hover:glow mt-4 inline-block"
diff --git a/app/(root)/questions/[year]/page.tsx b/app/(root)/questions/[year]/page.tsx
index b55c5ad..7fcc2e6 100644
--- a/app/(root)/questions/[year]/page.tsx
+++ b/app/(root)/questions/[year]/page.tsx
@@ -42,6 +42,7 @@ export default async function YearPage({ params }: YearPageProps) {
           </li>
         ))}
       </ul>
+
       <Link
         href="/"
         className="hover:bg-overlay-2/20 text-lavender mt-4 inline-block"
diff --git a/app/api/solutions/route.ts b/app/api/solutions/route.ts
new file mode 100644
index 0000000..d461324
--- /dev/null
+++ b/app/api/solutions/route.ts
@@ -0,0 +1,15 @@
+import { ApiError } from "@/lib/utils/ApiError";
+import { ApiResponse } from "@/lib/utils/ApiResponse";
+import { asyncHandler } from "@/lib/utils/asyncHandler";
+
+export const POST = asyncHandler(async (request: Request) => {
+  const body = await request.json();
+
+  if (!body.answer || !body.questionId) {
+    throw new ApiError({ message: "Missing required fields.", data: {} });
+  }
+
+  // TODO: Implement actual solution checking logic here
+
+  return new ApiResponse({ message: "Success", data: body });
+});
diff --git a/auth.ts b/auth.ts
index 2a5bdbb..c45b4e8 100644
--- a/auth.ts
+++ b/auth.ts
@@ -1,6 +1,6 @@
 import NextAuth from "next-auth";
 import Google from "next-auth/providers/google";
-import { AUTH_GOOGLE_CLIENT_ID, AUTH_GOOGLE_CLIENT_SECRET } from "@/env";
+import { AUTH_GOOGLE_CLIENT_ID, AUTH_GOOGLE_CLIENT_SECRET } from "@/env/server";
 import { DrizzleAdapter } from "@auth/drizzle-adapter";
 import { db } from "@/db";
 import { accounts, sessions, users, verificationTokens } from "@/db/schemas";
diff --git a/components/AnswerInput.tsx b/components/AnswerInput.tsx
new file mode 100644
index 0000000..ee636b2
--- /dev/null
+++ b/components/AnswerInput.tsx
@@ -0,0 +1,90 @@
+"use client";
+
+import React, { FormEvent, useState } from "react";
+import { z } from "zod";
+import axios from "axios";
+import { tryCatch } from "@/lib/utils/tryCatch";
+import { NEXT_PUBLIC_API_BASE_URL } from "@/env/client";
+
+interface AnswerInputProps {
+  questionId: string;
+  // Assume the validation schema validates a string (the answer)
+  validationSchema?: z.Schema<string>;
+}
+
+const AnswerInput: React.FC<AnswerInputProps> = ({
+  questionId,
+  validationSchema,
+}) => {
+  const [answer, setAnswer] = useState("");
+  const [message, setMessage] = useState<string | null>(null);
+  const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
+    e.preventDefault();
+
+    // Optionally validate the answer using the provided schema
+    let validatedAnswer: string = answer;
+    if (validationSchema) {
+      const parsed = validationSchema.safeParse(answer);
+      if (!parsed.success) {
+        setMessage(
+          "Invalid answer: " +
+            JSON.stringify(parsed.error.flatten().fieldErrors)
+        );
+        return;
+      } else {
+        validatedAnswer = parsed.data;
+      }
+    }
+
+    // Prepare the payload (including the questionId for context)
+    const payload = { questionId, answer: validatedAnswer };
+
+    // Use tryCatch to call your API
+    const { data: resData, error: resError } = await tryCatch(
+      axios.post(`${NEXT_PUBLIC_API_BASE_URL}/solutions`, payload)
+    );
+
+    if (resError) {
+      console.error(resError);
+      setMessage(resError.message || "Error submitting answer");
+    } else {
+      console.log(resData.data);
+      setMessage(resData.data.message);
+    }
+  };
+
+  return (
+    <form
+      onSubmit={handleSubmit}
+      className="mt-1"
+      aria-label="Answer submission form"
+    >
+      <label htmlFor="answer-input" className="sr-only">
+        Enter your answer
+      </label>
+      <input
+        type="text"
+        id="answer-input"
+        className="bg-crust border-overlay-0 min-w-1/3 border border-r-0 p-2"
+        placeholder="Enter your answer"
+        value={answer}
+        onChange={(e) => setAnswer(e.target.value)}
+        aria-required="true"
+      />
+      <button
+        type="submit"
+        className="text-text bg-surface-1 border-overlay-0 hover:bg-surface-2 cursor-pointer border p-2"
+      >
+        Submit
+      </button>
+
+      {message && (
+        <div className="text-lavender mt-2" role="status" aria-live="polite">
+          {message}
+        </div>
+      )}
+    </form>
+  );
+};
+
+export default AnswerInput;
diff --git a/db/index.ts b/db/index.ts
index a5908ac..a8afd11 100644
--- a/db/index.ts
+++ b/db/index.ts
@@ -1,4 +1,4 @@
 import { drizzle } from "drizzle-orm/neon-http";
-import { DATABASE_URL } from "@/env";
+import { DATABASE_URL } from "@/env/server";
 
 export const db = drizzle(DATABASE_URL);
diff --git a/drizzle.config.ts b/drizzle.config.ts
index ed50545..efd22b1 100644
--- a/drizzle.config.ts
+++ b/drizzle.config.ts
@@ -1,5 +1,5 @@
 import { defineConfig } from "drizzle-kit";
-import { DATABASE_URL } from "@/env";
+import { DATABASE_URL } from "@/env/server";
 
 export default defineConfig({
   out: "./drizzle",
diff --git a/env/client.ts b/env/client.ts
new file mode 100644
index 0000000..172a20c
--- /dev/null
+++ b/env/client.ts
@@ -0,0 +1,17 @@
+import { createEnv } from "@t3-oss/env-nextjs";
+import { z } from "zod";
+import { configDotenv } from "dotenv";
+
+configDotenv({
+  path: "./.env.local",
+});
+
+export const { NEXT_PUBLIC_API_BASE_URL } = createEnv({
+  client: {
+    NEXT_PUBLIC_API_BASE_URL: z.string().url(),
+  },
+  experimental__runtimeEnv: {
+    NEXT_PUBLIC_API_BASE_URL: process.env.NEXT_PUBLIC_API_BASE_URL,
+  },
+  emptyStringAsUndefined: true,
+});
diff --git a/env.ts b/env/server.ts
similarity index 78%
rename from env.ts
rename to env/server.ts
index d6db504..ee80013 100644
--- a/env.ts
+++ b/env/server.ts
@@ -1,4 +1,4 @@
-import { createEnv } from "@t3-oss/env-core";
+import { createEnv } from "@t3-oss/env-nextjs";
 import { z } from "zod";
 import { configDotenv } from "dotenv";
 
@@ -17,9 +17,6 @@ export const {
     AUTH_GOOGLE_CLIENT_ID: z.string(),
     AUTH_GOOGLE_CLIENT_SECRET: z.string(),
   },
-
-  clientPrefix: "PUBLIC_",
-  client: {},
-  runtimeEnv: process.env,
+  experimental__runtimeEnv: process.env,
   emptyStringAsUndefined: true,
 });
diff --git a/lib/utils/ApiError.ts b/lib/utils/ApiError.ts
new file mode 100644
index 0000000..03cd8db
--- /dev/null
+++ b/lib/utils/ApiError.ts
@@ -0,0 +1,7 @@
+export class ApiError extends Error {
+  data: object;
+  constructor({ message, data }: { message: string; data: object }) {
+    super(message);
+    this.data = data;
+  }
+}
diff --git a/lib/utils/ApiResponse.ts b/lib/utils/ApiResponse.ts
new file mode 100644
index 0000000..c77c7ed
--- /dev/null
+++ b/lib/utils/ApiResponse.ts
@@ -0,0 +1,39 @@
+interface ApiResponseProps {
+  message: string;
+  data: object;
+  success?: boolean;
+  options?: ResponseInit;
+}
+
+export class ApiResponse extends Response {
+  message: string;
+  data: object;
+  success: boolean;
+
+  constructor({
+    message,
+    data,
+    success = true,
+    options = {},
+  }: ApiResponseProps) {
+    const body = JSON.stringify({ message, data, success });
+    // Default options
+    const defaultOptions: ResponseInit = {
+      status: 200,
+      headers: { "Content-Type": "application/json" },
+    };
+    // Merge headers separately
+    const mergedOptions: ResponseInit = {
+      ...defaultOptions,
+      ...options,
+      headers: {
+        ...(defaultOptions.headers as object),
+        ...((options.headers as object) || {}),
+      },
+    };
+    super(body, mergedOptions);
+    this.message = message;
+    this.data = data;
+    this.success = success;
+  }
+}
diff --git a/lib/utils/asyncHandler.ts b/lib/utils/asyncHandler.ts
new file mode 100644
index 0000000..2d6f51f
--- /dev/null
+++ b/lib/utils/asyncHandler.ts
@@ -0,0 +1,23 @@
+import { ApiResponse } from "@/lib/utils/ApiResponse";
+
+export const asyncHandler = (handler: (req: Request) => Promise<Response>) => {
+  return async (req: Request): Promise<Response> => {
+    try {
+      return await handler(req);
+    } catch (error) {
+      console.error("API Error:", error);
+      const errorMessage =
+        error instanceof Error ? error.message : "Internal server error";
+      // Return a new ApiResponse instance with error options.
+      return new ApiResponse({
+        success: false,
+        message: errorMessage,
+        data: {},
+        options: {
+          status: 500,
+          headers: { "Content-Type": "application/json" },
+        },
+      });
+    }
+  };
+};
diff --git a/package.json b/package.json
index cc8a9f6..0522bc3 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,8 @@
   "dependencies": {
     "@auth/drizzle-adapter": "^1.8.0",
     "@neondatabase/serverless": "^0.10.4",
-    "@t3-oss/env-core": "^0.12.0",
+    "@t3-oss/env-nextjs": "^0.12.0",
+    "axios": "^1.8.4",
     "dotenv": "^16.4.7",
     "drizzle-orm": "^0.40.0",
     "gray-matter": "^4.0.3",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5ee97fe..6bc0072 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -14,9 +14,12 @@ importers:
       '@neondatabase/serverless':
         specifier: ^0.10.4
         version: 0.10.4
-      '@t3-oss/env-core':
+      '@t3-oss/env-nextjs':
         specifier: ^0.12.0
         version: 0.12.0(typescript@5.8.2)(zod@3.24.2)
+      axios:
+        specifier: ^1.8.4
+        version: 1.8.4
       dotenv:
         specifier: ^16.4.7
         version: 16.4.7
@@ -832,6 +835,20 @@ packages:
       zod:
         optional: true
 
+  '@t3-oss/env-nextjs@0.12.0':
+    resolution: {integrity: sha512-rFnvYk1049RnNVUPvY8iQ55AuQh1Rr+qZzQBh3t++RttCGK4COpXGNxS4+45afuQq02lu+QAOy/5955aU8hRKw==}
+    peerDependencies:
+      typescript: '>=5.0.0'
+      valibot: ^1.0.0-beta.7 || ^1.0.0
+      zod: ^3.24.0
+    peerDependenciesMeta:
+      typescript:
+        optional: true
+      valibot:
+        optional: true
+      zod:
+        optional: true
+
   '@tailwindcss/node@4.0.9':
     resolution: {integrity: sha512-tOJvdI7XfJbARYhxX+0RArAhmuDcczTC46DGCEziqxzzbIaPnfYaIyRT31n4u8lROrsO7Q6u/K9bmQHL2uL1bQ==}
 
@@ -1071,6 +1088,9 @@ packages:
     resolution: {integrity: sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==}
     engines: {node: '>= 0.4'}
 
+  asynckit@0.4.0:
+    resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
+
   available-typed-arrays@1.0.7:
     resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==}
     engines: {node: '>= 0.4'}
@@ -1079,6 +1099,9 @@ packages:
     resolution: {integrity: sha512-RE3mdQ7P3FRSe7eqCWoeQ/Z9QXrtniSjp1wUjt5nRC3WIpz5rSCve6o3fsZ2aCpJtrZjSZgjwXAoTO5k4tEI0w==}
     engines: {node: '>=4'}
 
+  axios@1.8.4:
+    resolution: {integrity: sha512-eBSYY4Y68NNlHbHBMdeDmKNtDgXWhQsJcGqzO3iLUM0GraQFSS9cVgPX5I9b3lbdFKyYoAEGAZF1DwhTaljNAw==}
+
   axobject-query@4.1.0:
     resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==}
     engines: {node: '>= 0.4'}
@@ -1161,6 +1184,10 @@ packages:
     resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==}
     engines: {node: '>=12.5.0'}
 
+  combined-stream@1.0.8:
+    resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
+    engines: {node: '>= 0.8'}
+
   comma-separated-tokens@2.0.3:
     resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==}
 
@@ -1224,6 +1251,10 @@ packages:
     resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==}
     engines: {node: '>= 0.4'}
 
+  delayed-stream@1.0.0:
+    resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
+    engines: {node: '>=0.4.0'}
+
   dequal@2.0.3:
     resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==}
     engines: {node: '>=6'}
@@ -1590,10 +1621,23 @@ packages:
   flatted@3.3.3:
     resolution: {integrity: sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==}
 
+  follow-redirects@1.15.9:
+    resolution: {integrity: sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==}
+    engines: {node: '>=4.0'}
+    peerDependencies:
+      debug: '*'
+    peerDependenciesMeta:
+      debug:
+        optional: true
+
   for-each@0.3.5:
     resolution: {integrity: sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==}
     engines: {node: '>= 0.4'}
 
+  form-data@4.0.2:
+    resolution: {integrity: sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==}
+    engines: {node: '>= 6'}
+
   fsevents@2.3.3:
     resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
     engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
@@ -2092,6 +2136,14 @@ packages:
     resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==}
     engines: {node: '>=8.6'}
 
+  mime-db@1.52.0:
+    resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
+    engines: {node: '>= 0.6'}
+
+  mime-types@2.1.35:
+    resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
+    engines: {node: '>= 0.6'}
+
   minimatch@3.1.2:
     resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==}
 
@@ -2373,6 +2425,9 @@ packages:
   property-information@7.0.0:
     resolution: {integrity: sha512-7D/qOz/+Y4X/rzSB6jKxKUsQnphO046ei8qxG59mtM3RG3DHgTK81HrxrmoDVINJb8NKT5ZsRbwHvQ6B68Iyhg==}
 
+  proxy-from-env@1.1.0:
+    resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
+
   punycode@2.3.1:
     resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
     engines: {node: '>=6'}
@@ -3199,6 +3254,13 @@ snapshots:
       typescript: 5.8.2
       zod: 3.24.2
 
+  '@t3-oss/env-nextjs@0.12.0(typescript@5.8.2)(zod@3.24.2)':
+    dependencies:
+      '@t3-oss/env-core': 0.12.0(typescript@5.8.2)(zod@3.24.2)
+    optionalDependencies:
+      typescript: 5.8.2
+      zod: 3.24.2
+
   '@tailwindcss/node@4.0.9':
     dependencies:
       enhanced-resolve: 5.18.1
@@ -3481,12 +3543,22 @@ snapshots:
 
   async-function@1.0.0: {}
 
+  asynckit@0.4.0: {}
+
   available-typed-arrays@1.0.7:
     dependencies:
       possible-typed-array-names: 1.1.0
 
   axe-core@4.10.2: {}
 
+  axios@1.8.4:
+    dependencies:
+      follow-redirects: 1.15.9
+      form-data: 4.0.2
+      proxy-from-env: 1.1.0
+    transitivePeerDependencies:
+      - debug
+
   axobject-query@4.1.0: {}
 
   bail@2.0.2: {}
@@ -3568,6 +3640,10 @@ snapshots:
       color-string: 1.9.1
     optional: true
 
+  combined-stream@1.0.8:
+    dependencies:
+      delayed-stream: 1.0.0
+
   comma-separated-tokens@2.0.3: {}
 
   concat-map@0.0.1: {}
@@ -3628,6 +3704,8 @@ snapshots:
       has-property-descriptors: 1.0.2
       object-keys: 1.1.1
 
+  delayed-stream@1.0.0: {}
+
   dequal@2.0.3: {}
 
   detect-libc@1.0.3: {}
@@ -4118,10 +4196,19 @@ snapshots:
 
   flatted@3.3.3: {}
 
+  follow-redirects@1.15.9: {}
+
   for-each@0.3.5:
     dependencies:
       is-callable: 1.2.7
 
+  form-data@4.0.2:
+    dependencies:
+      asynckit: 0.4.0
+      combined-stream: 1.0.8
+      es-set-tostringtag: 2.1.0
+      mime-types: 2.1.35
+
   fsevents@2.3.3:
     optional: true
 
@@ -4773,6 +4860,12 @@ snapshots:
       braces: 3.0.3
       picomatch: 2.3.1
 
+  mime-db@1.52.0: {}
+
+  mime-types@2.1.35:
+    dependencies:
+      mime-db: 1.52.0
+
   minimatch@3.1.2:
     dependencies:
       brace-expansion: 1.1.11
@@ -4989,6 +5082,8 @@ snapshots:
 
   property-information@7.0.0: {}
 
+  proxy-from-env@1.1.0: {}
+
   punycode@2.3.1: {}
 
   queue-microtask@1.2.3: {}


Reviews:
user: login: copilot-pull-request-reviewer[bot]
body: ## Pull Request Overview

This PR introduces input submission and validation logic for the app while refactoring environment configurations and updating imports. Key changes include updating environment imports to use the new "@t3-oss/env-nextjs" package, adding a new AnswerInput component for handling user answers, and creating a minimal API endpoint for solutions.

### Reviewed Changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 1 comment.

<details>
<summary>Show a summary per file</summary>

| File                                     | Description                                                                                |
| ---------------------------------------- | ------------------------------------------------------------------------------------------ |
| env/server.ts                            | Updated environment variable import and configuration.                                   |
| env/client.ts                            | Added public environment variable configuration for the client.                          |
| drizzle.config.ts & db/index.ts          | Updated import paths for DATABASE_URL to reflect the new environment structure.            |
| auth.ts                                  | Updated environment variable import for authentication credentials.                        |
| components/AnswerInput.tsx               | Added a new component to handle answer submission with validation and API call.            |
| app/api/solutions/route.ts               | Introduced a basic POST API endpoint to echo received submissions.                         |
| app/(root)/questions/[year]/page.tsx     | Minor update with the addition of a new link element.                                      |
| app/(root)/questions/[year]/[day]/page.tsx | Integrated the AnswerInput component and added a placeholder link for input retrieval.     |
</details>


<details>
<summary>Files not reviewed (2)</summary>

* **package.json**: Language not supported
* **pnpm-lock.yaml**: Language not supported
</details>

<details>
<summary>Comments suppressed due to low confidence (1)</summary>

**components/AnswerInput.tsx:44**
* [nitpick] Ensure that NEXT_PUBLIC_API_BASE_URL does not end with a trailing slash to avoid creating URLs with double slashes. If a trailing slash is possible, adjust the URL concatenation accordingly.
```
axios.post(`${NEXT_PUBLIC_API_BASE_URL}/solutions`, payload)
```
</details>


state: COMMENTED
author_association: NONE
submitted_at: 2025-04-01T13:34:09Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 2**

<details>
<summary>🧹 Nitpick comments (2)</summary><blockquote>

<details>
<summary>components/AnswerInput.tsx (2)</summary><blockquote>

`48-53`: **Remove console logging and improve error feedback.**

Production code should not contain `console.log` statements. Also, consider providing more specific error messages based on the actual error response from the API.

```diff
if (resError) {
-  console.error(resError);
-  setMessage("Error submitting answer");
+  const errorMessage = resError.response?.data?.message || "Error submitting answer";
+  setMessage(errorMessage);
} else {
-  console.log(resData.data);
  setMessage("Answer submitted successfully!");
}
```

---

`56-72`: **Enhance form with loading state and accessibility improvements.**

The form lacks a loading state indicator during submission and could benefit from accessibility improvements.

```diff
return (
  <form onSubmit={handleSubmit} className="mt-1">
+    <label htmlFor="answer-input" className="sr-only">Enter your answer</label>
    <input
      type="text"
+      id="answer-input"
      className="bg-crust border-overlay-0 min-w-1/3 border border-r-0 p-2"
      placeholder="Enter your answer"
      value={answer}
      onChange={(e) => setAnswer(e.target.value)}
+      aria-describedby={message ? "answer-feedback" : undefined}
    />
    <button
      type="submit"
      className="text-text bg-surface-1 border-overlay-0 hover:bg-surface-2 cursor-pointer border p-2"
+      disabled={isSubmitting}
    >
-      Submit
+      {isSubmitting ? "Submitting..." : "Submit"}
    </button>
-    {message && <div className="mt-2">{message}</div>}
+    {message && <div id="answer-feedback" className={`mt-2 ${message.includes("Error") ? "text-red-500" : "text-green-500"}`}>{message}</div>}
  </form>
);
```

You'll need to add a loading state:
```javascript
const [isSubmitting, setIsSubmitting] = useState(false);

const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
  e.preventDefault();
  setIsSubmitting(true);
  
  // ... existing validation code ...
  
  try {
    const { data: resData, error: resError } = await tryCatch(
      axios.post(`${NEXT_PUBLIC_API_BASE_URL}/solutions`, payload)
    );
    
    // ... existing response handling ...
  } finally {
    setIsSubmitting(false);
  }
};
```

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between b17265c810733b3c8b290f64955fcdcccea97a3a and 7e8e4a0284cdad6556bab3ed5b29b2de07e9886c.

</details>

<details>
<summary>⛔ Files ignored due to path filters (1)</summary>

* `pnpm-lock.yaml` is excluded by `!**/pnpm-lock.yaml`

</details>

<details>
<summary>📒 Files selected for processing (10)</summary>

* `app/(root)/questions/[year]/[day]/page.tsx` (2 hunks)
* `app/(root)/questions/[year]/page.tsx` (1 hunks)
* `app/api/solutions/route.ts` (1 hunks)
* `auth.ts` (1 hunks)
* `components/AnswerInput.tsx` (1 hunks)
* `db/index.ts` (1 hunks)
* `drizzle.config.ts` (1 hunks)
* `env/client.ts` (1 hunks)
* `env/server.ts` (2 hunks)
* `package.json` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Definitions (1)</summary>

<details>
<summary>env/client.ts (1)</summary><blockquote>

<details>
<summary>env/server.ts (1)</summary>

* `createEnv` (9-22)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>🔇 Additional comments (16)</summary><blockquote>

<details>
<summary>drizzle.config.ts (1)</summary>

`2-2`: **Environment import path updated correctly**

The import path for DATABASE_URL has been updated from "@/env" to "@/env/server", which is consistent with the application's new environment variable structure that separates client and server variables.

</details>
<details>
<summary>db/index.ts (1)</summary>

`2-2`: **Environment import path updated correctly**

The import path for DATABASE_URL has been updated from "@/env" to "@/env/server", maintaining consistency with the new environment variable organization pattern seen across the codebase.

</details>
<details>
<summary>auth.ts (1)</summary>

`3-3`: **Environment import path updated correctly**

The import for authentication environment variables has been properly updated to use "@/env/server" instead of "@/env", which aligns with the application's new pattern of organizing environment variables by their usage context (server vs client).

</details>
<details>
<summary>env/client.ts (2)</summary>

`1-7`: **Good setup for client-side environment variables**

The implementation correctly uses @t3-oss/env-nextjs for type-safe environment variables and configures dotenv to load from .env.local. This approach provides proper validation and typing for client-side environment variables.

---

`9-17`: **Well-structured client environment configuration**

The implementation correctly:
1. Defines and exports the NEXT_PUBLIC_API_BASE_URL with proper Zod validation
2. Uses the "client" property for client-side variables
3. Sets up experimental__runtimeEnv to access the environment variables at runtime
4. Enables emptyStringAsUndefined for better handling of empty values

This complements the server-side environment configuration seen in env/server.ts, creating a clean separation between client and server environment variables.

</details>
<details>
<summary>env/server.ts (2)</summary>

`1-1`: **Library migration appears correct but requires complementary changes.**

The change from `@t3-oss/env-core` to `@t3-oss/env-nextjs` aligns with the package.json updates. This migration to a Next.js-specific environment library is appropriate for a Next.js application.


Please confirm that you've also created the corresponding client-side environment file (env/client.ts) since the client environment configuration has been removed from this file.

---

`20-20`: <details>
<summary>✅ Verification successful</summary>

**Consider stable API alternatives if available.**

The property `experimental__runtimeEnv` suggests using an experimental API feature. While this works, experimental features may change in future releases.

---

🌐 Web query:

```web
Does @t3-oss/env-nextjs have a stable alternative to experimental__runtimeEnv?
```

💡 Result:

The T3 Env package for Next.js has consolidated its approach for handling environment variables across different Next.js versions. For Next.js **13.4.4 and above**, `experimental__runtimeEnv` is now the standard method to automatically bundle client-side environment variables. This approach replaces the manual `runtimeEnv` destructuring previously required[1][2][4].

Key points:
- **Next.js ≥13.4.4**: Use `experimental__runtimeEnv: process.env` to automatically handle client variables prefixed with `NEXT_PUBLIC_`
  ```typescript
  experimental__runtimeEnv: process.env
  ```
  This automatically includes all `NEXT_PUBLIC_*` variables in the client bundle[2][4].

- **Next.js <13.4.4**: Manual specification is still required:
  ```typescript
  runtimeEnv: {
    NEXT_PUBLIC_KEY: process.env.NEXT_PUBLIC_KEY,
  }
  ```

The "experimental" label remains in the property name but is now considered stable for production use in modern Next.js applications, as confirmed by the T3 Stack documentation and multiple implementation examples[1][2][4]. This dual approach ensures compatibility while maintaining type safety and validation through Zod schemas.

Citations:

- 1: https://create.t3.gg/en/usage/env-variables
- 2: https://env.t3.gg/docs/nextjs
- 3: https://create.t3.gg/en/other-recs
- 4: https://mwskwong.com/blog/why-t3-env-is-my-go-to-for-managing-environment-variables
- 5: https://www.nico.fyi/blog/stop-using-environment-variable-directly
- 6: https://notes.chiubaca.com/fleeting-notes/
- 7: https://www.npmjs.com/package/@t3-oss/env-nextjs
- 8: https://github.com/t3-oss/t3-env/issues/180
- 9: https://github.com/t3-oss/create-t3-app
- 10: https://github.com/t3-oss/t3-env

---



</details>

**Use of `experimental__runtimeEnv` is appropriate given recent Next.js versions**

The T3 Env package now endorses `experimental__runtimeEnv: process.env` as the standard method for bundling client-side environment variables in Next.js 13.4.4 and later—even though the API name includes "experimental." This usage is stable and recommended for production deployments on Next.js ≥13.4.4. For projects targeting versions below 13.4.4, however, you’d need to manually specify your runtime environment using the previous `runtimeEnv` approach.

No change is necessary if your project targets Next.js 13.4.4 or later.

</details>
<details>
<summary>app/(root)/questions/[year]/page.tsx (1)</summary>

`45-51`: **Good navigation improvement.**

Adding a "Back to Home" link improves the user navigation flow. The styling is consistent with other elements while the lavender color helps distinguish it as a navigation action.

</details>
<details>
<summary>package.json (1)</summary>

`14-15`: <details>
<summary>✅ Verification successful</summary>

**Dependency updates are appropriate but verify axios version.**

The migration to `@t3-oss/env-nextjs` aligns with the changes in env/server.ts. Adding axios for HTTP requests is appropriate for the new answer submission functionality.


---

🌐 Web query:

```web
Are there any known security vulnerabilities in axios 1.8.4?
```

💡 Result:

Axios 1.8.4, released on March 19, 2025, currently has no known security vulnerabilities according to multiple security scans and vulnerability databases[1][7][13][14][15]. This version includes fixes for previous security issues identified in older releases:

**Patched vulnerabilities in earlier versions:**
- **CVE-2025-27152** (Critical SSRF/Credential Leak):  
  Fixed in v1.8.2 and later, addressing absolute URL handling that could bypass `baseURL` restrictions[1][5][7]
  
- **CVE-2023-45857** (High Severity XSRF-TOKEN Exposure):  
  Resolved in v1.6.0+ by preventing unintended cookie disclosure[1][9]

Security analysis from ReversingLabs Spectra Assure and Snyk confirms[13][14][15]:
- No malware or tampering evidence
- No exposed secrets
- No license compliance issues
- 0 critical/high vulnerabilities in dependency tree

The package maintainers explicitly recommend v1.8.4 as the secure current version[1][5][7], with over 7.5 billion recorded downloads showing widespread adoption of this patched release[13].

Citations:

- 1: https://www.versioneye.com/NodeJS/axios/1.2.4
- 2: https://www.jsdocs.io/package/axios
- 3: https://github.com/axios/axios/issues/6821
- 4: https://www.ibm.com/support/pages/security-bulletin-vulnerabilities-axios-affect-ibm-voice-gateway-0
- 5: https://www.mail-archive.com/commits@airflow.apache.org/msg390413.html
- 6: https://laracasts.com/discuss/channels/laravel/github-warning-potential-security-vulnerability-found-in-the-axios-dependency
- 7: https://security.snyk.io/package/npm/axios
- 8: https://github.com/axios/axios/releases
- 9: https://github.com/axios/axios/blob/v1.x/CHANGELOG.md
- 10: https://security.snyk.io/package/npm/axios/0.18.1
- 11: https://github.com/axios/axios/issues
- 12: https://www.npmjs.com/package/axios
- 13: https://secure.software/npm/packages/axios/1.8.4
- 14: https://security.snyk.io/package/npm/axios/1.8.4
- 15: https://secure.software/npm/packages/axios/vulnerabilities/1.8.4

---



</details>

**Dependency Update Approval: Axios 1.8.4 is Secure**

The dependency changes in package.json are solid:
- Migrating to `@t3-oss/env-nextjs` aligns well with modifications in env/server.ts.
- The addition of axios (^1.8.4) for HTTP requests is appropriate. A recent web query confirms that axios 1.8.4 has no known security vulnerabilities.

All changes are cleared.

</details>
<details>
<summary>app/(root)/questions/[year]/[day]/page.tsx (3)</summary>

`5-5`: **Correct import of `AnswerInput` component.**

The import statement for the new `AnswerInput` component is appropriately placed with other imports.

---

`47-47`: **The `AnswerInput` component integration looks appropriate.**

The `AnswerInput` component is correctly positioned after the question content and receives the properly formatted `questionId` prop.

---

`46-46`: <details>
<summary>✅ Verification successful</summary>

**Placeholder link may need implementation.**

The "Get your input" link currently uses "#" as a placeholder href. This should be updated to point to the actual input data source when implemented.

---

🏁 Script executed:

```shell
#!/bin/bash
# Check if there are any API endpoints related to getting input data
rg -l "getInput|getUserInput|fetchInput" --type ts --type tsx app/
```

Length of output: 96

---

Please run the above script so we can verify whether any API endpoints related to getting input exist in the codebase before finalizing the review comment.

---

🏁 Script executed:

```shell
#!/bin/bash
# Re-run the search for input-related API endpoints in both .ts and .tsx files using globs.
rg -l "getInput|getUserInput|fetchInput" app/ --glob '*.ts' --glob '*.tsx'
```

Length of output: 76

---



</details>

**Action: Update Placeholder Link When API Is Available**

The `<Link href={"#"}>Get your input</Link>` at line 46 in `app/(root)/questions/[year]/[day]/page.tsx` is intentionally using a placeholder. Our verification searches (using keywords like `getInput`, `getUserInput`, and `fetchInput`) yielded no hits in the codebase, confirming that no dedicated input API endpoint currently exists. Please update this link to point to the actual input data source when the appropriate API is implemented.

</details>
<details>
<summary>components/AnswerInput.tsx (4)</summary>

`1-8`: **Client-side component setup with necessary imports.**

The component correctly uses the "use client" directive for client-side rendering and imports all required dependencies. The usage of environment variables and utility functions is good practice.

---

`9-13`: **Well-defined props interface with TypeScript.**

The `AnswerInputProps` interface is correctly typed with a required `questionId` and an optional `validationSchema`.

---

`19-20`: **State management is appropriately implemented.**

The component correctly uses React's useState hook for managing the answer input and feedback message.

---

`24-37`: **Validation logic is well-implemented.**

The optional validation using the provided schema is properly implemented with appropriate error handling and feedback.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-01T13:40:33Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 1**

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 7e8e4a0284cdad6556bab3ed5b29b2de07e9886c and c26c8bccd0fb92201fca54e4906c4da6c3ce5a84.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `app/api/solutions/route.ts` (1 hunks)

</details>

<details>
<summary>🔇 Additional comments (2)</summary><blockquote>

<details>
<summary>app/api/solutions/route.ts (2)</summary>

`13-13`: **TODO needs implementation.**

The solution checking logic is a critical part of this feature. Without it, the API only acknowledges receipt of the answer but doesn't validate its correctness.


Do you need help implementing the solution checking logic? Based on the requirements, this should compare the submitted answer against the correct answer for the given questionId.

---

`6-6`: <details>
<summary>❓ Verification inconclusive</summary>

**Verify field name consistency with frontend.**

I notice that you're checking for `body.answer` here, but previous comments mentioned `body.solution`. Ensure that the field names match between your frontend and backend implementations.


Verify that the AnswerInput component is actually sending an `answer` field and not a `solution` field.

---

🏁 Script executed:

```shell
#!/bin/bash
# Find the form submission in the AnswerInput component
grep -r "const.*submit" --include="*.tsx" .
```

Length of output: 45

---



</details>

I'll run a new script to search for the AnswerInput component and verify whether it sends an "answer" field or a "solution" field. This will help determine if the backend check is correct.

Please execute the following shell script from the repository root:

```shell
#!/bin/bash
# Locate the AnswerInput component (assuming it's named accordingly)
echo "Searching for files containing 'AnswerInput'..."
fd -e tsx AnswerInput

# Look for the onSubmit handler or form submission in TSX files
echo "Searching for onSubmit handlers in TSX files..."
rg -n "onSubmit" --include "*.tsx"

# Check for usage of the fields "answer" and "solution" in TSX files
echo "Searching for 'answer' field in TSX files..."
rg -n "\banswer\b" --include "*.tsx"

echo "Searching for 'solution' field in TSX files..."
rg -n "\bsolution\b" --include "*.tsx"
```

If these searches confirm that the frontend’s AnswerInput component is indeed sending an `answer` field (and not `solution`), then the backend check is correct. If not, please adjust the field names accordingly.

**Please verify the AnswerInput component's implementation manually in case these automated searches remain inconclusive.**

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-11T05:19:49Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 2**

<details>
<summary>♻️ Duplicate comments (1)</summary><blockquote>

<details>
<summary>components/AnswerInput.tsx (1)</summary><blockquote>

`15-54`: _🛠️ Refactor suggestion_

**Add loading state and improve error handling.**

The form submission logic is well-structured, but it lacks a loading state during form submission and more specific error handling as noted in previous reviews.




Add a loading state to prevent multiple submissions and improve error handling to distinguish between different error types:

```diff
const AnswerInput: React.FC<AnswerInputProps> = ({
  questionId,
  validationSchema,
}) => {
  const [answer, setAnswer] = useState("");
  const [message, setMessage] = useState<string | null>(null);
+ const [isSubmitting, setIsSubmitting] = useState(false);

  const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
    e.preventDefault();
+   
+   if (isSubmitting) return;
+   setIsSubmitting(true);
+   setMessage(null);

    // Optionally validate the answer using the provided schema
    let validatedAnswer: string = answer;
    if (validationSchema) {
      const parsed = validationSchema.safeParse(answer);
      if (!parsed.success) {
        setMessage(
          "Invalid answer: " +
            JSON.stringify(parsed.error.flatten().fieldErrors)
        );
+       setIsSubmitting(false);
        return;
      } else {
        validatedAnswer = parsed.data;
      }
    }

    // Prepare the payload (including the questionId for context)
    const payload = { questionId, answer: validatedAnswer };

    // Use tryCatch to call your API
    const { data: resData, error: resError } = await tryCatch(
      axios.post(`${NEXT_PUBLIC_API_BASE_URL}/solutions`, payload)
    );

    if (resError) {
      console.error(resError);
-     setMessage(resError.message || "Error submitting answer");
+     // More specific error handling
+     if (axios.isAxiosError(resError)) {
+       if (resError.response) {
+         // The request was made and the server responded with a status code
+         // that falls out of the range of 2xx
+         setMessage(`Server error: ${resError.response.status} - ${resError.response.data?.message || 'Unknown error'}`);
+       } else if (resError.request) {
+         // The request was made but no response was received
+         setMessage("Network error: No response received from server");
+       } else {
+         // Something happened in setting up the request that triggered an Error
+         setMessage(`Request error: ${resError.message}`);
+       }
+     } else {
+       setMessage(resError.message || "Error submitting answer");
+     }
    } else {
      console.log(resData.data);
      setMessage(resData.data.message);
    }
+   setIsSubmitting(false);
  };
```

</blockquote></details>

</blockquote></details>

<details>
<summary>🧹 Nitpick comments (3)</summary><blockquote>

<details>
<summary>lib/utils/ApiError.ts (1)</summary><blockquote>

`1-7`: **Good implementation of a custom error class.**

The `ApiError` class is a clean, focused extension of the built-in Error class that allows adding contextual data to error objects. This is particularly useful for API error handling scenarios.

A few enhancement suggestions:

1. Consider making the `data` parameter optional with a default value.
2. For API errors, adding a `statusCode` property would be beneficial.
3. Using a more specific type or generic type parameter for `data` could provide better type safety.



```diff
export class ApiError extends Error {
  data: object;
-  constructor({ message, data }: { message: string; data: object }) {
+  statusCode?: number;
+  constructor({ 
+    message, 
+    data = {}, 
+    statusCode 
+  }: { 
+    message: string; 
+    data?: object; 
+    statusCode?: number 
+  }) {
    super(message);
    this.data = data;
+    this.statusCode = statusCode;
  }
}
```

</blockquote></details>
<details>
<summary>lib/utils/ApiResponse.ts (2)</summary><blockquote>

`1-6`: **Interface definition looks good, consider using generics.**

The `ApiResponseProps` interface is well-structured with appropriate types. Consider using TypeScript generics for the `data` property to make it more type-safe and flexible for different response types.

```diff
-interface ApiResponseProps {
+interface ApiResponseProps<T = object> {
  message: string;
-  data: object;
+  data: T;
  success?: boolean;
  options?: ResponseInit;
}
```

---

`8-39`: **Robust implementation of API response pattern.**

The implementation properly extends the native Response class and correctly merges default options with custom options. The header merging technique is particularly well-implemented to avoid overwriting the entire headers object.



Consider adding JSDoc comments to improve code documentation and maintainability:

```diff
+/**
+ * StandardizedAPI response class that extends the native Response
+ * Provides a consistent format for all API responses
+ */
export class ApiResponse extends Response {
  message: string;
  data: object;
  success: boolean;

+  /**
+   * Creates a new API response with standardized format
+   * @param message - Message describing the response
+   * @param data - Data payload to be returned
+   * @param success - Whether the request was successful
+   * @param options - Additional response options (status, headers, etc.)
+   */
  constructor({
    message,
    data,
    success = true,
    options = {},
  }: ApiResponseProps) {
    // Rest of the code remains unchanged
```

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between c26c8bccd0fb92201fca54e4906c4da6c3ce5a84 and 5a0fcd90186838b7d8244757323abedb8089b4aa.

</details>

<details>
<summary>📒 Files selected for processing (5)</summary>

* `app/api/solutions/route.ts` (1 hunks)
* `components/AnswerInput.tsx` (1 hunks)
* `lib/utils/ApiError.ts` (1 hunks)
* `lib/utils/ApiResponse.ts` (1 hunks)
* `lib/utils/asyncHandler.ts` (1 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* app/api/solutions/route.ts

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (2)</summary>

<details>
<summary>lib/utils/asyncHandler.ts (1)</summary><blockquote>

<details>
<summary>lib/utils/ApiResponse.ts (1)</summary>

* `ApiResponse` (8-39)

</details>

</blockquote></details>
<details>
<summary>components/AnswerInput.tsx (1)</summary><blockquote>

<details>
<summary>lib/utils/tryCatch.ts (1)</summary>

* `tryCatch` (22-31)

</details>

</blockquote></details>

</details>

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-11T06:12:24Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 1**

<details>
<summary>♻️ Duplicate comments (2)</summary><blockquote>

<details>
<summary>components/AnswerInput.tsx (2)</summary><blockquote>

`43-45`: **Enhance error handling for API responses.**

The current error handling doesn't differentiate between network issues, server errors, or different API response status codes. Consider adding more robust error handling.



Consider parsing the response status code and providing more context-specific feedback based on different error scenarios:

```diff
  const { data: resData, error: resError } = await tryCatch(
    axios.post(`${NEXT_PUBLIC_API_BASE_URL}/solutions`, payload)
  );

  if (resError) {
    if (process.env.NODE_ENV !== "production") {
      console.error(resError);
    }
+   // Check if it's an Axios error with response
+   if (axios.isAxiosError(resError) && resError.response) {
+     const status = resError.response.status;
+     if (status === 400) {
+       setMessage("Invalid submission: " + (resError.response.data?.message || "Please check your answer"));
+     } else if (status === 401 || status === 403) {
+       setMessage("Authentication error: You must be logged in to submit answers");
+     } else if (status >= 500) {
+       setMessage("Server error: Please try again later");
+     } else {
+       setMessage(`Error (${status}): ${resError.response.data?.message || "Something went wrong"}`);
+     }
+   } else {
+     // Network or other errors
+     setMessage("Network error: Please check your connection and try again");
+   }
-   setMessage(resError.message || "Error submitting answer");
    setIsError(true);
  } else {
    // Success handling remains the same
  }
```

---

`56-87`: _🛠️ Refactor suggestion_

**Update form UI to reflect submission state and message type.**

The form should provide visual feedback during submission and differentiate between success and error messages.


```diff
  return (
    <form
      onSubmit={handleSubmit}
      className="mt-1"
      aria-label="Answer submission form"
    >
      <label htmlFor="answer-input" className="sr-only">
        Enter your answer
      </label>
      <input
        type="text"
        id="answer-input"
        className="bg-crust border-overlay-0 min-w-1/3 border border-r-0 p-2"
        placeholder="Enter your answer"
        value={answer}
        onChange={(e) => setAnswer(e.target.value)}
        aria-required="true"
+       disabled={isSubmitting}
      />
      <button
        type="submit"
        className="text-text bg-surface-1 border-overlay-0 hover:bg-surface-2 cursor-pointer border p-2"
+       disabled={isSubmitting}
      >
-       Submit
+       {isSubmitting ? "Submitting..." : "Submit"}
      </button>

      {message && (
        <div 
-         className="text-lavender mt-2" 
+         className={`mt-2 ${isError ? "text-red" : "text-green"}`}
          role="status" 
          aria-live="polite"
        >
          {message}
        </div>
      )}
    </form>
  );
```

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 5a0fcd90186838b7d8244757323abedb8089b4aa and d7a4ac4e594de80870d7f4a9fc147e2762c9864b.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `components/AnswerInput.tsx` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (1)</summary>

<details>
<summary>components/AnswerInput.tsx (1)</summary><blockquote>

<details>
<summary>lib/utils/tryCatch.ts (1)</summary>

* `tryCatch` (22-31)

</details>

</blockquote></details>

</details>

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-11T06:23:06Z

Review comments:
diff_hunk: @@ -0,0 +1,4 @@
+export async function POST(request: Request) {
+  const { body } = request;
+  return new Response(body);
path: app/api/solutions/route.ts
user: login: Copilot
body: The request body is currently not being parsed, which may leave it as a ReadableStream. Consider using 'await request.json()' to properly extract the JSON payload.
```suggestion
  const body = await request.json();
  return new Response(JSON.stringify(body), {
    headers: { 'Content-Type': 'application/json' },
  });
```
created_at: 2025-04-01T13:34:08Z
author_association: NONE
diff_hunk: @@ -0,0 +1,4 @@
+export async function POST(request: Request) {
+  const { body } = request;
+  return new Response(body);
+}
path: app/api/solutions/route.ts
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**API implementation is incomplete and contains errors.**

The current implementation has several issues:
1. The request body cannot be accessed via destructuring. In Next.js App Router, you need to use `await request.json()`, `await request.text()`, or similar methods.
2. There's no input validation or solution checking logic implemented.
3. The endpoint simply echoes back the input without processing it.


Here's a corrected implementation with validation:

```diff
export async function POST(request: Request) {
-  const { body } = request;
-  return new Response(body);
+  try {
+    const body = await request.json();
+    
+    // Validate required fields
+    if (!body.solution || !body.questionId) {
+      return Response.json({ error: "Missing required fields" }, { status: 400 });
+    }
+    
+    // TODO: Implement actual solution checking logic here
+    
+    return Response.json({ 
+      success: true,
+      message: "Solution received" 
+    });
+  } catch (error) {
+    console.error("Error processing solution:", error);
+    return Response.json({ error: "Invalid request" }, { status: 400 });
+  }
}
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

`````suggestion
export async function POST(request: Request) {
  try {
    const body = await request.json();
    
    // Validate required fields
    if (!body.solution || !body.questionId) {
      return Response.json({ error: "Missing required fields" }, { status: 400 });
    }
    
    // TODO: Implement actual solution checking logic here
    
    return Response.json({ 
      success: true,
      message: "Solution received" 
    });
  } catch (error) {
    console.error("Error processing solution:", error);
    return Response.json({ error: "Invalid request" }, { status: 400 });
  }
}
`````

</details>

<!-- suggestion_end -->

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-04-01T13:40:32Z
author_association: NONE
diff_hunk: @@ -0,0 +1,76 @@
+"use client";
+
+import React, { FormEvent, useState } from "react";
+import { z } from "zod";
+import axios from "axios";
+import { tryCatch } from "@/lib/utils/tryCatch";
+import { NEXT_PUBLIC_API_BASE_URL } from "@/env/client";
+
+interface AnswerInputProps {
+  questionId: string;
+  // Assume the validation schema validates a string (the answer)
+  validationSchema?: z.Schema<string>;
+}
+
+const AnswerInput: React.FC<AnswerInputProps> = ({
+  questionId,
+  validationSchema,
+}) => {
+  const [answer, setAnswer] = useState("");
+  const [message, setMessage] = useState<string | null>(null);
+  const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
+    e.preventDefault();
+
+    // Optionally validate the answer using the provided schema
+    let validatedAnswer: string = answer;
+    if (validationSchema) {
+      const parsed = validationSchema.safeParse(answer);
+      if (!parsed.success) {
+        setMessage(
+          "Invalid answer: " +
+            JSON.stringify(parsed.error.flatten().fieldErrors)
+        );
+        return;
+      } else {
+        validatedAnswer = parsed.data;
+      }
+    }
+
+    // Prepare the payload (including the questionId for context)
+    const payload = { questionId, answer: validatedAnswer };
+
+    // Use tryCatch to call your API
+    const { data: resData, error: resError } = await tryCatch(
+      axios.post(`${NEXT_PUBLIC_API_BASE_URL}/solutions`, payload)
+    );
path: components/AnswerInput.tsx
user: login: coderabbitai[bot]
body: _💡 Verification agent_

<details>
<summary>🧩 Analysis chain</summary>

**Verify API endpoint and consider more robust error handling.**

The API call uses a constructed URL that needs to be verified. Additionally, consider enhancing error handling to provide more specific feedback based on different error scenarios.

---

🏁 Script executed:

```shell
#!/bin/bash
# Check if the solutions API endpoint exists
rg -A 10 "export.*POST" --type ts app/api/solutions/route.ts || echo "API endpoint may not exist"
```

Length of output: 168

---



</details>

**API endpoint verified, but update error handling for clarity.**

The API endpoint is confirmed to exist in `app/api/solutions/route.ts` and is accessible via a POST request. However, the current implementation in `components/AnswerInput.tsx` only captures errors in a generic way. Please consider enhancing error handling—for instance, by evaluating response status codes and differentiating between network errors and server errors—to provide clearer, context-specific feedback.

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-04-01T13:40:32Z
author_association: NONE
diff_hunk: @@ -0,0 +1,23 @@
+export async function POST(request: Request) {
+  try {
+    const body = await request.json();
+
+    // Validate required fields
+    if (!body.answer || !body.questionId) {
+      return Response.json(
+        { message: "Missing required fields" },
+        { status: 400 }
+      );
+    }
+
+    // TODO: Implement actual solution checking logic here
+
+    return Response.json({
+      success: true,
+      message: "Solution received",
+    });
+  } catch (error) {
+    console.error("Error processing solution:", error);
+    return Response.json({ error: "Invalid request" }, { status: 400 });
+  }
+}
path: app/api/solutions/route.ts
user: login: coderabbitai[bot]
body: _🛠️ Refactor suggestion_

**API implementation is well-structured but incomplete.**

The solution submission API has been implemented with proper request parsing, validation, and error handling. This is a good foundation for the feature. However, there are a few items to address:

1. The actual solution checking logic is marked with a TODO and hasn't been implemented yet.
2. There's inconsistency in error response formats - using `message` in validation errors but `error` in caught exceptions.
3. No type safety for the request body structure.


Consider adding a TypeScript interface for the request body to improve type safety:

```typescript
interface SolutionSubmission {
  answer: string;
  questionId: string | number;
}
```

Then modify the initial parsing:

```diff
-    const body = await request.json();
+    const body = await request.json() as SolutionSubmission;
```

Also, standardize error response format:

```diff
      return Response.json(
-        { message: "Missing required fields" },
+        { success: false, error: "Missing required fields" },
        { status: 400 }
      );
```

```diff
-    return Response.json({ error: "Invalid request" }, { status: 400 });
+    return Response.json({ success: false, error: "Invalid request" }, { status: 400 });
```

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-04-11T05:19:48Z
author_association: NONE
diff_hunk: @@ -0,0 +1,23 @@
+import { ApiResponse } from "@/lib/utils/ApiResponse";
+
+export const asyncHandler = (handler: (req: Request) => Promise<Response>) => {
+  return async (req: Request): Promise<Response> => {
+    try {
+      return await handler(req);
+    } catch (error) {
+      console.error("API Error:", error);
+      const errorMessage =
+        error instanceof Error ? error.message : "Internal server error";
+      // Return a new ApiResponse instance with error options.
+      return new ApiResponse({
+        success: false,
+        message: errorMessage,
+        data: {},
+        options: {
+          status: 500,
+          headers: { "Content-Type": "application/json" },
+        },
+      });
+    }
+  };
+};
path: lib/utils/asyncHandler.ts
user: login: coderabbitai[bot]
body: _🛠️ Refactor suggestion_

**Good error handling pattern, but consider more specific error types.**

The asyncHandler effectively centralizes error handling for API routes, which is a good practice. However, it currently treats all errors with a 500 status code regardless of error type.



Consider enhancing the error handling to differentiate between various error types:

```diff
import { ApiResponse } from "@/lib/utils/ApiResponse";

+/**
+ * Higher-order function to handle async API routes with standardized error handling
+ * @param handler - The route handler function to wrap
+ * @returns A wrapped handler with error handling
+ */
export const asyncHandler = (handler: (req: Request) => Promise<Response>) => {
  return async (req: Request): Promise<Response> => {
    try {
      return await handler(req);
    } catch (error) {
      console.error("API Error:", error);
+      
+      // Determine appropriate status code based on error type
+      let statusCode = 500;
+      if (error instanceof TypeError || error instanceof SyntaxError) {
+        statusCode = 400; // Bad Request for client-side errors
+      }
+      // Add more error type checks as needed
+      
      const errorMessage =
        error instanceof Error ? error.message : "Internal server error";
      // Return a new ApiResponse instance with error options.
      return new ApiResponse({
        success: false,
        message: errorMessage,
        data: {},
        options: {
-          status: 500,
+          status: statusCode,
          headers: { "Content-Type": "application/json" },
        },
      });
    }
  };
};
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

`````suggestion
import { ApiResponse } from "@/lib/utils/ApiResponse";

/**
 * Higher-order function to handle async API routes with standardized error handling
 * @param handler - The route handler function to wrap
 * @returns A wrapped handler with error handling
 */
export const asyncHandler = (handler: (req: Request) => Promise<Response>) => {
  return async (req: Request): Promise<Response> => {
    try {
      return await handler(req);
    } catch (error) {
      console.error("API Error:", error);
      
      // Determine appropriate status code based on error type
      let statusCode = 500;
      if (error instanceof TypeError || error instanceof SyntaxError) {
        statusCode = 400; // Bad Request for client-side errors
      }
      // Add more error type checks as needed
      
      const errorMessage =
        error instanceof Error ? error.message : "Internal server error";
      // Return a new ApiResponse instance with error options.
      return new ApiResponse({
        success: false,
        message: errorMessage,
        data: {},
        options: {
          status: statusCode,
          headers: { "Content-Type": "application/json" },
        },
      });
    }
  };
};
`````

</details>

<!-- suggestion_end -->

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-04-11T06:12:23Z
author_association: NONE
diff_hunk: @@ -0,0 +1,76 @@
+"use client";
+
+import React, { FormEvent, useState } from "react";
+import { z } from "zod";
+import axios from "axios";
+import { tryCatch } from "@/lib/utils/tryCatch";
+import { NEXT_PUBLIC_API_BASE_URL } from "@/env/client";
+
+interface AnswerInputProps {
+  questionId: string;
+  // Assume the validation schema validates a string (the answer)
+  validationSchema?: z.Schema<string>;
+}
+
+const AnswerInput: React.FC<AnswerInputProps> = ({
+  questionId,
+  validationSchema,
+}) => {
+  const [answer, setAnswer] = useState("");
+  const [message, setMessage] = useState<string | null>(null);
+  const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
+    e.preventDefault();
+
+    // Optionally validate the answer using the provided schema
+    let validatedAnswer: string = answer;
+    if (validationSchema) {
+      const parsed = validationSchema.safeParse(answer);
+      if (!parsed.success) {
+        setMessage(
+          "Invalid answer: " +
+            JSON.stringify(parsed.error.flatten().fieldErrors)
+        );
+        return;
+      } else {
+        validatedAnswer = parsed.data;
+      }
+    }
+
+    // Prepare the payload (including the questionId for context)
+    const payload = { questionId, answer: validatedAnswer };
+
+    // Use tryCatch to call your API
+    const { data: resData, error: resError } = await tryCatch(
+      axios.post(`${NEXT_PUBLIC_API_BASE_URL}/solutions`, payload)
+    );
+
+    if (resError) {
+      console.error(resError);
+      setMessage(resError.message || "Error submitting answer");
+    } else {
+      console.log(resData.data);
+      setMessage(resData.data.message);
+    }
+  };
+
+  return (
+    <form onSubmit={handleSubmit} className="mt-1">
+      <input
+        type="text"
+        className="bg-crust border-overlay-0 min-w-1/3 border border-r-0 p-2"
+        placeholder="Enter your answer"
+        value={answer}
+        onChange={(e) => setAnswer(e.target.value)}
+      />
+      <button
+        type="submit"
+        className="text-text bg-surface-1 border-overlay-0 hover:bg-surface-2 cursor-pointer border p-2"
+      >
+        Submit
+      </button>
+      {message && <div className="text-green mt-2">{message}</div>}
+    </form>
+  );
path: components/AnswerInput.tsx
user: login: coderabbitai[bot]
body: _🛠️ Refactor suggestion_

**Improve form accessibility and add loading state UI.**

The form's accessibility could be improved, and visual feedback during submission would enhance user experience.



```diff
  return (
-   <form onSubmit={handleSubmit} className="mt-1">
+   <form onSubmit={handleSubmit} className="mt-1" aria-label="Answer submission form">
+     <label htmlFor="answer-input" className="sr-only">Enter your answer</label>
      <input
        type="text"
+       id="answer-input"
        className="bg-crust border-overlay-0 min-w-1/3 border border-r-0 p-2"
        placeholder="Enter your answer"
        value={answer}
        onChange={(e) => setAnswer(e.target.value)}
+       aria-required="true"
+       disabled={isSubmitting}
      />
      <button
        type="submit"
        className="text-text bg-surface-1 border-overlay-0 hover:bg-surface-2 cursor-pointer border p-2"
+       disabled={isSubmitting}
+       aria-busy={isSubmitting}
      >
-       Submit
+       {isSubmitting ? 'Submitting...' : 'Submit'}
      </button>
-     {message && <div className="text-green mt-2">{message}</div>}
+     {message && (
+       <div 
+         className={`mt-2 ${resError ? 'text-red-500' : 'text-green'}`} 
+         role="status" 
+         aria-live="polite"
+       >
+         {message}
+       </div>
+     )}
    </form>
  );
```

Note: You'll need to track the error state to distinguish between success and error messages for proper styling.


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

`````suggestion
  return (
    <form onSubmit={handleSubmit} className="mt-1" aria-label="Answer submission form">
      <label htmlFor="answer-input" className="sr-only">Enter your answer</label>
      <input
        type="text"
        id="answer-input"
        className="bg-crust border-overlay-0 min-w-1/3 border border-r-0 p-2"
        placeholder="Enter your answer"
        value={answer}
        onChange={(e) => setAnswer(e.target.value)}
        aria-required="true"
        disabled={isSubmitting}
      />
      <button
        type="submit"
        className="text-text bg-surface-1 border-overlay-0 hover:bg-surface-2 cursor-pointer border p-2"
        disabled={isSubmitting}
        aria-busy={isSubmitting}
      >
        {isSubmitting ? 'Submitting...' : 'Submit'}
      </button>
      {message && (
        <div 
          className={`mt-2 ${resError ? 'text-red-500' : 'text-green'}`} 
          role="status" 
          aria-live="polite"
        >
          {message}
        </div>
      )}
    </form>
  );
`````

</details>

<!-- suggestion_end -->

<!-- This is an auto-generated comment by CodeRabbit -->

✅ Addressed in commit d7a4ac4
created_at: 2025-04-11T06:12:23Z
author_association: NONE
diff_hunk: @@ -0,0 +1,90 @@
+"use client";
+
+import React, { FormEvent, useState } from "react";
+import { z } from "zod";
+import axios from "axios";
+import { tryCatch } from "@/lib/utils/tryCatch";
+import { NEXT_PUBLIC_API_BASE_URL } from "@/env/client";
+
+interface AnswerInputProps {
+  questionId: string;
+  // Assume the validation schema validates a string (the answer)
+  validationSchema?: z.Schema<string>;
+}
+
+const AnswerInput: React.FC<AnswerInputProps> = ({
+  questionId,
+  validationSchema,
+}) => {
+  const [answer, setAnswer] = useState("");
+  const [message, setMessage] = useState<string | null>(null);
+  const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
+    e.preventDefault();
+
+    // Optionally validate the answer using the provided schema
+    let validatedAnswer: string = answer;
+    if (validationSchema) {
+      const parsed = validationSchema.safeParse(answer);
+      if (!parsed.success) {
+        setMessage(
+          "Invalid answer: " +
+            JSON.stringify(parsed.error.flatten().fieldErrors)
+        );
+        return;
+      } else {
+        validatedAnswer = parsed.data;
+      }
+    }
+
+    // Prepare the payload (including the questionId for context)
+    const payload = { questionId, answer: validatedAnswer };
+
+    // Use tryCatch to call your API
+    const { data: resData, error: resError } = await tryCatch(
+      axios.post(`${NEXT_PUBLIC_API_BASE_URL}/solutions`, payload)
+    );
+
+    if (resError) {
+      console.error(resError);
+      setMessage(resError.message || "Error submitting answer");
+    } else {
+      console.log(resData.data);
+      setMessage(resData.data.message);
+    }
+  };
path: components/AnswerInput.tsx
user: login: coderabbitai[bot]
body: _🛠️ Refactor suggestion_

**Add submission loading state and improve error handling.**

The form handler currently lacks a loading state, which can lead to multiple submissions if a user clicks repeatedly. Additionally, validation errors are displayed as raw JSON which isn't user-friendly.


```diff
const AnswerInput: React.FC<AnswerInputProps> = ({
  questionId,
  validationSchema,
}) => {
  const [answer, setAnswer] = useState("");
  const [message, setMessage] = useState<string | null>(null);
+ const [isSubmitting, setIsSubmitting] = useState(false);
+ const [isError, setIsError] = useState(false);

  const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
    e.preventDefault();
+   setIsSubmitting(true);
+   setIsError(false);

    // Optionally validate the answer using the provided schema
    let validatedAnswer: string = answer;
    if (validationSchema) {
      const parsed = validationSchema.safeParse(answer);
      if (!parsed.success) {
+       const errorMessages = Object.values(parsed.error.flatten().fieldErrors)
+         .flat()
+         .join(", ");
        setMessage(
-         "Invalid answer: " +
-           JSON.stringify(parsed.error.flatten().fieldErrors)
+         `Invalid answer: ${errorMessages || "Please check your input"}`
        );
+       setIsError(true);
+       setIsSubmitting(false);
        return;
      } else {
        validatedAnswer = parsed.data;
      }
    }

    // Prepare the payload (including the questionId for context)
    const payload = { questionId, answer: validatedAnswer };

    // Use tryCatch to call your API
    const { data: resData, error: resError } = await tryCatch(
      axios.post(`${NEXT_PUBLIC_API_BASE_URL}/solutions`, payload)
    );

    if (resError) {
-     console.error(resError);
+     // Log only in development
+     if (process.env.NODE_ENV !== "production") {
+       console.error(resError);
+     }
      setMessage(resError.message || "Error submitting answer");
+     setIsError(true);
    } else {
-     console.log(resData.data);
+     // Log only in development
+     if (process.env.NODE_ENV !== "production") {
+       console.log(resData.data);
+     }
      setMessage(resData.data.message);
    }
+   setIsSubmitting(false);
  };
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

`````suggestion
const AnswerInput: React.FC<AnswerInputProps> = ({
  questionId,
  validationSchema,
}) => {
  const [answer, setAnswer] = useState("");
  const [message, setMessage] = useState<string | null>(null);
  const [isSubmitting, setIsSubmitting] = useState(false);
  const [isError, setIsError] = useState(false);

  const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
    e.preventDefault();
    setIsSubmitting(true);
    setIsError(false);

    // Optionally validate the answer using the provided schema
    let validatedAnswer: string = answer;
    if (validationSchema) {
      const parsed = validationSchema.safeParse(answer);
      if (!parsed.success) {
        const errorMessages = Object.values(parsed.error.flatten().fieldErrors)
          .flat()
          .join(", ");
        setMessage(
          `Invalid answer: ${errorMessages || "Please check your input"}`
        );
        setIsError(true);
        setIsSubmitting(false);
        return;
      } else {
        validatedAnswer = parsed.data;
      }
    }

    // Prepare the payload (including the questionId for context)
    const payload = { questionId, answer: validatedAnswer };

    // Use tryCatch to call your API
    const { data: resData, error: resError } = await tryCatch(
      axios.post(`${NEXT_PUBLIC_API_BASE_URL}/solutions`, payload)
    );

    if (resError) {
      // Log only in development
      if (process.env.NODE_ENV !== "production") {
        console.error(resError);
      }
      setMessage(resError.message || "Error submitting answer");
      setIsError(true);
    } else {
      // Log only in development
      if (process.env.NODE_ENV !== "production") {
        console.log(resData.data);
      }
      setMessage(resData.data.message);
    }
    setIsSubmitting(false);
  };

  // ... (rest of the component code, e.g., form rendering)
};
`````

</details>

<!-- suggestion_end -->

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-04-11T06:23:05Z
author_association: NONE

PR comments:
user: login: vercel[bot]
created_at: 2025-04-01T13:33:15Z
body: [vc]: #HXRYcuLhbix+NXscQKqV+/VUeb51O2bxemjS6bYeCgA=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJyZXRyZWF0LW9mLWNvZGUiLCJsaXZlRmVlZGJhY2siOnsicmVzb2x2ZWQiOjAsInVucmVzb2x2ZWQiOjAsInRvdGFsIjowLCJsaW5rIjoicmV0cmVhdC1vZi1jb2RlLWdpdC1mZWF0LWlucHV0LXN1Ym1pc3Npb24tcmFodWxjMGR5cy1wcm9qZWN0cy52ZXJjZWwuYXBwIn0sImluc3BlY3RvclVybCI6Imh0dHBzOi8vdmVyY2VsLmNvbS9yYWh1bGMwZHlzLXByb2plY3RzL3JldHJlYXQtb2YtY29kZS9FaUxlN3lvVGtkR2M2UHM5S3pzRGY2WWoxeWZRIiwicHJldmlld1VybCI6InJldHJlYXQtb2YtY29kZS1naXQtZmVhdC1pbnB1dC1zdWJtaXNzaW9uLXJhaHVsYzBkeXMtcHJvamVjdHMudmVyY2VsLmFwcCIsIm5leHRDb21taXRTdGF0dXMiOiJERVBMT1lFRCIsInJvb3REaXJlY3RvcnkiOm51bGx9XX0=
**The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)

| Name | Status | Preview | Comments | Updated (UTC) |
| :--- | :----- | :------ | :------- | :------ |
| **retreat-of-code** | ✅ Ready ([Inspect](https://vercel.com/rahulc0dys-projects/retreat-of-code/EiLe7yoTkdGc6Ps9KzsDf6Yj1yfQ)) | [Visit Preview](https://retreat-of-code-git-feat-input-submission-rahulc0dys-projects.vercel.app) | 💬 [**Add feedback**](https://vercel.live/open-feedback/retreat-of-code-git-feat-input-submission-rahulc0dys-projects.vercel.app?via=pr-comment-feedback-link) | Apr 11, 2025 6:19am |


author_association: NONE
user: login: coderabbitai[bot]
created_at: 2025-04-01T13:33:20Z
body: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- walkthrough_start -->

## Walkthrough
The changes introduce new UI elements and backend functionality. A new `AnswerInput` component is added and integrated into the question page, allowing users to submit answers. A new link is introduced on the questions page to navigate back home. A POST API endpoint is implemented to handle solution submissions by extracting the request body and returning it in the response. Additionally, several environment configuration imports are updated, and the environment management is enhanced via new client and server files. The dependencies in the project are updated accordingly.

## Changes

| File(s) | Summary |
|---------|---------|
| `app/(root)/questions/[year]/[day]/page.tsx`<br>`app/(root)/questions/[year]/page.tsx` | Added new UI elements: integrated `AnswerInput` in the day-specific page with a "Get your input" link, and added a "Back to Home" link in the year page. |
| `components/AnswerInput.tsx` | Introduced new `AnswerInput` React component that captures user answers, validates input, and sends a POST request with the answer payload via Axios. |
| `app/api/solutions/route.ts` | Added an asynchronous `POST` function to handle solution submissions by extracting the request body and returning it in the response. |
| `auth.ts`<br>`db/index.ts`<br>`drizzle.config.ts` | Updated import paths for environment variables from `"@/env"` to `"@/env/server"`. |
| `env/client.ts`<br>`env/server.ts` | Created a new client environment file setting up `NEXT_PUBLIC_API_BASE_URL` with validation and modified the server environment configuration (updated `createEnv` import and config properties). |
| `package.json` | Removed dependency `@t3-oss/env-core`, added `@t3-oss/env-nextjs`, and introduced the `axios` dependency. |
| `lib/utils/ApiError.ts` | Added a new `ApiError` class extending the built-in `Error` class with additional properties for error handling. |
| `lib/utils/ApiResponse.ts` | Introduced a new interface `ApiResponseProps` and a new class `ApiResponse` extending the built-in `Response` class for structured API responses. |
| `lib/utils/asyncHandler.ts` | Added a new utility function `asyncHandler` to manage asynchronous request handling with error logging and response formatting. |

## Sequence Diagram(s)
```mermaid
sequenceDiagram
    participant U as User
    participant AI as AnswerInput Component
    participant API as POST Endpoint
    participant S as Server

    U->>AI: Fills in answer and submits form
    AI->>AI: Validates input (using Zod if provided)
    AI->>API: Sends payload via Axios POST request
    API->>S: Processes request and echoes payload
    S-->>API: Returns response data
    API-->>AI: Sends response or error message
    AI-->>U: Displays success/error feedback
```

## Assessment against linked issues

| Objective | Addressed | Explanation |
|-----------|-----------|-------------|
| Add unique answer submission per user (#4) | ✅ |  |

> 🐇 In a world of questions and answers bright,  
> A new input box brings delight!  
> Users can share their thoughts with glee,  
> While hopping back home, oh so free!  
> With paths updated and errors caught,  
> A smoother journey, all thanks to thought! 🌟

<!-- walkthrough_end -->

<!-- announcements_start -->

> [!TIP]
> <details>
> <summary>⚡💬 Agentic Chat (Pro Plan, General Availability)</summary>
> 
> - We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
> 
> </details>

<!-- announcements_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpADK2VmgqyjcEj2wAbb5AokAI7Y0riQ4rjedJAARABmJNQAFPAY3HiQiNgCzEiI8PgYAJRcaLT0qelhWTl5BVgU+HgkMZAA7mjINbm4NPRy4bCe2IiU/miwPgwADLTymBXI8EoY4nHw0Z2QGE4CYwAc/Fi4Q5AA4uoAEtn+JNz4+QSukHH4fDEBuAHUYPhxYEwlBpWh4eBR4MwXPJXgwRvw4oNULYUMgCOhyig0hlunVCugMPQGEMGABrVJESDefBEeAMcL4QaeNDcbjeWnUeoadynJSIBjg7jiPFNSKpaSDaiMxiwTCkZCQpSYxHIZFlWgBRDINCZbiieDrOm8QRRZi3bzUaJoyoZGUEtkYCltdQIY6nZncAA0Or1BrQvnkZFtDHJUri2AwYnqfvU8gGENZJDYqxDJ085AY0kQUMp1NpLzekBGlFRDJxYWtuC1BPzfFT6BZbIYHLxaKJohJgwengryBIcQSkak3lkGhgCBVdlo+HFGHwYQYVNG+IDAA8kOIHSistIuQYAILldRR/1euvI1IL7C89DS9tsxBhE6SutoPCwAsy5BGiTLS0MshZAEErzooIZENgv72uKLieK8vj4G0dBetqozeP8AQ/iQbTwlKgLdl+lCvBQbC0F66aZtmTCsOwWpAWqSH4vQNAPrR3YRt4V5/pAEjRrQFpSn2A7iFI5CajhdZErKO5jkyb4FkwGDrMRqIymEAhzrA2xYYxkAkGu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QG5ECBDUAAThbFKBpguY1sfsH2CVi6QmMX6IwENT9j9gAgSqLQGmBxABArYw1KahfZxAmw3I+1AWNbHTB+x9qPiP2KToZhuRaAUsZGKzFDi9xU48sWuJfZ9j9gSdMcdmNoD7BDU9qe1NmO5HZik6hqJOioH7L7Bpg+wdsYWO1CDiIAq8bMWgELEMAVx3I1sZuLzE/jsxswbMXEELGtjFxL7J8SQENTZjKxhqBgD2MrH2oBAh4o8UBLJjqA4xtmRMZhBTGMV/okYoAA= -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details>
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=rahulc0dy/retreat-of-code&utm_content=8):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Generate unit testing code for this file.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai generate unit testing code for this file.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and generate unit testing code.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai plan` to trigger planning for file edits and PR creation.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
author_association: NONE
user: login: socket-security[bot]
created_at: 2025-04-11T05:17:30Z
body: **Review the following changes in direct dependencies.** Learn more about [Socket for GitHub ↗](https://socket.dev?utm_medium=gh).

<table>
<thead>
<tr>
<th width="6%"></th>
<th width="200px">Package</th>
<th align="center" width="100px">Supply Chain<br/>Security</th>
<th align="center" width="100px">Vulnerability</th>
<th align="center" width="100px">Quality</th>
<th align="center" width="100px">Maintenance</th>
<th align="center" width="100px">License</th>
</tr>
</thead>
<tbody>
<tr><td><a href="https://socket.dev/dashboard/org/rahulc0dy/diff/fb909cd9-3d33-45c9-82a1-a99506475741/21a0163b-141b-4b47-b2ba-6b2ea510c66d?tab=dependencies&dependency_item_key=16473324082"><img src="https://github-app-statics.socket.dev/diff-added.svg" title="Added" alt="Added" width="20" height="20"></a></td><td><a href="https://socket.dev/dashboard/org/rahulc0dy/diff/fb909cd9-3d33-45c9-82a1-a99506475741/21a0163b-141b-4b47-b2ba-6b2ea510c66d?tab=dependencies&dependency_item_key=16473324082">axios@1.8.4</a></td><td align="center"><a href="https://socket.dev/dashboard/org/rahulc0dy/diff/fb909cd9-3d33-45c9-82a1-a99506475741/21a0163b-141b-4b47-b2ba-6b2ea510c66d?tab=dependencies&dependency_item_key=16473324082"><img src="https://github-app-statics.socket.dev/score-99.svg" title="Supply Chain Security" width="40" height="40" alt="99"></a></td><td align="center"><a href="https://socket.dev/dashboard/org/rahulc0dy/diff/fb909cd9-3d33-45c9-82a1-a99506475741/21a0163b-141b-4b47-b2ba-6b2ea510c66d?tab=dependencies&dependency_item_key=16473324082"><img src="https://github-app-statics.socket.dev/score-100.svg" title="Vulnerability" width="40" height="40" alt="100"></a></td><td align="center"><a href="https://socket.dev/dashboard/org/rahulc0dy/diff/fb909cd9-3d33-45c9-82a1-a99506475741/21a0163b-141b-4b47-b2ba-6b2ea510c66d?tab=dependencies&dependency_item_key=16473324082"><img src="https://github-app-statics.socket.dev/score-100.svg" title="Quality" width="40" height="40" alt="100"></a></td><td align="center"><a href="https://socket.dev/dashboard/org/rahulc0dy/diff/fb909cd9-3d33-45c9-82a1-a99506475741/21a0163b-141b-4b47-b2ba-6b2ea510c66d?tab=dependencies&dependency_item_key=16473324082"><img src="https://github-app-statics.socket.dev/score-97.svg" title="Maintenance" width="40" height="40" alt="97"></a></td><td align="center"><a href="https://socket.dev/dashboard/org/rahulc0dy/diff/fb909cd9-3d33-45c9-82a1-a99506475741/21a0163b-141b-4b47-b2ba-6b2ea510c66d?tab=dependencies&dependency_item_key=16473324082"><img src="https://github-app-statics.socket.dev/score-100.svg" title="License" width="40" height="40" alt="100"></a></td></tr>
</tbody>
</table>

[View full report ↗](https://socket.dev/dashboard/org/rahulc0dy/diff/fb909cd9-3d33-45c9-82a1-a99506475741/21a0163b-141b-4b47-b2ba-6b2ea510c66d?tab=dependencies)

<!-- overview-comment -->
author_association: NONE