Skip to content

Commit fa5804f

Browse files
committed
improve and simplify orgName
1 parent 65a26b0 commit fa5804f

2 files changed

Lines changed: 3 additions & 35 deletions

File tree

devconnect/src/pages/api/notion/organization/[id].ts

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
8585
return value && typeof value === 'object' && value.type === 'relation';
8686
});
8787

88-
let orgName = '';
88+
const orgName = pageDetails.properties?.['Org']?.title?.[0]?.plain_text || 'Unknown Org';
8989
let subItems: any[] = [];
9090

9191
// Get sub-items from relation properties (excluding Quest)
@@ -96,33 +96,6 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
9696
continue;
9797
}
9898

99-
// Process Supporters Tracker property first to get orgName
100-
if (propertyName === 'Supporters Tracker') {
101-
const propertyData = property as any;
102-
if (propertyData.relation && propertyData.relation.length > 0) {
103-
console.log(`[API Call] Processing Supporters Tracker for orgName`);
104-
105-
const supporterPageId = propertyData.relation[0].id;
106-
console.log(`[API Call] Supporter Page ID: ${supporterPageId}`);
107-
try {
108-
const supporterPage = await notion.pages.retrieve({ page_id: supporterPageId });
109-
const supporterData = supporterPage as any;
110-
111-
// Extract just the supporter name/title
112-
orgName = supporterData.properties?.['Supporter Name']?.title?.[0]?.plain_text ||
113-
supporterData.properties?.Name?.title?.[0]?.plain_text ||
114-
supporterData.properties?.Title?.title?.[0]?.plain_text ||
115-
'Unknown Supporter';
116-
117-
console.log(`[API Call] Set orgName to: ${orgName}`);
118-
} catch (err) {
119-
console.error(`[API Call] Failed to retrieve Supporters Tracker page ${supporterPageId}:`, err);
120-
orgName = 'Error loading supporter data';
121-
}
122-
}
123-
continue; // Skip further processing for this property
124-
}
125-
12699
// Process Sub-item property with individual page retrievals for detailed data
127100
if (propertyName === 'Sub-item') {
128101
const propertyData = property as any;
@@ -247,16 +220,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
247220
}
248221
}
249222

250-
// console.log(`[API Call] Final result for ${pageId}:`, {
251-
// orgName: orgName,
252-
// totalSubItems: subItems.length,
253-
// subItemsWithData: subItems.filter(item => item.completionPercentage > 0 || item.status !== 'No Status').length
254-
// });
255-
256223
return res.status(200).json({
257224
children: subItems,
258225
count: subItems.length,
259-
orgName: orgName,
226+
orgName,
260227
accreditationGuideUrl: process.env.ACCREDITATION_GUIDE || ''
261228
});
262229
} catch (error) {

devconnect/src/pages/form/[name]/[id].tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,6 +1676,7 @@ export default function UpdatePage({ params }: { params?: { name: string; id: st
16761676
>
16771677
<a
16781678
href={`/form/accreditation/${item.id}`}
1679+
target="_blank"
16791680
style={{
16801681
color: '#007bff',
16811682
textDecoration: 'none',

0 commit comments

Comments
 (0)