Skip to content

Commit

Permalink
feat: add new pro eoa to eoa
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Jun 25, 2024
1 parent de8c313 commit acc6b27
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
2 changes: 1 addition & 1 deletion apps/web/src/components/Pro/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const details = {
'Profile Analytics',
'Publication Drafts',
'Choose your app icon',
'Higher video upload limits',
'Higher video and audio upload limits',
'Pro Badge on your profile',
'Early access to new features',
'Priority support'
Expand Down
57 changes: 35 additions & 22 deletions apps/web/src/hooks/useUploadAttachments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import { useCallback } from 'react';
import { toast } from 'react-hot-toast';
import { usePublicationAttachmentStore } from 'src/store/non-persisted/publication/usePublicationAttachmentStore';
import { usePublicationVideoStore } from 'src/store/non-persisted/publication/usePublicationVideoStore';
import { useProStore } from 'src/store/non-persisted/useProStore';
import { v4 as uuid } from 'uuid';

const useUploadAttachments = () => {
const { isPro } = useProStore();
const { setUploadedPercentage } = usePublicationVideoStore();
const {
addAttachments,
Expand All @@ -17,31 +19,41 @@ const useUploadAttachments = () => {
updateAttachments
} = usePublicationAttachmentStore((state) => state);

const validateFileSize = (file: any) => {
const isImage = file.type.includes('image');
const isVideo = file.type.includes('video');
const isAudio = file.type.includes('audio');

if (isImage && file.size > 50000000) {
toast.error('Image size should be less than 50MB');
return false;
}
const handleUploadAttachments = useCallback(
async (attachments: any): Promise<NewAttachment[]> => {
const validateFileSize = (file: any) => {
const isImage = file.type.includes('image');
const isVideo = file.type.includes('video');
const isAudio = file.type.includes('audio');

const IMAGE_UPLOAD_LIMIT = 5000000;
const VIDEO_UPLOAD_LIMIT = isPro ? 200000000 : 50000000;
const AUDIO_UPLOAD_LIMIT = isPro ? 60000000 : 20000000;

if (isImage && file.size > IMAGE_UPLOAD_LIMIT) {
toast.error(
`Image size should be less than ${IMAGE_UPLOAD_LIMIT / 1000000}MB`
);
return false;
}

if (isVideo && file.size > 500000000) {
toast.error('Video size should be less than 500MB');
return false;
}
if (isVideo && file.size > VIDEO_UPLOAD_LIMIT) {
toast.error(
`Video size should be less than ${VIDEO_UPLOAD_LIMIT / 1000000}MB`
);
return false;
}

if (isAudio && file.size > 200000000) {
toast.error('Audio size should be less than 200MB');
return false;
}
if (isAudio && file.size > AUDIO_UPLOAD_LIMIT) {
toast.error(
`Audio size should be less than ${AUDIO_UPLOAD_LIMIT / 1000000}MB`
);
return false;
}

return true;
};
return true;
};

const handleUploadAttachments = useCallback(
async (attachments: any): Promise<NewAttachment[]> => {
setIsUploading(true);

const files = Array.from(attachments);
Expand Down Expand Up @@ -117,7 +129,8 @@ const useUploadAttachments = () => {
removeAttachments,
updateAttachments,
setIsUploading,
setUploadedPercentage
setUploadedPercentage,
isPro
]
);

Expand Down

1 comment on commit acc6b27

@vercel
Copy link

@vercel vercel bot commented on acc6b27 Jun 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

web – ./apps/web

heyxyz.vercel.app
web-heyxyz.vercel.app
web-git-main-heyxyz.vercel.app
hey.xyz

Please sign in to comment.