Skip to content

Commit

Permalink
Merge pull request #78 from compsci-adl/main
Browse files Browse the repository at this point in the history
Production 2024-02-19_02
  • Loading branch information
rayokamoto authored Feb 19, 2024
2 parents 5ce88f4 + 1d8752f commit 5321596
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/app/admin/MemberForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,32 @@

import Autocomplete from '@/components/Autocomplete';
import { fetcher } from '@/lib/fetcher';
import { useState } from 'react';
import { useRouter } from 'next/navigation';
import { useEffect, useState } from 'react';
import useSWRMutation from 'swr/mutation';
import type { Member } from './page';

const getMemberStr = (member: Member) => `${member.email} - ${member.firstName} ${member.lastName}`;

function MemberDetail({ member }: { member: Member }) {
const { paid, ...details } = member;

const [payment, setPayment] = useState(member.paid);
useEffect(() => {
setPayment(member.paid);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [member.id]);

const router = useRouter();
const updatePayment = useSWRMutation('payment', fetcher.put.mutate, {
onSuccess: () => {
setPayment(!payment);
router.refresh();
},
});
const handlePaymentChange = () => {
updatePayment.trigger({ id: member.id, paid: !payment });
};

const { paid, ...details } = member;
return (
<table className="relative [&>tbody>*>*]:border [&>tbody>*>*]:border-grey [&>tbody>*>*]:px-4 [&>tbody>*>*]:py-2">
<tbody>
Expand Down

0 comments on commit 5321596

Please sign in to comment.