refactor: add proper props interfaces

This commit is contained in:
ramvignesh-b
2026-04-28 03:10:42 +05:30
parent 867b01bd1e
commit 4f178a3b03
4 changed files with 25 additions and 11 deletions
+10 -8
View File
@@ -2,6 +2,15 @@ import { LockIcon, LockKeyOpenIcon } from "@phosphor-icons/react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { PATHS } from "../../config/routes"; import { PATHS } from "../../config/routes";
interface LetterItemProps {
preview: string;
timestamp: string;
id: string;
status: "DRAFT" | "SEALED" | "BURNED";
unlock_at?: string;
isLocked?: boolean;
}
export function LetterItem({ export function LetterItem({
preview, preview,
timestamp, timestamp,
@@ -9,14 +18,7 @@ export function LetterItem({
status, status,
unlock_at, unlock_at,
isLocked = false, isLocked = false,
}: { }: LetterItemProps) {
preview: string;
timestamp: string;
id: string;
status: "DRAFT" | "SEALED" | "BURNED";
unlock_at?: string;
isLocked?: boolean;
}) {
const navigate = useNavigate(); const navigate = useNavigate();
function handleNavigate(): void { function handleNavigate(): void {
if (isLocked) return; if (isLocked) return;
+8 -1
View File
@@ -1,12 +1,19 @@
import { CampfireIcon, FlameIcon, XCircleIcon } from "@phosphor-icons/react"; import { CampfireIcon, FlameIcon, XCircleIcon } from "@phosphor-icons/react";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
interface BurnModalProps {
burnLetter: () => void;
isBurning: boolean;
setShowBurnModal: (show: boolean) => void;
setRevealState: (state: "sealed" | "revealed" | "burning" | "burned") => void;
}
export function BurnModal({ export function BurnModal({
burnLetter, burnLetter,
isBurning, isBurning,
setShowBurnModal, setShowBurnModal,
setRevealState, setRevealState,
}) { }: BurnModalProps) {
const [flameOn, setFlameOn] = useState(0); const [flameOn, setFlameOn] = useState(0);
const [rotate, setRotate] = useState(0); const [rotate, setRotate] = useState(0);
const [burnClicked, setBurnClicked] = useState(false); const [burnClicked, setBurnClicked] = useState(false);
@@ -4,7 +4,12 @@ import {
XCircleIcon, XCircleIcon,
} from "@phosphor-icons/react"; } from "@phosphor-icons/react";
export function ShareModal({ shareLink, setShareLink }) { interface ShareModalProps {
shareLink: string | null;
setShareLink: (link: string | null) => void;
}
export function ShareModal({ shareLink, setShareLink }: ShareModalProps) {
const copyToClipboard = async () => { const copyToClipboard = async () => {
if (!shareLink) return; if (!shareLink) return;
await navigator.clipboard.writeText(shareLink); await navigator.clipboard.writeText(shareLink);
+1 -1
View File
@@ -44,7 +44,7 @@ export default function Reader() {
const [isDecrypting, setIsDecrypting] = useState(true); const [isDecrypting, setIsDecrypting] = useState(true);
const [revealState, setRevealState] = useState< const [revealState, setRevealState] = useState<
"sealed" | "revealed" | "burned" "sealed" | "revealed" | "burned" | "burning"
>("sealed"); >("sealed");
const [error, setError] = useState<{ const [error, setError] = useState<{
message: string; message: string;