Merge pull request #367 from chrishollandaise/fix/limit-inputs-accept-values

fix: file inputs limit to their respective file formats
This commit is contained in:
Badr B. 2024-10-27 20:29:08 +01:00 committed by GitHub
commit 94c2ed50ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 55 additions and 6 deletions

View file

@ -6,7 +6,7 @@ import {
uploadOrganizationLogo,
uploadOrganizationThumbnail,
} from '@services/settings/org'
import { UploadCloud, Info, Check, FileWarning } from 'lucide-react'
import { UploadCloud, Info } from 'lucide-react'
import { revalidateTags } from '@services/utils/ts/requests'
import { useRouter } from 'next/navigation'
import { useOrg } from '@components/Contexts/OrgContext'
@ -14,6 +14,9 @@ import { useLHSession } from '@components/Contexts/LHSessionContext'
import { getOrgLogoMediaDirectory, getOrgThumbnailMediaDirectory } from '@services/media/media'
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import { Toaster, toast } from 'react-hot-toast';
import { constructAcceptValue } from '@/lib/constants';
const SUPPORTED_FILES = constructAcceptValue(['png', 'jpg'])
interface OrganizationValues {
name: string
@ -174,6 +177,7 @@ function OrgEditGeneral() {
<input
type="file"
id="fileInput"
accept={SUPPORTED_FILES}
style={{ display: 'none' }}
onChange={handleFileChange}
/>
@ -205,6 +209,7 @@ function OrgEditGeneral() {
<div className="flex justify-center items-center">
<input
type="file"
accept={SUPPORTED_FILES}
id="thumbnailInput"
style={{ display: 'none' }}
onChange={handleThumbnailChange}

View file

@ -12,6 +12,9 @@ import {
} from 'lucide-react'
import UserAvatar from '@components/Objects/UserAvatar'
import { updateUserAvatar } from '@services/users/users'
import { constructAcceptValue } from '@/lib/constants';
const SUPPORTED_FILES = constructAcceptValue(['image'])
function UserEditGeneral() {
const session = useLHSession() as any;
@ -125,6 +128,7 @@ function UserEditGeneral() {
<input
type="file"
id="fileInput"
accept={SUPPORTED_FILES}
className="hidden"
onChange={handleFileChange}
/>