@@ -7,13 +7,14 @@ import { useTranslation } from "react-i18next";
77import i18n from '../resourceBundles/i18n' ;
88import { StorageService } from "@formsflow/service" ;
99import { LANGUAGE , MULTITENANCY_ENABLED , USER_LANGUAGE_LIST } from '../constants/constants' ;
10- import version from "../../package.json" ;
1110
1211export const ProfileSettingsModal = ( { show, onClose, tenant, publish } ) => {
1312 const [ selectLanguages , setSelectLanguages ] = useState ( [ ] ) ;
1413 const prevSelectedLang = localStorage . getItem ( 'i18nextLng' ) ;
1514 const [ selectedLang , setSelectedLang ] = useState ( prevSelectedLang || LANGUAGE ) ;
15+ const [ daysDifference , setDaysDifference ] = useState ( null ) ;
1616 const { t } = useTranslation ( ) ;
17+
1718 useEffect ( ( ) => {
1819
1920 fetchSelectLanguages ( ( languages ) => {
@@ -24,8 +25,31 @@ export const ProfileSettingsModal = ({ show, onClose, tenant, publish }) => {
2425 setSelectLanguages ( supportedLanguages . length > 0 ? supportedLanguages : languages ) ;
2526 } ) ;
2627
28+ // Calculate remaining days from expiry_dt
29+ try {
30+ const tenantDataStr = StorageService . get ( "TENANT_DATA" ) ;
31+ const expiry_dt = tenantDataStr
32+ ? JSON . parse ( tenantDataStr ) ?. expiry_dt
33+ : tenant ?. tenantData ?. expiry_dt ;
34+
35+ if ( expiry_dt ) {
36+ const expiry = new Date ( expiry_dt ) ;
37+ const currentDate = new Date ( ) ;
38+ currentDate . setHours ( 0 , 0 , 0 , 0 ) ;
39+ expiry . setHours ( 0 , 0 , 0 , 0 ) ;
40+ const timeDifference = expiry . getTime ( ) - currentDate . getTime ( ) ;
41+ const days = Math . floor ( timeDifference / ( 1000 * 60 * 60 * 24 ) ) ;
42+ setDaysDifference ( days ) ;
43+ } else {
44+ setDaysDifference ( null ) ;
45+ }
46+ } catch ( error ) {
47+ console . error ( "Error calculating days difference:" , error ) ;
48+ setDaysDifference ( null ) ;
49+ }
50+
2751 } , [ tenant ] ) ;
28-
52+
2953
3054 const handleLanguageChange = ( newLang ) => {
3155 setSelectedLang ( newLang ) ;
@@ -49,6 +73,9 @@ export const ProfileSettingsModal = ({ show, onClose, tenant, publish }) => {
4973
5074 const selectedLangLabel = selectLanguages . find ( lang => lang . name === selectedLang ) ?. value || selectedLang ;
5175
76+ // Get tenantId from tenant prop or StorageService
77+ const tenantId = tenant ?. tenantId || StorageService . get ( "tenantKey" ) ;
78+
5279 return (
5380 < Modal
5481 show = { show }
@@ -82,8 +109,15 @@ export const ProfileSettingsModal = ({ show, onClose, tenant, publish }) => {
82109 className = "mb-3 w-100"
83110 onChange = { handleLanguageChange }
84111 />
85- < CustomInfo className = "note" heading = "Note"
86- content = { `You are running version ${ version . version } of Formsflow` } />
112+ { tenantId && daysDifference !== null ? (
113+ < CustomInfo
114+ className = "note"
115+ heading = "Note"
116+ content = {
117+ `You are currently using a test instance. The trial period ends in ${ daysDifference } days.`
118+ }
119+ />
120+ ) : null }
87121 </ Modal . Body >
88122
89123 < Modal . Footer >
@@ -113,7 +147,9 @@ ProfileSettingsModal.propTypes = {
113147 show : PropTypes . bool . isRequired ,
114148 onClose : PropTypes . func . isRequired ,
115149 tenant : PropTypes . shape ( {
150+ tenantId : PropTypes . string ,
116151 tenantData : PropTypes . shape ( {
152+ expiry_dt : PropTypes . string ,
117153 details : PropTypes . shape ( {
118154 locale : PropTypes . string ,
119155 langList : PropTypes . oneOfType ( [
0 commit comments