({
+ defaultValues: { key: secretKey },
+ values: { key: secretKey },
+ resolver: zodResolver(formSchema)
+ });
+
+ useEffect(() => {
+ let timer: NodeJS.Timeout;
+ if (isSecNameCopied) {
+ timer = setTimeout(() => setIsSecNameCopied.off(), 2000);
+ }
+ return () => clearTimeout(timer);
+ }, [isSecNameCopied]);
+
+ const handleFormSubmit = async (data: TFormSchema) => {
+ if (!data.key) {
+ createNotification({
+ type: "error",
+ text: "Secret name cannot be empty"
+ });
+ return;
+ }
+
+ const promises = secrets
+ .filter((secret) => !!secret)
+ .map((secret) => {
+ if (!secret) return null;
+
+ return updateSecretV3({
+ environment: secret?.env,
+ workspaceId,
+ secretPath,
+ secretName: secret.key,
+ secretId: secret.id,
+ secretValue: secret.value || "",
+ type: "shared",
+ latestFileKey: decryptFileKey!,
+ tags: secret.tags.map((tag) => tag.id),
+ secretComment: secret.comment,
+ secretReminderRepeatDays: secret.reminderRepeatDays,
+ secretReminderNote: secret.reminderNote,
+ skipMultilineEncoding: secret.skipMultilineEncoding,
+ newSecretName: data.key
+ });
+ });
+
+ await Promise.all(promises)
+ .then(() => {
+ createNotification({
+ type: "success",
+ text: "Successfully renamed the secret"
+ });
+ })
+ .catch(() => {
+ createNotification({
+ type: "error",
+ text: "Error renaming the secret"
+ });
+ });
+ };
+
+ const copyTokenToClipboard = () => {
+ const [key] = getValues(["key"]);
+ navigator.clipboard.writeText(key as string);
+ setIsSecNameCopied.on();
+ };
+
+ return (
+
+ );
+}
+
+export default SecretRenameRow;