Skip to content

Commit 5fb2412

Browse files
committed
fix(wallet-admin): hide edit button if user does not have permissions to edit
Signed-off-by: Rakib Ansary <rakibansary@topcoder.com>
1 parent 8f1c5c1 commit 5fb2412

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/apps/wallet-admin/src/home/tabs/payments/PaymentsTab.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
249249
// eslint-disable-next-line react-hooks/exhaustive-deps
250250
}, [handleValueUpdated, editState])
251251

252+
const isEditingAllowed = (): boolean => props.profile.roles.includes('Payment Admin') || props.profile.roles.includes('Payment Editor')
253+
252254
return (
253255
<>
254256
<div className={styles.container}>
@@ -378,6 +380,7 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
378380
{isLoading && <LoadingCircles className={styles.centered} />}
379381
{!isLoading && winnings.length > 0 && (
380382
<PaymentsTable
383+
canEdit={isEditingAllowed()}
381384
currentPage={pagination.currentPage}
382385
numPages={pagination.totalPages}
383386
payments={winnings}

src/apps/wallet-admin/src/lib/components/payment-view/PaymentView.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ const PaymentView: React.FC<PaymentViewProps> = (props: PaymentViewProps) => {
107107
<p className={styles.value}>{props.payment.releaseDateObj.toLocaleDateString()}</p>
108108
</div>
109109

110+
{props.payment.datePaid !== '-' && (
111+
(
112+
<div className={styles.infoItem}>
113+
<span className={styles.label}>Date Paid</span>
114+
<p className={styles.value}>{props.payment.datePaid}</p>
115+
</div>
116+
))}
117+
110118
<div className={styles.infoItem}>
111119
<Button
112120
onClick={handleToggleView}
@@ -121,6 +129,7 @@ const PaymentView: React.FC<PaymentViewProps> = (props: PaymentViewProps) => {
121129
<div className={styles.auditSection}>
122130
{auditLines && auditLines.length > 0 && auditLines.map(line => (
123131
<Collapsible
132+
key={line.id}
124133
header={(
125134
<h3>
126135
{

src/apps/wallet-admin/src/lib/components/payments-table/PaymentTable.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface PaymentTableProps {
1818
onNextPageClick: () => void;
1919
onPreviousPageClick: () => void;
2020
onPageClick: (pageNumber: number) => void;
21+
canEdit: boolean;
2122
}
2223

2324
const PaymentsTable: React.FC<PaymentTableProps> = (props: PaymentTableProps) => {
@@ -58,7 +59,7 @@ const PaymentsTable: React.FC<PaymentTableProps> = (props: PaymentTableProps) =>
5859
<td>{payment.releaseDate}</td>
5960
<td>{payment.datePaid}</td>
6061
<td className={styles.actionButtons}>
61-
{payment.status.toUpperCase() !== 'PAID' && (
62+
{props.canEdit && payment.status.toUpperCase() !== 'PAID' && (
6263
<Button
6364
icon={IconOutline.PencilIcon}
6465
size='sm'

0 commit comments

Comments
 (0)