This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { create } from "ipfs-http-client"; | |
import { ImportCandidate } from "ipfs-core-types/src/utils"; | |
const client = create({ url: "https://ipfs.infura.io:5001/api/v0" }); | |
const useIpfs = () => { | |
const upload = async (file: ImportCandidate) => { | |
try { | |
const added = await client.add(file); | |
const url = `https://ipfs.infura.io/ipfs/${added.path}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const dynamicTimeLeft = (date1: Date, date2: Date) => { | |
const distance = date2.getTime() - date1.getTime(); | |
const hours = Math.floor( | |
(distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60) | |
); | |
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); | |
const seconds = Math.floor((distance % (1000 * 60)) / 1000); | |
const addZero = (t: number) => (t > 9 ? t : `0${t}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState } from "react"; | |
import { dynamicTimeLeft } from "utils/date"; | |
interface TimerProps { | |
dateEnd: Date; | |
} | |
const Timer: React.FC<TimerProps> = ({ dateEnd }) => { | |
const [time, setTime] = useState<null | string>(null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Compressor from "compressorjs"; | |
export const compressImage = async ( | |
file: File, | |
quality: number, | |
maxHeight: number, | |
maxWidth: number, | |
convertSize?: number | |
): Promise<File | Blob> => { | |
return await new Promise((resolve, reject) => { |
OlderNewer