MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / DomainsSection

Function DomainsSection

apps/cloud/src/routes/app/org.tsx:215–314  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

213}
214
215function DomainsSection() {
216 const domainsResult = useAtomValue(orgDomainsAtom);
217 const doDeleteDomain = useAtomSet(deleteDomain, { mode: "promiseExit" });
218 const doGetVerificationLink = useAtomSet(getDomainVerificationLink, {
219 mode: "promiseExit",
220 });
221 const { check, isLoading: customerLoading } = useCustomer();
222 const canUseDomains = customerLoading
223 ? false
224 : check({ featureId: "domain-verification" }).allowed;
225
226 const handleDeleteDomain = async (domainId: string, domain: string) => {
227 const exit = await doDeleteDomain({
228 params: { domainId },
229 reactivityKeys: orgDomainWriteKeys,
230 });
231 trackEvent("org_domain_removed", { success: Exit.isSuccess(exit) });
232 toast[Exit.isSuccess(exit) ? "success" : "error"](
233 Exit.isSuccess(exit) ? `Removed ${domain}` : "Failed to remove domain",
234 );
235 };
236
237 const handleAddDomain = async () => {
238 const exit = await doGetVerificationLink({
239 reactivityKeys: orgDomainWriteKeys,
240 });
241 trackEvent("org_domain_added", { success: Exit.isSuccess(exit) });
242 if (Exit.isSuccess(exit)) {
243 window.open(exit.value.link, "_blank");
244 } else {
245 toast.error("Failed to generate verification link");
246 }
247 };
248
249 return (
250 <section className="mb-2">
251 <div className="flex items-center justify-between mb-4">
252 <div>
253 <h2 className="text-sm font-medium text-foreground">Domains</h2>
254 <p className="mt-0.5 text-sm text-muted-foreground">
255 Verify a domain to let anyone with a matching email join automatically.
256 </p>
257 </div>
258 <Button size="sm" className="min-w-32" disabled={!canUseDomains} onClick={handleAddDomain}>
259 Add domain
260 </Button>
261 </div>
262
263 {!canUseDomains && (
264 <div className="mb-3 flex items-center justify-between rounded-lg border border-border px-4 py-3">
265 <p className="text-sm text-muted-foreground">
266 Join by domain is available on the Team plan.
267 </p>
268 <Link to="/{-$orgSlug}/billing/plans">
269 <Button size="sm" variant="outline">
270 Upgrade
271 </Button>
272 </Link>

Callers

nothing calls this directly

Calls 2

handleDeleteDomainFunction · 0.85
checkFunction · 0.50

Tested by

no test coverage detected