Compare commits
2 Commits
5bad3ee9eb
...
b22c5e7e50
Author | SHA1 | Date | |
---|---|---|---|
b22c5e7e50 | |||
4bb16d287b |
@ -18,15 +18,6 @@ export default function Home(): ReactElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Limit the paste size to 400,000 characters
|
|
||||||
if (value.length > 400_000) {
|
|
||||||
toast({
|
|
||||||
title: "Paste",
|
|
||||||
description: "Pastes can't be longer than 400,000 characters",
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Upload the paste to the server
|
// Upload the paste to the server
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`${process.env.NEXT_PUBLIC_API_ENDPOINT}/upload`,
|
`${process.env.NEXT_PUBLIC_API_ENDPOINT}/upload`,
|
||||||
@ -39,8 +30,17 @@ export default function Home(): ReactElement {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// Redirect to the new paste
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
toast({
|
||||||
|
title: "Paste",
|
||||||
|
description: data.message,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect to the new paste
|
||||||
window.location.href = `/${data.id}`;
|
window.location.href = `/${data.id}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user