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

schema changes for email and toast bug fixed #9

Merged
merged 1 commit into from
Jan 8, 2025
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
run: |
npm run dev &
sleep 10 # Wait for the server to start
curl -f http://localhost:5173 # Change this to the actual port your Vite server runs on
curl -f http://localhost:5173
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function App() {
const showSuccessToast = () => {
toast({
title: 'Success',
description: 'Your operation was successful!',
description: 'Registered Successfully!',
});
};

Expand Down
4 changes: 2 additions & 2 deletions src/SelectItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { SelectItem } from '@/components/ui/select';

export const SelectItems = () => (
<>
<SelectItem value="cse">Computer Science</SelectItem>
<SelectItem value="cse">Computer Science and Engineering</SelectItem>
<SelectItem value="csse">Computer Science and Systems Engineering</SelectItem>
<SelectItem value="csce">Computer Science and Communication Engineering</SelectItem>
<SelectItem value="etc">Electronics and Telecommunication Engineering</SelectItem>
<SelectItem value="ee">Electrical Engineering</SelectItem>
<SelectItem value="eee">Electronics and Electrical Engineering</SelectItem>
<SelectItem value="ecse">Electronics and Computer Science Engineering</SelectItem>
<SelectItem value="me">Mechanical Engineering</SelectItem>
<SelectItem value="mce">Mechantronics Engineering</SelectItem>
<SelectItem value="mce">Mechatronics Engineering</SelectItem>
<SelectItem value="ce">Civil Engineering</SelectItem>
<SelectItem value="it">Information Technology</SelectItem>
<SelectItem value="ae">Aerospace Engineering</SelectItem>
Expand Down
32 changes: 16 additions & 16 deletions src/components/ui/toast.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import { Cross2Icon } from '@radix-ui/react-icons';
import * as ToastPrimitives from '@radix-ui/react-toast';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '@/lib/utils';
import * as React from "react";
import { Cross2Icon } from "@radix-ui/react-icons";
import * as ToastPrimitives from "@radix-ui/react-toast";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";

const ToastProvider = ToastPrimitives.Provider;

Expand All @@ -13,7 +13,7 @@ const ToastViewport = React.forwardRef<
<ToastPrimitives.Viewport
ref={ref}
className={cn(
'fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]',
"fixed bottom-0 left-0 right-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
className
)}
{...props}
Expand All @@ -22,17 +22,17 @@ const ToastViewport = React.forwardRef<
ToastViewport.displayName = ToastPrimitives.Viewport.displayName;

const toastVariants = cva(
'group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full',
"group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
{
variants: {
variant: {
default: 'border bg-[#1a1a1a] text-white', // Dark theme with white text
success: 'border bg-green-600 text-white', // Success variant
failure: 'border bg-red-600 text-white', // Failure variant
default: "border bg-[#1a1a1a] text-white", // Dark theme with white text
success: "border border-green-600 bg-green-600 text-white", // Success variant
failure: "border border-red-600 bg-red-600 text-white", // Failure variant
},
},
defaultVariants: {
variant: 'default',
variant: "default",
},
}
);
Expand All @@ -59,7 +59,7 @@ const ToastAction = React.forwardRef<
<ToastPrimitives.Action
ref={ref}
className={cn(
'inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-red-600 group-[.destructive]:hover:bg-red-600 group-[.destructive]:hover:text-white group-[.destructive]:focus:ring-red-600',
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-red-600 group-[.destructive]:hover:bg-red-600 group-[.destructive]:hover:text-white group-[.destructive]:focus:ring-red-600",
className
)}
{...props}
Expand All @@ -74,7 +74,7 @@ const ToastClose = React.forwardRef<
<ToastPrimitives.Close
ref={ref}
className={cn(
'absolute right-1 top-1 rounded-md p-1 text-white/50 opacity-0 transition-opacity hover:text-white focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600',
"absolute right-1 top-1 rounded-md p-1 text-white/50 opacity-0 transition-opacity hover:text-white focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
className
)}
toast-close=""
Expand All @@ -91,7 +91,7 @@ const ToastTitle = React.forwardRef<
>(({ className, ...props }, ref) => (
<ToastPrimitives.Title
ref={ref}
className={cn('text-sm font-semibold [&+div]:text-xs', className)}
className={cn("text-sm font-semibold [&+div]:text-xs", className)}
{...props}
/>
));
Expand All @@ -103,7 +103,7 @@ const ToastDescription = React.forwardRef<
>(({ className, ...props }, ref) => (
<ToastPrimitives.Description
ref={ref}
className={cn('text-sm opacity-90', className)}
className={cn("text-sm opacity-90", className)}
{...props}
/>
));
Expand All @@ -123,4 +123,4 @@ export {
ToastDescription,
ToastClose,
ToastAction,
};
};
12 changes: 8 additions & 4 deletions src/components/ui/toaster.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useToast } from '../../hooks/use-toast';
import { useToast } from "../../hooks/use-toast";
import {
Toast,
ToastClose,
ToastDescription,
ToastProvider,
ToastTitle,
ToastViewport,
} from './toast';
} from "./toast";

export function Toaster() {
const { toasts } = useToast();
Expand All @@ -15,7 +15,11 @@ export function Toaster() {
<ToastProvider>
{toasts.map(function ({ id, title, description, action, ...props }) {
return (
<Toast key={id} variant={title ? 'success' : 'failure'} {...props}>
<Toast
key={id}
variant={title === "Success" ? "success" : "failure"}
{...props}
>
<div className="grid gap-1">
{title && <ToastTitle>{title}</ToastTitle>}
{description && (
Expand All @@ -30,4 +34,4 @@ export function Toaster() {
<ToastViewport />
</ToastProvider>
);
}
}
40 changes: 25 additions & 15 deletions src/lib/schema.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import * as z from 'zod';
import * as z from "zod";

export const formSchema = z.object({
teamName: z.string().min(2, 'Team name must be at least 2 characters'),
fullName: z.string().min(2, 'Name must be at least 2 characters'),
rollNo: z.string().min(1, 'Roll number is required'),
email: z.string().email('Invalid email address'),
branch: z.string().min(1, 'Branch is required'),
teamMembers: z.array(
z.object({
fullName: z.string().min(2, 'Name must be at least 2 characters'),
rollNo: z.string().min(1, 'Roll number is required'),
email: z.string().email('Invalid email address'),
branch: z.string().min(1, 'Branch is required'),
}).optional()
).max(2, "You can only have up to 2 team members"),
});
teamName: z.string().min(2, "Team name must be at least 2 characters"),
fullName: z.string().min(2, "Name must be at least 2 characters"),
rollNo: z
.string()
.min(1, "Roll number is required")
.regex(/^\d{6,}$/, "Roll number must be a number with 6 or more digits"),
email: z
.string()
.email("Invalid email address")
.regex(/@kiit\.ac\.in$/, "Email must end with @kiit.ac.in"),
branch: z.string().min(1, "Branch is required"),
teamMembers: z
.array(
z
.object({
fullName: z.string().min(2, "Name must be at least 2 characters"),
rollNo: z.string().min(1, "Roll number is required"),
email: z.string().email("Invalid email address"),
branch: z.string().min(1, "Branch is required"),
})
.optional()
)
.max(2, "You can only have up to 2 team members"),
});
Loading