fix logo not updating
This commit is contained in:
@@ -107,10 +107,9 @@ export const Route = createFileRoute("/api/teams/upload-logo")({
|
|||||||
const pbFormData = new FormData();
|
const pbFormData = new FormData();
|
||||||
pbFormData.append("logo", logoFile);
|
pbFormData.append("logo", logoFile);
|
||||||
|
|
||||||
const updatedTeam = await pbAdmin.updateTeam(
|
await pbAdmin.updateTeam(teamId, pbFormData as any);
|
||||||
teamId,
|
const updatedTeam = await pbAdmin.getTeam(teamId);
|
||||||
pbFormData as any
|
if (!updatedTeam) throw new Error("Failed to fetch updated team");
|
||||||
);
|
|
||||||
|
|
||||||
logger.info("Team logo uploaded successfully", {
|
logger.info("Team logo uploaded successfully", {
|
||||||
teamId,
|
teamId,
|
||||||
|
|||||||
@@ -106,11 +106,6 @@ const TeamForm = ({
|
|||||||
|
|
||||||
mutation(teamData, {
|
mutation(teamData, {
|
||||||
onSuccess: async (team: any) => {
|
onSuccess: async (team: any) => {
|
||||||
queryClient.invalidateQueries({ queryKey: teamKeys.list });
|
|
||||||
queryClient.invalidateQueries({
|
|
||||||
queryKey: teamKeys.details(team.id),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (logo && team) {
|
if (logo && team) {
|
||||||
try {
|
try {
|
||||||
let processedLogo = logo;
|
let processedLogo = logo;
|
||||||
@@ -152,7 +147,12 @@ const TeamForm = ({
|
|||||||
|
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
|
|
||||||
|
console.log("Logo upload result:", result);
|
||||||
|
|
||||||
|
queryClient.invalidateQueries({ queryKey: teamKeys.list });
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: teamKeys.details(team.id),
|
||||||
|
});
|
||||||
queryClient.setQueryData(
|
queryClient.setQueryData(
|
||||||
tournamentKeys.details(result.team!.id),
|
tournamentKeys.details(result.team!.id),
|
||||||
result.team
|
result.team
|
||||||
@@ -164,6 +164,11 @@ const TeamForm = ({
|
|||||||
toast.error(logoErrorMessage);
|
toast.error(logoErrorMessage);
|
||||||
logger.error("Team logo upload error", error);
|
logger.error("Team logo upload error", error);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
queryClient.invalidateQueries({ queryKey: teamKeys.list });
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: teamKeys.details(team.id),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (team && team.id) {
|
if (team && team.id) {
|
||||||
|
|||||||
@@ -72,9 +72,17 @@ export function createTeamsService(pb: PocketBase) {
|
|||||||
|
|
||||||
const result = await pb.collection("teams").update(id, data);
|
const result = await pb.collection("teams").update(id, data);
|
||||||
|
|
||||||
return transformTeam(await pb.collection("teams").getOne(result.id, {
|
if (data instanceof FormData && data.has('logo')) {
|
||||||
expand: "players, tournaments"
|
await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
}));
|
}
|
||||||
|
|
||||||
|
const updated = await pb.collection("teams").getOne(result.id, {
|
||||||
|
expand: "players, tournaments",
|
||||||
|
// @ts-ignore - Add cache busting
|
||||||
|
$cancelKey: Date.now().toString()
|
||||||
|
});
|
||||||
|
|
||||||
|
return transformTeam(updated);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error("PocketBase | Error updating team", error);
|
logger.error("PocketBase | Error updating team", error);
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
Reference in New Issue
Block a user