MCPcopy Create free account
hub / github.com/dailydotdev/apps / FeedbackModal

Function FeedbackModal

packages/shared/src/components/modals/FeedbackModal.tsx:44–367  ·  view source on GitHub ↗
({
  onRequestClose,
  ...props
}: FeedbackModalProps)

Source from the content-addressed store, hash-verified

42];
43
44const FeedbackModal = ({
45 onRequestClose,
46 ...props
47}: FeedbackModalProps): ReactElement => {
48 const { displayToast } = useToastNotification();
49 const { themeMode } = useSettingsContext();
50 const fileInputRef = useRef<HTMLInputElement>(null);
51 const hasSubmitted = useRef(false);
52
53 const [category, setCategory] = useState<FeedbackCategory>(
54 FeedbackCategory.BugReport,
55 );
56 const [description, setDescription] = useState('');
57 const [screenshot, setScreenshot] = useState<File | null>(null);
58 const [screenshotPreview, setScreenshotPreview] = useState<string | null>(
59 null,
60 );
61 const [isCapturing, setIsCapturing] = useState(false);
62
63 // Clean up preview URL when component unmounts or screenshot changes
64 useEffect(() => {
65 return () => {
66 if (screenshotPreview) {
67 revokePreviewUrl(screenshotPreview);
68 }
69 };
70 }, [screenshotPreview]);
71
72 const handleScreenshotChange = useCallback(
73 (file: File | null) => {
74 // Revoke old preview URL
75 if (screenshotPreview) {
76 revokePreviewUrl(screenshotPreview);
77 }
78
79 if (!file) {
80 setScreenshot(null);
81 setScreenshotPreview(null);
82 return;
83 }
84
85 // Validate file type
86 if (!isValidImageType(file)) {
87 displayToast('Invalid image type. Use PNG, JPG, WebP, or GIF.');
88 return;
89 }
90
91 // Validate file size
92 if (!isValidFileSize(file)) {
93 displayToast(
94 `File too large. Maximum size is ${
95 MAX_SCREENSHOT_SIZE / 1024 / 1024
96 }MB.`,
97 );
98 return;
99 }
100
101 setScreenshot(file);

Callers

nothing calls this directly

Calls 11

useToastNotificationFunction · 0.90
useSettingsContextFunction · 0.90
revokePreviewUrlFunction · 0.90
isValidImageTypeFunction · 0.90
isValidFileSizeFunction · 0.90
createPreviewUrlFunction · 0.90
captureScreenshotFunction · 0.90
submitFeedbackFunction · 0.90
uploadContentImageFunction · 0.90
displayToastFunction · 0.85
onRequestCloseFunction · 0.50

Tested by

no test coverage detected