Просмотр исходного кода

Merge pull request #10132 from weseek/fix/sharelink-calendar-parser

fix: Sharelink expiration date parsing when the date is cleared by the calendar UI
mergify[bot] 9 месяцев назад
Родитель
Сommit
cbb537239b

+ 14 - 3
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) => {
   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());
     const parsedDate = parse(customExpirationDate, 'yyyy-MM-dd', new Date());
     setCustomExpirationDate(parsedDate);
     setCustomExpirationDate(parsedDate);
   }, []);
   }, []);
@@ -199,9 +205,14 @@ export const ShareLinkForm: FC<Props> = (props: Props) => {
             />
             />
           </div>
           </div>
         </div>
         </div>
-        <button type="button" className="btn btn-primary d-block mx-auto px-5" onClick={handleIssueShareLink} data-testid="btn-sharelink-issue">
-          {t('share_links.Issue')}
-        </button>
+
+        <div className="row mt-4">
+          <div className="col">
+            <button type="button" className="btn btn-primary d-block mx-auto px-5" onClick={handleIssueShareLink} data-testid="btn-sharelink-issue">
+              {t('share_links.Issue')}
+            </button>
+          </div>
+        </div>
       </div>
       </div>
     </div>
     </div>
   );
   );