mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-04 04:26:11 +00:00
Minor improvements on new reminders api
This commit is contained in:
@@ -13,7 +13,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
t.integer("repeatDays").checkPositive().nullable();
|
t.integer("repeatDays").checkPositive().nullable();
|
||||||
t.timestamp("nextReminderDate").notNullable();
|
t.timestamp("nextReminderDate").notNullable();
|
||||||
t.timestamps(true, true, true);
|
t.timestamps(true, true, true);
|
||||||
t.index("secretId");
|
|
||||||
t.unique("secretId");
|
t.unique("secretId");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,6 @@ export const registerSecretReminderRouter = async (server: FastifyZodProvider) =
|
|||||||
params: z.object({
|
params: z.object({
|
||||||
secretId: z.string().uuid()
|
secretId: z.string().uuid()
|
||||||
}),
|
}),
|
||||||
querystring: z.object({
|
|
||||||
projectId: z.string().uuid()
|
|
||||||
}),
|
|
||||||
body: z
|
body: z
|
||||||
.object({
|
.object({
|
||||||
message: z.string().trim().max(1024).optional(),
|
message: z.string().trim().max(1024).optional(),
|
||||||
@@ -43,7 +40,6 @@ export const registerSecretReminderRouter = async (server: FastifyZodProvider) =
|
|||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgId: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
actorAuthMethod: req.permission.authMethod,
|
actorAuthMethod: req.permission.authMethod,
|
||||||
projectId: req.query.projectId,
|
|
||||||
reminder: {
|
reminder: {
|
||||||
secretId: req.params.secretId,
|
secretId: req.params.secretId,
|
||||||
message: req.body.message,
|
message: req.body.message,
|
||||||
@@ -56,7 +52,6 @@ export const registerSecretReminderRouter = async (server: FastifyZodProvider) =
|
|||||||
await server.services.auditLog.createAuditLog({
|
await server.services.auditLog.createAuditLog({
|
||||||
...req.auditLogInfo,
|
...req.auditLogInfo,
|
||||||
orgId: req.permission.orgId,
|
orgId: req.permission.orgId,
|
||||||
projectId: req.query.projectId,
|
|
||||||
event: {
|
event: {
|
||||||
type: EventType.CREATE_SECRET_REMINDER,
|
type: EventType.CREATE_SECRET_REMINDER,
|
||||||
metadata: {
|
metadata: {
|
||||||
@@ -83,9 +78,6 @@ export const registerSecretReminderRouter = async (server: FastifyZodProvider) =
|
|||||||
params: z.object({
|
params: z.object({
|
||||||
secretId: z.string().uuid()
|
secretId: z.string().uuid()
|
||||||
}),
|
}),
|
||||||
querystring: z.object({
|
|
||||||
projectId: z.string().uuid()
|
|
||||||
}),
|
|
||||||
response: {
|
response: {
|
||||||
200: z.object({
|
200: z.object({
|
||||||
reminder: RemindersSchema.extend({
|
reminder: RemindersSchema.extend({
|
||||||
@@ -103,14 +95,12 @@ export const registerSecretReminderRouter = async (server: FastifyZodProvider) =
|
|||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgId: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
actorAuthMethod: req.permission.authMethod,
|
actorAuthMethod: req.permission.authMethod,
|
||||||
secretId: req.params.secretId,
|
secretId: req.params.secretId
|
||||||
projectId: req.query.projectId
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await server.services.auditLog.createAuditLog({
|
await server.services.auditLog.createAuditLog({
|
||||||
...req.auditLogInfo,
|
...req.auditLogInfo,
|
||||||
orgId: req.permission.orgId,
|
orgId: req.permission.orgId,
|
||||||
projectId: req.query.projectId,
|
|
||||||
event: {
|
event: {
|
||||||
type: EventType.GET_SECRET_REMINDER,
|
type: EventType.GET_SECRET_REMINDER,
|
||||||
metadata: {
|
metadata: {
|
||||||
@@ -132,9 +122,6 @@ export const registerSecretReminderRouter = async (server: FastifyZodProvider) =
|
|||||||
params: z.object({
|
params: z.object({
|
||||||
secretId: z.string().uuid()
|
secretId: z.string().uuid()
|
||||||
}),
|
}),
|
||||||
querystring: z.object({
|
|
||||||
projectId: z.string().uuid()
|
|
||||||
}),
|
|
||||||
response: {
|
response: {
|
||||||
200: z.object({
|
200: z.object({
|
||||||
message: z.string()
|
message: z.string()
|
||||||
@@ -148,14 +135,12 @@ export const registerSecretReminderRouter = async (server: FastifyZodProvider) =
|
|||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgId: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
actorAuthMethod: req.permission.authMethod,
|
actorAuthMethod: req.permission.authMethod,
|
||||||
secretId: req.params.secretId,
|
secretId: req.params.secretId
|
||||||
projectId: req.query.projectId
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await server.services.auditLog.createAuditLog({
|
await server.services.auditLog.createAuditLog({
|
||||||
...req.auditLogInfo,
|
...req.auditLogInfo,
|
||||||
orgId: req.permission.orgId,
|
orgId: req.permission.orgId,
|
||||||
projectId: req.query.projectId,
|
|
||||||
event: {
|
event: {
|
||||||
type: EventType.DELETE_SECRET_REMINDER,
|
type: EventType.DELETE_SECRET_REMINDER,
|
||||||
metadata: {
|
metadata: {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { ForbiddenError } from "@casl/ability";
|
import { ForbiddenError } from "@casl/ability";
|
||||||
import { Knex } from "knex";
|
import { Knex } from "knex";
|
||||||
|
|
||||||
|
import { TableName } from "@app/db/schemas";
|
||||||
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
|
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
|
||||||
import { ProjectPermissionSecretActions, ProjectPermissionSub } from "@app/ee/services/permission/project-permission";
|
import { ProjectPermissionSecretActions, ProjectPermissionSub } from "@app/ee/services/permission/project-permission";
|
||||||
import { BadRequestError } from "@app/lib/errors";
|
import { BadRequestError } from "@app/lib/errors";
|
||||||
@@ -21,7 +22,7 @@ type TReminderServiceFactoryDep = {
|
|||||||
smtpService: TSmtpService;
|
smtpService: TSmtpService;
|
||||||
projectMembershipDAL: Pick<TProjectMembershipDALFactory, "findAllProjectMembers">;
|
projectMembershipDAL: Pick<TProjectMembershipDALFactory, "findAllProjectMembers">;
|
||||||
permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;
|
permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;
|
||||||
secretV2BridgeDAL: Pick<TSecretV2BridgeDALFactory, "invalidateSecretCacheByProjectId">;
|
secretV2BridgeDAL: Pick<TSecretV2BridgeDALFactory, "invalidateSecretCacheByProjectId" | "findOneWithTags">;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const reminderServiceFactory = ({
|
export const reminderServiceFactory = ({
|
||||||
@@ -136,13 +137,16 @@ export const reminderServiceFactory = ({
|
|||||||
actorId,
|
actorId,
|
||||||
actorOrgId,
|
actorOrgId,
|
||||||
actorAuthMethod,
|
actorAuthMethod,
|
||||||
projectId,
|
|
||||||
reminder
|
reminder
|
||||||
}: TCreateReminderDTO) => {
|
}: TCreateReminderDTO) => {
|
||||||
|
const secret = await secretV2BridgeDAL.findOneWithTags({ [`${TableName.SecretV2}.id` as "id"]: reminder.secretId });
|
||||||
|
if (!secret) {
|
||||||
|
throw new BadRequestError({ message: `Secret ${reminder.secretId} not found` });
|
||||||
|
}
|
||||||
const { permission } = await permissionService.getProjectPermission({
|
const { permission } = await permissionService.getProjectPermission({
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
projectId,
|
projectId: secret.projectId,
|
||||||
actorAuthMethod,
|
actorAuthMethod,
|
||||||
actorOrgId
|
actorOrgId
|
||||||
});
|
});
|
||||||
@@ -150,30 +154,32 @@ export const reminderServiceFactory = ({
|
|||||||
|
|
||||||
const response = await createReminderInternal({
|
const response = await createReminderInternal({
|
||||||
...reminder,
|
...reminder,
|
||||||
projectId
|
projectId: secret.projectId
|
||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getReminder: TReminderServiceFactory["getReminder"] = async ({
|
const getReminder: TReminderServiceFactory["getReminder"] = async ({
|
||||||
secretId,
|
secretId,
|
||||||
projectId,
|
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgId,
|
actorOrgId,
|
||||||
actorAuthMethod
|
actorAuthMethod
|
||||||
}: {
|
}: {
|
||||||
secretId: string;
|
secretId: string;
|
||||||
projectId: string;
|
|
||||||
actor: ActorType;
|
actor: ActorType;
|
||||||
actorId: string;
|
actorId: string;
|
||||||
actorOrgId: string;
|
actorOrgId: string;
|
||||||
actorAuthMethod: ActorAuthMethod;
|
actorAuthMethod: ActorAuthMethod;
|
||||||
}) => {
|
}) => {
|
||||||
|
const secret = await secretV2BridgeDAL.findOneWithTags({ [`${TableName.SecretV2}.id` as "id"]: secretId });
|
||||||
|
if (!secret) {
|
||||||
|
throw new BadRequestError({ message: `Secret ${secretId} not found` });
|
||||||
|
}
|
||||||
const { permission } = await permissionService.getProjectPermission({
|
const { permission } = await permissionService.getProjectPermission({
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
projectId,
|
projectId: secret.projectId,
|
||||||
actorAuthMethod,
|
actorAuthMethod,
|
||||||
actorOrgId
|
actorOrgId
|
||||||
});
|
});
|
||||||
@@ -228,40 +234,29 @@ export const reminderServiceFactory = ({
|
|||||||
actorId,
|
actorId,
|
||||||
actorOrgId,
|
actorOrgId,
|
||||||
actorAuthMethod,
|
actorAuthMethod,
|
||||||
secretId,
|
secretId
|
||||||
projectId
|
|
||||||
}: {
|
}: {
|
||||||
actor: ActorType;
|
actor: ActorType;
|
||||||
actorId: string;
|
actorId: string;
|
||||||
actorOrgId: string;
|
actorOrgId: string;
|
||||||
actorAuthMethod: ActorAuthMethod;
|
actorAuthMethod: ActorAuthMethod;
|
||||||
secretId: string;
|
secretId: string;
|
||||||
projectId: string;
|
|
||||||
}) => {
|
}) => {
|
||||||
|
const secret = await secretV2BridgeDAL.findOneWithTags({ [`${TableName.SecretV2}.id` as "id"]: secretId });
|
||||||
|
if (!secret) {
|
||||||
|
throw new BadRequestError({ message: `Secret ${secretId} not found` });
|
||||||
|
}
|
||||||
const { permission } = await permissionService.getProjectPermission({
|
const { permission } = await permissionService.getProjectPermission({
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
projectId,
|
projectId: secret.projectId,
|
||||||
actorAuthMethod,
|
actorAuthMethod,
|
||||||
actorOrgId
|
actorOrgId
|
||||||
});
|
});
|
||||||
|
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionSecretActions.Edit, ProjectPermissionSub.Secrets);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionSecretActions.Edit, ProjectPermissionSub.Secrets);
|
||||||
await reminderDAL.delete({ secretId });
|
await reminderDAL.delete({ secretId });
|
||||||
await secretV2BridgeDAL.invalidateSecretCacheByProjectId(projectId);
|
await secretV2BridgeDAL.invalidateSecretCacheByProjectId(secret.projectId);
|
||||||
};
|
|
||||||
|
|
||||||
const removeReminderRecipients: TReminderServiceFactory["removeReminderRecipients"] = async (
|
|
||||||
secretId: string,
|
|
||||||
projectId: string,
|
|
||||||
tx?: Knex
|
|
||||||
) => {
|
|
||||||
const reminder = await reminderDAL.findOne({ secretId }, tx);
|
|
||||||
if (!reminder) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await reminderRecipientDAL.delete({ reminderId: reminder.id }, tx);
|
|
||||||
await secretV2BridgeDAL.invalidateSecretCacheByProjectId(projectId);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteReminderBySecretId: TReminderServiceFactory["deleteReminderBySecretId"] = async (
|
const deleteReminderBySecretId: TReminderServiceFactory["deleteReminderBySecretId"] = async (
|
||||||
@@ -354,7 +349,6 @@ export const reminderServiceFactory = ({
|
|||||||
getReminder,
|
getReminder,
|
||||||
sendDailyReminders,
|
sendDailyReminders,
|
||||||
deleteReminder,
|
deleteReminder,
|
||||||
removeReminderRecipients,
|
|
||||||
deleteReminderBySecretId,
|
deleteReminderBySecretId,
|
||||||
batchCreateReminders,
|
batchCreateReminders,
|
||||||
createReminderInternal
|
createReminderInternal
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ export type TCreateReminderDTO = {
|
|||||||
actorId: string;
|
actorId: string;
|
||||||
actorOrgId: string;
|
actorOrgId: string;
|
||||||
actorAuthMethod: ActorAuthMethod;
|
actorAuthMethod: ActorAuthMethod;
|
||||||
projectId: string;
|
|
||||||
reminder: {
|
reminder: {
|
||||||
secretId?: string;
|
secretId?: string;
|
||||||
message?: string | null;
|
message?: string | null;
|
||||||
@@ -37,28 +36,19 @@ export type TBatchCreateReminderDTO = {
|
|||||||
}[];
|
}[];
|
||||||
|
|
||||||
export interface TReminderServiceFactory {
|
export interface TReminderServiceFactory {
|
||||||
createReminder: ({
|
createReminder: ({ actor, actorId, actorOrgId, actorAuthMethod, reminder }: TCreateReminderDTO) => Promise<{
|
||||||
actor,
|
|
||||||
actorId,
|
|
||||||
actorOrgId,
|
|
||||||
actorAuthMethod,
|
|
||||||
projectId,
|
|
||||||
reminder
|
|
||||||
}: TCreateReminderDTO) => Promise<{
|
|
||||||
id: string;
|
id: string;
|
||||||
created: boolean;
|
created: boolean;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
getReminder: ({
|
getReminder: ({
|
||||||
secretId,
|
secretId,
|
||||||
projectId,
|
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgId,
|
actorOrgId,
|
||||||
actorAuthMethod
|
actorAuthMethod
|
||||||
}: {
|
}: {
|
||||||
secretId: string;
|
secretId: string;
|
||||||
projectId: string;
|
|
||||||
actor: ActorType;
|
actor: ActorType;
|
||||||
actorId: string;
|
actorId: string;
|
||||||
actorOrgId: string;
|
actorOrgId: string;
|
||||||
@@ -72,19 +62,15 @@ export interface TReminderServiceFactory {
|
|||||||
actorId,
|
actorId,
|
||||||
actorOrgId,
|
actorOrgId,
|
||||||
actorAuthMethod,
|
actorAuthMethod,
|
||||||
secretId,
|
secretId
|
||||||
projectId
|
|
||||||
}: {
|
}: {
|
||||||
actor: ActorType;
|
actor: ActorType;
|
||||||
actorId: string;
|
actorId: string;
|
||||||
actorOrgId: string;
|
actorOrgId: string;
|
||||||
actorAuthMethod: ActorAuthMethod;
|
actorAuthMethod: ActorAuthMethod;
|
||||||
secretId: string;
|
secretId: string;
|
||||||
projectId: string;
|
|
||||||
}) => Promise<void>;
|
}) => Promise<void>;
|
||||||
|
|
||||||
removeReminderRecipients: (secretId: string, projectId: string, tx?: Knex) => Promise<void>;
|
|
||||||
|
|
||||||
deleteReminderBySecretId: (secretId: string, projectId: string, tx?: Knex) => Promise<void>;
|
deleteReminderBySecretId: (secretId: string, projectId: string, tx?: Knex) => Promise<void>;
|
||||||
|
|
||||||
batchCreateReminders: (
|
batchCreateReminders: (
|
||||||
|
|||||||
@@ -344,7 +344,6 @@ export const secretV2BridgeServiceFactory = ({
|
|||||||
actorId,
|
actorId,
|
||||||
actorOrgId,
|
actorOrgId,
|
||||||
actorAuthMethod,
|
actorAuthMethod,
|
||||||
projectId,
|
|
||||||
reminder: {
|
reminder: {
|
||||||
secretId: secret.id,
|
secretId: secret.id,
|
||||||
message: inputSecret.secretReminderNote,
|
message: inputSecret.secretReminderNote,
|
||||||
@@ -558,7 +557,6 @@ export const secretV2BridgeServiceFactory = ({
|
|||||||
actorId,
|
actorId,
|
||||||
actorOrgId,
|
actorOrgId,
|
||||||
actorAuthMethod,
|
actorAuthMethod,
|
||||||
projectId,
|
|
||||||
reminder: {
|
reminder: {
|
||||||
secretId: secret.id,
|
secretId: secret.id,
|
||||||
message: inputSecret.secretReminderNote,
|
message: inputSecret.secretReminderNote,
|
||||||
|
|||||||
@@ -111,10 +111,7 @@ type TSecretQueueFactoryDep = {
|
|||||||
resourceMetadataDAL: Pick<TResourceMetadataDALFactory, "insertMany" | "delete">;
|
resourceMetadataDAL: Pick<TResourceMetadataDALFactory, "insertMany" | "delete">;
|
||||||
folderCommitService: Pick<TFolderCommitServiceFactory, "createCommit">;
|
folderCommitService: Pick<TFolderCommitServiceFactory, "createCommit">;
|
||||||
secretSyncQueue: Pick<TSecretSyncQueueFactory, "queueSecretSyncsSyncSecretsByPath">;
|
secretSyncQueue: Pick<TSecretSyncQueueFactory, "queueSecretSyncsSyncSecretsByPath">;
|
||||||
reminderService: Pick<
|
reminderService: Pick<TReminderServiceFactory, "createReminderInternal" | "deleteReminderBySecretId">;
|
||||||
TReminderServiceFactory,
|
|
||||||
"createReminderInternal" | "deleteReminderBySecretId" | "removeReminderRecipients"
|
|
||||||
>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TGetSecrets = {
|
export type TGetSecrets = {
|
||||||
|
|||||||
@@ -1859,7 +1859,6 @@ export const secretServiceFactory = ({
|
|||||||
actorId,
|
actorId,
|
||||||
actorOrgId,
|
actorOrgId,
|
||||||
actorAuthMethod,
|
actorAuthMethod,
|
||||||
projectId,
|
|
||||||
reminder: {
|
reminder: {
|
||||||
secretId: secret.id,
|
secretId: secret.id,
|
||||||
message: secretReminderNote,
|
message: secretReminderNote,
|
||||||
@@ -2269,7 +2268,6 @@ export const secretServiceFactory = ({
|
|||||||
actorId,
|
actorId,
|
||||||
actorOrgId,
|
actorOrgId,
|
||||||
actorAuthMethod,
|
actorAuthMethod,
|
||||||
projectId,
|
|
||||||
reminder: {
|
reminder: {
|
||||||
secretId: secrets.find(
|
secretId: secrets.find(
|
||||||
(el) =>
|
(el) =>
|
||||||
|
|||||||
@@ -5,17 +5,16 @@ import { apiRequest } from "@app/config/request";
|
|||||||
import { CreateReminderDTO, DeleteReminderDTO, Reminder } from "./types";
|
import { CreateReminderDTO, DeleteReminderDTO, Reminder } from "./types";
|
||||||
|
|
||||||
export const reminderKeys = {
|
export const reminderKeys = {
|
||||||
getReminder: (secretId: string, projectId: string) =>
|
getReminder: (secretId: string) => ["get-reminder", secretId] as const
|
||||||
["get-reminder", secretId, projectId] as const
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useCreateReminder = (secretId: string, projectId: string) => {
|
export const useCreateReminder = (secretId: string) => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
return useMutation<Reminder, object, CreateReminderDTO>({
|
return useMutation<Reminder, object, CreateReminderDTO>({
|
||||||
mutationFn: async ({ message, repeatDays, nextReminderDate, recipients }) => {
|
mutationFn: async ({ message, repeatDays, nextReminderDate, recipients }) => {
|
||||||
const { data } = await apiRequest.post<{ reminder: Reminder }>(
|
const { data } = await apiRequest.post<{ reminder: Reminder }>(
|
||||||
`/api/v1/reminders/secrets/${secretId}?projectId=${projectId}`,
|
`/api/v1/reminders/secrets/${secretId}`,
|
||||||
{
|
{
|
||||||
message,
|
message,
|
||||||
repeatDays,
|
repeatDays,
|
||||||
@@ -26,36 +25,36 @@ export const useCreateReminder = (secretId: string, projectId: string) => {
|
|||||||
return data.reminder;
|
return data.reminder;
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: reminderKeys.getReminder(secretId, projectId) });
|
queryClient.invalidateQueries({ queryKey: reminderKeys.getReminder(secretId) });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useDeleteReminder = (secretId: string, projectId: string) => {
|
export const useDeleteReminder = (secretId: string) => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
return useMutation<Reminder, object, DeleteReminderDTO>({
|
return useMutation<Reminder, object, DeleteReminderDTO>({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
const { data } = await apiRequest.delete<{ reminder: Reminder }>(
|
const { data } = await apiRequest.delete<{ reminder: Reminder }>(
|
||||||
`/api/v1/reminders/secrets/${secretId}?projectId=${projectId}`
|
`/api/v1/reminders/secrets/${secretId}`
|
||||||
);
|
);
|
||||||
return data.reminder;
|
return data.reminder;
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: reminderKeys.getReminder(secretId, projectId) });
|
queryClient.invalidateQueries({ queryKey: reminderKeys.getReminder(secretId) });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useGetReminder = (secretId: string, projectId: string) => {
|
export const useGetReminder = (secretId: string) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: reminderKeys.getReminder(secretId, projectId),
|
queryKey: reminderKeys.getReminder(secretId),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await apiRequest.get<{ reminder: Reminder }>(
|
const { data } = await apiRequest.get<{ reminder: Reminder }>(
|
||||||
`/api/v1/reminders/secrets/${secretId}?projectId=${projectId}`
|
`/api/v1/reminders/secrets/${secretId}`
|
||||||
);
|
);
|
||||||
return data.reminder;
|
return data.reminder;
|
||||||
},
|
},
|
||||||
enabled: Boolean(secretId && projectId)
|
enabled: Boolean(secretId)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-3
@@ -143,8 +143,8 @@ export const CreateReminderForm = ({
|
|||||||
const { memberOptions } = useWorkspaceMembers();
|
const { memberOptions } = useWorkspaceMembers();
|
||||||
|
|
||||||
// API mutations
|
// API mutations
|
||||||
const { mutateAsync: createReminder } = useCreateReminder(secretId, workspaceId);
|
const { mutateAsync: createReminder } = useCreateReminder(secretId);
|
||||||
const { mutateAsync: deleteReminder } = useDeleteReminder(secretId, workspaceId);
|
const { mutateAsync: deleteReminder } = useDeleteReminder(secretId);
|
||||||
|
|
||||||
// Form setup
|
// Form setup
|
||||||
const form = useForm<TReminderFormSchema>({
|
const form = useForm<TReminderFormSchema>({
|
||||||
@@ -183,7 +183,7 @@ export const CreateReminderForm = ({
|
|||||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||||
});
|
});
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: reminderKeys.getReminder(secretId, workspaceId)
|
queryKey: reminderKeys.getReminder(secretId)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -115,7 +115,7 @@ export const SecretDetailSidebar = ({
|
|||||||
|
|
||||||
const { permission } = useProjectPermission();
|
const { permission } = useProjectPermission();
|
||||||
const { currentWorkspace } = useWorkspace();
|
const { currentWorkspace } = useWorkspace();
|
||||||
const { data: reminderData } = useGetReminder(secret?.id, currentWorkspace.id);
|
const { data: reminderData } = useGetReminder(secret?.id);
|
||||||
|
|
||||||
const tagFields = useFieldArray({
|
const tagFields = useFieldArray({
|
||||||
control,
|
control,
|
||||||
|
|||||||
Reference in New Issue
Block a user