Skip to content

Commit

Permalink
Merge pull request #1605 from rockingrohit9639/fix/reminders-tm
Browse files Browse the repository at this point in the history
fix(reminders): update action url to fix edit issue
  • Loading branch information
DonKoko authored Jan 28, 2025
2 parents 1d8dc0b + 105e81e commit 591de82
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/components/asset-reminder/reminders-table.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState } from "react";
import type { Prisma } from "@prisma/client";
import { useParams } from "@remix-run/react";
import colors from "tailwindcss/colors";
import type { ASSET_REMINDER_INCLUDE_FIELDS } from "~/modules/asset-reminder/fields";
import { List } from "../list";
Expand Down Expand Up @@ -29,6 +30,7 @@ export default function RemindersTable({
isAssetReminderPage,
}: RemindersTableProps) {
const [isReminderDialogOpen, setIsReminderDialogOpen] = useState(false);
const { assetId } = useParams<{ assetId: string }>();

const emptyStateTitle = isAssetReminderPage
? "No reminders for this asset"
Expand Down Expand Up @@ -86,6 +88,7 @@ export default function RemindersTable({
/>

<SetOrEditReminderDialog
action={isAssetReminderPage ? `/assets/${assetId}` : undefined}
open={isReminderDialogOpen}
onClose={() => {
setIsReminderDialogOpen(false);
Expand Down
7 changes: 4 additions & 3 deletions app/components/asset-reminder/set-or-edit-reminder-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect } from "react";
import { Form, useNavigation } from "@remix-run/react";
import { useLocation, useParams, useSearchParams } from "react-router-dom";
import { useLocation, useSearchParams } from "react-router-dom";
import { useZorm } from "react-zorm";
import { z } from "zod";
import Input from "~/components/forms/input";
Expand All @@ -25,16 +25,17 @@ type SetOrEditReminderDialogProps = {
open: boolean;
onClose: () => void;
reminder?: z.infer<typeof setReminderSchema> & { id: string };
action?: string;
};

export default function SetOrEditReminderDialog({
open,
onClose,
reminder,
action,
}: SetOrEditReminderDialogProps) {
const navigation = useNavigation();
const disabled = isFormProcessing(navigation.state);
const { assetId } = useParams<{ assetId: string }>();

const pathname = useLocation().pathname;
const [searchParams, setSearchParams] = useSearchParams();
Expand Down Expand Up @@ -84,7 +85,7 @@ export default function SetOrEditReminderDialog({
method="POST"
encType="multipart/form-data"
className="grid grid-cols-1 divide-x md:grid-cols-2"
action={`/assets/${assetId}`}
action={action}
>
<div className="px-6 py-4">
<input
Expand Down
1 change: 1 addition & 0 deletions app/components/assets/actions-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ const ConditionalActionsDropdown = () => {
</When>
<When truthy={isSetReminderDialogOpen && isAdministratorOrOwner}>
<SetOrEditReminderDialog
action={`/assets/${asset.id}`}
open={isSetReminderDialogOpen}
onClose={() => {
setIsSetReminderDialogOpen(false);
Expand Down

0 comments on commit 591de82

Please sign in to comment.