mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* page placeholder * block info snippet * add actions for calendar buttons * add timer * add redirect when timer runs out * add redirect from not found block page * block countdown index page * link to countdown index page * add link to search suggest * add URL to an event * add link to block countdown on mobile * tests * add countdown text to search result page * update margins * show block countdown when search results are not empty
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { route } from 'nextjs-routes';
|
|
|
|
import config from 'configs/app';
|
|
import type dayjs from 'lib/date/dayjs';
|
|
|
|
interface Params {
|
|
date: dayjs.Dayjs;
|
|
blockHeight: string;
|
|
}
|
|
|
|
const DATE_FORMAT = 'YYYYMMDDTHHmmss';
|
|
|
|
export default function createIcsFileBlob({ date, blockHeight }: Params): Blob {
|
|
const name = `Block #${ blockHeight } reminder | ${ config.chain.name }`;
|
|
const description = `#${ blockHeight } block creation time on ${ config.chain.name } blockchain.`;
|
|
const startTime = date.format(DATE_FORMAT);
|
|
const endTime = date.add(15, 'minutes').format(DATE_FORMAT);
|
|
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
const blockUrl = config.app.baseUrl + route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: blockHeight } });
|
|
|
|
const icsContent = `BEGIN:VCALENDAR
|
|
VERSION:2.0
|
|
BEGIN:VEVENT
|
|
SUMMARY:${ name }
|
|
DESCRIPTION:${ description }
|
|
DTSTART;TZID=${ timeZone }:${ startTime }
|
|
DTEND;TZID=${ timeZone }:${ endTime }
|
|
URL:${ blockUrl }
|
|
END:VEVENT
|
|
END:VCALENDAR`;
|
|
|
|
const blob = new Blob([ icsContent ], { type: 'text/calendar' });
|
|
|
|
return blob;
|
|
}
|