new column (filterable for push notificaitons status

This commit is contained in:
Dobromir Popov
2024-05-12 19:00:11 +03:00
parent d528c5c6ee
commit 6e884777fb
2 changed files with 25 additions and 2 deletions

View File

@ -37,7 +37,8 @@ function ContactsPage({ allPublishers }) {
const [hideEmptyFields, setHideEmptyFields] = useState({
availability: false,
assignments: false,
lastLogin: false
lastLogin: false,
notifiications: false
});
function handleSort(field) {
@ -56,6 +57,7 @@ function ContactsPage({ allPublishers }) {
&& (!hideEmptyFields.availability || publisher.currentMonthAvailabilityDaysCount > 0)
&& (!hideEmptyFields.assignments || publisher.currentMonthAssignments > 0)
&& (!hideEmptyFields.lastLogin || publisher.lastLogin)
&& (!hideEmptyFields.notifiications || publisher.isPushActive)
);
if (sortField) {
@ -177,6 +179,17 @@ function ContactsPage({ allPublishers }) {
type="checkbox" className='ml-2'
checked={hideEmptyFields.lastLogin}
onChange={() => setHideEmptyFields({ ...hideEmptyFields, lastLogin: !hideEmptyFields.lastLogin })}
title="Скрий редове без нотификации"
/>
</th>
<th className="border-b font-medium p-4 pt-0 pb-3 cursor-pointer">
<p className="inline-block" >
Нотификации
</p>
<input
type="checkbox" className='ml-2'
checked={hideEmptyFields.notifiications}
onChange={() => setHideEmptyFields({ ...hideEmptyFields, notifiications: !hideEmptyFields.notifiications })}
title="Скрий редове без последно влизане"
/>
</th>
@ -228,6 +241,14 @@ function ContactsPage({ allPublishers }) {
<td className="border-b p-4"></td> {/* Empty cell for alignment */}
</>
)}
<td className="border-b p-4">
{/* show notification checkmark badge if isPushActive */}
{pub.isPushActive ? (
<span className="badge py-1 px-2 rounded-md text-xs bg-green-500 text-white"></span>
) : (
<span className="badge py-1 px-2 rounded-md text-xs bg-gray-300 text-gray-500">-</span>
)}
</td>
</tr>
);
})}

View File

@ -346,7 +346,6 @@ async function filterPublishersNew(selectFields, filterDate, isExactTime = false
}
}
console.log(`getting publishers for date: ${filterDate}, isExactTime: ${isExactTime}, isForTheMonth: ${isForTheMonth}`);
console.log`whereClause: ${JSON.stringify(whereClause)}`
//include availabilities if flag is true
@ -532,6 +531,7 @@ async function getAllPublishersWithStatistics(filterDate, noEndDateFilter = fals
desiredShiftsPerMonth: true,
lastLogin: true,
type: true,
pushSubscription: true,
assignments: {
select: {
id: true,
@ -575,6 +575,8 @@ async function getAllPublishersWithStatistics(filterDate, noEndDateFilter = fals
allPublishers.forEach(publisher => {
publisher.isPushActive = publisher.pushSubscription ? true : false;
delete publisher.pushSubscription
// Use helper functions to calculate and assign assignment counts
publisher.currentMonthAssignments = countAssignments(publisher.assignments, monthInfo.firstMonday, monthInfo.lastSunday);
publisher.previousMonthAssignments = countAssignments(publisher.assignments, prevMonthInfo.firstMonday, prevMonthInfo.lastSunday);