This file contains hidden or 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 API = ({ baseUrl }: { baseUrl: string }) => ({ | |
| async get(url: string, options: { params?: any } = {}) { | |
| const paramsString = Object.entries(options.params || {}) | |
| .map(([key, value]) => `${key}=${value}`) | |
| .join('&') | |
| const endpoint = `${baseUrl}${url}?${paramsString}`; | |
| const response = await fetch(endpoint, { | |
| method: 'GET', |
This file contains hidden or 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 { forwardRef, useImperativeHandle, useState } from "react" | |
| import { ModalContext } from "./context" | |
| export const ModalContextProvider = forwardRef(({ | |
| children, | |
| modalProps, | |
| modal: Modal | |
| }, ref) => { | |
| const [state, setState] = useState({ | |
| isModalOpen: false, |
This file contains hidden or 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 { useRef, useEffect } from "react"; | |
| // Hook taken from here https://usehooks.com/usePrevious/ | |
| export function usePrevious(value) { | |
| // The ref object is a generic container whose current property is mutable ... | |
| // ... and can hold any value, similar to an instance property on a class | |
| const ref = useRef(); | |
| // Store current value in ref | |
| useEffect(() => { | |
| ref.current = value; |
This file contains hidden or 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
| const fs = require('fs') | |
| const tmp = require("tmp"); | |
| const PDFDocument = require('pdfkit'); | |
| const MemoryStream = require('memorystream'); | |
| const { ChartJSNodeCanvas } = require('chartjs-node-canvas'); | |
| export async function generatePDFWithCharts() { | |
| // Sample chart with ChartJS | |
| const chartJSNodeCanvas = new ChartJSNodeCanvas({ type: 'png', width: 800, height: 600 }); | |
| const configuration = { |