Files
pingvin-share/frontend/src/pages/upload/[reverseShareToken].tsx
Elias Schneider 4a5fb549c6 feat: reverse shares (#86)
* add first concept

* add reverse share funcionality to frontend

* allow creator to limit share expiration

* moved reverse share in seperate module

* add table to manage reverse shares

* delete complete share if reverse share was deleted

* optimize function names

* add db migration

* enable reverse share email notifications

* fix config variable descriptions

* fix migration for new installations
2023-01-26 13:44:04 +01:00

44 lines
1.3 KiB
TypeScript

import { LoadingOverlay } from "@mantine/core";
import { useModals } from "@mantine/modals";
import { GetServerSidePropsContext } from "next";
import { useEffect, useState } from "react";
import Upload from ".";
import showErrorModal from "../../components/share/showErrorModal";
import shareService from "../../services/share.service";
export function getServerSideProps(context: GetServerSidePropsContext) {
return {
props: { reverseShareToken: context.params!.reverseShareToken },
};
}
const Share = ({ reverseShareToken }: { reverseShareToken: string }) => {
const modals = useModals();
const [isLoading, setIsLoading] = useState(true);
const [maxShareSize, setMaxShareSize] = useState(0);
useEffect(() => {
shareService
.setReverseShare(reverseShareToken)
.then((reverseShareTokenData) => {
setMaxShareSize(parseInt(reverseShareTokenData.maxShareSize));
setIsLoading(false);
})
.catch(() => {
showErrorModal(
modals,
"Invalid Link",
"This link is invalid. Please check your link."
);
setIsLoading(false);
});
}, []);
if (isLoading) return <LoadingOverlay visible />;
return <Upload isReverseShare maxShareSize={maxShareSize} />;
};
export default Share;