Skip to content

Commit

Permalink
feat: make toggle button default (#4437)
Browse files Browse the repository at this point in the history
* feat: make switch default

* fix: refetch invalidated query

* React-query caching the previous isDefault state.

* fix: switch label color

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
G3root and kodiakhq[bot] committed Sep 14, 2022
1 parent 4505955 commit 3bada22
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
20 changes: 8 additions & 12 deletions apps/web/pages/v2/availability/[schedule].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function AvailabilityForm(props: inferQueryOutput<"viewer.availability.sc
const updateMutation = trpc.useMutation("viewer.availability.schedule.update", {
onSuccess: async ({ schedule }) => {
await utils.invalidateQueries(["viewer.availability.schedule"]);
await utils.refetchQueries(["viewer.availability.schedule"]);
await router.push("/availability");
showToast(
t("availability_updated_successfully", {
Expand Down Expand Up @@ -72,18 +73,13 @@ export function AvailabilityForm(props: inferQueryOutput<"viewer.availability.sc
</div>
</div>
<div className="min-w-40 col-span-3 ml-2 space-y-2 lg:col-span-1">
{props.isDefault ? (
<span className="flex items-center">
<BadgeCheckIcon className="mr-1 h-4 w-4" /> {t("default")}
</span>
) : (
<Controller
name="isDefault"
render={({ field: { onChange, value } }) => (
<Switch label={t("set_to_default")} onCheckedChange={onChange} checked={value} />
)}
/>
)}
<Controller
name="isDefault"
render={({ field: { onChange, value } }) => (
<Switch label={t("set_to_default")} onCheckedChange={onChange} checked={value} />
)}
/>

<div className="xl:max-w-80 w-full">
<div>
<label htmlFor="timeZone" className="block text-sm font-medium text-gray-700">
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/v2/core/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Switch = (
{label && (
<Label.Root
htmlFor={id}
className="ml-2 cursor-pointer align-text-top text-sm font-medium text-neutral-700 ltr:ml-3 rtl:mr-3 dark:text-white">
className="ml-2 cursor-pointer align-text-top text-sm font-medium text-gray-900 ltr:ml-3 rtl:mr-3 dark:text-white">
{label}
</Label.Root>
)}
Expand Down

0 comments on commit 3bada22

Please sign in to comment.