added lastLogin to publishers

This commit is contained in:
Dobromir Popov
2024-04-25 19:51:13 +03:00
parent d28b82b1fa
commit 2fb9dc3803
6 changed files with 48 additions and 36 deletions

64
package-lock.json generated
View File

@ -16,7 +16,7 @@
"@mui/material": "^5.15.10",
"@mui/x-date-pickers": "^6.19.4",
"@premieroctet/next-crud": "^3.0.0",
"@prisma/client": "^5.12.1",
"@prisma/client": "^5.13.0",
"@react-pdf/renderer": "^3.3.8",
"@tailwindcss/forms": "^0.5.7",
"@types/multer": "^1.4.11",
@ -95,7 +95,7 @@
"devDependencies": {
"cross-env": "^7.0.3",
"depcheck": "^1.4.7",
"prisma": "^5.12.1"
"prisma": "^5.13.0"
}
},
"node_modules/@alloc/quick-lru": {
@ -3761,9 +3761,9 @@
}
},
"node_modules/@prisma/client": {
"version": "5.12.1",
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.12.1.tgz",
"integrity": "sha512-6/JnizEdlSBxDIdiLbrBdMW5NqDxOmhXAJaNXiPpgzAPr/nLZResT6MMpbOHLo5yAbQ1Vv5UU8PTPRzb0WIxdA==",
"version": "5.13.0",
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.13.0.tgz",
"integrity": "sha512-uYdfpPncbZ/syJyiYBwGZS8Gt1PTNoErNYMuqHDa2r30rNSFtgTA/LXsSk55R7pdRTMi5pHkeP9B14K6nHmwkg==",
"hasInstallScript": true,
"engines": {
"node": ">=16.13"
@ -3778,39 +3778,39 @@
}
},
"node_modules/@prisma/debug": {
"version": "5.12.1",
"resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.12.1.tgz",
"integrity": "sha512-kd/wNsR0klrv79o1ITsbWxYyh4QWuBidvxsXSParPsYSu0ircUmNk3q4ojsgNc3/81b0ozg76iastOG43tbf8A==",
"version": "5.13.0",
"resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.13.0.tgz",
"integrity": "sha512-699iqlEvzyCj9ETrXhs8o8wQc/eVW+FigSsHpiskSFydhjVuwTJEfj/nIYqTaWFYuxiWQRfm3r01meuW97SZaQ==",
"devOptional": true
},
"node_modules/@prisma/engines": {
"version": "5.12.1",
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.12.1.tgz",
"integrity": "sha512-HQDdglLw2bZR/TXD2Y+YfDMvi5Q8H+acbswqOsWyq9pPjBLYJ6gzM+ptlTU/AV6tl0XSZLU1/7F4qaWa8bqpJA==",
"version": "5.13.0",
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.13.0.tgz",
"integrity": "sha512-hIFLm4H1boj6CBZx55P4xKby9jgDTeDG0Jj3iXtwaaHmlD5JmiDkZhh8+DYWkTGchu+rRF36AVROLnk0oaqhHw==",
"devOptional": true,
"hasInstallScript": true,
"dependencies": {
"@prisma/debug": "5.12.1",
"@prisma/engines-version": "5.12.0-21.473ed3124229e22d881cb7addf559799debae1ab",
"@prisma/fetch-engine": "5.12.1",
"@prisma/get-platform": "5.12.1"
"@prisma/debug": "5.13.0",
"@prisma/engines-version": "5.13.0-23.b9a39a7ee606c28e3455d0fd60e78c3ba82b1a2b",
"@prisma/fetch-engine": "5.13.0",
"@prisma/get-platform": "5.13.0"
}
},
"node_modules/@prisma/engines-version": {
"version": "5.12.0-21.473ed3124229e22d881cb7addf559799debae1ab",
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.12.0-21.473ed3124229e22d881cb7addf559799debae1ab.tgz",
"integrity": "sha512-6yvO8s80Tym61aB4QNtYZfWVmE3pwqe807jEtzm8C5VDe7nw8O1FGX3TXUaXmWV0fQTIAfRbeL2Gwrndabp/0g==",
"version": "5.13.0-23.b9a39a7ee606c28e3455d0fd60e78c3ba82b1a2b",
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.13.0-23.b9a39a7ee606c28e3455d0fd60e78c3ba82b1a2b.tgz",
"integrity": "sha512-AyUuhahTINGn8auyqYdmxsN+qn0mw3eg+uhkp8zwknXYIqoT3bChG4RqNY/nfDkPvzWAPBa9mrDyBeOnWSgO6A==",
"devOptional": true
},
"node_modules/@prisma/fetch-engine": {
"version": "5.12.1",
"resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.12.1.tgz",
"integrity": "sha512-qSs3KcX1HKcea1A+hlJVK/ljj0PNIUHDxAayGMvgJBqmaN32P9tCidlKz1EGv6WoRFICYnk3Dd/YFLBwnFIozA==",
"version": "5.13.0",
"resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.13.0.tgz",
"integrity": "sha512-Yh4W+t6YKyqgcSEB3odBXt7QyVSm0OQlBSldQF2SNXtmOgMX8D7PF/fvH6E6qBCpjB/yeJLy/FfwfFijoHI6sA==",
"devOptional": true,
"dependencies": {
"@prisma/debug": "5.12.1",
"@prisma/engines-version": "5.12.0-21.473ed3124229e22d881cb7addf559799debae1ab",
"@prisma/get-platform": "5.12.1"
"@prisma/debug": "5.13.0",
"@prisma/engines-version": "5.13.0-23.b9a39a7ee606c28e3455d0fd60e78c3ba82b1a2b",
"@prisma/get-platform": "5.13.0"
}
},
"node_modules/@prisma/generator-helper": {
@ -3827,12 +3827,12 @@
"integrity": "sha512-tZ+MOjWlVvz1kOEhNYMa4QUGURY+kgOUBqLHYIV8jmCsMuvA1tWcn7qtIMLzYWCbDcQT4ZS8xDgK0R2gl6/0wA=="
},
"node_modules/@prisma/get-platform": {
"version": "5.12.1",
"resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.12.1.tgz",
"integrity": "sha512-pgIR+pSvhYHiUcqXVEZS31NrFOTENC9yFUdEAcx7cdQBoZPmHVjtjN4Ss6NzVDMYPrKJJ51U14EhEoeuBlMioQ==",
"version": "5.13.0",
"resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.13.0.tgz",
"integrity": "sha512-B/WrQwYTzwr7qCLifQzYOmQhZcFmIFhR81xC45gweInSUn2hTEbfKUPd2keAog+y5WI5xLAFNJ3wkXplvSVkSw==",
"devOptional": true,
"dependencies": {
"@prisma/debug": "5.12.1"
"@prisma/debug": "5.13.0"
}
},
"node_modules/@prisma/internals": {
@ -14361,13 +14361,13 @@
"integrity": "sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew=="
},
"node_modules/prisma": {
"version": "5.12.1",
"resolved": "https://registry.npmjs.org/prisma/-/prisma-5.12.1.tgz",
"integrity": "sha512-SkMnb6wyIxTv9ACqiHBI2u9gD6y98qXRoCoLEnZsF6yee5Qg828G+ARrESN+lQHdw4maSZFFSBPPDpvSiVTo0Q==",
"version": "5.13.0",
"resolved": "https://registry.npmjs.org/prisma/-/prisma-5.13.0.tgz",
"integrity": "sha512-kGtcJaElNRAdAGsCNykFSZ7dBKpL14Cbs+VaQ8cECxQlRPDjBlMHNFYeYt0SKovAVy2Y65JXQwB3A5+zIQwnTg==",
"devOptional": true,
"hasInstallScript": true,
"dependencies": {
"@prisma/engines": "5.12.1"
"@prisma/engines": "5.13.0"
},
"bin": {
"prisma": "build/index.js"

View File

@ -33,7 +33,7 @@
"@mui/material": "^5.15.10",
"@mui/x-date-pickers": "^6.19.4",
"@premieroctet/next-crud": "^3.0.0",
"@prisma/client": "^5.12.1",
"@prisma/client": "^5.13.0",
"@react-pdf/renderer": "^3.3.8",
"@tailwindcss/forms": "^0.5.7",
"@types/multer": "^1.4.11",
@ -112,6 +112,6 @@
"devDependencies": {
"cross-env": "^7.0.3",
"depcheck": "^1.4.7",
"prisma": "^5.12.1"
"prisma": "^5.13.0"
}
}

View File

@ -145,11 +145,17 @@ export const authOptions: NextAuthOptions = {
user.id = dbUser.id;
//user.permissions = dbUser.permissions;
const session = { ...user };
prisma.publisher.update({
where: { id: dbUser.id },
data: { lastLogin: new Date() }
});
return true; // Sign-in successful
} else {
// Optionally create a new user in your DB
// Or return false to deny access
return false;
//Let's customize the error message to give a better user experience
throw new Error(`Твоят имейл '${user.email}' не е регистриран в системата. Моля свържи се с нас за да те регистрираме ако искаш да ползваш този имейл.`);
}
} catch (e) {
console.log(e);

View File

@ -39,6 +39,7 @@ function ContactsPage({ publishers, allPublishers }) {
<th className="border-b font-medium p-4 pl-8 pt-0 pb-3">Име</th>
<th className="border-b font-medium p-4 pt-0 pb-3">Възможности</th>
<th className="border-b font-medium p-4 pt-0 pb-3">Участия</th>
<th className="border-b font-medium p-4 pt-0 pb-3">Последно влизане</th>
</tr>
</thead>
<tbody>
@ -67,6 +68,7 @@ function ContactsPage({ publishers, allPublishers }) {
</div>
</div>
</td>
<td className="border-b p-4">{pub.lastLogin ? common.getDateFormated(pub.lastLogin) : ""}</td>
</>
) : (
<>
@ -125,7 +127,7 @@ export const getServerSideProps = async (context) => {
const prisma = common.getPrismaClient();
const dateStr = new Date().toISOString().split('T')[0];
let publishers = await data.filterPublishersNew('id,firstName,lastName,email,isActive,desiredShiftsPerMonth', dateStr, false, true, true);
let publishers = await data.filterPublishersNew('id,firstName,lastName,email,isActive,desiredShiftsPerMonth,lastLogin', dateStr, false, true, true);
// const axios = await axiosServer(context);
// const { data: publishers } = await axios.get(`api/?action=filterPublishers&assignments=true&availabilities=true&date=${dateStr}&select=id,firstName,lastName,isActive,desiredShiftsPerMonth`);
@ -175,6 +177,7 @@ export const getServerSideProps = async (context) => {
phone: true,
isActive: true,
desiredShiftsPerMonth: true,
lastLogin: true,
assignments: {
select: {
id: true,

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE `publisher` ADD COLUMN `lastLogin` DATETIME(3) NULL;

View File

@ -122,6 +122,7 @@ model Publisher {
reports Report[]
Message Message[]
EventLog EventLog[]
lastLogin DateTime?
}
model Availability {