Download src/hooks/useInfluencerAuth.ts from SherlockHolmes786/tradewithlive: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/SherlockHolmes786/tradewithlive/resolve/main/src/hooks/useInfluencerAuth.ts
- Command line
-
hf download hf://SherlockHolmes786/tradewithlive/src/hooks/useInfluencerAuth.ts
-
curl -L -o useInfluencerAuth.ts https://huggingface.co/SherlockHolmes786/tradewithlive/resolve/main/src/hooks/useInfluencerAuth.ts
1.07 kB
| import { useState, useEffect } from 'react'; | |
| const STORAGE_KEY = 'unlocked_influencers'; | |
| export const useInfluencerAuth = () => { | |
| const [unlockedInfluencers, setUnlockedInfluencers] = useState<string[]>([]); | |
| useEffect(() => { | |
| const stored = localStorage.getItem(STORAGE_KEY); | |
| if (stored) { | |
| setUnlockedInfluencers(JSON.parse(stored)); | |
| } | |
| }, []); | |
| const unlockInfluencer = (influencerId: string) => { | |
| const updated = [...unlockedInfluencers, influencerId]; | |
| setUnlockedInfluencers(updated); | |
| localStorage.setItem(STORAGE_KEY, JSON.stringify(updated)); | |
| }; | |
| const lockInfluencer = (influencerId: string) => { | |
| const updated = unlockedInfluencers.filter((id: string) => id !== influencerId); | |
| setUnlockedInfluencers(updated); | |
| localStorage.setItem(STORAGE_KEY, JSON.stringify(updated)); | |
| }; | |
| const isInfluencerUnlocked = (influencerId: string) => { | |
| return unlockedInfluencers.includes(influencerId); | |
| }; | |
| return { | |
| unlockedInfluencers, | |
| unlockInfluencer, | |
| lockInfluencer, | |
| isInfluencerUnlocked | |
| }; | |
| }; | |