mirror of
https://github.com/20kaushik02/spotify-manager-web.git
synced 2026-01-25 08:04:05 +00:00
setting up
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import App from './App';
|
||||
|
||||
test('renders learn react link', () => {
|
||||
render(<App />);
|
||||
const linkElement = screen.getByText(/learn react/i);
|
||||
expect(linkElement).toBeInTheDocument();
|
||||
});
|
||||
0
src/api/README.md
Normal file
0
src/api/README.md
Normal file
26
src/boilerplates/apiResp.js
Normal file
26
src/boilerplates/apiResp.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { useContext } from "react";
|
||||
import { RefreshAuthContext } from "../App";
|
||||
import { showErrorToastNotification, showSuccessToastNotification } from "../components/ToastNotification";
|
||||
import LocalStorage from "../utils/localStorageHelper";
|
||||
|
||||
const refreshAuth = useContext(RefreshAuthContext);
|
||||
|
||||
if (resp === undefined) {
|
||||
showErrorToastNotification(<p>Please try again after sometime</p>);
|
||||
return;
|
||||
} else {
|
||||
if (resp.status === 200) {
|
||||
showSuccessToastNotification(<p>{resp.data.message}</p>);
|
||||
// proceed with data
|
||||
} else if (resp.status >= 400 && resp.status < 500) {
|
||||
if (resp.data.auth === false) {
|
||||
LocalStorage.clear();
|
||||
refreshAuth();
|
||||
}
|
||||
showErrorToastNotification(<p>{resp.data.message}</p>);
|
||||
return;
|
||||
} else if (resp.status >= 500 && resp.status < 600) {
|
||||
showErrorToastNotification(<p>{resp.data.message}</p>);
|
||||
return;
|
||||
}
|
||||
}
|
||||
24
src/boilerplates/media_query.css
Normal file
24
src/boilerplates/media_query.css
Normal file
@@ -0,0 +1,24 @@
|
||||
/* Media Queries */
|
||||
|
||||
/* Above Tablet */
|
||||
@media only screen and (min-width: 1024px) {
|
||||
}
|
||||
|
||||
/* Both Tablet and Mobile */
|
||||
@media only screen and (max-width: 1023px) {
|
||||
}
|
||||
|
||||
/* Tablet only */
|
||||
@media only screen and (min-width: 768px) and (max-width: 1023px) {
|
||||
}
|
||||
|
||||
/* Mobile only */
|
||||
@media only screen and (max-width: 767px) {
|
||||
}
|
||||
|
||||
/* Color theme matching */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
||||
// allows you to do things like:
|
||||
// expect(element).toHaveTextContent(/react/i)
|
||||
// learn more: https://github.com/testing-library/jest-dom
|
||||
import '@testing-library/jest-dom';
|
||||
17
src/utils/ScrollToTop.js
Normal file
17
src/utils/ScrollToTop.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useEffect } from "react";
|
||||
import { useLocation } from "react-router-dom";
|
||||
|
||||
function ScrollToTop() {
|
||||
let { pathname } = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
window.scrollTo(0, 0);
|
||||
}, 100);
|
||||
return () => { };
|
||||
}, [pathname]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export default ScrollToTop;
|
||||
16
src/utils/numFormatter.js
Normal file
16
src/utils/numFormatter.js
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Returns a string with zero padding of the number
|
||||
*
|
||||
* @param {number} num Input number (positive integer only, for now)
|
||||
* @param {number} places Number of zeroes to pad
|
||||
* @param {"before" | "after"} position Position of zeroes
|
||||
* @returns {string} Zero-padded string
|
||||
*/
|
||||
export const zeroPaddedString = (num, places, position) => {
|
||||
if (num < 0) throw new Error("negative number");
|
||||
if (places < 0) throw new Error("invalid number of zeroes");
|
||||
if (position !== "before" && position !== "after") throw new Error("invalid position (before or after only)");
|
||||
|
||||
const zeroes = "0".repeat(places);
|
||||
return position === "before" ? '' + zeroes + num : '' + num + zeroes;
|
||||
}
|
||||
Reference in New Issue
Block a user