wip
This commit is contained in:
@@ -32,24 +32,19 @@ export default function JoinLeagueButton({
|
||||
const membershipRepo = getLeagueMembershipRepository();
|
||||
|
||||
if (isInviteOnly) {
|
||||
// For alpha, treat "request to join" as creating a pending membership
|
||||
const pending = await membershipRepo.getMembership(leagueId, currentDriverId);
|
||||
if (pending) {
|
||||
const existing = await membershipRepo.getMembership(leagueId, currentDriverId);
|
||||
if (existing) {
|
||||
throw new Error('Already a member or have a pending request');
|
||||
}
|
||||
|
||||
await membershipRepo.saveMembership({
|
||||
leagueId,
|
||||
driverId: currentDriverId,
|
||||
role: 'member',
|
||||
status: 'pending',
|
||||
joinedAt: new Date(),
|
||||
});
|
||||
} else {
|
||||
const useCase = getJoinLeagueUseCase();
|
||||
await useCase.execute({ leagueId, driverId: currentDriverId });
|
||||
throw new Error(
|
||||
'Requesting to join invite-only leagues is not available in this alpha build.',
|
||||
);
|
||||
}
|
||||
|
||||
const useCase = getJoinLeagueUseCase();
|
||||
await useCase.execute({ leagueId, driverId: currentDriverId });
|
||||
|
||||
onMembershipChange?.();
|
||||
setShowConfirmDialog(false);
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user