MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / BrandingView

Function BrandingView

apps/web/ui/BrandingView/index.tsx:23–371  ·  view source on GitHub ↗
({
  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;
})

Source from the content-addressed store, hash-verified

21import Banner from './Banner';
22
23export 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({

Callers

nothing calls this directly

Calls 4

debounceFunction · 0.85
dnsSettingsFunction · 0.85
mapMethod · 0.80
updateAccountFunction · 0.70

Tested by

no test coverage detected