diff --git a/src/components/organizations/Organization.tsx b/src/components/organizations/Organization.tsx index 96a61c4..04c5089 100644 --- a/src/components/organizations/Organization.tsx +++ b/src/components/organizations/Organization.tsx @@ -653,7 +653,9 @@ export function Organization() { loadingOrgIds={loadingOrgIds} onMirror={handleMirrorOrg} onAddOrganization={() => setIsDialogOpen(true)} - onRefresh={() => fetchOrganizations(false)} + onRefresh={async () => { + await fetchOrganizations(false); + }} /> => { try { - const [orgConfig] = await db + const result = await db .select() .from(organizations) .where(and(eq(organizations.name, orgName), eq(organizations.userId, userId))) .limit(1); - return orgConfig || null; + if (!result[0]) { + return null; + } + + // Validate and cast the membershipRole to ensure type safety + const rawOrg = result[0]; + const membershipRole = membershipRoleEnum.parse(rawOrg.membershipRole); + const status = repoStatusEnum.parse(rawOrg.status); + + return { + ...rawOrg, + membershipRole, + status, + } as Organization; } catch (error) { console.error(`Error fetching organization config for ${orgName}:`, error); return null; @@ -113,7 +127,7 @@ export const getGiteaRepoOwner = ({ // Get the mirror strategy - use preserveOrgStructure for backward compatibility const mirrorStrategy = config.giteaConfig.mirrorStrategy || - (config.githubConfig.preserveOrgStructure ? "preserve" : "flat-user"); + (config.giteaConfig.preserveOrgStructure ? "preserve" : "flat-user"); switch (mirrorStrategy) { case "preserve": @@ -870,8 +884,8 @@ export async function mirrorGitHubOrgToGitea({ }); // Get the mirror strategy - use preserveOrgStructure for backward compatibility - const mirrorStrategy = config.giteaConfig?.mirrorStrategy || - (config.githubConfig?.preserveOrgStructure ? "preserve" : "flat-user"); + const mirrorStrategy = config.giteaConfig?.mirrorStrategy || + (config.giteaConfig?.preserveOrgStructure ? "preserve" : "flat-user"); let giteaOrgId: number; let targetOrgName: string;