diff --git a/src/app/[locale]/(main)/match/components/FeuilleMatchPDF.tsx b/src/app/[locale]/(main)/match/components/FeuilleMatchPDF.tsx
index e5a7a4b..fb67744 100644
--- a/src/app/[locale]/(main)/match/components/FeuilleMatchPDF.tsx
+++ b/src/app/[locale]/(main)/match/components/FeuilleMatchPDF.tsx
@@ -1,14 +1,12 @@
-import { Document, Font, Page, Text, View } from "@react-pdf/renderer";
+import { Document, Page, Text, View } from "@react-pdf/renderer";
import { type MatchFormValues } from "@/app/[locale]/(main)/match/MatchForm";
import Header from "@/app/[locale]/(main)/match/components/pdf/Header";
import InfoTable from "@/app/[locale]/(main)/match/components/pdf/InfoTable";
+import Team from "@/app/[locale]/(main)/match/components/pdf/Team";
import { styles } from "./pdf/styles";
-// Register fonts if needed (optional)
-// Font.register({ family: 'Roboto', src: '...' });
-
interface PdfProps {
data: MatchFormValues;
}
@@ -18,6 +16,7 @@ export const FeuilleMatchPdf = ({ data }: PdfProps) => {
data.team1_players?.length || 0,
data.team2_players?.length || 0,
);
+
const boards = Array.from({ length: boardsCount });
return (
@@ -32,170 +31,43 @@ export const FeuilleMatchPdf = ({ data }: PdfProps) => {
- {/*Team Container*/}
+ {/* Main Content: Two Columns for Teams */}
- {/*Team Headers*/}
-
-
- CLUB RECEVANT (ayant les blancs sur l'échiquier 1)
- Code Club
-
-
- {data.team1}
- 2
-
-
+ {/* --- Team A Column --- */}
+
-
-
-
- CLUB SE DEPLACANT ( ayant les noirs sur l'échiquier 1)
-
- Code Club
-
-
- {data.team2}
- 2
-
-
+ {/* --- Team B Column --- */}
+
- {/*Board Header Container*/}
-
- Ech.
- Nom
- Code FFE
- ELO
- Result
-
-
-
- Ech.
- Nom
- Code FFE
- ELO
- Result
-
+ Capitaine A
+ Arbitre
+ Capitaine B
-
- {/*Boards Container*/}
-
-
- {boards.map((_, i) => (
-
-
- {`${i + 1}`} {i === 0 || i % 2 == 0 ? "B" : "N"}
-
- {data.team1_players[i]?.name || ""}
- {data.team1_players[i]?.nrFFE || ""}
- {data.team1_players[i]?.elo || ""}
-
- ))}
-
-
-
- {boards.map((_, i) => (
-
-
- {`${i + 1}`} {i === 0 || i % 2 == 0 ? "N" : "B"}
-
- {data.team2_players[i]?.name || ""}
- {data.team2_players[i]?.nrFFE || ""}
- {data.team2_players[i]?.elo || ""}
-
- ))}
-
-
-
- {/* Table Header */}
- {/**/}
- {/* Ech.*/}
- {/* Noms Prénoms (A)*/}
- {/* Elo*/}
- {/* Res.*/}
- {/* Noms Prénoms (B)*/}
- {/* Elo*/}
- {/**/}
-
- {/* Table Rows */}
- {/*{boards.map((_, i) => (*/}
- {/* */}
- {/* {i + 1}*/}
- {/* */}
- {/* {data.team1_players?.[i]?.name || ""}*/}
- {/* */}
- {/* */}
- {/* {data.team1_players?.[i]?.elo || ""}*/}
- {/* */}
- {/* /!* Result placeholder *!/*/}
- {/* */}
- {/* {data.team2_players?.[i]?.name || ""}*/}
- {/* */}
- {/* */}
- {/* {data.team2_players?.[i]?.elo || ""}*/}
- {/* */}
- {/* */}
- {/*))}*/}
-
- {/**/}
- {/* Capitaine A*/}
- {/* Arbitre*/}
- {/* Capitaine B*/}
- {/**/}
);
diff --git a/src/app/[locale]/(main)/match/components/pdf/Team.tsx b/src/app/[locale]/(main)/match/components/pdf/Team.tsx
new file mode 100644
index 0000000..f73850e
--- /dev/null
+++ b/src/app/[locale]/(main)/match/components/pdf/Team.tsx
@@ -0,0 +1,118 @@
+import { Text, View } from "@react-pdf/renderer";
+
+import { styles } from "@/app/[locale]/(main)/match/components/pdf/styles";
+import { Player } from "@/interfaces";
+
+const teamAHeaderText = "CLUB RECEVANT (Blancs échiquier 1)";
+const teamBHeaderText = "CLUB SE DEPLACANT (Noirs échiquier 1)";
+
+interface IProps {
+ team: "A" | "B";
+ teamName: string;
+ teamPlayers: Pick[];
+ boards: unknown[];
+}
+
+const Team = ({ team, teamName, teamPlayers, boards }: IProps) => {
+ const calculateBoardColor = ({
+ team,
+ boardNumber,
+ }: {
+ team: "A" | "B";
+ boardNumber: number;
+ }) => {
+ const option1 = team === "A" ? "B" : "N";
+ const option2 = team === "A" ? "N" : "B";
+ return boardNumber % 2 !== 0 ? option1 : option2;
+ };
+
+ return (
+
+ {/* Header Info */}
+
+
+ {team === "A" ? teamAHeaderText : teamBHeaderText}
+ Code Club
+
+
+ {teamName}
+
+
+
+
+ {/* Team Board Header */}
+
+ Ech.
+ Nom
+ Code FFE
+ ELO
+ Result
+
+
+ {/* Team Players List */}
+
+ {boards.map((_, i) => (
+
+
+ {`${i + 1}`} {calculateBoardColor({ team, boardNumber: i + 1 })}
+
+
+ {teamPlayers[i]?.name || ""}
+
+
+ {teamPlayers[i]?.nrFFE || ""}
+
+
+ {teamPlayers[i]?.elo || ""}
+
+
+
+ ))}
+
+
+ Gain: 1
+ Null: X
+ Perte: 0
+
+
+ );
+};
+
+export default Team;
diff --git a/src/app/[locale]/(main)/match/components/pdf/styles.ts b/src/app/[locale]/(main)/match/components/pdf/styles.ts
index c359344..1ebea1f 100644
--- a/src/app/[locale]/(main)/match/components/pdf/styles.ts
+++ b/src/app/[locale]/(main)/match/components/pdf/styles.ts
@@ -30,6 +30,7 @@ export const styles = StyleSheet.create({
boardHeaderRow: {
flexDirection: "row",
justifyContent: "space-between",
+ borderBottom: "1px solid black",
},
infoTable: {
borderWidth: 1,