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 React, { useRef, useState, useEffect } from "react"; | |
| import { useRouter } from "next/router"; | |
| const useNexJSPreviousRoute = () => { | |
| const router = useRouter(); | |
| const ref = useRef<string>(""); | |
| useEffect(() => { |
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 { useRouter } from "next/router"; | |
| import { useRef, useEffect } from "react"; | |
| export const useNexJSPreviousRoute = () => { | |
| const router = useRouter(); | |
| const ref = useRef<string>(""); | |
| useEffect(() => { | |
| if (ref.current === "") { |
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"; | |
| import { useQueryClient } from "@tanstack/react-query"; | |
| import type { InvalidateQueryFilters, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query"; | |
| type TypeSafeQueryKey<TQueryFnData> = UseQueryOptions<TQueryFnData>["queryKey"]; | |
| type TypeSafeMutationKey = NonNullable<UseMutationOptions["mutationKey"]>; | |
| type ReactQueryCacheOptions<TQFnData> = { | |
| noRenderOnWrite?: boolean, |
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 axios, { AxiosError, AxiosHeaders } from "axios"; | |
| import AxiosMockAdapter from "axios-mock-adapter"; | |
| import type { AxiosResponse, AxiosRequestConfig } from "axios"; | |
| export type { AxiosError }; | |
| export interface OptionsArgs<BodyType, ParamType = unknown> { | |
| body?: BodyType; | |
| headers?: { [key: string]: string }; |
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 React, { useRef, useState, useEffect, useCallback, Children, isValidElement, cloneElement } from "react"; | |
| import Router from "next/router"; | |
| import useIsFirstRender from "beautiful-react-hooks/useIsFirstRender"; | |
| export type FormStepComponentProps = { | |
| currentStep: string | number, | |
| stepsTotal: number, | |
| /* @ts-ignore */ | |
| onStepChange: (data: Record<string, any>, disableFormSubmission?: boolean, shouldNavigate?: boolean) => Promise<boolean>, |
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 Yup from "yup"; | |
| import type { InferType } from "yup"; | |
| const UserSchema = Yup.object({ | |
| name: Yup.string().required(), | |
| email: Yup.string().email().required(), | |
| fullname: Yup.string().required(), | |
| title: Yup.string().required(), | |
| gender: Yup.string().required().default("male"), | |
| rating: Yup.number().min(1).max(10).required(), |
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 React, { useContext, useMemo, useRef, useEffect } from "react"; | |
| import type { ComponentProps } from "react"; | |
| import type { UseQueryResult } from "react-query"; | |
| type ReactQueryFetchHook<F extends Array<unknown>, Q = any, E = unknown, P = any> = (...hookArguments: [...F, P?]) => UseQueryResult<Q, E> | |
| const QueryHooksMapContext = React.createContext<Record<(string & {}), ReactQueryFetchHook<unknown[]>>>({}); | |
| type QueryHooksProviderProps = ComponentProps<typeof QueryHooksMapContext.Provider> |
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
| /* | |
| * object.watch polyfill | |
| * | |
| * 2012-04-03 | |
| * | |
| * By Eli Grey, http://eligrey.com | |
| * Public Domain. | |
| * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. | |
| */ |
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
| /* @HINT: NPM package for rendering colored text on the command-line (or standard output) */ | |
| const chalk = require('chalk'); | |
| /* @HINT: This uses the `chalk` NPM package to setup colors for failed test assertions as well as passed test assertions */ | |
| const failStatus = chalk.red; | |
| const passStatus = chalk.green; | |
| /* @HINT: A helper function using the status of an assertion to color text sent to the command-line (or standard output) */ | |
| const standardOutputPrettify = (isOk, statusText, prefix = "") => { | |
| return isOk |
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 fileInput = window.document.getElementById('file_input'); | |
| const fileUploadChunkSize = 10 * Math.pow(1024, 2) // 10 by 1MB = 10MB | |
| fileInput.adddEvenListener('change', (event) => { | |
| const [ file ] = event.target.files; | |
| const reader = file.stream().getReader(); | |
| let uploadedBytes = 0; | |
| console.info('Upload Start >'); | |