itizawa 5 anni fa
parent
commit
48f935b2bb
1 ha cambiato i file con 14 aggiunte e 8 eliminazioni
  1. 14 8
      src/client/js/components/Page/ShareLinkAlert.jsx

+ 14 - 8
src/client/js/components/Page/ShareLinkAlert.jsx

@@ -10,17 +10,23 @@ const ShareLinkAlert = (props) => {
   const createdAt = shareContent.getAttribute('data-share-link-created-at');
   const createdAt = shareContent.getAttribute('data-share-link-created-at');
   const wholeTime = new Date(expiredAt).getTime() - new Date(createdAt).getTime();
   const wholeTime = new Date(expiredAt).getTime() - new Date(createdAt).getTime();
   const remainingTime = new Date(expiredAt).getTime() - new Date().getTime();
   const remainingTime = new Date(expiredAt).getTime() - new Date().getTime();
-  const percentage = remainingTime / wholeTime * 100;
+  const ratio = remainingTime / wholeTime;
 
 
   function specifyColor() {
   function specifyColor() {
-    if (percentage >= 75) {
-      return 'success';
-    } if (percentage >= 50) {
-      return 'info';
-    } if (percentage >= 25) {
-      return 'warning';
+    let color;
+    if (ratio >= 0.75) {
+      color = 'success';
     }
     }
-    return 'danger';
+    else if (ratio < 0.75 && ratio >= 0.5) {
+      color = 'info';
+    }
+    else if (ratio < 0.5 && ratio >= 0.25) {
+      color = 'warning';
+    }
+    else {
+      color = 'danger';
+    }
+    return color;
   }
   }
 
 
   return (
   return (