Skip to content

Commit

Permalink
set default button
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-justin committed Dec 11, 2023
1 parent 7bd42a3 commit af405fb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
35 changes: 29 additions & 6 deletions src/pages/Admin/Charity/PayoutMethods/List/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BankingApplicationStatus, PayoutMethod } from "types/aws";
import { useUpdateBankingApplicationMutation } from "services/aws/banking-applications";
import TableSection, { Cells } from "components/TableSection";

type Props = {
Expand All @@ -19,14 +20,12 @@ export default function Table({ methods, classes = "" }: Props) {
type="th"
cellClass="px-3 py-4 text-xs uppercase font-semibold text-left first:rounded-tl last:rounded-tr"
>
<>Date</>
<>Endowment</>
<>Bank name</>
<></>
<>Account number</>
<>Bank name</>
<>Currency</>
<th className="text-center">Status</th>
<th className="text-center">Bank Statement</th>
<></>
<>default</>
</Cells>
</TableSection>
<TableSection
Expand All @@ -40,19 +39,43 @@ export default function Table({ methods, classes = "" }: Props) {
type="td"
cellClass="p-3 border-t border-prim max-w-[256px] truncate first:rounded-bl last:rounded-br"
>
<>{row.bankName}</>
<>-</>
<>{row.bankAccountNumber}</>
<>{row.bankName}</>
<>{row.payoutCurrency}</>
<td className="text-center">
<Status status={row.status} />
</td>
<SetDefaultBtn {...row} />
</Cells>
))}
</TableSection>
</table>
);
}

function SetDefaultBtn({
wiseRecipientID,
status,
thisPriorityNum,
topPriorityNum,
}: PayoutMethod) {
const [update] = useUpdateBankingApplicationMutation();

if (status !== "approved") return <></>;
if (thisPriorityNum === topPriorityNum && topPriorityNum !== 0)
return <>default</>;

return (
<button
type="button"
onClick={() => update({ type: "prioritize", uuid: wiseRecipientID })}
>
set default
</button>
);
}

const bg: { [key in BankingApplicationStatus]: string } = {
approved: "bg-green",
"under-review": "bg-gray-d1",
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Admin/Charity/PayoutMethods/PayoutMethods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export default function PayoutMethods() {
onClick={async () => {
await newApplication({
wiseRecipientID: window.crypto.randomUUID(),
bankAccountNumber: "1234",
bankName: "Bitcoin bank LTD",
bankAccountNumber: "3321",
bankName: "No coiners fiat bank",
endowmentID: 32,
payoutCurrency: "USD",
bankStatementFile: {
Expand Down

0 comments on commit af405fb

Please sign in to comment.