({
reload,
api,
currentCommunity,
setCurrentCommunity,
setCommunities,
InternalLink,
}: {
reload(): void;
currentCommunity: SerializedAccount;
api: ApiClient;
setCurrentCommunity: React.Dispatch<React.SetStateAction<SerializedAccount>>;
setCommunities: React.Dispatch<React.SetStateAction<SerializedAccount[]>>;
InternalLink: any;
})
| 21 | import Banner from './Banner'; |
| 22 | |
| 23 | export default function BrandingView({ |
| 24 | reload, |
| 25 | api, |
| 26 | currentCommunity, |
| 27 | setCurrentCommunity, |
| 28 | setCommunities, |
| 29 | InternalLink, |
| 30 | }: { |
| 31 | reload(): void; |
| 32 | currentCommunity: SerializedAccount; |
| 33 | api: ApiClient; |
| 34 | setCurrentCommunity: React.Dispatch<React.SetStateAction<SerializedAccount>>; |
| 35 | setCommunities: React.Dispatch<React.SetStateAction<SerializedAccount[]>>; |
| 36 | InternalLink: any; |
| 37 | }) { |
| 38 | const [records, setRecords] = useState<DNSRecord[]>(); |
| 39 | const debouncedUpdateAccount = useCallback(debounce(api.updateAccount), []); |
| 40 | |
| 41 | useEffect(() => { |
| 42 | let mounted = true; |
| 43 | if ( |
| 44 | currentCommunity && |
| 45 | currentCommunity.premium && |
| 46 | currentCommunity.redirectDomain |
| 47 | ) { |
| 48 | dnsSettings(mounted); |
| 49 | } |
| 50 | return () => { |
| 51 | mounted = false; |
| 52 | }; |
| 53 | }, []); |
| 54 | |
| 55 | function dnsSettings(mounted: boolean) { |
| 56 | api |
| 57 | .getDnsSettings(currentCommunity.id) |
| 58 | .then((response) => { |
| 59 | if (mounted && response && response.records) { |
| 60 | setRecords(response.records); |
| 61 | } |
| 62 | }) |
| 63 | .catch((_) => {}); |
| 64 | } |
| 65 | |
| 66 | const updateAccount = async (options?: any) => { |
| 67 | const form = document.getElementById('branding-form') as HTMLFormElement; |
| 68 | if (!form) { |
| 69 | return; |
| 70 | } |
| 71 | const googleAnalyticsId = form.googleAnalyticsId?.value; |
| 72 | const brandColor = form.brandColor.value; |
| 73 | const description = form.description.value; |
| 74 | const params = { |
| 75 | description, |
| 76 | brandColor, |
| 77 | googleAnalyticsId, |
| 78 | ...options, |
| 79 | }; |
| 80 | return debouncedUpdateAccount({ |
nothing calls this directly
no test coverage detected