Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/joshsoftware/lingo.ai into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sourabh-josh committed Sep 24, 2024
2 parents eccd9c6 + 1d97cb4 commit d748382
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 16 deletions.
10 changes: 8 additions & 2 deletions app/src/app/new/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import NavigateBack from "@/components/NavigateBack";
import RecorderCard from "@/components/RecorderCard";
import { Metadata } from "next";

Expand All @@ -7,8 +8,13 @@ export const metadata: Metadata = {

const page = () => {
return (
<div className="flex flex-col h-screen md:flex-row w-full justify-center items-center gap-4 pt-16 px-0 md:px-16">
<RecorderCard />
<div className="flex flex-col w-full h-screen pt-16 px-0 md:px-16">
<div className="flex justify-start w-full px-4 mt-8">
<NavigateBack href="/" />
</div>
<div className="flex flex-1 justify-center items-center">
<RecorderCard />
</div>
</div>
);
};
Expand Down
12 changes: 9 additions & 3 deletions app/src/app/register/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import NavigateBack from "@/components/NavigateBack";
import RegisterForm from "@/components/RegisterForm";

import { Metadata } from "next";
Expand All @@ -8,10 +9,15 @@ export const metadata: Metadata = {

const page = async () => {
return (
<div className="flex flex-col md:flex-row w-full h-screen justify-center items-center gap-4 pt-16 px-0 md:px-16">
<RegisterForm />
<div className="flex flex-col w-full h-screen pt-16 px-0 md:px-16">
<div className="flex justify-start w-full px-4 mt-8">
<NavigateBack />
</div>
<div className="flex flex-1 justify-center items-center">
<RegisterForm />
</div>
</div>
);
};

export default page;
export default page;
15 changes: 11 additions & 4 deletions app/src/app/transcriptions/[transcription_id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// transcriptions / [transcription_id] / page.tsx

import DetailedTranscription from "@/components/DetailedTranscription";
import NavigateBack from "@/components/NavigateBack";
import { db } from "@/db";
import { transcriptions } from "@/db/schema";
import { eq } from "drizzle-orm";
Expand All @@ -26,10 +27,16 @@ const page = async (props: PageProps) => {
.where(eq(transcriptions.id, transcription_id));

return (
<div className="flex flex-col w-full min-h-screen overflow-y-auto justify-center items-center gap-4 pt-16 px-0 md:px-16">
{transcription.length > 0 && (
<DetailedTranscription transcription={transcription[0]} />
)}

<div className="flex flex-col w-full h-screen pt-16 px-0 md:px-16">
<div className="flex justify-start w-full px-4 mt-8">
<NavigateBack subHeading={`Transcription for ${transcription[0].documentName}`} />
</div>
<div className="flex flex-1 justify-center items-center">
{transcription.length > 0 && (
<DetailedTranscription transcription={transcription[0]} />
)}
</div>
</div>
);
};
Expand Down
16 changes: 11 additions & 5 deletions app/src/app/transcriptions/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import NavigateBack from "@/components/NavigateBack";
import TranscriptionItem from "@/components/TranscriptionItem";
import { db } from "@/db";
import { transcriptions } from "@/db/schema";
Expand Down Expand Up @@ -26,11 +27,16 @@ const page = async () => {
.orderBy(desc(transcriptions.createdAt));

return (
<div className="flex flex-col w-full h-screen overflow-y-hidden justify-center items-center gap-4 pt-16 px-0 md:px-16">
<div className="flex flex-col w-full max-h-96 overflow-y-auto gap-4">
{userTranscriptions.map((transcription, idx) => (
<TranscriptionItem key={idx} index={idx} transcription={transcription} />
))}
<div className="flex flex-col w-full h-screen pt-16 px-0 md:px-16">
<div className="flex justify-start w-full px-4 mt-8">
<NavigateBack subHeading="Transcriptions" />
</div>
<div className="flex flex-1 justify-center items-center">
<div className="flex flex-col w-full max-h-96 overflow-y-auto gap-4">
{userTranscriptions.map((transcription, idx) => (
<TranscriptionItem key={idx} index={idx} transcription={transcription} />
))}
</div>
</div>
</div>
);
Expand Down
31 changes: 31 additions & 0 deletions app/src/components/NavigateBack.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use client'

import { useRouter } from "next/navigation"
import { Button } from "./ui/button"
import { ArrowLeftIcon } from "lucide-react"

interface NavigateBackProps {
href?: string
subHeading?: string
}

const NavigateBack = (props: NavigateBackProps) => {
const { href, subHeading } = props
const router = useRouter()

const handleBack = () => {
href ? router.push(href) : router.back()
}

return (
<div className="flex justify-between items-center w-full">
<Button className="flex gap-4" variant={"ghost"} onClick={handleBack}>
<ArrowLeftIcon className="w-6 h-6" />
Back
</Button>
{subHeading && <div className="w-full flex justify-center items-center text-2xl font-bold">{subHeading}</div>}
</div>
)
}

export default NavigateBack
8 changes: 6 additions & 2 deletions app/src/components/RegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import { useMutation } from "@tanstack/react-query";
import axios, { AxiosError } from "axios";
import { toast } from "sonner";
import { useRouter } from "next/navigation";
import { useEffect } from "react";
import { useEffect, useState } from "react";

const RegisterForm = () => {
const router = useRouter();
const [isPersistingUser,setIsPersistingUser] = useState(false);

useEffect(() => {
if (typeof window !== "undefined" && localStorage.getItem("user")) {
Expand Down Expand Up @@ -51,6 +52,7 @@ const RegisterForm = () => {
}
form.reset();
router.push("/new");
setIsPersistingUser(false);
},
onError: (error) => {
if (error instanceof AxiosError) {
Expand All @@ -67,6 +69,7 @@ const RegisterForm = () => {
});

const onSubmit = (data: RegisterUserRequest) => {
setIsPersistingUser(true);
mutate(data);
};

Expand Down Expand Up @@ -110,7 +113,8 @@ const RegisterForm = () => {
/>
</div>
<Button
isLoading={isPending}
isLoading={isPersistingUser || isPending}
disabled={isPersistingUser || isPending}
type="submit"
className="bg-[#668D7E] hover:bg-[#668D7E] text-white w-full"
>
Expand Down

0 comments on commit d748382

Please sign in to comment.