mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 16:40:30 +00:00
feat(secret-reminders): addressed PR suggestions and improvements
This commit is contained in:
@@ -1,3 +1 @@
|
||||
export { useDeleteReminder } from "./queries";
|
||||
export { useCreateReminder } from "./queries";
|
||||
export { useGetReminder } from "./queries";
|
||||
export { useCreateReminder, useDeleteReminder, useGetReminder } from "./queries";
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
+8
-9
@@ -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>
|
||||
|
||||
+1
-1
@@ -314,7 +314,7 @@ export const SecretDetailSidebar = ({
|
||||
workspaceId={currentWorkspace.id}
|
||||
environment={environment}
|
||||
secretPath={secretPath}
|
||||
secret={secret}
|
||||
secretId={secret?.id}
|
||||
reminder={reminderData}
|
||||
/>
|
||||
<UpgradePlanModal
|
||||
|
||||
Reference in New Issue
Block a user