Skip to content

Commit 28d8aac

Browse files
Merge pull request #173 from SingularityNET-Archive:development
feat: Add text properties for no summary and canceled summary in SummaryTemplate
2 parents fdc6e0e + a15905e commit 28d8aac

File tree

6 files changed

+126
-55
lines changed

6 files changed

+126
-55
lines changed

components/ArchiveSummaries.tsx

Lines changed: 98 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,22 @@ const ArchiveSummaries = () => {
1717
workgroup: myVariable.summary?.workgroup || "",
1818
meetingSummary: generateMarkdown(myVariable.summary),
1919
meeting_id: myVariable.summary?.meeting_id || "",
20-
confirmed: myVariable.summary?.confirmed || false
20+
confirmed: myVariable.summary?.confirmed || false,
21+
noSummaryGivenText: myVariable.summary?.noSummaryGivenText || "",
22+
canceledSummaryText: myVariable.summary?.canceledSummaryText || ""
2123
});
2224
const [commitToGitBook, setCommitToGitBook] = useState(true);
2325
const [sendToDiscord, setSendToDiscord] = useState(true);
2426
const [renderedMarkdown, setRenderedMarkdown] = useState("");
2527
const formattedDate = new Date(formData.date).toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
2628

29+
// Determine which text value to use based on summary type:
30+
const summaryText = myVariable.summary.noSummaryGiven
31+
? formData.noSummaryGivenText
32+
: myVariable.summary.canceledSummary
33+
? formData.canceledSummaryText
34+
: formData.meetingSummary;
35+
2736
useEffect(() => {
2837
setRenderedMarkdown(formData.meetingSummary);
2938
console.log(formData.meetingSummary, myVariable.summary)
@@ -38,7 +47,9 @@ const ArchiveSummaries = () => {
3847
workgroup: myVariable.summary?.workgroup || "",
3948
meetingSummary: generateMarkdown(myVariable.summary, currentOrder),
4049
meeting_id: myVariable.summary?.meeting_id || "",
41-
confirmed: myVariable.summary?.confirmed || false
50+
confirmed: myVariable.summary?.confirmed || false,
51+
noSummaryGivenText: myVariable.summary?.noSummaryGivenText || "",
52+
canceledSummaryText: myVariable.summary?.canceledSummaryText || ""
4253
});
4354
setRenderedMarkdown(generateMarkdown(myVariable.summary, currentOrder));
4455
}
@@ -57,12 +68,26 @@ const ArchiveSummaries = () => {
5768
if (type === "checkbox") {
5869
const checked = (e.target as HTMLInputElement).checked;
5970
name === "commitToGitBook" ? setCommitToGitBook(checked) : setSendToDiscord(checked);
60-
} else if (name == 'date' && (myVariable.summary?.noSummaryGiven == true || myVariable.summary?.canceledSummary == true)) {
61-
console.log(myVariable, formData, value)
62-
setFormData({ ...formData, [name]: value, confirmed: false });
71+
} else if (myVariable.summary.noSummaryGiven) {
72+
// Update the noSummaryGiven text field when in that mode
73+
setFormData((prev) => ({
74+
...prev,
75+
noSummaryGivenText: value,
76+
}));
77+
setSendToDiscord(false);
78+
} else if (myVariable.summary.canceledSummary) {
79+
// Update the canceledSummary text field when in that mode
80+
setFormData((prev) => ({
81+
...prev,
82+
canceledSummaryText: value,
83+
}));
6384
setSendToDiscord(false);
6485
} else {
65-
setFormData({ ...formData, [name]: value });
86+
// Regular meeting summary update
87+
setFormData((prev) => ({
88+
...prev,
89+
[name]: value,
90+
}));
6691
}
6792
if (name === 'meetingSummary') {
6893
adjustTextareaHeight();
@@ -73,10 +98,37 @@ const ArchiveSummaries = () => {
7398
async function handleSubmit(e: React.FormEvent) {
7499
e.preventDefault();
75100
setLoading(true);
76-
if (myVariable.summary?.noSummaryGiven == true || myVariable.summary?.canceledSummary == true) {
77-
const data: any = await saveCustomAgenda(myVariable.summary);
78-
console.log(data);
79-
}
101+
102+
let currentMeetingId = formData.meeting_id;
103+
104+
// If this is a noSummary or canceled summary and meeting_id is missing, save first
105+
if ((myVariable.summary?.noSummaryGiven || myVariable.summary?.canceledSummary) && !currentMeetingId) {
106+
// Merge the updated text fields from formData into the summary object
107+
const updatedSummary = {
108+
...myVariable.summary,
109+
noSummaryGivenText: formData.noSummaryGivenText,
110+
canceledSummaryText: formData.canceledSummaryText,
111+
};
112+
const data: any = await saveCustomAgenda(updatedSummary);
113+
if (data && data[0]?.meeting_id) {
114+
currentMeetingId = data[0].meeting_id;
115+
// Update context and state with the new meeting_id
116+
setMyVariable(prev => ({
117+
...prev,
118+
summary: {
119+
...prev.summary,
120+
meeting_id: currentMeetingId,
121+
noSummaryGivenText: formData.noSummaryGivenText,
122+
canceledSummaryText: formData.canceledSummaryText,
123+
}
124+
}));
125+
setFormData(prev => ({
126+
...prev,
127+
meeting_id: currentMeetingId
128+
}));
129+
}
130+
}
131+
80132
// Check if there are any confirmed summaries with the same date
81133
const isDuplicateConfirmedSummary = myVariable.summaries.some((summary: any) => {
82134
// Convert both dates to Date objects to strip off the time part
@@ -94,41 +146,36 @@ const ArchiveSummaries = () => {
94146
}
95147

96148
if (!formData.confirmed) {
149+
const payload = { ...formData, meeting_id: currentMeetingId };
97150
if (commitToGitBook) {
98-
const data = await updateGitbook(formData);
151+
const data = await updateGitbook(payload);
99152
if (data) {
100153
setMyVariable(prevState => ({
101154
...prevState,
102-
summary: {
103-
...prevState.summary,
104-
confirmed: true,
105-
},
155+
summary: { ...prevState.summary, confirmed: true },
106156
}));
107157
}
108158
} else {
109-
await confirmedStatusUpdate(formData);
159+
await confirmedStatusUpdate(payload);
110160
setMyVariable(prevState => ({
111161
...prevState,
112-
summary: {
113-
...prevState.summary,
114-
confirmed: true,
115-
},
162+
summary: { ...prevState.summary, confirmed: true },
116163
}));
117164
}
118-
165+
119166
if (sendToDiscord) {
120167
await sendDiscordMessage(myVariable, renderedMarkdown);
121168
}
122169
} else {
123-
if (myVariable.summary.noSummaryGiven == true || myVariable.summary.canceledSummary == true) {
124-
alert('Select a date')
170+
if (myVariable.summary.noSummaryGiven || myVariable.summary.canceledSummary) {
171+
alert('Select a date');
125172
} else {
126173
alert('Summary already archived');
127174
}
128175
}
129176

130177
setLoading(false);
131-
}
178+
}
132179

133180
return (
134181
<div className={styles['main-container']}>
@@ -155,6 +202,7 @@ const ArchiveSummaries = () => {
155202
onChange={handleChange}
156203
className={styles['form-input']}
157204
/>
205+
158206
<label className={styles['form-label']}>
159207
Workgroup:
160208
</label>
@@ -166,40 +214,45 @@ const ArchiveSummaries = () => {
166214
className={styles['form-input']}
167215
autoComplete="off"
168216
/>
217+
169218
<label className={styles['form-label']}>
170219
Meeting Summary Markdown:
171220
</label>
172221
<textarea
173222
ref={textareaRef}
174-
name="meetingSummary"
175-
value={formData.meetingSummary}
223+
name="meetingSummary"
224+
value={summaryText}
176225
onChange={handleChange}
177226
className={styles['meeting-summary-textarea']}
178227
autoComplete="off"
179228
/>
229+
180230
<button type="submit" disabled={loading} className={styles['submit-button']}>
181231
{loading ? "Loading..." : "Submit"}
182232
</button>
233+
183234
<div className={styles['form-checkbox']}>
184-
<input
185-
type="checkbox"
186-
id="commitToGitBook"
187-
name="commitToGitBook"
188-
checked={commitToGitBook}
189-
onChange={handleChange}
190-
/>
191-
<label htmlFor="commitToGitBook">Commit to GitBook</label>
192-
</div>
193-
<div className={styles['form-checkbox']}>
194-
<input
195-
type="checkbox"
196-
id="sendToDiscord"
197-
name="sendToDiscord"
198-
checked={sendToDiscord}
199-
onChange={handleChange}
200-
/>
201-
<label htmlFor="sendToDiscord">Send Discord Message</label>
202-
</div>
235+
<input
236+
type="checkbox"
237+
id="commitToGitBook"
238+
name="commitToGitBook"
239+
checked={commitToGitBook}
240+
onChange={handleChange}
241+
/>
242+
<label htmlFor="commitToGitBook">Commit to GitBook</label>
243+
</div>
244+
245+
<div className={styles['form-checkbox']}>
246+
<input
247+
type="checkbox"
248+
id="sendToDiscord"
249+
name="sendToDiscord"
250+
checked={sendToDiscord}
251+
onChange={handleChange}
252+
/>
253+
<label htmlFor="sendToDiscord">Send Discord Message</label>
254+
</div>
255+
203256
</form>
204257
</div>
205258
<div className={styles['markdown-rendered']}>

components/SummaryTemplate.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ const defaultFormData = {
6060
tags: { topicsCovered: "", emotions: "", other: "", gamesPlayed: "" },
6161
type: "Custom",
6262
noSummaryGiven: false,
63-
canceledSummary: false
63+
canceledSummary: false,
64+
noSummaryGivenText: "No Summary Given",
65+
canceledSummaryText: "Meeting was cancelled"
6466
};
6567

6668
function formatTimestampForPdf(timestamp: any) {

pages/submit-meeting-summary/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ const SubmitMeetingSummary: NextPage = () => {
373373
type: "Custom",
374374
noSummaryGiven: false,
375375
canceledSummary: false,
376+
noSummaryGivenText: "No Summary Given",
377+
canceledSummaryText: "Meeting was cancelled",
376378
updated_at: new Date()
377379
};
378380

@@ -403,7 +405,9 @@ const SubmitMeetingSummary: NextPage = () => {
403405
updated_at: new Date(),
404406
confirmed: false,
405407
noSummaryGiven: false,
406-
canceledSummary: false
408+
canceledSummary: false,
409+
noSummaryGivenText: "No Summary Given",
410+
canceledSummaryText: "Meeting was cancelled"
407411
};
408412
setMyVariable((prev) => ({
409413
...prev,
@@ -442,6 +446,8 @@ const SubmitMeetingSummary: NextPage = () => {
442446
type: "Custom",
443447
noSummaryGiven: false,
444448
canceledSummary: false,
449+
noSummaryGivenText: "No Summary Given",
450+
canceledSummaryText: "Meeting was cancelled",
445451
updated_at: new Date()
446452
};
447453
setMyVariable((prev) => ({
@@ -469,6 +475,7 @@ const SubmitMeetingSummary: NextPage = () => {
469475
tags: {},
470476
noSummaryGiven: true,
471477
canceledSummary: false,
478+
noSummaryGivenText: "No Summary Given",
472479
updated_at: new Date()
473480
};
474481
setMyVariable((prev) => ({
@@ -495,6 +502,7 @@ const SubmitMeetingSummary: NextPage = () => {
495502
tags: {},
496503
noSummaryGiven: false,
497504
canceledSummary: true,
505+
canceledSummaryText: "Meeting was cancelled",
498506
updated_at: new Date()
499507
};
500508
setMyVariable((prev) => ({

utils/confirmedStatusUpdate.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import { supabase } from "../lib/supabaseClient";
22
import { tableNames } from '../config/config';
33

44
export async function confirmedStatusUpdate(formData) {
5+
6+
if (!formData.meeting_id) {
7+
console.error('Cannot update confirmed status: meeting_id is missing');
8+
return false;
9+
}
10+
511
let updates = {
612
meeting_id: formData.meeting_id,
713
confirmed: true

utils/generateMarkdown.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,11 @@ export function generateMarkdown(summary, order) {
242242
if (gamesPlayed) markdown += `- **games played:** ${gamesPlayed}\n`;
243243
}
244244

245-
if (summary.noSummaryGiven == true) {
246-
markdown += `No Summary Given \n`;
245+
if (summary.noSummaryGiven === true) {
246+
markdown += `${summary.noSummaryGivenText || "No Summary Given"}\n`;
247247
}
248-
//canceledSummary
249-
if (summary.canceledSummary == true) {
250-
markdown += `Meeting was cancelled \n`;
248+
if (summary.canceledSummary === true) {
249+
markdown += `${summary.canceledSummaryText || "Meeting was cancelled"}\n`;
251250
}
252251
return markdown;
253252
};

utils/prepareFormDataForSave.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ../utils/prepareFormDataForSave.ts
22

33
export function prepareFormDataForSave(rawData: any) {
4-
const filteredWorkingDocs = rawData.meetingInfo.workingDocs.filter(
4+
const filteredWorkingDocs = rawData.meetingInfo?.workingDocs?.filter(
55
(doc: any) => doc.title || doc.link
66
);
77
let newData = {
@@ -10,8 +10,11 @@ export function prepareFormDataForSave(rawData: any) {
1010
...rawData.meetingInfo,
1111
workingDocs: filteredWorkingDocs,
1212
},
13-
noSummaryGiven: false,
14-
canceledSummary: false,
13+
noSummaryGiven: rawData.noSummaryGiven || false,
14+
canceledSummary: rawData.canceledSummary || false,
15+
noSummaryGivenText: rawData.noSummaryGivenText || "",
16+
canceledSummaryText: rawData.canceledSummaryText || "",
17+
type: 'custom'
1518
};
1619

1720
// Specify the root-level keys you want to remove

0 commit comments

Comments
 (0)