added wpa needed files. WPA is still WIP.

This commit is contained in:
Dobromir Popov
2024-04-06 19:22:35 +03:00
parent 239207e1d3
commit b669e71146
10 changed files with 95 additions and 32 deletions

9
.gitignore vendored
View File

@ -19,6 +19,15 @@ next-env.d.ts
.vercel .vercel
.env*.local .env*.local
# PWA files
**/public/sw.js
**/public/workbox-*.js
**/public/worker-*.js
**/public/sw.js.map
**/public/workbox-*.js.map
**/public/worker-*.js.map
*.zip *.zip
next-cart-app.zip next-cart-app.zip

View File

@ -1,14 +1,17 @@
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const withPWA = require("next-pwa"); const withPWA = require("next-pwa")({
dest: 'public'
});
module.exports = withPWA({ module.exports = withPWA({
pwa: { // pwa: {
dest: "public", // dest: "public",
// register: true, // // register: true,
// skipwaiting: true, // // skipwaiting: true,
// disable: process.env.NODE_ENV === "development", // // disable: process.env.NODE_ENV === "development",
}, // },
typescript: { typescript: {
// !! WARN !! // !! WARN !!
// Dangerously allow production builds to successfully complete even if // Dangerously allow production builds to successfully complete even if

30
package-lock.json generated
View File

@ -84,6 +84,7 @@
"uuid": "^9.0.1", "uuid": "^9.0.1",
"webpack-bundle-analyzer": "^4.10.1", "webpack-bundle-analyzer": "^4.10.1",
"winston": "^3.11.0", "winston": "^3.11.0",
"workbox": "^0.0.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.19.1/xlsx-0.19.1.tgz", "xlsx": "https://cdn.sheetjs.com/xlsx-0.19.1/xlsx-0.19.1.tgz",
"xlsx-style": "^0.8.13", "xlsx-style": "^0.8.13",
"xml-js": "^1.6.11", "xml-js": "^1.6.11",
@ -5311,6 +5312,20 @@
"@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0"
} }
}, },
"node_modules/babel-runtime": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
"integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==",
"dependencies": {
"core-js": "^2.4.0",
"regenerator-runtime": "^0.11.0"
}
},
"node_modules/babel-runtime/node_modules/regenerator-runtime": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
"integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg=="
},
"node_modules/balanced-match": { "node_modules/balanced-match": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@ -6418,6 +6433,13 @@
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
}, },
"node_modules/core-js": {
"version": "2.6.12",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz",
"integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==",
"deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.",
"hasInstallScript": true
},
"node_modules/core-js-compat": { "node_modules/core-js-compat": {
"version": "3.36.1", "version": "3.36.1",
"resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.36.1.tgz", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.36.1.tgz",
@ -16610,6 +16632,14 @@
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
"integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==" "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q=="
}, },
"node_modules/workbox": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/workbox/-/workbox-0.0.0.tgz",
"integrity": "sha512-/I5JIWHK18DDGGoXOZgOkOFLsiMQZlHLnwEzw328ZMU4TA21yFCw11YEnZ1CsOnSazl0DMbFmLJ6q5hpQhP/aQ==",
"dependencies": {
"babel-runtime": "6.x.x"
}
},
"node_modules/workbox-background-sync": { "node_modules/workbox-background-sync": {
"version": "7.0.0", "version": "7.0.0",
"resolved": "https://registry.npmjs.org/workbox-background-sync/-/workbox-background-sync-7.0.0.tgz", "resolved": "https://registry.npmjs.org/workbox-background-sync/-/workbox-background-sync-7.0.0.tgz",

View File

@ -102,6 +102,7 @@
"uuid": "^9.0.1", "uuid": "^9.0.1",
"webpack-bundle-analyzer": "^4.10.1", "webpack-bundle-analyzer": "^4.10.1",
"winston": "^3.11.0", "winston": "^3.11.0",
"workbox": "^0.0.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.19.1/xlsx-0.19.1.tgz", "xlsx": "https://cdn.sheetjs.com/xlsx-0.19.1/xlsx-0.19.1.tgz",
"xlsx-style": "^0.8.13", "xlsx-style": "^0.8.13",
"xml-js": "^1.6.11", "xml-js": "^1.6.11",

View File

@ -28,13 +28,6 @@ export default function App({
return ( return (
<> <>
<Head>
{/* Other tags */}
<link
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
rel="stylesheet"
/>
</Head>
<SessionProvider session={session} > <SessionProvider session={session} >
<LocalizationProvider dateAdapter={AdapterDayjs}> <LocalizationProvider dateAdapter={AdapterDayjs}>
<Component {...pageProps} /> <Component {...pageProps} />

View File

@ -7,6 +7,10 @@ class MyDocument extends Document {
<Head> <Head>
<link rel="manifest" href="/manifest.json" /> <link rel="manifest" href="/manifest.json" />
<link rel="apple-touch-icon" href="/favicon.png"></link> <link rel="apple-touch-icon" href="/favicon.png"></link>
<link
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
rel="stylesheet"
/>
<meta name="theme-color" content="#e36600" /> <meta name="theme-color" content="#e36600" />
</Head> </Head>
<body> <body>

View File

@ -290,6 +290,8 @@ export default async function handler(req, res) {
} }
break; break;
case "sendNewAssignmentEmails":
default: default:
return res.status(400).json({ message: "Invalid action" }); return res.status(400).json({ message: "Invalid action" });
} }

View File

@ -113,7 +113,7 @@ export default function MySchedulePage({ assignments }) {
Добави в календар Добави в календар
</button> </button>
<button <button
className="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" className="mr-2 mb-2 inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
onClick={() => { onClick={() => {
setАssignment(assignment); setАssignment(assignment);
setIsModalOpen(true) setIsModalOpen(true)
@ -122,7 +122,7 @@ export default function MySchedulePage({ assignments }) {
Избери Заместник Избери Заместник
</button> </button>
<button <button
className="inline-flex items-center px-3 mx-2 py-2 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" className="mr-2 mb-2 inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
onClick={() => searchReplacement(assignment.id)} onClick={() => searchReplacement(assignment.id)}
> >
Търси заместник Търси заместник

View File

@ -20,7 +20,7 @@
"dir": "auto", "dir": "auto",
"lang": "en-US", "lang": "en-US",
"name": "Специално Свидетелстване София", "name": "Специално Свидетелстване София",
"short_name": "ССС", "short_name": "ССС"
"start_url": "https://sofia.mwitnessing.com/dash", // "start_url": "https://sofia.mwitnessing.com/dash",
"scope": "https://sofia.mwitnessing.com/cart" // "scope": "https://sofia.mwitnessing.com/cart"
} }

View File

@ -3,10 +3,13 @@ const multer = require('multer');
const next = require("next"); const next = require("next");
const path = require("path"); const path = require("path");
const fs = require("fs"); const fs = require("fs");
// const { promises: fs } = require('fs');
const dotenv = require("dotenv"); const dotenv = require("dotenv");
const data = require("./src/helpers/data"); const data = require("./src/helpers/data");
const sharp = require('sharp'); const sharp = require('sharp');
const https = require('https'); const https = require('https');
const { parse } = require('url');
const { join } = require('path');
//const getPort = require("get-port"); //const getPort = require("get-port");
@ -18,7 +21,7 @@ import('get-port').then(module => {
process.env.TZ = 'Europe/Sofia'; process.env.TZ = 'Europe/Sofia';
// Global variable to store the base URL // Global variable to store the base URL
let baseUrlGlobal; // let baseUrlGlobal;
console.log("initial process.env.APP_ENV = ", process.env.APP_ENV); console.log("initial process.env.APP_ENV = ", process.env.APP_ENV);
console.log("initial process.env.NODE_ENV = ", process.env.NODE_ENV); //NODE_ENV can be passed as docker param console.log("initial process.env.NODE_ENV = ", process.env.NODE_ENV); //NODE_ENV can be passed as docker param
@ -84,25 +87,43 @@ else {
console.log(`> Ready on ${PROTOCOL}://${HOST}:${PORT}`); console.log(`> Ready on ${PROTOCOL}://${HOST}:${PORT}`);
}); });
} }
// handlers // handlers
nextApp nextApp
.prepare() .prepare()
.then(() => { .then(() => {
// Add the middleware to set 'x-forwarded-host' header // Middleware to handle the 'x-forwarded-host' header
server.use((req, res, next) => { server.use((req, res, next) => {
req.headers['x-forwarded-host'] = req.headers['x-forwarded-host'] || req.headers.host; req.headers['x-forwarded-host'] = req.headers['x-forwarded-host'] || req.headers.host;
// ---------------
if (!baseUrlGlobal) {
const protocol = req.headers['x-forwarded-proto'] || 'http';
const host = req.headers.host;
const baseUrl = `${protocol}://${host}`;
baseUrlGlobal = baseUrl;
fs.writeFileSync(path.join(__dirname, 'baseUrl.txt'), baseUrlGlobal, 'utf8');
console.log("baseUrlGlobal set to: " + baseUrlGlobal);
}
next(); next();
}); });
// Middleware to handle service worker and specific js files
server.use(async (req, res, next) => {
const parsedUrl = parse(req.url, true);
const { pathname } = parsedUrl;
// Check if the request is for a service worker or a specific js file
// if (pathname === '/sw.js' || /^\/(workbox|worker|fallback)-\w+\.js$/.test(pathname)) {
// const filePath =
// join(__dirname, '.next', pathname);
// // Use Next.js's serveStatic method to serve the file from the .next directory
// try {
// const fileContent = fs.readFileSync(filePath);
// res.setHeader('Content-Type', 'application/javascript');
// res.send(fileContent);
// } catch (err) {
// // If there's an error (file not found, etc.), pass to the next handler
// next(err);
// }
// } else {
// // For all other requests, proceed to the next middleware
// next();
// }
});
server.use("/favicon.ico", express.static("styles/favicon_io/favicon.ico")); server.use("/favicon.ico", express.static("styles/favicon_io/favicon.ico"));
// server.use("/robots.txt", express.static("styles/favicon_io/robots.txt")); // server.use("/robots.txt", express.static("styles/favicon_io/robots.txt"));
// server.use("/sitemap.xml", express.static("styles/favicon_io/sitemap.xml")); // server.use("/sitemap.xml", express.static("styles/favicon_io/sitemap.xml"));
@ -659,5 +680,5 @@ async function Stat() {
Stat(); Stat();
exports.baseUrlGlobal = baseUrlGlobal; // exports.baseUrlGlobal = baseUrlGlobal;
exports.default = nextApp; // exports.default = nextApp;