sourcebot/packages/web/src/app/[domain]/components/resubmitAccountRequestButton.tsx

64 lines
2.1 KiB
TypeScript
Raw Normal View History

V4 (#311) Sourcebot V4 introduces authentication, performance improvements and code navigation. Checkout the [migration guide](https://docs.sourcebot.dev/self-hosting/upgrade/v3-to-v4-guide) for information on upgrading your instance to v4. ### Changed - [**Breaking Change**] Authentication is now required by default. Notes: - When setting up your instance, email / password login will be the default authentication provider. - The first user that logs into the instance is given the `owner` role. ([docs](https://docs.sourcebot.dev/docs/more/roles-and-permissions)). - Subsequent users can request to join the instance. The `owner` can approve / deny requests to join the instance via `Settings` > `Members` > `Pending Requests`. - If a user is approved to join the instance, they are given the `member` role. - Additional login providers, including email links and SSO, can be configured with additional environment variables. ([docs](https://docs.sourcebot.dev/self-hosting/configuration/authentication)). - Clicking on a search result now takes you to the `/browse` view. Files can still be previewed by clicking the "Preview" button or holding `Cmd` / `Ctrl` when clicking on a search result. [#315](https://github.com/sourcebot-dev/sourcebot/pull/315) ### Added - [Sourcebot EE] Added search-based code navigation, allowing you to jump between symbol definition and references when viewing source files. [Read the documentation](https://docs.sourcebot.dev/docs/search/code-navigation). [#315](https://github.com/sourcebot-dev/sourcebot/pull/315) - Added collapsible filter panel. [#315](https://github.com/sourcebot-dev/sourcebot/pull/315) ### Fixed - Improved scroll performance for large numbers of search results. [#315](https://github.com/sourcebot-dev/sourcebot/pull/315)
2025-05-28 23:08:42 +00:00
"use client"
import { Button } from "@/components/ui/button"
import { Clock } from "lucide-react"
import { useState } from "react"
import { useToast } from "@/components/hooks/use-toast"
import { createAccountRequest } from "@/actions"
import { isServiceError } from "@/lib/utils"
interface ResubmitButtonProps {
domain: string
userId: string
}
export function ResubmitAccountRequestButton({ domain, userId }: ResubmitButtonProps) {
const { toast } = useToast()
const [isSubmitting, setIsSubmitting] = useState(false)
const handleSubmit = async () => {
setIsSubmitting(true)
const result = await createAccountRequest(userId, domain)
if (!isServiceError(result)) {
if (result.existingRequest) {
toast({
title: "Request Already Submitted",
description: "Your request to join the organization has already been submitted. Please wait for it to be approved.",
variant: "default",
})
} else {
toast({
title: "Request Resubmitted",
description: "Your request to join the organization has been resubmitted.",
variant: "default",
})
}
} else {
toast({
title: "Failed to Resubmit",
description: `There was an error resubmitting your request. Reason: ${result.message}`,
variant: "destructive",
})
}
setIsSubmitting(false)
}
return (
<form onSubmit={(e) => {
e.preventDefault();
handleSubmit();
}}>
<input type="hidden" name="domain" value={domain} />
<Button
type="submit"
className="flex items-center gap-2"
variant="outline"
disabled={isSubmitting}
>
<Clock className="h-4 w-4" />
{isSubmitting ? "Submitting..." : "Resubmit Request"}
</Button>
</form>
)
}