Skip to content

Commit

Permalink
feat: fees list
Browse files Browse the repository at this point in the history
  • Loading branch information
NyAndoMayah committed Nov 14, 2024
1 parent 527b0b6 commit eee6f0d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
8 changes: 6 additions & 2 deletions src/operations/fees/TransactionFeeList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Check,
Download,
} from "@mui/icons-material";
import {Chip} from "@mui/material";
import {Chip, Typography} from "@mui/material";
import {FeeStatusEnum} from "@haapi/typescript-client";
import {HaList} from "@/ui/haList/HaList";
import {EMPTY_TEXT} from "@/ui/constants";
Expand Down Expand Up @@ -57,7 +57,11 @@ const TransactionFeeList = () => {
<>
<ListHeader
cardContents={headerCardContent}
title="Liste des frais (en retard par défaut)"
title={
<Typography variant="h6" fontWeight="bold">
Statistiques des frais de ce mois-ci
</Typography>
}
/>
<HaList
icon={<Money />}
Expand Down
5 changes: 2 additions & 3 deletions src/operations/fees/components/StudentFeeList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ const CatchupFeesCreate = ({toggle}) => {

const MpbsCreate = ({toggle}) => {
const notify = useNotify();
const {id} = useRecordContext();
const {id: fee_id, mpbs} = useRecordContext();
const {id: student_id} = authProvider.getCachedWhoami();

return (
<Create
resource="fees"
Expand All @@ -172,7 +171,7 @@ const MpbsCreate = ({toggle}) => {
}
},
}}
transform={(data) => ({...data, student_id, id})}
transform={(data) => ({...data, student_id, fee_id, mpbs_id: mpbs?.id})}
>
<SimpleForm>
<TextInput
Expand Down
27 changes: 13 additions & 14 deletions src/providers/feeProvider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {WhoamiRoleEnum} from "@haapi/typescript-client";
import {payingApi} from "./api";
import {HaDataProviderType} from "./HaDataProviderType";
import {v4 as uuid} from "uuid";
import authProvider from "./authProvider";

const raSeparator = "--";
Expand Down Expand Up @@ -53,34 +54,32 @@ const feeProvider: HaDataProviderType = {
},

async saveOrUpdate(resources: Array<any>) {
const fees = resources[0];
const payload = resources[0];
const role = authProvider.getCachedRole();

if (fees?.psp_id) {
const fee = fees;
if (payload?.psp_id) {
const feeId = toApiIds(payload?.fee_id).feeId;

const feeId = toApiIds(fee?.id).feeId;

const createMpbs = {
student_id: fee?.student_id,
const mpbs = {
id: payload.mpbs_id ?? uuid(),
student_id: payload?.student_id,
fee_id: feeId,
psp_id: fee?.psp_id,
psp_type: fee?.psp_type,
psp_id: payload?.psp_id,
psp_type: payload?.psp_type,
};

return await payingApi()
.createMpbs(createMpbs?.student_id, createMpbs?.fee_id, createMpbs)
.then((result) => [{...result.data, ...fee}]);
.crupdateMpbs(mpbs?.student_id, mpbs?.fee_id, mpbs)
.then((result) => [{...result.data, ...payload}]);
}
console.log("role jhejhejheh", role);
if (role === WhoamiRoleEnum.STUDENT) {
return await payingApi()
.createStudentFees(fees[0].student_id, fees)
.createStudentFees(payload[0].student_id, payload)
.then((result) => result.data);
}
if (role === WhoamiRoleEnum.MANAGER) {
return await payingApi()
.crupdateStudentFees(fees)
.crupdateStudentFees(payload)
.then((result) => result.data);
}
},
Expand Down

0 comments on commit eee6f0d

Please sign in to comment.