Skip to content

Commit

Permalink
Merge branch 'ms2/modeler-share-modal' of github.com:PROCEED-Labs/pro…
Browse files Browse the repository at this point in the history
…ceed into ms2/modeler-share-modal
  • Loading branch information
anishsapkota committed Jan 15, 2024
2 parents 022b1bc + 54215c6 commit d3f18d0
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/management-system-v2/components/modeler-share-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ const ModelerShareModalButton: FC<ShareModalProps> = ({ onExport, onExportMobile
}
};

const shareWrapper = async (fn: (args: any) => Promise<void>, args: any) => {
try {
if (isSharing) return;
setIsSharing(true);
await fn(args);
} catch (error) {
console.error('Sharing failed:', error);
} finally {
setIsSharing(false);
}
};

const handleShareMobile = async (sharedAs: 'public' | 'protected') => {
const { token, processData } = await generateToken({ processId });
await updateProcessGuestAccessRights(processId, { shared: true, sharedAs: sharedAs });
Expand Down Expand Up @@ -99,9 +111,9 @@ const ModelerShareModalButton: FC<ShareModalProps> = ({ onExport, onExportMobile
},
{
optionIcon: <LinkOutlined style={{ fontSize: '24px' }} />,
optionName: 'Share Process Link for Registered Users',
optionTitle: 'Share Process Link for Registered Users',
optionOnClick: () => shareWrapper(handleShareMobile, 'protected'),
optionName: 'Share Process for Registered Users',
optionTitle: 'Share Process for Registered Users',
optionOnClick: () => handleShareMobile('protected'),
},
{
optionIcon: <FilePdfOutlined style={{ fontSize: '24px' }} />,
Expand Down

0 comments on commit d3f18d0

Please sign in to comment.