Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/ArchiveSummaries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const ArchiveSummaries = () => {
if (type === "checkbox") {
const checked = (e.target as HTMLInputElement).checked;
name === "commitToGitBook" ? setCommitToGitBook(checked) : setSendToDiscord(checked);
} else if (name == 'date' && myVariable.summary.noSummaryGiven == true) {
} else if (name == 'date' && (myVariable.summary?.noSummaryGiven == true || myVariable.summary?.canceledSummary == true)) {
console.log(myVariable, formData, value)
setFormData({ ...formData, [name]: value, confirmed: false });
setSendToDiscord(false);
Expand Down Expand Up @@ -116,7 +116,7 @@ const ArchiveSummaries = () => {
await sendDiscordMessage(myVariable, renderedMarkdown);
}
} else {
if (myVariable.summary.noSummaryGiven == true) {
if (myVariable.summary.noSummaryGiven == true || myVariable.summary.canceledSummary == true) {
alert('Select a date')
} else {
alert('Summary already archived');
Expand Down
12 changes: 9 additions & 3 deletions components/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,15 @@ const Nav = () => {
<Link href='/issues' className="navitems">
Issues
</Link>
{roleData?.appRole == "admin" && (<Link href='/status-of-summaries' className="navitems">
Summaries
</Link>)}
{roleData?.appRole == "admin" && (<>
<Link href='/status-of-summaries' className="navitems">
Summaries
</Link>
<Link href='/admin-tools' className="navitems">
Admin Tools
</Link>
</>
)}
</div>
<div>{latestTag}</div>
<div>
Expand Down
61 changes: 61 additions & 0 deletions pages/admin-tools.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { useState } from "react";
import type { NextPage } from "next";
import styles from '../styles/admintools.module.css';
import { exportTags, exportUsers } from '../utils/exportUtils';

const AdminTools: NextPage = () => {
const [loading, setLoading] = useState(false);

const handleExport = async (entity: 'tags' | 'users', format: 'csv' | 'pdf' | 'json') => {
setLoading(true);
if (entity === 'tags') {
await exportTags(format);
} else if (entity === 'users') {
await exportUsers(format);
}
setLoading(false);
};

// Simplified and more scalable structure for export operations
const exportOperations = [
{
entity: 'Tags',
formats: ['csv', 'pdf', 'json'],
},
{
entity: 'Users',
formats: ['csv', 'pdf', 'json'],
},
// Example of how to add a new entity
// {
// entity: 'NewEntity',
// formats: ['csv', 'pdf'],
// },
];

return (
<div className={styles.container}>
{!loading && (
<div>
<h1>Admin Tools</h1>
{exportOperations.map((operation: any) => (
<div key={operation.entity} className={styles.column}>
<h2 className={styles.columnHeading}>{operation.entity}</h2>
{operation.formats.map((format: any) => (
<button
key={format}
className={styles.button}
onClick={() => handleExport(operation.entity.toLowerCase(), format)}
>
Export {operation.entity} ({format.toUpperCase()})
</button>
))}
</div>
))}
</div>
)}
</div>
);
};

export default AdminTools;
1 change: 1 addition & 0 deletions pages/api/convertToPdf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//convertToPdf.js
import axios from 'axios';

export default async function handler(req, res) {
Expand Down
2 changes: 1 addition & 1 deletion pages/issues.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Issues: NextPage = () => {
async function getIssues() {
setLoading(true);
const issues = await fetchIssues();
console.log(issues)
//console.log(issues)
const open = issues.filter((issue: Issue) => issue.state === 'open');
const closed = issues.filter((issue: Issue) => issue.state === 'closed');
setOpenIssues(open);
Expand Down
Loading