Skip to content

Commit

Permalink
fix: fix buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
D0dii authored and simon-the-shark committed Sep 10, 2024
1 parent d5fa45a commit 47e5476
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 71 deletions.
49 changes: 0 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/app/api/profile/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createUsosService } from "@/lib/usos";

export async function GET() {
return Response.json(await createUsosService().getProfile());
}
1 change: 0 additions & 1 deletion src/components/Schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const ScheduleTest = ({
const filterScheduleByDay = (dayCode: string) => {
return schedule.filter((item) => item.day === dayCode);
};
console.log(schedule);

return (
<div className="overflow-x flex flex-col gap-3 overflow-auto scrollbar-thin scrollbar-track-sky-300 scrollbar-thumb-sky-900">
Expand Down
8 changes: 5 additions & 3 deletions src/pages/createplan/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const CreatePlan = ({
}: InferGetServerSidePropsType<typeof getServerSideProps>) => {
const [plan, setPlan] = useAtom(planFamily({ id: planId }));
const inputRef = useRef<HTMLInputElement>(null);
console.log(plan);
const [isError, setIsError] = useState(false);

const handleDepartmentChange = async (
facultyName: string,
Expand Down Expand Up @@ -131,6 +131,7 @@ const CreatePlan = ({
);

if (!selectedRegistration) {
setIsError(true);
throw new Error(`Registration with ID ${registrationId} not found`);
}

Expand Down Expand Up @@ -280,9 +281,9 @@ const CreatePlan = ({
</div>

<div className="flex w-full items-center justify-between gap-1 md:flex-col lg:flex-row">
<PlanDisplayLink
{/* <PlanDisplayLink
hash={encodeToBase64(JSON.stringify(plan))}
/>
/> */}
</div>
</div>
</div>
Expand All @@ -293,6 +294,7 @@ const CreatePlan = ({
handleDepartmentChange={handleDepartmentChange}
handleRegistrationChange={handleRegistrationChange}
/>
{isError && <div>Wystąpił błąd</div>}
</div>
</div>
<hr />
Expand Down
56 changes: 38 additions & 18 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useQuery } from "@tanstack/react-query";
import { motion } from "framer-motion";
// import { ChevronRightIcon } from "lucide-react";
import Image from "next/image";
Expand Down Expand Up @@ -159,7 +160,13 @@ const AnimationLogo = () => (
</Block>
);

const JoinUsBlock = () => (
const JoinUsBlock = ({
canPlan,
isLoading,
}: {
canPlan: boolean;
isLoading: boolean;
}) => (
<Block className="flex flex-col items-center justify-center gap-6 md:gap-10">
<div className="">
<h1 className="text-center text-4xl font-medium leading-tight md:text-left">
Expand All @@ -175,35 +182,38 @@ const JoinUsBlock = () => (
</p>
</div>
<div className="z-50">
{process.env.NODE_ENV === "development" ||
(typeof window !== "undefined" &&
window.location.hostname === "planer.solvro.pl") ? (
{isLoading ? (
<div className="text-white">Loading...</div>
) : canPlan ? (
<Link
href="#"
href="/plans"
data-umami-event="Landing - Go to planning"
className={buttonVariants({
size: "lg",
variant: "outline",
className: cn(
"h-20 cursor-wait self-center border-4 text-xl opacity-80 transition-all duration-300 md:mt-0 md:p-7",
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
false &&
"cursor-pointer hover:bg-white hover:shadow-[0_0_5px_rgb(200,200,255),0_0_10px_rgb(164,200,255)]",
"cursor-pointer hover:bg-white hover:shadow-[0_0_5px_rgb(200,200,255),0_0_10px_rgb(164,200,255)]",
),
})}
>
{/* Przejdź do planowania <ChevronRightIcon className="ml-2" /> */}
Startujemy 10 września
Przejdź do planowania
</Link>
) : (
<Button
disabled={true}
variant="outline"
data-umami-event="Landing - incoming soon"
className="h-20 cursor-pointer self-center border-4 text-xl transition-all duration-300 hover:bg-white hover:shadow-[0_0_5px_rgb(200,200,255),0_0_10px_rgb(164,200,255)] md:mt-0 md:p-7"
<Link
href="/login"
data-umami-event="Landing - Go to planning"
className={buttonVariants({
size: "lg",
variant: "outline",
className: cn(
"cursor-pointer hover:bg-white hover:shadow-[0_0_5px_rgb(200,200,255),0_0_10px_rgb(164,200,255)]",
),
})}
>
Już niedługo :)
</Button>
{/* Przejdź do planowania <ChevronRightIcon className="ml-2" /> */}
Zaloguj się
</Link>
)}
</div>
</Block>
Expand Down Expand Up @@ -240,6 +250,16 @@ export const Footer = () => {
};

const Home = () => {
const query = useQuery({
queryKey: ["profile"],
queryFn: async () => {
const response = await fetch("/api/profile");
return response.json();
},
});
const isLoading = query.isLoading;
let canPlan = false;
canPlan = Boolean(query.data?.first_name);
return (
<>
<Seo />
Expand Down Expand Up @@ -358,7 +378,7 @@ const Home = () => {
</div>
</div>
<section className="flex justify-center">
<JoinUsBlock />
<JoinUsBlock canPlan={canPlan} isLoading={isLoading} />
</section>
</div>
<Footer />
Expand Down

0 comments on commit 47e5476

Please sign in to comment.