Files
webstudio/apps/builder/app/shared/error/toast-error.tsx
Bogdan Chadkin a65ab3379f build: forbid unused parameters (#3732)
Enabled flag in tsconfig to forbid unused parameters.
2024-07-15 21:17:13 +02:00

32 lines
742 B
TypeScript

import { toast } from "@webstudio-is/design-system";
import { useEffect } from "react";
import { $toastErrors } from "../nano-states";
let toastErrorsIndex = 0;
/**
* To show errors exposed from the canvas | builder
*/
export const useToastErrors = () => {
useEffect(() => {
return $toastErrors.subscribe((toastErrors) => {
for (
let errorIndex = toastErrorsIndex;
errorIndex < toastErrors.length;
errorIndex++
) {
toast.error(toastErrors[errorIndex]);
}
toastErrorsIndex = toastErrors.length;
});
}, []);
};
export const toastError = (_error: string) => {
$toastErrors.set([
...$toastErrors.get(),
"Copying has been disabled by the project owner",
]);
};