Skip to content

Scheduling infrastructure for absolutely everyone.

fix: round robin settings update only on change (#24853)

spandev0ae6e92558c2
diff --git a/packages/features/ee/teams/components/RoundRobinSettings.tsx b/packages/features/ee/teams/components/RoundRobinSettings.tsx
index a9aed3fba50..d4aead1b678 100644
--- a/packages/features/ee/teams/components/RoundRobinSettings.tsx
+++ b/packages/features/ee/teams/components/RoundRobinSettings.tsx
@@ -26,13 +26,23 @@ const RoundRobinSettings = ({ team }: RoundRobinSettingsProps) => {
const rrResetInterval = team?.rrResetInterval ?? undefined;
const utils = trpc.useUtils();
+ const initialResetInterval = rrResetInterval ?? RRResetInterval.MONTH;
+ const initialTimestampBasis = team?.rrTimestampBasis ?? RRTimestampBasis.CREATED_AT;
+
const form = useForm<{ rrResetInterval: RRResetInterval; rrTimestampBasis: RRTimestampBasis }>({
defaultValues: {
- rrResetInterval: rrResetInterval ?? RRResetInterval.MONTH,
- rrTimestampBasis: team?.rrTimestampBasis ?? RRTimestampBasis.CREATED_AT,
+ rrResetInterval: initialResetInterval,
+ rrTimestampBasis: initialTimestampBasis,
},
});
+ const [watchedResetInterval, watchedTimestampBasis] = form.watch([
+ "rrResetInterval",
+ "rrTimestampBasis",
+ ]);
+ const hasChanges =
+ watchedResetInterval !== initialResetInterval || watchedTimestampBasis !== initialTimestampBasis;
+
const mutation = trpc.viewer.teams.update.useMutation({
onError: (err) => {
showToast(err.message, "error");
@@ -85,7 +95,7 @@ const RoundRobinSettings = ({ team }: RoundRobinSettingsProps) => {
</div>
</div>
<SectionBottomActions align="end">
- <Button type="submit" color="primary" loading={mutation.isPending}>
+ <Button type="submit" disabled={!hasChanges} color="primary" loading={mutation.isPending}>
{t("update")}
</Button>
</SectionBottomActions>