Skip to content

Commit

Permalink
Loading Icons and API .env template
Browse files Browse the repository at this point in the history
  • Loading branch information
VVoruganti committed Sep 2, 2024
1 parent 18a096b commit 199dd95
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 17 deletions.
14 changes: 14 additions & 0 deletions api/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Azure Mirascope Keys
AZURE_OPENAI_ENDPOINT=
AZURE_OPENAI_API_KEY=
AZURE_OPENAI_API_VERSION=
AZURE_OPENAI_DEPLOYMENT=

# Supabase Settings
SUPABASE_URL=
SUPABASE_KEY=

# NextJS & fastAPI
URL=http://localhost:3000
HONCHO_URL=https://demo.honcho.dev
HONCHO_APP_NAME=
2 changes: 1 addition & 1 deletion api/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

LOCK = asyncio.Lock()
honcho = Honcho(base_url=getenv("HONCHO_URL"))
app = honcho.apps.get_or_create("Tutor-GPT")
app = honcho.apps.get_or_create(getenv("HONCHO_APP_NAME"))
36 changes: 24 additions & 12 deletions www/components/auth/signIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,29 @@ export default function SignIn(props: any) {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [error, setError] = useState(false)
const [isLoading, setIsLoading] = useState(false)
const formRef = useRef<HTMLFormElement>(null);

const handleSignIn = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
if (!formRef.current) return;

setIsLoading(true)
const formData = new FormData(formRef.current);

const error = await handler(formData);
if (error) {
setError(true)
Swal.fire({
title: 'Error!',
text: 'Incorrect Credentials',
icon: 'error',
confirmButtonText: 'Close',
confirmButtonColor: "#3085d6",
})
try {
const error = await handler(formData);
if (error) {
setError(true)
Swal.fire({
title: 'Error!',
text: 'Incorrect Credentials',
icon: 'error',
confirmButtonText: 'Close',
confirmButtonColor: "#3085d6",
})
}
} finally {
setIsLoading(false)
}
};

Expand Down Expand Up @@ -67,7 +72,14 @@ export default function SignIn(props: any) {
<button
className="inline-block shrink-0 rounded-md border border-neon-green bg-neon-green px-12 py-3 text-sm font-medium transition hover:bg-transparent hover:text-blue-600 focus:outline-none focus:ring active:text-blue-500"
>
Login
{isLoading ? (
<>
<svg className="animate-spin h-5 w-5" viewBox="0 0 24 24">
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
</>
): 'Login'}
</button>

<p className="mt-4 text-sm text-gray-500 sm:mt-0">
Expand Down
29 changes: 25 additions & 4 deletions www/components/auth/signUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ export default function SignUp(props: any) {
const [passwordConfirmation, setPasswordConfirmation] = useState('');
const [opt, setOpt] = useState<boolean>(true)
const [age, setAge] = useState<boolean>(false)
const [isLoading, setIsLoading] = useState(false)
const formRef = useRef<HTMLFormElement>(null);

const handleSignUp = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
if (!formRef.current) return;
const formData = new FormData(formRef.current);
if (!age) {
setIsLoading(true)
try {
const formData = new FormData(formRef.current);
if (!age) {
await Swal.fire({
title: "Age Verification Required",
icon: 'error',
text: 'Please confirm that you are 13 years or older',
confirmButtonText: 'Close',
confirmButtonColor: "#3085d6",
})
return
}
Expand All @@ -31,6 +36,8 @@ export default function SignUp(props: any) {
title: "Passwords don't match",
icon: 'error',
text: 'Re-confirm you password and try again',
confirmButtonText: 'Close',
confirmButtonColor: "#3085d6",
})
return
}
Expand All @@ -39,6 +46,8 @@ export default function SignUp(props: any) {
title: "Insufficient Password",
icon: 'error',
text: 'Make sure the password is atleast 6 characters long',
confirmButtonText: 'Close',
confirmButtonColor: "#3085d6",
})
return
}
Expand All @@ -49,15 +58,22 @@ export default function SignUp(props: any) {
title: "Something went wrong",
icon: "error",
text: "Please try again and make sure the password is atleast 6 characters long",
confirmButtonText: 'Close',
confirmButtonColor: "#3085d6",
})
console.error(error);
} else {
Swal.fire({
title: "Success",
icon: "success",
text: "Please check your email for a verification link"
text: "Please check your email for a verification link",
confirmButtonText: 'Close',
confirmButtonColor: "#3085d6",
})
}
} finally {
setIsLoading(false)
}
}


Expand Down Expand Up @@ -164,7 +180,12 @@ export default function SignUp(props: any) {
<button
className="inline-block shrink-0 rounded-md border border-neon-green bg-neon-green px-12 py-3 text-sm font-medium transition hover:bg-transparent hover:text-blue-600 focus:outline-none focus:ring active:text-blue-500"
>
Create an account
{isLoading ? (
<svg className="animate-spin h-5 w-5" viewBox="0 0 24 24">
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
) : 'Create an account'}
</button>

<p className="mt-4 text-sm text-gray-500 sm:mt-0">
Expand Down

0 comments on commit 199dd95

Please sign in to comment.