-
-
Save Daltonic/3d435edb31132fce74070ab77e7cf341 to your computer and use it in GitHub Desktop.
DappBnb Project the store file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createGlobalState } from "react-hooks-global-state"; | |
const { setGlobalState, useGlobalState, getGlobalState } = createGlobalState({ | |
appartments: [], | |
appartment: null, | |
reviews: [], | |
connectedAccount: "", | |
authModal: "scale-0", | |
reviewModal: "scale-0", | |
securityFee: null, | |
bookings: [], | |
booking: null, | |
booked: false, | |
status: null, | |
timestamps: [], | |
currentUser: null, | |
recentConversations: [], | |
messages: [] | |
}); | |
const truncate = (text, startChars, endChars, maxLength) => { | |
if (text.length > maxLength) { | |
let start = text.substring(0, startChars); | |
let end = text.substring(text.length - endChars, text.length); | |
while (start.length + end.length < maxLength) { | |
start = start + "."; | |
} | |
return start + end; | |
} | |
return text; | |
}; | |
export { setGlobalState, useGlobalState, getGlobalState, truncate }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment