diff --git a/app/(authentication)/admin/superguide/page.tsx b/app/(authentication)/admin/superguide/page.tsx index 2e7a9389..cc12f9ab 100644 --- a/app/(authentication)/admin/superguide/page.tsx +++ b/app/(authentication)/admin/superguide/page.tsx @@ -2,8 +2,9 @@ import { Container } from '@/components/Container' import { Button } from '@/components/Button' -import React from 'react' +import React, { useState, useEffect } from 'react' import Link from 'next/link' +import BroadcastFormModal from '@/components/BroadcastFormModal' const openNewYearForm = async () => { // Show loading message @@ -108,13 +109,71 @@ const openNewYearForm = async () => { const adminHelp = () => { const currentYear = new Date().getFullYear(); + const [showBroadcastModal, setShowBroadcastModal] = useState(false); + const [userInfo, setUserInfo] = useState<{userId: number, userRoles: string[]} | null>(null); + + // Get user info from cookies on component mount + useEffect(() => { + const getUserInfo = () => { + // Get user info from cookies (this should match your authentication system) + const userIdCookie = document.cookie + .split('; ') + .find(row => row.startsWith('userId=')) + ?.split('=')[1]; + + const userRolesCookie = document.cookie + .split('; ') + .find(row => row.startsWith('userRoles=')) + ?.split('=')[1]; + + if (userIdCookie && userRolesCookie) { + try { + const roles = JSON.parse(decodeURIComponent(userRolesCookie)); + setUserInfo({ + userId: parseInt(userIdCookie), + userRoles: roles + }); + } catch (error) { + console.error('Failed to parse user info from cookies:', error); + } + } + }; + + getUserInfo(); + }, []); + return ( <>
+ Use "Open Forms & Broadcast" to create a new form session, open all library forms for editing (62-day period), + and automatically send notification emails to all CEAL members. +
+Super admin privileges required to access this feature.
+ +{error}
++ This email will be sent to all members in the broadcast list. +
++ Form session for {year} has been created and notification emails have been sent to all CEAL members. +
+Please sign in to access forms.
++ Forms are not currently open for editing. Please contact the CEAL Database Administrator for assistance. +
++ You can only edit forms for libraries you are associated with. + If you believe this is an error, please contact your administrator. +
++ You can now edit and submit this library's forms. Please ensure all data is accurate before submitting. +
+( + WrappedComponent: React.ComponentType
,
+ libraryId: number
+) {
+ const WithFormSessionControl = (props: P) => {
+ return (
+
+ Forms are not currently open for editing. Please contact the CEAL Database Administrator for assistance. +
+