update dependencies and devDependencies, address lint issues
[squeep-indie-auther] / src / template / admin-maintenance-html.js
index 031eb30c18527602aed4c9a30ae1897432997e39..0f4de44ce599fa62b745f1b63dab9d8ec90a2ca4 100644 (file)
@@ -1,7 +1,13 @@
 'use strict';
 
 const th = require('./template-helper');
+const { sessionNavLinks } = require('@squeep/authentication-module');
 
+/**
+ *
+ * @param {object} entry entry
+ * @returns {string} tr
+ */
 function renderAlmanacRow(entry) {
   const { event, date } = entry;
   return `<tr>
@@ -10,21 +16,34 @@ function renderAlmanacRow(entry) {
 </tr>`;
 }
 
+/**
+ *
+ * @param {object[]} almanac entries
+ * @returns {string} section
+ */
 function almanacSection(almanac) {
   return `<section>
 \t<h2>Almanac</h2>
 \t<table>
 \t\t<thead>
-\t\t\t<th>Event</th>
-\t\t\t<th>Date</th>
+\t\t\t\t<tr>
+\t\t\t\t<th scope="col">Event</th>
+\t\t\t\t<th scope="col">Date</th>
+\t\t\t</tr>
 \t\t</thead>
 \t\t<tbody>
 ${almanac.map((entry) => renderAlmanacRow(entry)).join('\n')}
 \t\t</tbody>
-\t<table>
+\t</table>
 </section>`;
 }
 
+/**
+ *
+ * @param {string} choreName name
+ * @param {object} choreDetails details
+ * @returns {string} tr
+ */
 function renderChoreRow(choreName, choreDetails) {
   const { intervalMs, nextSchedule } = choreDetails;
   return `<tr>
@@ -34,53 +53,53 @@ function renderChoreRow(choreName, choreDetails) {
 </tr>`;
 }
 
+/**
+ *
+ * @param {object} chores chores
+ * @returns {string} section
+ */
 function choresSection(chores) {
   return `<section>
 \t<h2>Chores</h2>
 \t<table>
 \t\t<thead>
-\t\t\t<th>Chore</th>
-\t\t\t<th>Frequency</th>
-\t\t\t<th>Next Run</th>
+\t\t\t<tr>
+\t\t\t\t<th scope="col">Chore</th>
+\t\t\t\t<th scope="col">Frequency</th>
+\t\t\t\t<th scope="col">Next Run</th>
+\t\t\t</tr>
 \t\t</thead>
 \t\t<tbody>
 ${Object.entries(chores).map((chore) => renderChoreRow(...chore)).join('\n')}
 \t\t</tbody>
-\t<table>
+\t</table>
 </section>`;
 }
 
 /**
  * 
- * @param {Object} ctx
- * @param {Object[]} ctx.almanac
- * @param {Object} ctx.chores
- * @param {Object} options
- * @param {Object} options.manager
- * @param {String} options.manager.pageTitle
- * @param {String[]} options.manager.footerEntries
- * @param {String} options.adminContactHTML
- * @returns {String}
+ * @param {object} ctx context
+ * @param {object[]} ctx.almanac entries
+ * @param {object} ctx.chores chores
+ * @param {object} options options
+ * @param {object} options.manager manager options
+ * @param {string} options.manager.pageTitle page title
+ * @param {string[]} options.manager.footerEntries footer entires
+ * @returns {string} page
  */
 module.exports = (ctx, options) => {
+  const pagePathLevel = 1;
   const htmlOptions = {
+    pageIdentifier: 'maintenance',
     pageTitle: options.manager.pageTitle + ' - Maintenance',
     logoUrl: options.manager.logoUrl,
     footerEntries: options.manager.footerEntries,
-    navLinks: [
-      {
-        text: 'Admin',
-        href: '.',
-      },
-      {
-        text: 'Ticket',
-        href: './ticket',
-      },
-    ],
   };
+  th.navLinks(pagePathLevel, ctx, htmlOptions);
+  sessionNavLinks(pagePathLevel, ctx, htmlOptions);
   const content = [
     almanacSection(ctx.almanac || []),
     choresSection(ctx.chores || {}),
   ];
-  return th.htmlPage(1, ctx, htmlOptions, content);
+  return th.htmlPage(pagePathLevel, ctx, htmlOptions, content);
 };
\ No newline at end of file