瀏覽代碼

set customExpirationDate to today if the input is empty

Yuki Takei 11 月之前
父節點
當前提交
3e0d62e82e
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      apps/app/src/client/components/PageAccessoriesModal/ShareLink/ShareLinkForm.tsx

+ 6 - 0
apps/app/src/client/components/PageAccessoriesModal/ShareLink/ShareLinkForm.tsx

@@ -48,6 +48,12 @@ export const ShareLinkForm: FC<Props> = (props: Props) => {
   }, []);
 
   const handleChangeCustomExpirationDate = useCallback((customExpirationDate: string) => {
+    // set customExpirationDate to today if the input is empty
+    if (customExpirationDate.length === 0) {
+      setCustomExpirationDate(new Date());
+      return;
+    }
+
     const parsedDate = parse(customExpirationDate, 'yyyy-MM-dd', new Date());
     setCustomExpirationDate(parsedDate);
   }, []);