From 4bb45bfde1fda3ce44b3afd3e311c092ee8c28f5 Mon Sep 17 00:00:00 2001
From: Harry Chung <144231383+chungchihhan@users.noreply.github.com>
Date: Sat, 10 Aug 2024 02:50:39 +0800
Subject: [PATCH] v0.6.1
# Release Notes - TPET v0.6.1
## New Features
- User can hover to see the tips of each input
## Fix
- User can unselect the files
---
src/app/ui/attach-dropdown.tsx | 19 ++++++++-
src/app/ui/help-tip.tsx | 26 ++++++++++++
src/app/ui/select-dropdown.tsx | 25 ++++++++++--
src/app/ui/send-email-form.tsx | 72 ++++++++++++++++++++++++++--------
4 files changed, 121 insertions(+), 21 deletions(-)
create mode 100644 src/app/ui/help-tip.tsx
diff --git a/src/app/ui/attach-dropdown.tsx b/src/app/ui/attach-dropdown.tsx
index e4bb239..8087f31 100644
--- a/src/app/ui/attach-dropdown.tsx
+++ b/src/app/ui/attach-dropdown.tsx
@@ -105,7 +105,13 @@ export default function AttachDropdown({ onSelect }: AttachDropdownProps) {
setIsOpen(!isOpen);
};
- const handleSelect = (file: fileDataType) => {
+ const handleSelect = (file: fileDataType | null) => {
+ if (!file) {
+ setSelectedFiles([]);
+ onSelect([]);
+ setIsOpen(false);
+ return;
+ }
const alreadySelected = selectedFiles.some(
(selectedFile) => selectedFile.file_id === file.file_id
);
@@ -215,6 +221,17 @@ export default function AttachDropdown({ onSelect }: AttachDropdownProps) {
+ handleSelect(null)}
+ >
+
+ No Selection
+ |
+
{filteredOptions.map((option) => (
setIsVisible(true)}
+ onMouseLeave={() => setIsVisible(false)}
+ >
+ {children}
+ {isVisible && (
+
+ )}
+
+ );
+}
diff --git a/src/app/ui/select-dropdown.tsx b/src/app/ui/select-dropdown.tsx
index a1c3a8d..293b777 100644
--- a/src/app/ui/select-dropdown.tsx
+++ b/src/app/ui/select-dropdown.tsx
@@ -120,12 +120,18 @@ export default function SelectDropdown({
};
const handleSelect = (
- file_id: string,
- file_url: string,
- file_name: string
+ file_id: string | null,
+ file_url: string | null,
+ file_name: string | null
) => {
+ if (!file_id || !file_url || !file_name) {
+ onSelect("", "");
+ setSelectedFileName(`Select a ${fileExtension} file`);
+ setIsOpen(false);
+ return;
+ }
onSelect(file_id, file_url);
- console.log("Selected file:", file_id);
+ // console.log("Selected file:", file_id);
setSelectedFileName(file_name);
setIsOpen(false);
};
@@ -217,6 +223,17 @@ export default function SelectDropdown({
+ handleSelect(null, null, null)}
+ >
+
+ No Selection
+ |
+
{filteredOptions.map((option) => (
(null);
const [isSubmitting, setIsSubmitting] = useState(false);
- const [selectedHtmlFile, setSelectedHtmlFile] = useState("");
- const [selectedXlsxFile, setSelectedXlsxFile] = useState("");
- const [htmlPreviewLink, setHtmlPreviewLink] = useState("");
- const [xlsxPreviewLink, setXlsxPreviewLink] = useState("");
+ const [selectedHtmlFile, setSelectedHtmlFile] = useState("");
+ const [selectedXlsxFile, setSelectedXlsxFile] = useState("");
+ const [htmlPreviewLink, setHtmlPreviewLink] = useState("");
+ const [xlsxPreviewLink, setXlsxPreviewLink] = useState("");
const [errors, setErrors] = useState<{ [key: string]: string }>({});
const [showHtmlUpload, setShowHtmlUpload] = useState(false);
const [showXlsxUpload, setShowXlsxUpload] = useState(false);
@@ -105,7 +106,10 @@ export default function SendEmailForm() {
setIsSubmitting(false);
};
- const handleHtmlSelect = (file_id: string, file_url: string) => {
+ const handleHtmlSelect = (
+ file_id: string | null,
+ file_url: string | null
+ ) => {
setSelectedHtmlFile(file_id);
setHtmlPreviewLink(file_url);
};
@@ -188,8 +192,11 @@ export default function SendEmailForm() {
Required
-