mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 04:27:29 +00:00
fix: review suggestions
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import { useMemo } from "react";
|
|
||||||
import { faClock, faEye } from "@fortawesome/free-solid-svg-icons";
|
import { faClock, faEye } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
@@ -10,21 +9,21 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const SecretShareInfo = ({ secret }: Props) => {
|
export const SecretShareInfo = ({ secret }: Props) => {
|
||||||
const timeRemaining = useMemo(() => {
|
let timeRemaining: string | null = null;
|
||||||
if (!secret.expiresAt) return null;
|
|
||||||
|
|
||||||
|
if (secret.expiresAt) {
|
||||||
try {
|
try {
|
||||||
return format(new Date(secret.expiresAt), "yyyy-MM-dd 'at' HH:mm a");
|
timeRemaining = format(new Date(secret.expiresAt), "yyyy-MM-dd 'at' HH:mm a");
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
timeRemaining = null;
|
||||||
}
|
}
|
||||||
}, [secret.expiresAt]);
|
}
|
||||||
|
|
||||||
const viewsRemaining = useMemo(() => {
|
let viewsRemaining: number | null = null;
|
||||||
if (!secret.expiresAfterViews) return null;
|
|
||||||
|
|
||||||
return secret.expiresAfterViews - 1;
|
if (secret.expiresAfterViews) {
|
||||||
}, [secret.expiresAfterViews]);
|
viewsRemaining = secret.expiresAfterViews - 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!timeRemaining && viewsRemaining === null) {
|
if (!timeRemaining && viewsRemaining === null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user