Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { useDisclosure } from "@mantine/hooks";
import { IconTrash, IconUpload, IconUser } from "@tabler/icons-react";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useEffect, useState } from "react";
import { useEffect, useRef, useState } from "react";
import { useCurrentUser } from "@/components/auth/hooks";
import { ConfirmModal } from "@/components/common/ConfirmModal";
import { ImageCropModal } from "@/components/common/ImageCropModal";
Expand All @@ -35,6 +35,7 @@ export const AccountSettingsCard = () => {

const avatarFileId = user?.avatar as string | null;

const resetFileInputRef = useRef<() => void>(null);
const [cropSrc, setCropSrc] = useState<string | null>(null);
const [cropOpened, { open: openCrop, close: closeCrop }] =
useDisclosure(false);
Expand Down Expand Up @@ -102,6 +103,7 @@ export const AccountSettingsCard = () => {
});

const handleFileSelect = (file: File | null) => {
resetFileInputRef.current?.();
if (!file) return;
const reader = new FileReader();
reader.onload = () => {
Expand Down Expand Up @@ -133,6 +135,7 @@ export const AccountSettingsCard = () => {
<Stack gap={4}>
<Group gap="xs">
<FileButton
resetRef={resetFileInputRef}
onChange={handleFileSelect}
accept="image/png,image/jpeg,image/webp"
>
Expand Down
5 changes: 4 additions & 1 deletion echo/frontend/src/components/settings/WhitelabelLogoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { useDisclosure } from "@mantine/hooks";
import { IconPhoto, IconTrash, IconUpload } from "@tabler/icons-react";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useState } from "react";
import { useRef, useState } from "react";
import { useCurrentUser } from "@/components/auth/hooks";
import { ConfirmModal } from "@/components/common/ConfirmModal";
import { ImageCropModal } from "@/components/common/ImageCropModal";
Expand All @@ -29,6 +29,7 @@ export const WhitelabelLogoCard = () => {
? `${DIRECTUS_PUBLIC_URL}/assets/${logoFileId}`
: null;

const resetFileInputRef = useRef<() => void>(null);
const [cropSrc, setCropSrc] = useState<string | null>(null);
const [cropOpened, { open: openCrop, close: closeCrop }] =
useDisclosure(false);
Expand Down Expand Up @@ -91,6 +92,7 @@ export const WhitelabelLogoCard = () => {
});

const handleFileSelect = (file: File | null) => {
resetFileInputRef.current?.();
if (!file) return;
const reader = new FileReader();
reader.onload = () => {
Expand Down Expand Up @@ -155,6 +157,7 @@ export const WhitelabelLogoCard = () => {
)}

<FileButton
resetRef={resetFileInputRef}
onChange={handleFileSelect}
accept="image/png,image/jpeg,image/svg+xml,image/webp"
>
Expand Down
Loading