Skip to content

Commit

Permalink
init: init update
Browse files Browse the repository at this point in the history
  • Loading branch information
qamarq committed Nov 20, 2024
1 parent 1b07b98 commit 0fb424c
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 31 deletions.
25 changes: 20 additions & 5 deletions frontend/package-lock.json

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

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"dependencies": {
"@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-avatar": "^1.1.0",
"@radix-ui/react-avatar": "^1.1.1",
"@radix-ui/react-checkbox": "^1.1.1",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-icons": "^1.3.0",
Expand Down
63 changes: 63 additions & 0 deletions frontend/src/app/plans/_components/PlansTopbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React from 'react'
import { SolvroLogo } from "@/components/SolvroLogo";
import { Button, buttonVariants } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import Link from "next/link";
import { createUsosService } from '@/lib/usos';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';

export const PlansTopbar = () => {
return (
<div className="flex w-full items-center justify-between bg-mainbutton7 py-4 shadow-sm">
<div className="container mx-auto flex items-center justify-between">
<div className="ml-4 flex items-center gap-4 text-2xl font-bold text-white md:w-1/4">
<SolvroLogo />
<h1 className="hidden md:block text-2xl font-semibold">Kreator</h1>
</div>
<div className="mr-4 flex w-1/4 items-center justify-end">
<Link
href="/plans"
data-umami-event="Back to plans"
className={cn(buttonVariants({ variant: "link" }), "text-white")}
>
<span className="text-nowrap">Moje plany</span>
</Link>
<Link
href="https://web.usos.pwr.edu.pl/kontroler.php?_action=news/default&panel=DOMYSLNY&file=zapisyPL.html"
target='_blank'
data-umami-event="Go to USOS"
className={cn(buttonVariants({ variant: "link" }), "text-white")}
>
<span className="text-nowrap">Terminarz USOS</span>
</Link>

<UserProfile />
</div>
</div>
</div>
)
}

const UserProfile = async () => {
try {
const usos = await createUsosService();
const profile = await usos.getProfile();

return (
<div className='flex items-center gap-2'>
{/* <div className='text-right text-nowrap'>
<h1 className='text-lg font-semibold text-white leading-none'>{profile.first_name + " " + profile.last_name}</h1>
<h2 className='text-xs text-muted leading-none'>Nr. indeksu: <span className='font-medium'>{profile.student_number}</span></h2>
</div> */}
<Avatar>
<AvatarImage src={profile.photo_urls["50x50"]} />
<AvatarFallback>{profile.first_name.slice(0,1) + profile.last_name.slice(0,1)}</AvatarFallback>
</Avatar>
</div>
)
} catch (error) {
return (
<Button variant="default" size="sm">Zaloguj się</Button>
)
}
}
27 changes: 2 additions & 25 deletions frontend/src/app/plans/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import Link from "next/link";
import type React from "react";

import { SolvroLogo } from "@/components/SolvroLogo";
import { buttonVariants } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import { PlansTopbar } from "./_components/PlansTopbar";

export default function PlansLayout({
children,
Expand All @@ -12,26 +8,7 @@ export default function PlansLayout({
}) {
return (
<div className="flex h-screen min-h-screen flex-col items-center overflow-x-hidden">
<div className="flex w-full items-center justify-between bg-mainbutton7 py-4 shadow-sm">
<div className="container mx-auto flex items-center justify-between">
<div className="ml-4 flex items-center gap-2 text-2xl font-bold text-white md:w-1/4">
<SolvroLogo />
<div className="md:hidden">Kreator</div>
</div>
<div className="hidden w-1/2 items-center justify-center font-bold text-white md:flex md:text-3xl">
Kreator
</div>
<div className="mr-4 flex w-1/4 items-center justify-end">
<Link
href="/plans"
data-umami-event="Back to plans"
className={cn(buttonVariants({ variant: "link" }), "text-white")}
>
<span className="text-nowrap">Moje plany</span>
</Link>
</div>
</div>
</div>
<PlansTopbar />

{children}

Expand Down
8 changes: 8 additions & 0 deletions frontend/src/lib/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import crypto from "crypto";
import OAuth from "oauth-1.0a";

import { env } from "@/env.mjs";
import { createUsosService } from "../usos";
import type { GetProfile } from "@/services/usos/getProfile";

export const oauth = new OAuth({
consumer: { key: env.USOS_CONSUMER_KEY, secret: env.USOS_CONSUMER_SECRET },
Expand Down Expand Up @@ -86,3 +88,9 @@ export async function getRequestToken() {
secret: params.get("oauth_token_secret"),
};
}

export const userProfile = async (): Promise<GetProfile> => {
const usos = await createUsosService();
const profile = await usos.getProfile();
return profile;
}

0 comments on commit 0fb424c

Please sign in to comment.