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
// Merges additional properties into an object, ensuring type consistency. | |
export const mergeProperties = <T, U>( | |
originalObject: T, | |
additionalProps: U, | |
): T & U => { | |
return { ...originalObject, ...additionalProps }; | |
}; |
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 { type ZodError } from 'zod'; | |
export const stringifyZodError = (error: ZodError): string => { | |
return error.issues | |
.map((issue) => { | |
const path = issue.path.join('.'); | |
const message = issue.message; | |
return `Currently facing issue with the field "${path}". ${message}`; | |
}) | |
.join('\n'); |
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 { faker } from "@faker-js/faker"; | |
import { promises as fs } from "fs"; | |
const users = Array.from({ length: 1000 }, (_, i) => ({ | |
name: faker.name.fullName(), | |
tel: faker.phone.number("###-###-####"), | |
img: faker.image.avatar(), | |
})).map((user) => { | |
const { name } = user; | |
const [firstName, lastName] = name.split(" "); |
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
function formatMinutesSeconds(time) { | |
return `${Math.floor(time / 60)}:${(time % 60).toString().padStart(2, "0")}`; | |
} |
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 WINNING_INDICES = [ | |
[0, 1, 2], | |
[0, 3, 6], | |
[0, 4, 8], | |
[1, 4, 7], | |
[2, 5, 8], | |
[2, 4, 6], | |
[3, 4, 5], | |
[6, 7, 8], | |
]; |
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 getLenOfLongestSubstringWithoutRepeatingChars = ( | |
str: string, | |
): number => { | |
// If the string is empty, return 0 | |
if (str.length === 0) { | |
return 0; | |
} | |
// Start building a substring from the first character until we duplicate a character | |
return str |
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
<main className="flex h-screen items-center justify-center"> | |
<div className="border-gray mr-3 h-48 w-48 animate-spin rounded-full border-4 border-t-4 border-t-blue-300" /> | |
</main> |
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 WINNING_INDICES = [ | |
[0, 1, 2], | |
[0, 3, 6], | |
[0, 4, 8], | |
[1, 4, 7], | |
[2, 5, 8], | |
[2, 4, 6], | |
[3, 4, 5], | |
[6, 7, 8], | |
]; |
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 { render, screen, within } from "@testing-library/react"; | |
import userEvent from "@testing-library/user-event"; | |
import App from "./App"; | |
import renderer from "react-test-renderer"; | |
const setup = () => { | |
render(<App />); | |
return screen.getByRole("table"); | |
}; |
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 PropTypes from "prop-types"; | |
import React from "react"; | |
export const UserContext = React.createContext(); | |
export default function UserContextProvider({ children }) { | |
const [currentUser, setCurrentUser] = React.useState( | |
JSON.parse(localStorage.getItem("user")) | |
); |