add prefilled calendar provider links
This commit is contained in:
@@ -40,6 +40,43 @@ export function createTenderICS(t, now = new Date()) {
|
||||
'END:VEVENT','END:VCALENDAR',''].map(fold).join('\r\n');
|
||||
}
|
||||
|
||||
const calendarInstant = date => date.toISOString().replace(/\.000Z$/, 'Z');
|
||||
const calendarText = t => [
|
||||
`İKN: ${t.ikn || t.id || ''}`,
|
||||
t.kurum || '',
|
||||
'Kaynak sürümünü ve ihale tarihini resmi kaynaktan doğrulayın.',
|
||||
].filter(Boolean).join('\n');
|
||||
|
||||
/** Google Calendar'a kaynak tarihiyle ön-doldurulmuş etkinlik taslağı açar. */
|
||||
export function googleCalendarUrl(t) {
|
||||
const start = tenderDeadline(t);
|
||||
const instant = calendarInstant(start).replace(/[-:]/g, '');
|
||||
const params = new URLSearchParams({
|
||||
action: 'TEMPLATE',
|
||||
text: `İhale son teklif: ${t.baslik || t.ikn || 'İhale'}`,
|
||||
dates: `${instant}/${instant}`,
|
||||
details: calendarText(t),
|
||||
location: t.ihaleYeri || t.teslimYeri || '',
|
||||
});
|
||||
return `https://calendar.google.com/calendar/render?${params}`;
|
||||
}
|
||||
|
||||
/** Outlook web takviminde kaynak tarihiyle ön-doldurulmuş taslak açar. */
|
||||
export function outlookCalendarUrl(t) {
|
||||
const start = tenderDeadline(t);
|
||||
const instant = calendarInstant(start);
|
||||
const params = new URLSearchParams({
|
||||
path: '/calendar/action/compose',
|
||||
rru: 'addevent',
|
||||
startdt: instant,
|
||||
enddt: instant,
|
||||
subject: `İhale son teklif: ${t.baslik || t.ikn || 'İhale'}`,
|
||||
body: calendarText(t),
|
||||
location: t.ihaleYeri || t.teslimYeri || '',
|
||||
});
|
||||
return `https://outlook.live.com/calendar/0/deeplink/compose?${params}`;
|
||||
}
|
||||
|
||||
function parseICSDate(value, params = '') {
|
||||
const raw = String(value || '').trim();
|
||||
const match = /^(\d{4})(\d{2})(\d{2})(?:T(\d{2})(\d{2})(\d{2})Z?)?$/.exec(raw);
|
||||
|
||||
Reference in New Issue
Block a user