mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-02 19:26:50 -05:00
* Variables rearranged * Make patron.json empty again * Fix styles.css * Working prototype * Table legible color * UI furthened * Set opaque theme color with custom colors * Control Color Selector with buttons * Show info if can't edit colors * borzoic can also edit colors * Add migration * Can send colors to backend * Edit existing colors * Use new layering strat for footer * useMutation custom hook * Footer adjusted text color * Reset style after profile visit * Set squid color after page load * Mutate user after color selection
38 lines
819 B
TypeScript
38 lines
819 B
TypeScript
import { createStandaloneToast } from "@chakra-ui/react";
|
|
import { t } from "@lingui/macro";
|
|
|
|
export async function sendData(method = "POST", url = "", data = {}) {
|
|
const response = await fetch(url, {
|
|
method,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify(data),
|
|
});
|
|
|
|
if (response.status < 200 || response.status > 299) {
|
|
const toast = createStandaloneToast();
|
|
|
|
let description = t`An error occurred`;
|
|
try {
|
|
const error = await response.json();
|
|
if (error.message) {
|
|
description = error.message;
|
|
console.error(error.message);
|
|
}
|
|
} catch {}
|
|
|
|
toast({
|
|
duration: null,
|
|
isClosable: true,
|
|
position: "top-right",
|
|
status: "error",
|
|
description,
|
|
});
|
|
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|