From ca29b6a68b29e7629b714c06c91523c0cc6a201e Mon Sep 17 00:00:00 2001 From: wahyuun Date: Wed, 20 Mar 2024 17:25:07 +0700 Subject: [PATCH] update profile for super admin --- .../Settings/components/Plan/Container1.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/views/SimproV2/Settings/components/Plan/Container1.js b/src/views/SimproV2/Settings/components/Plan/Container1.js index 85d06c3..dfc9ba9 100644 --- a/src/views/SimproV2/Settings/components/Plan/Container1.js +++ b/src/views/SimproV2/Settings/components/Plan/Container1.js @@ -8,7 +8,6 @@ import moment from "moment"; const Container1 = () => { const token = localStorage.getItem("token") const user_id = localStorage.getItem("user_id") - let company_id = '', configApp = ''; const role = window.localStorage.getItem('role_name'); const [totalPage, setTotalPage] = useState(0); const [transaction, setTransaction] = useState([]); @@ -17,9 +16,9 @@ const Container1 = () => { const givenDate = new Date(transaction.exp_ospro); const createdDate = new Date(transaction.created_at) const differenceInMillis = givenDate.getTime() - currentDate.getTime(); + const differenceInDays = role !== 'Super Admin' ? Math.floor(differenceInMillis / (1000 * 60 * 60 * 24)) : 30; - const differenceInDays = Math.floor(differenceInMillis / (1000 * 60 * 60 * 24)); - + let company_id = '', configApp = ''; if(role !== 'Super Admin') { company_id = localStorage.getItem("company_id"); configApp = JSON.parse(window.localStorage.getItem('configApp')); @@ -33,8 +32,10 @@ const Container1 = () => { useEffect(()=>{ getDataProyek(); - getDataTransaction(); getLimitInformation(); + if(role !== 'Super Admin') { + getDataTransaction(); + } },[]) const getDataProyek = async () => { @@ -88,13 +89,13 @@ const Container1 = () => { } const getLimitInformation = async () => { - const url = STORAGE_LIMIT_INFORMATION(configApp.company_name); + const url = STORAGE_LIMIT_INFORMATION(role !== 'Super Admin' ? configApp.company_name : 'Super Admin'); const result = await axios .get(url, config) .then((res) => res) .catch((error) => error.response); if (result.data) { - setLimitInformation(result.data); + setLimitInformation(role !== 'Super Admin' ? parseFloat(result.data) : 0); } else { NotificationManager.error("Gagal Mengambil Data!!", "Failed"); } @@ -169,13 +170,13 @@ const Container1 = () => {
- {Math.abs(differenceInDays)} days remaining until your plan requires update + { role !== 'Super Admin' ? Math.abs(differenceInDays) : 0} days remaining until your plan requires update
Storage
-
{storage} of {transaction.type_paket === 'Basic' ? 500 : 50}MB
+
{storage} of {transaction?.type_paket === 'Basic' ? 500 : 50}MB
@@ -192,7 +193,7 @@ const Container1 = () => {
- {((storage / (transaction.type_paket === 'Basic' ? 500 : 50)) * 100).toFixed(2)}% storage remaining until your plan requires update + {(((storage / (transaction.type_paket === 'Basic' ? 500 : 50)) * 100).toFixed(2))}% has been filled until your plan requires an update