This commit is contained in:
Dobromir Popov
2024-05-04 14:34:54 +03:00
parent 18c11928cc
commit b6912390ef
5 changed files with 79 additions and 39 deletions

View File

@ -85,43 +85,46 @@ function ConfirmationModal({ isOpen, onClose, onConfirm, subscribedPublishers, a
return (
<div className="fixed inset-0 flex items-center justify-center z-50">
<div className="absolute inset-0 bg-black opacity-50" onClick={onClose}></div>
<div className="bg-white p-6 rounded-lg shadow-lg z-10">
<div className="bg-white p-6 rounded-lg shadow-lg z-10 max-h-screen overflow-y-auto">
<h2 className="text-lg font-semibold mb-4">Можете да изпратите заявка за заместник до следните групи:</h2>
<div className="mb-4">
<label className="block mb-2">
<div className="flex items-center mb-2">
<input
type="checkbox"
className="mr-2 leading-tight"
checked={selectedGroups.includes('subscribedPublishers')}
onChange={() => handleToggleGroup('subscribedPublishers')}
/>
<span className="text-sm font-medium">Абонирани:</span>
</div>
<div className="flex flex-wrap">
{subscribedPublishers.map(pub => (
<span key={pub.id} className="bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">{pub.name}</span>
))}
</div>
</label>
</div>
<div className="mb-4">
<label className="block mb-2">
<div className="flex items-center mb-2">
<input
type="checkbox"
className="mr-2 leading-tight"
checked={selectedGroups.includes('availablePublishers')}
onChange={() => handleToggleGroup('availablePublishers')}
/>
<span className="text-sm font-medium">На разположение :</span>
</div>
<div className="flex flex-wrap">
{availablePublishers.map(pub => (
<span key={pub.id} className="bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">{pub.name}</span>
))}
</div>
</label>
<div className="space-y-1">
<div className="flex items-center mb-2">
<input id="subscribedPublishersCheckbox"
type="checkbox"
className="mr-2 leading-tight"
checked={selectedGroups.includes('subscribedPublishers')}
onChange={() => handleToggleGroup('subscribedPublishers')}
/>
<label htmlFor="subscribedPublishersCheckbox" className="text-sm font-medium">Абонирани:</label>
</div>
<div className="overflow-y-auto max-h-64">
<label className="block mb-2">
<div className="flex flex-wrap">
{subscribedPublishers.map(pub => (
<span key={pub.id} className="bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">{pub.name}</span>
))}
</div>
</label>
</div>
<div className="flex items-center mb-2">
<input id="availablePublishersCheckbox"
type="checkbox"
className="mr-2 leading-tight"
checked={selectedGroups.includes('availablePublishers')}
onChange={() => handleToggleGroup('availablePublishers')}
/>
<label htmlFor="availablePublishersCheckbox" className="text-sm font-medium">На разположение :</label>
</div>
<div className="overflow-y-auto max-h-64">
<label className="block mb-2">
<div className="flex flex-wrap">
{availablePublishers.map(pub => (
<span key={pub.id} className="bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">{pub.name}</span>
))}
</div>
</label>
</div>
</div>
<div className="text-right">
<button

View File

@ -142,7 +142,7 @@ export default function Sidebar({ isSidebarOpen, toggleSidebar }) {
return (
<>
<button onClick={toggleSidebar}
className="fixed top-1 left-4 z-40 m- text-xl bg-white border border-gray-200 p-2 rounded-full shadow-lg focus:outline-none"
className="fixed top-1 left-5 z-40 m- text-xl bg-white border border-gray-200 px-3 py-2.5 rounded-full shadow-lg focus:outline-none"
style={{ transform: isSidebarOpen ? `translateX(${sidebarWidth - 64}px)` : 'translateX(-20px)' }}></button>
<aside id="sidenav" ref={sidebarRef}
className="px-2 fixed top-0 left-0 z-30 h-screen overflow-y-auto bg-white border-r dark:bg-gray-900 dark:border-gray-700 transition-all duration-300 sm:translate-x-0 w-64"

View File

@ -131,9 +131,10 @@ export default function SignIn({ csrfToken }) {
// This gets called on every request
export async function getServerSideProps(context) {
const csrfToken = await getCsrfToken(context);
return {
props: {
csrfToken: await getCsrfToken(context),
...(csrfToken ? { csrfToken } : {}),
},
};
}

View File

@ -68,7 +68,7 @@ export default function IndexPage({ initialItems, initialUserId }: IProps) {
return (
<Layout>
<ProtectedRoute deniedMessage="">
<ProtectedRoute allowedRoles={[UserRole.ADMIN, UserRole.POWERUSER, UserRole.USER, UserRole.EXTERNAL]} deniedMessage="">
<h1 className="pt-2 pb-1 text-xl font-bold text-center">Графика на {userName}</h1>
<ProtectedRoute allowedRoles={[UserRole.ADMIN]} deniedMessage="">
<PublisherSearchBox selectedId={userId} infoText="" onChange={handleUserSelection} />

View File

@ -0,0 +1,36 @@
UPDATE `Availability`
SET
`startTime` = ADDTIME(`startTime`, '01:00:00'),
`endTime` = ADDTIME(`endTime`, '01:00:00'),
`name` = CONCAT(`name`, ' (DHT)')
WHERE
`startTime` LIKE '%05:00%' -- this is 9:00; -4 hours difference, where -3 is expected
OR `startTime` LIKE '%06:30%' -- this is 10:30; -4 hours difference, where -3 is expected
OR `startTime` LIKE '%08:00%' -- this is 12:00; -4 hours difference, where -3 is expected
OR `startTime` LIKE '%09:30%' -- this is 13:30 UTC
OR `startTime` LIKE '%11:00%' -- this is 15:00 UTC
OR `startTime` LIKE '%12:30%' -- this is 16:30 UTC
OR `startTime` LIKE '%14:00%' -- this is 18:00 UTC
SELECT
p.id,
p.firstName,
p.lastName,
a.id,
name,
dayofweek,
startTime,
endTime,
dayOfMonth,
weekOfMonth,
isFromPreviousAssignment,
isFromPreviousMonth,
endDate,
repeatWeekly,
dateOfEntry,
parentAvailabilityId
FROM
`Availability` a
left join Publisher p on p.id = publisherId
WHERE
name LIKE '%(DHT)%'