Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export const AssetManager = <T extends AssetType>({ division, assetType }: Asset
const {
data: assets = [] as T[],
error,
isLoading
isLoading,
mutate: updateAssets
} = useSWR<T[]>(
division ? `/admin/events/${division.eventId}/divisions/${division.id}/${assetType}` : null,
{
Expand Down Expand Up @@ -123,7 +124,11 @@ export const AssetManager = <T extends AssetType>({ division, assetType }: Asset
return rest;
});
showSuccess();
mutate(`/admin/events/${division.eventId}/divisions/${division.id}/${assetType}`);
// Update the asset name in-place to preserve list order
updateAssets(
currentAssets => currentAssets?.map(a => (a.id === asset.id ? { ...a, name } : a)) as T[],
{ revalidate: false }
);
} else {
setErrors({ [asset.id]: t('messages.save-error') });
}
Expand Down
Loading