From bb5057a7735237b13012defa82c7ee4e7c5688b5 Mon Sep 17 00:00:00 2001
From: PadamSinha2511
Date: Thu, 15 Aug 2024 21:51:49 +0530
Subject: [PATCH 1/2] Synced local files to container files
---
compose.yaml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/compose.yaml b/compose.yaml
index 6f7c26f..3a5de47 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -3,6 +3,9 @@ services:
build:
context: .
dockerfile: Dockerfile.dev
+ volumes:
+ - .:/usr/src/app
+ - /usr/src/app/node_modules
env_file:
- .env
environment: # To override the DB URL in the .env file
From d91be981915994714ef7a9ec85e548aa40850b5f Mon Sep 17 00:00:00 2001
From: PadamSinha2511
Date: Fri, 16 Aug 2024 16:51:25 +0530
Subject: [PATCH 2/2] Save button only enables when repo url is valid
---
src/app/account/repo/add/form.js | 26 ++++++++++++++++++++++----
src/components/forms/Input.js | 2 ++
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/src/app/account/repo/add/form.js b/src/app/account/repo/add/form.js
index 7db2b93..e4158e3 100644
--- a/src/app/account/repo/add/form.js
+++ b/src/app/account/repo/add/form.js
@@ -7,6 +7,7 @@ import { SubmitButton } from "@/components/forms/SubmitButton";
import Input from "@/components/forms/Input";
import Checkbox from "@/components/forms/Checkbox";
import Alert from "@/components/Alert";
+import {useState,useEffect} from "react"
const initialState = {
data: undefined,
@@ -16,8 +17,22 @@ const initialState = {
export default function Form({ usage }) {
const [state, formAction] = useFormState(getRepo, initialState);
- const disabled = usage >= process.env.NEXT_PUBLIC_REPO_LIMIT ? true : false;
+ const [usageLimitReached,setUsageLimitReached] = useState(false)
+ const [githubUrl , setGithubUrl] = useState(state?.data?.url || '')
+ const [isGithubUrlValid,setIsGithubUrlValid] = useState(false)
+ const [isDisabled,setIsDisabled] = useState(true)
+ const githubRegex = /^https:\/\/github\.com\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+$/;
+
+ useEffect(()=>{
+
+ setUsageLimitReached(usage >= process.env.NEXT_PUBLIC_REPO_LIMIT);
+ setIsGithubUrlValid(githubRegex.test(githubUrl))
+
+ setIsDisabled(usageLimitReached || !isGithubUrlValid)
+
+ },[usage,githubUrl])
+
return (
+
setGithubUrl(e.target.value)}
+ disabled={usageLimitReached}
/>
@@ -79,7 +96,8 @@ export default function Form({ usage }) {
-
+
+
);
diff --git a/src/components/forms/Input.js b/src/components/forms/Input.js
index bc344e7..ef4a7c4 100644
--- a/src/components/forms/Input.js
+++ b/src/components/forms/Input.js
@@ -11,6 +11,7 @@ export default function Input({
error,
prepend,
disabled = false,
+ onChange,
type = "text",
}) {
const { pending } = useFormStatus();
@@ -28,6 +29,7 @@ export default function Input({
type={type}
disabled={pending || disabled ? true : false}
name={id}
+ onChange={onChange}
id={id}
className={classNames(
"block w-full rounded-md border-0 sm:text-sm sm:leading-6 bg-gray-800 disabled:bg-gray-600",