Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added alert dialog for logout & some UI fixes #953

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,593 changes: 1,541 additions & 52 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@icons-pack/react-simple-icons": "^9.4.0",
"@prisma/client": "^5.6.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.1.1",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
Expand Down
8 changes: 6 additions & 2 deletions src/app/admin/content/[courseId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ export default async function UpdateCourseContent({

return (
<div className="mx-auto max-w-screen-xl justify-between p-4 text-black dark:text-white">
{course?.title}
<div className="font-bold md:text-5xl lg:text-6xl">Content</div>
<div className="text-xl font-semibold">
Course: <span className="font-bold">{course.title}</span>
</div>
<div className="my-1.5 font-bold md:text-4xl lg:text-5xl">
Add Content
</div>
<AddContent
courseId={parseInt(courseId, 10)}
parentContentId={parseFloat(rest[rest.length - 1])}
Expand Down
8 changes: 5 additions & 3 deletions src/components/ContentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ export const ContentCard = ({
<div className="flex items-center justify-between p-4">
<div className="space-y-2">
<h3 className="text-bold text-lg tracking-normal">{title}</h3>
<h4 className="text-bold text-sm tracking-normal text-[#64748B]">
Posted on: 10 Aug 2024
</h4>
{type !== 'folder' && (
<h4 className="text-bold text-sm tracking-normal text-[#64748B]">
Posted on: 10 Aug 2024
</h4>
)}
</div>
<div className="hidden rounded-full border border-gray-700/60 p-4 lg:block">
<div className="rounded-full border border-[#64748b] p-2">
Expand Down
6 changes: 3 additions & 3 deletions src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ export function ToggleButton({
className="flex flex-col items-center justify-center"
>
<span
className={`h - 0.5 w - 6 - sm bg - black - all duration - 300 ease - out dark: bg - white block rounded transition ${!sidebarOpen ? 'translate-y-1 rotate-45' : '-translate-y-0.5'} `}
className={`h - 0.5 w 6 sm bg black all duration 300 ease out dark: white block rounded transition ${!sidebarOpen ? 'translate-y-1 rotate-45' : '-translate-y-0.5'} `}
></span>
<span
className={`my - 0.5 h - 0.5 w - 6 - sm bg - black - all duration - 300 ease - out dark: bg - white block rounded transition ${
className={`my - 0.5 h w 6 sm bg black all duration 300 ease out dark: white block rounded transition ${
!sidebarOpen ? 'opacity-0' : 'opacity-100'
} `}
></span>
<span
className={`h - 0.5 w - 6 - sm bg - black - all duration - 300 ease - out dark: bg - white block rounded transition ${
className={`h - 0.5 w 6 sm bg black all duration 300 ease out dark: white block rounded transition ${
!sidebarOpen ? '-translate-y-1 -rotate-45' : 'translate-y-0.5'
} `}
></span>
Expand Down
2 changes: 1 addition & 1 deletion src/components/admin/AddContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const AddContent = ({
},
});
}}
className="rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700"
className="my-3 rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700"
>
Submit
</button>
Expand Down
61 changes: 51 additions & 10 deletions src/components/profile-menu/ProfileDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import Link from 'next/link';
import {
BookmarkIcon,
HistoryIcon,
LogOutIcon,
User2Icon,
Bird,
CreditCard,
LogOut,
AlertTriangleIcon,
} from 'lucide-react';
import {
DropdownMenu,
Expand All @@ -18,6 +19,17 @@ import {
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
import ExternalLinks from './ExternalLinks';
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from '@/components/ui/alert-dialog';
import { signOut } from 'next-auth/react';

const ProfileDropdown = () => {
Expand Down Expand Up @@ -72,15 +84,44 @@ const ProfileDropdown = () => {
</DropdownMenuGroup>

<DropdownMenuSeparator />

<DropdownMenuItem
onClick={() => {
signOut();
}}
>
<LogOutIcon className="mr-2 h-4 w-4" />
<span>Logout</span>
</DropdownMenuItem>
<div>
<AlertDialog>
<AlertDialogTrigger asChild>
<div className="flex cursor-pointer items-center justify-center rounded-md px-4 py-2 text-red-600 transition-colors hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-500 dark:hover:text-white">
Logout <LogOut className="ml-2 h-5 w-5" />
</div>
</AlertDialogTrigger>
<AlertDialogContent className="mx-auto max-w-lg transform rounded-lg border border-gray-200 bg-white p-8 text-gray-900 shadow-2xl transition-all duration-300 ease-in-out dark:border-gray-700 dark:bg-background dark:text-gray-100">
<AlertDialogHeader className="mb-6">
<div className="flex items-center space-x-6">
<div className="text-red-400">
<AlertTriangleIcon size={40} />
</div>
<div>
<AlertDialogTitle className="text-xl font-semibold tracking-tight">
Confirm Logout
</AlertDialogTitle>
<AlertDialogDescription className="mt-2 text-sm text-gray-600 dark:text-gray-400">
Are you sure you want to log out? You will need to sign in
again to access your account.
</AlertDialogDescription>
</div>
</div>
</AlertDialogHeader>
<AlertDialogFooter className="flex justify-end gap-4">
<AlertDialogCancel className="transform rounded-md bg-gray-100 px-4 py-2 font-medium text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600">
Cancel
</AlertDialogCancel>
<AlertDialogAction
className="transform rounded-md bg-gradient-to-r from-red-500 to-red-600 px-4 py-2 font-medium shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:from-red-600 hover:to-red-700 dark:from-red-600 dark:to-red-700 dark:text-white dark:hover:from-red-700 dark:hover:to-red-800"
onClick={async () => await signOut()}
>
Logout
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
</DropdownMenuContent>
</DropdownMenu>
);
Expand Down
67 changes: 50 additions & 17 deletions src/components/sidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
'use client';
import { useState } from 'react';
import { AnimatedTooltip } from '@/components/ui/animated-tooltip';
import { signOut } from 'next-auth/react';

import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from '@/components/ui/alert-dialog';
import Logo from '../landing/logo/logo';
import {
Library,
Expand All @@ -11,8 +20,9 @@ import {
History,
PanelRightOpen,
LogOut,
AlertTriangleIcon,
} from 'lucide-react';

import { signOut } from 'next-auth/react';
export const menuOptions = [
{ id: 1, name: 'My Courses', Component: Library, href: '/my-courses' },
{ id: 3, name: 'Bookmarks', Component: Bookmark, href: '/bookmark' },
Expand Down Expand Up @@ -47,20 +57,43 @@ export const MenuOptions = () => {
<AnimatedTooltip expanded={expanded} items={menuOptions} />
</div>

<div className="border-t p-4">
<div className="flex rounded-md p-2">
<LogOut size={24} color="#DD503F" />
<button
onClick={() => {
signOut();
}}
className={`flex items-center justify-between overflow-hidden transition-all ${
expanded ? 'ml-3 w-52' : 'w-0'
}`}
>
<h4 className="font-semibold text-[#DD503F]">Logout</h4>
</button>
</div>
<div className="border-t">
<AlertDialog>
<AlertDialogTrigger asChild>
<div className="flex cursor-pointer items-center justify-center rounded-md px-4 py-2 text-red-600 transition-colors hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-500 dark:hover:text-white">
Logout <LogOut className="ml-2 h-5 w-5" />
</div>
</AlertDialogTrigger>
<AlertDialogContent className="mx-auto max-w-lg transform rounded-lg border border-gray-200 bg-white p-8 text-gray-900 shadow-2xl transition-all duration-300 ease-in-out dark:border-gray-700 dark:bg-background dark:text-gray-100">
<AlertDialogHeader className="mb-6">
<div className="flex items-center space-x-6">
<div className="text-red-400">
<AlertTriangleIcon size={40} />
</div>
<div>
<AlertDialogTitle className="text-xl font-semibold tracking-tight">
Confirm Logout
</AlertDialogTitle>
<AlertDialogDescription className="mt-2 text-sm text-gray-600 dark:text-gray-400">
Are you sure you want to log out? You will need to sign in
again to access your account.
</AlertDialogDescription>
</div>
</div>
</AlertDialogHeader>
<AlertDialogFooter className="flex justify-end gap-4">
<AlertDialogCancel className="transform rounded-md bg-gray-100 px-4 py-2 font-medium text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600">
Cancel
</AlertDialogCancel>
<AlertDialogAction
className="transform rounded-md bg-gradient-to-r from-red-500 to-red-600 px-4 py-2 font-medium shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:from-red-600 hover:to-red-700 dark:from-red-600 dark:to-red-700 dark:text-white dark:hover:from-red-700 dark:hover:to-red-800"
onClick={async () => await signOut()}
>
Logout
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
</nav>
</aside>
Expand Down
141 changes: 141 additions & 0 deletions src/components/ui/alert-dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
'use client';

import * as React from 'react';
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';

import { cn } from '@/lib/utils';
import { buttonVariants } from '@/components/ui/button';

const AlertDialog = AlertDialogPrimitive.Root;

const AlertDialogTrigger = AlertDialogPrimitive.Trigger;

const AlertDialogPortal = AlertDialogPrimitive.Portal;

const AlertDialogOverlay = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Overlay
className={cn(
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
className,
)}
{...props}
ref={ref}
/>
));
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;

const AlertDialogContent = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
>(({ className, ...props }, ref) => (
<AlertDialogPortal>
<AlertDialogOverlay />
<AlertDialogPrimitive.Content
ref={ref}
className={cn(
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
className,
)}
{...props}
/>
</AlertDialogPortal>
));
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;

const AlertDialogHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
'flex flex-col space-y-2 text-center sm:text-left',
className,
)}
{...props}
/>
);
AlertDialogHeader.displayName = 'AlertDialogHeader';

const AlertDialogFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
className,
)}
{...props}
/>
);
AlertDialogFooter.displayName = 'AlertDialogFooter';

const AlertDialogTitle = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Title
ref={ref}
className={cn('text-lg font-semibold', className)}
{...props}
/>
));
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;

const AlertDialogDescription = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Description
ref={ref}
className={cn('text-sm text-muted-foreground', className)}
{...props}
/>
));
AlertDialogDescription.displayName =
AlertDialogPrimitive.Description.displayName;

const AlertDialogAction = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Action>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Action
ref={ref}
className={cn(buttonVariants(), className)}
{...props}
/>
));
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;

const AlertDialogCancel = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Cancel
ref={ref}
className={cn(
buttonVariants({ variant: 'outline' }),
'mt-2 sm:mt-0',
className,
)}
{...props}
/>
));
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;

export {
AlertDialog,
AlertDialogPortal,
AlertDialogOverlay,
AlertDialogTrigger,
AlertDialogContent,
AlertDialogHeader,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogAction,
AlertDialogCancel,
};
2 changes: 1 addition & 1 deletion src/components/ui/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
<input
type={type}
className={cn(
'flex h-10 w-full rounded-md border border-gray-700/50 bg-transparent',
'flex h-10 w-full rounded-md border border-gray-700/50 bg-transparent px-3 py-2',
className,
)}
ref={ref}
Expand Down
Loading
Loading