feat(secret-reminders): addressed PR suggestions and improvements

This commit is contained in:
Carlos Monastyrski
2025-07-04 11:58:09 -03:00
parent 0efc314f33
commit e2559f10bc
26 changed files with 276 additions and 186 deletions
+1 -3
View File
@@ -1,3 +1 @@
export { useDeleteReminder } from "./queries";
export { useCreateReminder } from "./queries";
export { useGetReminder } from "./queries";
export { useCreateReminder, useDeleteReminder, useGetReminder } from "./queries";
+1 -2
View File
@@ -15,9 +15,8 @@ export const useCreateReminder = (secretId: string, projectId: string) => {
return useMutation<Reminder, object, CreateReminderDTO>({
mutationFn: async ({ message, repeatDays, nextReminderDate, recipients }) => {
const { data } = await apiRequest.post<{ reminder: Reminder }>(
`/api/v1/reminders/${projectId}/reminder`,
`/api/v1/reminders/${projectId}/reminder/${secretId}`,
{
secretId,
message,
repeatDays,
nextReminderDate,
+1 -8
View File
@@ -11,11 +11,4 @@ export type DeleteReminderDTO = {
reminderId: string;
};
export type Reminder = {
id: string;
message?: string | null;
repeatDays?: number | null;
nextReminderDate?: Date | null;
secretId: string;
recipients?: string[];
};
export type Reminder = { id: string } & CreateReminderDTO;
@@ -53,9 +53,7 @@ interface ReminderFormProps {
workspaceId: string;
environment: string;
secretPath: string;
secret: {
id: string;
};
secretId: string;
reminder?: Reminder;
}
@@ -134,7 +132,7 @@ export const CreateReminderForm = ({
workspaceId,
environment,
secretPath,
secret,
secretId,
reminder
}: ReminderFormProps) => {
const queryClient = useQueryClient();
@@ -145,8 +143,8 @@ export const CreateReminderForm = ({
const { memberOptions } = useWorkspaceMembers();
// API mutations
const { mutateAsync: createReminder } = useCreateReminder(secret?.id, workspaceId);
const { mutateAsync: deleteReminder } = useDeleteReminder(secret?.id, workspaceId);
const { mutateAsync: createReminder } = useCreateReminder(secretId, workspaceId);
const { mutateAsync: deleteReminder } = useDeleteReminder(secretId, workspaceId);
// Form setup
const form = useForm<TReminderFormSchema>({
@@ -185,7 +183,7 @@ export const CreateReminderForm = ({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
});
queryClient.invalidateQueries({
queryKey: reminderKeys.getReminder(secret.id, workspaceId)
queryKey: reminderKeys.getReminder(secretId, workspaceId)
});
};
@@ -196,7 +194,7 @@ export const CreateReminderForm = ({
repeatDays: data.repeatDays,
message: data.message,
recipients: data.recipients?.map((r) => r.value) || [],
secretId: secret.id,
secretId,
nextReminderDate: data.nextReminderDate
});
@@ -221,7 +219,7 @@ export const CreateReminderForm = ({
// Delete reminder handler
const handleDeleteReminder = async () => {
try {
await deleteReminder({ reminderId: reminder?.id || "", secretId: secret.id });
await deleteReminder({ reminderId: reminder?.id || "", secretId });
invalidateQueries();
reset();
onOpenChange();
@@ -387,6 +385,7 @@ export const CreateReminderForm = ({
}}
popUpContentProps={{}}
hideTime
hidden={{ before: new Date(Date.now() + 86400000) }}
/>
</FormControl>
</div>
@@ -314,7 +314,7 @@ export const SecretDetailSidebar = ({
workspaceId={currentWorkspace.id}
environment={environment}
secretPath={secretPath}
secret={secret}
secretId={secret?.id}
reminder={reminderData}
/>
<UpgradePlanModal