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
interface IMealCategory { | |
id: number | |
key: 'desert' | 'slow-cook' | 'breakfast' | 'protein' | |
} | |
const getMealCategoryBy = <T extends IMealCategory, K extends keyof IMealCategory>(mealCategories: T[], by: K) => { | |
return (value: T[K]) => { | |
return mealCategories.find((mealCategory) => { | |
return mealCategory[by] === value | |
}) |
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 * as DialogPrimitive from '@radix-ui/react-dialog' | |
import CloseIcon from 'components/icons/CloseIcon' | |
import React from 'react' | |
const classes = { | |
overlay: /* tw: */ `fixed inset-0 bg-black/30 rdx-state-open:animate-fade-in rdx-state-closed:animate-fade-out`, | |
content: /* tw: */ `fixed left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 w-[calc(100%-40px)] h-[calc(100%-40px)] md:h-auto max-w-[900px] overflow-hidden rounded-md drop-shadow-card bg-white outline-none rdx-state-open:animate-fade-in rdx-state-closed:animate-fade-out` | |
} | |
type DialogProps = { |
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 { EExperimentVersion } from '@/types' | |
import ProductCardA, { type IProductCardAProps } from './ProductCardA' | |
import ProductCardC, { type IProductCardCProps } from './ProductCardC' | |
type PropsVariantA = { | |
variant?: Extract<keyof typeof EExperimentVersion, 'a'> | |
} & IProductCardAProps | |
type PropsVariantC = { |
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, { ReactNode } from 'react' | |
type CardProps = { | |
children: React.ReactNode | |
} | |
const Slots = { | |
image: null, | |
title: null, | |
content: 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 cn from 'classnames' | |
import useEmblaCarousel, { UseEmblaCarouselType } from 'embla-carousel-react' | |
import React, { useCallback, useContext, useEffect, useState } from 'react' | |
import { NextButton, PrevButton } from './CarouselButtons' | |
const Context = React.createContext<{ | |
emblaRef: UseEmblaCarouselType[0] | |
thumbRef: UseEmblaCarouselType[0] |
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
/** | |
* @deprecated Use the new {@see [Tooltip](../common/Tooltip/Tooltip.tsx)} component instead. | |
*/ |
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
# .vscode/launch.json | |
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "node", | |
"request": "attach", | |
"name": "Launch Program", | |
"skipFiles": ["<node_internals>/**"], |
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
const request = require("request"); | |
const baseUrl = "https://jsonmock.hackerrank.com/api/football_matches"; | |
async function myReq(url) { | |
return new Promise((resolve) => { | |
request.get(url.toString(), (err, response, body) => { | |
const data = JSON.parse(body); | |
resolve(data); | |
}); |
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 * as React from "react"; | |
import useSWR, { SWRConfig } from "swr"; | |
import { ErrorBoundary } from "react-error-boundary"; | |
import axios from "axios"; | |
// grab it with Swagger instead of manually write | |
interface PokemonDTO { | |
abilities: {}[]; | |
base_experience: number; | |
forms: {}[]; |
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
interface Pokemon { | |
id: number; | |
name: string; | |
height: number; | |
types: { id: number; name: string }[]; | |
} | |
type GetPokemonSuccessResult = { isOk: true; data: Pokemon; error: null }; | |
type GetPokemonErrorResult = { isOk: false; data: null; error: string }; | |
type GetPokemonResult = GetPokemonSuccessResult | GetPokemonErrorResult; |
NewerOlder