This commit is contained in:
Dobromir Popov
2024-05-04 14:34:57 +03:00
9 changed files with 98 additions and 48 deletions

6
.env
View File

@ -24,6 +24,9 @@ AZURE_AD_TENANT_ID=f69d1a93-bfba-498a-9b60-e87c1bc26276
APPLE_TEAM_ID=XC57P9SXDK
APPLE_KEY_ID=TB3V355G5Y
APPLE_APP_ID=com.mwhitnessing.sofia
APPLE_SECRET=eyJhbGciOiJFUzI1NiIsImtpZCI6IjlRVzkyNkZTSzkifQ.eyJhdWQiOiJodHRwczovL2FwcGxlaWQuYXBwbGUuY29tIiwiaXNzIjoiWEM1N1A5U1hESyIsImlhdCI6MTcxNDY3MDQxOSwiZXhwIjoxNzMwMjIyNDIwLCJzdWIiOiJjb20ubXdoaXRuZXNzaW5nLnNvZmlhIn0.KUW2roM2MAyfe2RphAoeAB-OK4LolGcO347SCxIocM3RXR0Z_5GVwu0BJiHwh2nO4WGXi2xHJgBvuwZhdAPWug
APPLE_PK=-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgLJtuaml9xsCzcKSH\nRvaTqmxoQgPzxXtk9jWZGU90FQCgCgYIKoZIzj0DAQehRANCAATM910/AhLshLvn\nWbmWi7F580AqLoNvHKHB4A1bccz+9QSvj0AcYA4J0BiMFfQrhXC5/SKEe7I0pDcv\nn4UlL3Sx\n-----END PRIVATE KEY-----
# APPLE_APP_ID=com.mwhitnessing.sofia
# APPLE_SECRET=eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlRCM1YzNTVHNVkifQ.eyJpYXQiOjE3MTMzMDQ1OTMsImV4cCI6MTcyODg1NjU5MywiYXVkIjoiaHR0cHM6Ly9hcHBsZWlkLmFwcGxlLmNvbSIsImlzcyI6IlhDNTdQOVNYREsiLCJzdWIiOiJjb20ubXdoaXRuZXNzaW5nLnNvZmlhIn0.iO2prjQ_4P7F17R7LTJfG9zHluj59uUtm8DA1LbK49jVBMeGHQP_Az7s_yU5D-GeMHSwU7VnVHcaVKiGWT_Yjg
@ -32,8 +35,7 @@ APPLE_KEY_ID=TB3V355G5Y
#APPLE_APP_ID=XC57P9SXDK.com.mwhitnessing.sofia
#APPLE_SECRET=eyJhbGciOiJFUzI1NiIsImtpZCI6IlRCM1YzNTVHNVkifQ.eyJhdWQiOiJodHRwczovL2FwcGxlaWQuYXBwbGUuY29tIiwiaXNzIjoiWEM1N1A5U1hESyIsImlhdCI6MTcxMjE3ODM0MiwiZXhwIjoxNzI3NzMwMzQzLCJzdWIiOiJjb20ubXdoaXRuZXNzaW5nLnNvZmlhIn0.XceA0qUQi0tXg0GM_LkJkpNU5AqXLiSB2JlEVbHCB_nINbQTWkjtoWxfqmvdOkIzwKtvdQ8FFb-crK9no9Bbbw
# to generate
APPLE_APP_ID=com.mwhitnessing.sofia
APPLE_SECRET=eyJhbGciOiJFUzI1NiIsImtpZCI6IjlRVzkyNkZTSzkifQ.eyJhdWQiOiJodHRwczovL2FwcGxlaWQuYXBwbGUuY29tIiwiaXNzIjoiWEM1N1A5U1hESyIsImlhdCI6MTcxNDY3MDQxOSwiZXhwIjoxNzMwMjIyNDIwLCJzdWIiOiJjb20ubXdoaXRuZXNzaW5nLnNvZmlhIn0.KUW2roM2MAyfe2RphAoeAB-OK4LolGcO347SCxIocM3RXR0Z_5GVwu0BJiHwh2nO4WGXi2xHJgBvuwZhdAPWug

12
.vscode/launch.json vendored
View File

@ -41,7 +41,7 @@
"type": "node-terminal"
},
{
"name": "Run conda nodemon (DEV)",
"name": "Conda debug (DB)",
"request": "launch",
"type": "node-terminal",
"cwd": "${workspaceFolder}",
@ -50,6 +50,16 @@
"APP_ENV": "development.popov"
}
},
{
"name": "Conda run (DB)",
"request": "launch",
"type": "node-terminal",
"cwd": "${workspaceFolder}",
"command": "conda activate node && npm run start-env",
"env": {
"APP_ENV": "development.popov"
}
},
{
"name": "Run conda npm TEST",
"request": "launch",

View File

@ -530,6 +530,7 @@ const AvCalendar = ({ publisherId, events, selectedDate }) => {
showAllEvents={true}
onNavigate={setDate}
className="rounded-lg shadow-lg"
longPressThreshold={150} // default value 250
/>
{isModalOpen && (
<div className="fixed inset-0 flex items-center justify-center z-50">

View File

@ -246,15 +246,54 @@ export default function PublisherForm({ item, me }) {
<label className="label" htmlFor="town">Град</label>
<input type="text" id="town" name="town" value={publisher.town} onChange={handleChange} className="textbox" placeholder="Град" autoFocus />
</div>
<div className="mb-4">
{/* notifications */}
<div className="form-check">
<input className="checkbox" type="checkbox" id="isSubscribedToCoverMe" name="isSubscribedToCoverMe" onChange={handleChange} checked={publisher.isSubscribedToCoverMe} autoComplete="off" />
<label className="label" htmlFor="isSubscribedToCoverMe">Абониран за имейли за заместване</label>
<input className="checkbox" type="checkbox" id="isSubscribedToReminders" name="isSubscribedToReminders" onChange={handleChange} checked={publisher.isSubscribedToReminders} autoComplete="off" />
<label className="label" htmlFor="isSubscribedToReminders">Абониран за напомняния (имейл)</label>
{/* prompt to install PWA */}
</div>
{/* notifications */}
<div className="mb-6 p-4 border border-gray-300 rounded-lg">
<fieldset>
<legend className="text-lg font-medium mb-2">Известия по имейл</legend>
<div className="space-y-4">
<div className="form-check">
<input
className="checkbox cursor-not-allowed opacity-50"
type="checkbox"
id="isSubscribedToCoverMeMandatory"
name="isSubscribedToCoverMeMandatory"
onChange={handleChange} // This will not fire due to being disabled, but kept for consistency
checked={true} // Always checked
disabled={true} // User cannot change this field
autoComplete="off" />
<label className="label cursor-not-allowed opacity-50" htmlFor="isSubscribedToCoverMeMandatory">
Имейли за заместване които отговарят на моите предпочитания
</label>
</div>
<div className="form-check">
<input
className="checkbox"
type="checkbox"
id="isSubscribedToCoverMe"
name="isSubscribedToCoverMe"
onChange={handleChange}
checked={publisher.isSubscribedToCoverMe}
autoComplete="off" />
<label className="label" htmlFor="isSubscribedToCoverMe">
Всички заявки за заместване
</label>
</div>
<div className="form-check">
<input
className="checkbox"
type="checkbox"
id="isSubscribedToReminders"
name="isSubscribedToReminders"
onChange={handleChange}
checked={publisher.isSubscribedToReminders}
autoComplete="off" />
<label className="label" htmlFor="isSubscribedToReminders">
Други напомняния
</label>
</div>
</div>
</fieldset>
</div>
{/* button to install PWA */}
@ -267,6 +306,7 @@ export default function PublisherForm({ item, me }) {
{/* ADMINISTRATORS ONLY */}
<ProtectedRoute allowedRoles={[UserRole.ADMIN]} deniedMessage=" " className="">
<div className="border border-blue-500 border-solid p-2">
{/* prompt to install PWA */}
<PwaManager />
<div className="mb-4">
<label className="label" htmlFor="type">Тип</label>

6
package-lock.json generated
View File

@ -26,7 +26,6 @@
"axios": "^1.6.7",
"axios-jwt": "^4.0.2",
"bcrypt": "^5.1.1",
"bcryptjs": "^2.4.3",
"date-fns": "^3.3.1",
"docx": "^8.5.0",
"docx-templates": "^4.11.4",
@ -5499,11 +5498,6 @@
"tweetnacl": "^0.14.3"
}
},
"node_modules/bcryptjs": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",
"integrity": "sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ=="
},
"node_modules/bidi-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/bidi-js/-/bidi-js-1.0.3.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "pwwa",
"version": "1.2.0",
"version": "1.2.2",
"private": true,
"description": "JW PW Web App",
"repository": "http://git.d-popov.com/popov/next-cart-app.git",
@ -11,7 +11,7 @@
"scripts": {
"debug": "node server.js",
"debug-env": "dotenv -e .env.$APP_ENV -- nodemon --inspect server.js",
"nodeenv": "dotenv -e .env.$APP_ENV -- node server.js",
"start-env": "dotenv -e .env.$APP_ENV -- npm run build && dotenv -e .env.$APP_ENV -- npm run start",
"prod": "dotenv -e .env.production -- node server.js",
"build": "next build",
"buildWin": "npm run build",

View File

@ -45,10 +45,17 @@ export const authOptions: NextAuthOptions = {
}
}
}),
// AppleProvider({
// clientId: process.env.APPLE_APP_ID,
// clientSecret: process.env.APPLE_SECRET
// }),
AppleProvider({
// clientId: process.env.APPLE_APP_ID,
// clientSecret: process.env.APPLE_SECRET
clientId: process.env.APPLE_APP_ID,
clientSecret: {
appleId: process.env.APPLE_APP_ID,
teamId: process.env.APPLE_TEAM_ID,
privateKey: process.env.APPLE_PK,
keyId: process.env.APPLE_KEY_ID,
}
}),
// AzureADProvider({
// clientId: process.env.AZURE_AD_CLIENT_ID,
// clientSecret: process.env.AZURE_AD_CLIENT_SECRET,
@ -251,13 +258,13 @@ export const authOptions: NextAuthOptions = {
};
},
},
pages: {
signIn: "/auth/signin",
signOut: "/auth/signout",
error: "/message", // Error code passed in query string as ?error=
verifyRequest: "/auth/verify-request", // (used for check email message)
newUser: null // If set, new users will be directed here on first sign in
},
// pages: {
// signIn: "/auth/signin",
// signOut: "/auth/signout",
// error: "/message", // Error code passed in query string as ?error=
// verifyRequest: "/auth/verify-request", // (used for check email message)
// newUser: null // If set, new users will be directed here on first sign in
// },
}
export default NextAuth(authOptions)

View File

@ -58,10 +58,7 @@ export default function SignIn({ csrfToken }) {
<div className="page">
<div className="signin">
<div className="min-h-screen flex flex-col items-center justify-center bg-gray-100">
{/* Page Title */}
<h1 className="text-2xl font-bold text-gray-900 mt-6">Вход</h1>
{/* Section for Social Sign-On Providers */}
<div className="mt-8 w-full max-w-md px-4 py-8 bg-white shadow rounded-lg">
{/* <h2 className="text-center text-lg font-semibold text-gray-900 mb-4">Sign in with a Social Media Account</h2> */}
<button onClick={() => signIn('google', { callbackUrl: '/' })}
@ -70,22 +67,17 @@ export default function SignIn({ csrfToken }) {
src="https://authjs.dev/img/providers/google.svg" className="mr-2" />
Влез чрез Google
</button>
{/* Add more buttons for other SSO providers here in similar style */}
{/* Apple Sign-In Button */}
{/* <button onClick={() => signIn('apple', { callbackUrl: '/' })}
className="mt-4 flex items-center justify-center w-full py-3 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">
<img loading="lazy" height="24" width="24" alt="Apple logo"
src="https://authjs.dev/img/providers/apple.svg" className="mr-2" />
Влез чрез Apple
</button> */}
</div>
{/* Apple Sign-In Button */}
<button onClick={() => signIn('apple', { callbackUrl: '/' })}
className="mt-4 flex items-center justify-center w-full py-3 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">
<img loading="lazy" height="24" width="24" alt="Apple logo"
src="https://authjs.dev/img/providers/apple.svg" className="mr-2" />
Влез чрез Apple
</button>
{/* Divider (Optional) */}
<div className="w-full max-w-xs mt-8 mb-8">
<hr className="border-t border-gray-300" />
</div>
{/* Local Account Email and Password Form */}
<div className="w-full max-w-md mt-8 mb-8 px-4 py-8 bg-white shadow rounded-lg">
<h2 className="text-center text-lg font-semibold text-gray-900 mb-4">Влез с локален акаунт</h2>
<form onSubmit={handleSubmit}>
@ -138,3 +130,4 @@ export async function getServerSideProps(context) {
},
};
}

View File

@ -336,8 +336,11 @@ nextApp
placeOfEvent: shift.cartEvent.location.name,
time: time,
//bold the text after - in the notes
notes: shift.notes.substring(0, shift.notes.indexOf("-") + 1),
notes_bold: shift.notes.substring(shift.notes.indexOf("-") + 1),
//notes: shift.notes.substring(0, shift.notes.indexOf("-") + 1),
//notes_bold: shift.notes.substring(shift.notes.indexOf("-") + 1),
notes: shift.assignments.some(a => a.isWithTransport) ? "Транспорт: " : "",
notes_bold: shift.assignments.filter(a => a.isWithTransport).map(a => common.getInitials(a.publisher.firstName + " " + a.publisher.lastName)).join(", "),
names: shift.assignments
.map((assignment) => {
return (