Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
dyzhuu committed Aug 15, 2023
1 parent 9153ec4 commit 36b3f21
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 30 deletions.
6 changes: 2 additions & 4 deletions src/app/direct-debit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,16 @@ export default function DirectDebitPage() {
<div className="flex flex-col overflow-y-auto w-full gap-4 bg-bottom h-[calc(100dvh-460px)] max-h-[248px]">
<DebitDetailsCard
title="Account Number:"
text={[accountNumber]}
copy={true}
subtitle={accountNumber}
onClick={() => {
navigator.clipboard.writeText(accountNumber);
}}
/>

<DebitDetailsCard
title="Reference:"
text={[firstName + " " + lastName]}
subtitle={`${firstName} ${lastName}`}
sessionId={sessionId}
copy={true}
onClick={() => {
navigator.clipboard.writeText(sessionId);
}}
Expand Down
42 changes: 18 additions & 24 deletions src/components/DebitDetailsCard/DebitDetailsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,29 @@ import Card from "../Card/Card";
import DebitDetailsCardProps from "./DebitDetailsCardProps";
import { MdContentCopy } from "react-icons/md";

const DebitDetailsCard = ({title, text, sessionId, onClick, copy}: DebitDetailsCardProps) => {
const DebitDetailsCard = ({
title,
subtitle,
sessionId,
onClick,
}: DebitDetailsCardProps) => {
return (
<Card className="bg-gray-200 p-5 mt-0 pt-50 relative">
<Card className="bg-gray-200 font-normal p-5 mt-0 pt-50 relative">
<p className="font-medium text-xl top-5">{title}</p>

{text.map((text, index) => {
return (
<p className="font-normal text-gray-500" key={index}>
{text}
</p>
);
})}
<p className="text-gray-500">{subtitle}</p>

{sessionId && (
<>
<br />
<p className="font-normal blueGray-200 inline">SessionID: </p>
<p className="font-bold blueGray-200 inline">{sessionId}</p>
</>
)}

{copy && (
<button
onPointerDown={onClick}
className="absolute right-4 top-1/2 translate-y-[-50%] p-2 rounded-lg"
>
<MdContentCopy className="text-3xl" />
</button>
<p className="pt-5 blueGray-200">
SessionID: <span className="font-bold">{sessionId}</span>
</p>
)}
{/* Clipboard button is positioned absolute relative to the parent card container */}
<button
onPointerDown={onClick}
className="absolute right-4 top-1/2 translate-y-[-50%] p-2 rounded-lg"
>
<MdContentCopy className="text-3xl" />
</button>
</Card>
);
};
Expand Down
3 changes: 1 addition & 2 deletions src/components/DebitDetailsCard/DebitDetailsCardProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

type DebitDetailsCardProps = {
title: string;
text: string[];
subtitle: string;
sessionId?: string;
copy?: boolean; // TODO: redundant
onClick?: () => void;
};

Expand Down

0 comments on commit 36b3f21

Please sign in to comment.