Skip to content

Commit a79c48b

Browse files
Merge pull request #109 from SingularityNET-Archive:development
feat: Add saveCustomAgenda function and update ArchiveSummaries component
2 parents d89f0dc + 32ad9de commit a79c48b

File tree

8 files changed

+42
-13
lines changed

8 files changed

+42
-13
lines changed

components/ArchiveSummaries.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { generateMarkdown } from '../utils/generateMarkdown';
55
import { updateGitbook } from '../utils/updateGitbook';
66
import { sendDiscordMessage } from '../utils/sendDiscordMessage';
77
import { useMyVariable } from '../context/MyVariableContext';
8-
import { confirmedStatusUpdate } from '../utils/confirmedStatusUpdate'
8+
import { confirmedStatusUpdate } from '../utils/confirmedStatusUpdate';
9+
import { saveCustomAgenda } from '../utils/saveCustomAgenda';
910

1011
const ArchiveSummaries = () => {
1112
const textareaRef = useRef<HTMLTextAreaElement>(null);
@@ -25,7 +26,7 @@ const ArchiveSummaries = () => {
2526

2627
useEffect(() => {
2728
setRenderedMarkdown(formData.meetingSummary);
28-
//console.log(formData.meetingSummary)
29+
console.log(formData.meetingSummary, myVariable.summary)
2930
}, [formData.meetingSummary]);
3031

3132
useEffect(() => {
@@ -72,7 +73,10 @@ const ArchiveSummaries = () => {
7273
async function handleSubmit(e: React.FormEvent) {
7374
e.preventDefault();
7475
setLoading(true);
75-
76+
if (myVariable.summary?.noSummaryGiven == true || myVariable.summary?.canceledSummary == true) {
77+
const data: any = await saveCustomAgenda(myVariable.summary);
78+
console.log(data);
79+
}
7680
// Check if there are any confirmed summaries with the same date
7781
const isDuplicateConfirmedSummary = myVariable.summaries.some((summary: any) => {
7882
// Convert both dates to Date objects to strip off the time part

components/SummaryTemplate.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ const SummaryTemplate = ({ updateMeetings }: SummaryTemplateProps) => {
8787
otherMediaLink: "",
8888
transcriptLink: "",
8989
mediaLink: "",
90-
workingDocs: [{ title: '', link: '' }],
91-
timestampedVideo: { url: '', intro: '', timestamps: [{ title: '', timestamp: '' }] }
90+
workingDocs: [{ title: "", link: "" }],
91+
timestampedVideo: { url: "", intro: "", timestamps: [{ title: "", timestamp: "" }] }
9292
},
9393
agendaItems: [
9494
{
@@ -108,7 +108,8 @@ const SummaryTemplate = ({ updateMeetings }: SummaryTemplateProps) => {
108108
],
109109
tags: { topicsCovered: "", emotions: "", other: "", gamesPlayed: "" },
110110
type: "Custom",
111-
noSummaryGiven: false
111+
noSummaryGiven: false,
112+
canceledSummary: false
112113
};
113114

114115
const [formData, setFormData] = useState(filterFormData(filterKeys(myVariable.summary || {}, defaultFormData)));
@@ -247,7 +248,12 @@ const SummaryTemplate = ({ updateMeetings }: SummaryTemplateProps) => {
247248

248249
summary.confirmed = false;
249250

250-
const cleanedFormData = removeEmptyValues({ ...formData, meetingInfo: { ...formData.meetingInfo, workingDocs: filteredWorkingDocs } });
251+
const cleanedFormData = removeEmptyValues({
252+
...formData,
253+
meetingInfo: { ...formData.meetingInfo, workingDocs: filteredWorkingDocs },
254+
noSummaryGiven: false,
255+
canceledSummary: false
256+
});
251257
setLoading(true);
252258

253259
try {

config/config.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// config.js
2+
const isTestMode = process.env.NEXT_PUBLIC_NODE_ENV === 'test';
3+
4+
const tableSuffix = isTestMode ? '_test' : '';
5+
6+
export const tableNames = {
7+
meetingsummaries: `meetingsummaries${tableSuffix}`,
8+
documents: `documents${tableSuffix}`,
9+
// Add more table names as needed
10+
};

pages/submit-meeting-summary/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,10 @@ const SubmitMeetingSummary: NextPage = () => {
242242
...prevMyVariable,
243243
summary: {
244244
...prevMyVariable.summary,
245-
meetingInfo: {},
245+
meetingInfo: {
246+
name:"Weekly",
247+
date: prevMyVariable.summary.meetingInfo.date
248+
},
246249
agendaItems: [],
247250
tags: {},
248251
noSummaryGiven: true,
@@ -264,7 +267,10 @@ const SubmitMeetingSummary: NextPage = () => {
264267
...prevMyVariable,
265268
summary: {
266269
...prevMyVariable.summary,
267-
meetingInfo: {},
270+
meetingInfo: {
271+
name:"Weekly",
272+
date: prevMyVariable.summary.meetingInfo.date
273+
},
268274
agendaItems: [],
269275
tags: {},
270276
noSummaryGiven: false,

utils/confirmedStatusUpdate.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { supabase } from "../lib/supabaseClient";
2+
import { tableNames } from '../config/config';
23

34
export async function confirmedStatusUpdate(formData) {
45
let updates = {
@@ -7,7 +8,7 @@ export async function confirmedStatusUpdate(formData) {
78
}
89

910
const { data, error } = await supabase
10-
.from('meetingsummaries')
11+
.from(tableNames.meetingsummaries)
1112
.upsert(updates);
1213

1314
if (error) {

utils/generateMarkdown.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function generateMarkdown(summary, order) {
3939
const { date, name, host, documenter, peoplePresent, purpose, googleSlides, townHallNumber, otherMediaLink, meetingVideoLink, mediaLink, miroBoardLink, transcriptLink, workingDocs, timestampedVideo } = summary.meetingInfo;
4040

4141
// Add meeting information to markdown
42-
if (name) markdown += `- Type of meeting: ${name}\n`;
42+
if ( name && !summary.canceledSummary && !summary.noSummaryGiven ) markdown += `- Type of meeting: ${name}\n`;
4343
if (host || documenter || peoplePresent) {
4444
markdown += `- Present: `;
4545
if (host) markdown += `${host} [facilitator], `;

utils/saveAgenda.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { supabase } from "../lib/supabaseClient";
2+
import { tableNames } from '../config/config';
23

34
export async function saveAgenda(agendaData) {
45
let updates = {
@@ -10,7 +11,7 @@ export async function saveAgenda(agendaData) {
1011
}
1112

1213
const { data, error } = await supabase
13-
.from('meetingsummaries')
14+
.from(tableNames.meetingsummaries)
1415
.upsert(updates, { onConflict: ['name', 'date', 'workgroup_id', 'user_id'] });
1516

1617
if (error) {

utils/saveCustomAgenda.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { supabase } from "../lib/supabaseClient";
2+
import { tableNames } from '../config/config';
23

34
export async function saveCustomAgenda(agendaData) {
45
let updates = {
@@ -11,7 +12,7 @@ export async function saveCustomAgenda(agendaData) {
1112
}
1213

1314
const { data, error } = await supabase
14-
.from('meetingsummaries')
15+
.from(tableNames.meetingsummaries)
1516
.upsert(updates, { onConflict: ['name', 'date', 'workgroup_id', 'user_id'] })
1617
.select('date, meeting_id, updated_at');
1718

0 commit comments

Comments
 (0)