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

policy section #49

Merged
merged 4 commits into from
Dec 29, 2024
Merged
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
261 changes: 153 additions & 108 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -24,14 +24,15 @@
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-slot": "^1.1.1",
"@radix-ui/react-tabs": "^1.1.2",
"@radix-ui/react-tooltip": "^1.1.4",
"@tanstack/react-query": "^5.62.8",
"@tanstack/react-table": "^8.20.5",
"@uploadthing/react": "^7.1.3",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"date-fns": "^3.6.0",
"express": "^4.21.2",
"http": "^0.0.1-security",
"i18next": "^24.0.5",
@@ -40,10 +41,10 @@
"next": "^15.0.4",
"react": "18.2.0",
"react-calendar": "^5.1.0",
"react-day-picker": "^8.10.1",
"react-dom": "18.2.0",
"react-hook-form": "^7.54.2",
"react-hot-toast": "^2.4.1",
"react-i18next": "^15.1.3",
"react-icons": "^5.3.0",
"react-loading-skeleton": "^3.5.0",
"react-router-dom": "^7.0.2",
29 changes: 28 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -52,6 +52,8 @@ model User {

Department Department? @relation(fields: [departmentId], references: [id])
university University? @relation("UserToUniversity", fields: [universityId], references: [id])

Policy Policy[]
}

model University {
@@ -77,6 +79,8 @@ model University {
subjects Subject[]
admin User @relation("universityAdmin", fields: [adminId], references: [id])
users User[] @relation("UserToUniversity")

Policy Policy[]
}

model NonTeachingStaff {
@@ -174,6 +178,8 @@ model Department {
timeTable TimeTable[]
User User[]
classes Class[]

Policy Policy[]
}

model Course {
@@ -413,6 +419,7 @@ model Announcement {
category String
departmentId Int
universityId Int
announcerName String
createdAt DateTime @default(now())
updatedAt DateTime @default(now())

@@ -450,10 +457,30 @@ model Event {
budget Int
organiserId String
universityId Int
departmentId Int?
departmentId Int
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
department Department? @relation(fields: [departmentId], references: [id])
organiser User @relation(fields: [organiserId], references: [clerkId])
university University @relation(fields: [universityId], references: [id])
}

model Policy {
id Int @id @default(autoincrement())
title String
description String?
attachments Json[]
category String
effectiveDate String
expiryDate String?
departmentId Int
universityId Int
authorId String
authorName String
createdAt DateTime @default(now())
updatedAt DateTime @default(now())

sharedBy User @relation(fields: [authorId], references: [clerkId])
department Department @relation(fields: [departmentId], references: [id])
university University @relation(fields: [universityId], references: [id])
}
9 changes: 4 additions & 5 deletions prisma/seed.js
Original file line number Diff line number Diff line change
@@ -102,8 +102,8 @@ async function main() {
const dummyPrincipalUser = await prisma.user.create({
// Principal
data: {
id: "user_2qcpeeEw8rTPzWIKUgjppr0xWUo",
clerkId: "user_2qcpeeEw8rTPzWIKUgjppr0xWUo",
id: "user_2qrHhQZhnV8h24O5Yw52yYm3dws",
clerkId: "user_2qrHhQZhnV8h24O5Yw52yYm3dws",
name: "Nilax Modi",
email: "principal_uit@ku.edu.in",
phone: "7894567898",
@@ -123,8 +123,8 @@ async function main() {
const dummyDeanUser = await prisma.user.create({
// Dean
data: {
id: "user_2qVuNTsat2QYT68j069juHP3cqI",
clerkId: "user_2qVuNTsat2QYT68j069juHP3cqI",
id: "user_2qrHoqnzAhnRgTExHVB4qoCoU9Y",
clerkId: "user_2qrHoqnzAhnRgTExHVB4qoCoU9Y",
name: "Mohak shah",
email: "dean_uit@ku.edu.in",
phone: "7894567898",
@@ -497,4 +497,3 @@ main()
process.exit(1)
})


30 changes: 13 additions & 17 deletions src/app/(module)/announcements/_components/AnnouncementCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react"
import { useContext, useState } from "react"
import { useRouter } from "next/navigation"
import {
ChevronDown,
@@ -7,29 +7,21 @@ import {
Edit,
Loader2,
Paperclip,
Trash2
Trash2,
User
} from "lucide-react"
import toast from "react-hot-toast"

// Format date function
const formatDate = (dateString: string) => {
return new Date(dateString).toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric"
})
}
import { UserContext } from "@/context/user"

export default function AnnouncementCard({
announcement,
refetch,
canCreateAnnouncement
refetch
}: {
announcement: any
refetch: () => void
canCreateAnnouncement: boolean
}) {
const router = useRouter()
const { user } = useContext(UserContext)
const [isExpanded, setIsExpanded] = useState<boolean>(false)
const [isDeleting, setIsDeleting] = useState<boolean>(false)
const [showConfirmDelete, setShowConfirmDelete] = useState<boolean>(false)
@@ -62,14 +54,18 @@ export default function AnnouncementCard({
}

return (
<div className="group p-3 mx-0.5 sm:p-4 md:p-6 bg-white hover:bg-lamaSkyLight/50 transition-all duration-300 rounded-lg shadow-sm hover:shadow-lg border border-transparent hover:border-ColorThree/20">
<div className="group p-3 mx-0.5 sm:p-4 md:p-6 bg-lamaSkyLight/50 hover:bg-white transition-all duration-300 rounded-lg shadow-sm hover:shadow-lg border border-ColorThree/20">
<div className="flex flex-col sm:flex-row justify-between items-start gap-2 sm:gap-4 mb-2 sm:mb-3">
<h2 className="text-lg sm:text-xl font-semibold text-TextTwo group-hover:text-ColorThree transition-colors line-clamp-2">
{announcement.title}
</h2>
<div className="text-base flex items-center gap-1.5 sm:text-xl font-semibold text-TextTwo group-hover:text-ColorThree transition-colors">
<User size={18} className="shrink-0" />
{announcement.announcerName}
</div>
<div className="flex items-center text-xs sm:text-sm text-TextTwo/70 whitespace-nowrap bg-lamaSkyLight px-3 py-1 rounded-full">
<Clock size={14} className="mr-1.5 shrink-0" />
{formatDate(announcement.createdAt)}
{`${new Date(announcement.updatedAt).toLocaleString()}`}
</div>
</div>

@@ -123,7 +119,7 @@ export default function AnnouncementCard({
</div>
)}

{canCreateAnnouncement && (
{announcement.announcerId === user?.id && (
<div className="mt-6 flex flex-col sm:flex-row gap-3 sm:justify-end">
<button
onClick={handleEdit}
1 change: 1 addition & 0 deletions src/app/(module)/announcements/form/page.tsx
Original file line number Diff line number Diff line change
@@ -160,6 +160,7 @@ export default function CreateAnnouncement() {
universityId: user?.universityId,
announcerId: user?.id,
category,
announcerName: user?.name,
attachments: [...existingFiles, ...uploadedFileData]
}

1 change: 0 additions & 1 deletion src/app/(module)/announcements/page.tsx
Original file line number Diff line number Diff line change
@@ -117,7 +117,6 @@ export default function AnnouncementsPage() {
key={announcement.id}
announcement={announcement}
refetch={refetch}
canCreateAnnouncement={canCreateAnnouncement}
/>
))
) : (
Loading