Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(reminders): update action url to fix edit issue #1605

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
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
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
Loading