mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-11-18 07:22:06 +00:00
Fix routing details
This commit is contained in:
@@ -40,7 +40,7 @@ export function html(params: {
|
||||
<tr>
|
||||
<td align="center"
|
||||
style="padding: 10px 0px; font-size: 22px; font-family: Helvetica, Arial, sans-serif; color: ${color.text};">
|
||||
${t("email.subject", { host })}
|
||||
${t("email.subject", { host: escapedHost })}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -144,12 +144,10 @@ export default function Nodemailer(
|
||||
|
||||
const t = await getTranslations({ locale, namespace: "SignIn" });
|
||||
|
||||
console.log("Connection URL", url);
|
||||
|
||||
const { host } = new URL(url);
|
||||
|
||||
console.log(config);
|
||||
if (!(config.server as unknown as any)?.host) {
|
||||
console.log("Connection URL", url);
|
||||
console.log(text({ url, host, t }));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
function round(n: number) {
|
||||
return Math.round(n * 10) / 10;
|
||||
}
|
||||
|
||||
function polarToCartesian(radius: number, angleInDegrees: number) {
|
||||
var radians = ((angleInDegrees - 90) * Math.PI) / 180;
|
||||
|
||||
return {
|
||||
x: round(radius + radius * Math.cos(radians)),
|
||||
y: round(radius + radius * Math.sin(radians)),
|
||||
};
|
||||
}
|
||||
|
||||
function getDAttribute(radius: number, startAngle: number, endAngle: number) {
|
||||
const isCircle = endAngle - startAngle === 360;
|
||||
|
||||
if (isCircle) endAngle--;
|
||||
|
||||
const start = polarToCartesian(radius, startAngle);
|
||||
const end = polarToCartesian(radius, endAngle);
|
||||
|
||||
const largeArcFlag = endAngle - startAngle <= 180 ? 0 : 1;
|
||||
const d = [
|
||||
"M",
|
||||
start.x,
|
||||
start.y,
|
||||
"A",
|
||||
radius,
|
||||
radius,
|
||||
0,
|
||||
largeArcFlag,
|
||||
1,
|
||||
end.x,
|
||||
end.y,
|
||||
];
|
||||
|
||||
if (isCircle) {
|
||||
d.push("Z");
|
||||
} else {
|
||||
d.push("L", radius, radius, "L", start.x, start.y, "Z");
|
||||
}
|
||||
return d.join(" ");
|
||||
}
|
||||
|
||||
function path(d: string, colour: string) {
|
||||
return `<path d='${d}' style="fill: ${colour}" />`;
|
||||
}
|
||||
|
||||
function svg(className: string, width: number, content: string) {
|
||||
return `<svg class="${className}" viewBox="0 0 ${width} ${width}"><g class='pie'>${content}</g></svg>`;
|
||||
}
|
||||
|
||||
type PieSlice = {
|
||||
value: number;
|
||||
colour: string;
|
||||
};
|
||||
|
||||
export function generatePieSVG(
|
||||
className: string,
|
||||
radius: number,
|
||||
values: PieSlice[],
|
||||
) {
|
||||
type Sector = {
|
||||
colour: string;
|
||||
degrees: number;
|
||||
from?: number;
|
||||
to?: number;
|
||||
};
|
||||
|
||||
const total = values.reduce((a, b) => a + b.value, 0);
|
||||
const data: Sector[] = values.map(({ value, colour }) => ({
|
||||
colour,
|
||||
degrees: (value / total) * 360,
|
||||
}));
|
||||
|
||||
const paths = data.reduce<[number, string][]>((prev, value, i) => {
|
||||
const from = i === 0 ? 0 : prev[i - 1][0];
|
||||
const to = from + value.degrees;
|
||||
|
||||
return [...prev, [to, path(getDAttribute(radius, from, to), value.colour)]];
|
||||
}, []);
|
||||
|
||||
return svg(className, radius * 2, paths.map(([to, path]) => path).join(""));
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
import { createLocalizedPathnamesNavigation } from "next-intl/navigation";
|
||||
import { defineRouting } from "next-intl/routing";
|
||||
|
||||
export const locales = ["fr", "en"] as const;
|
||||
|
||||
export const routing = defineRouting({
|
||||
locales,
|
||||
locales: ["fr", "en"],
|
||||
defaultLocale: "fr",
|
||||
localePrefix: "as-needed",
|
||||
|
||||
Reference in New Issue
Block a user