mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-07-22 20:16:57 +00:00
Save and use user's locale preference
This commit is contained in:
Vendored
+1
-337
@@ -1,340 +1,4 @@
|
|||||||
import * as L from "leaflet";
|
|
||||||
|
|
||||||
// Use type safe message keys with `next-intl`
|
// Use type safe message keys with `next-intl`
|
||||||
type Messages = typeof import("./src/messages/fr.json");
|
type Messages = typeof import("./src/messages/fr.json");
|
||||||
|
|
||||||
declare global {
|
interface IntlMessages extends Messages {}
|
||||||
// Use type safe message keys with `next-intl`
|
|
||||||
interface IntlMessages extends Messages {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// For some reason, @types/leaflet.markercluster isn't being recognized
|
|
||||||
// I'm including it here by hand
|
|
||||||
declare module "leaflet" {
|
|
||||||
class MarkerCluster extends Marker {
|
|
||||||
/*
|
|
||||||
* Recursively retrieve all child markers of this cluster.
|
|
||||||
*/
|
|
||||||
getAllChildMarkers(): Marker[];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the count of how many child markers we have.
|
|
||||||
*/
|
|
||||||
getChildCount(): number;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Zoom to the minimum of showing all of the child markers, or the extents of this cluster.
|
|
||||||
*/
|
|
||||||
zoomToBounds(options?: FitBoundsOptions): void;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the cluster bounds.
|
|
||||||
*/
|
|
||||||
getBounds(): LatLngBounds;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Spiderfies the child markers of this cluster.
|
|
||||||
*/
|
|
||||||
spiderfy(): void;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Unspiderfies a cluster (opposite of spiderfy).
|
|
||||||
*/
|
|
||||||
unspiderfy(): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MarkerClusterGroupOptions extends LayerOptions {
|
|
||||||
/*
|
|
||||||
* The maximum radius that a cluster will cover from the central marker (in pixels). Default 80.
|
|
||||||
* Decreasing will make more, smaller clusters. You can also use a function that accepts
|
|
||||||
* the current map zoom and returns the maximum cluster radius in pixels
|
|
||||||
*/
|
|
||||||
maxClusterRadius?: number | ((zoom: number) => number) | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function used to create the cluster icon
|
|
||||||
*/
|
|
||||||
iconCreateFunction?:
|
|
||||||
| ((cluster: MarkerCluster) => Icon | DivIcon)
|
|
||||||
| undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Map pane where the cluster icons will be added.
|
|
||||||
* Defaults to L.Marker's default (currently 'markerPane')
|
|
||||||
*/
|
|
||||||
clusterPane?: string | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* When you click a cluster at any zoom level we spiderfy it
|
|
||||||
* so you can see all of its markers.
|
|
||||||
*/
|
|
||||||
spiderfyOnEveryZoom?: boolean | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* When you click a cluster at the bottom zoom level we spiderfy it
|
|
||||||
* so you can see all of its markers.
|
|
||||||
*/
|
|
||||||
spiderfyOnMaxZoom?: boolean | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* When you mouse over a cluster it shows the bounds of its markers.
|
|
||||||
*/
|
|
||||||
showCoverageOnHover?: boolean | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* When you click a cluster we zoom to its bounds.
|
|
||||||
*/
|
|
||||||
zoomToBoundsOnClick?: boolean | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If set to true, overrides the icon for all added markers to make them appear as a 1 size cluster.
|
|
||||||
*/
|
|
||||||
singleMarkerMode?: boolean | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If set, at this zoom level and below markers will not be clustered. This defaults to disabled.
|
|
||||||
*/
|
|
||||||
disableClusteringAtZoom?: number | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Clusters and markers too far from the viewport are removed from the map
|
|
||||||
* for performance.
|
|
||||||
*/
|
|
||||||
removeOutsideVisibleBounds?: boolean | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Smoothly split / merge cluster children when zooming and spiderfying.
|
|
||||||
* If L.DomUtil.TRANSITION is false, this option has no effect (no animation is possible).
|
|
||||||
*/
|
|
||||||
animate?: boolean | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If set to true (and animate option is also true) then adding individual markers to the
|
|
||||||
* MarkerClusterGroup after it has been added to the map will add the marker and animate it
|
|
||||||
* into the cluster. Defaults to false as this gives better performance when bulk adding markers.
|
|
||||||
* addLayers does not support this, only addLayer with individual Markers.
|
|
||||||
*/
|
|
||||||
animateAddingMarkers?: boolean | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Custom function to calculate spiderfy shape positions
|
|
||||||
*/
|
|
||||||
spiderfyShapePositions?:
|
|
||||||
| ((count: number, centerPoint: Point) => Point[])
|
|
||||||
| undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Increase from 1 to increase the distance away from the center that spiderfied markers are placed.
|
|
||||||
* Use if you are using big marker icons (Default: 1).
|
|
||||||
*/
|
|
||||||
spiderfyDistanceMultiplier?: number | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Allows you to specify PolylineOptions to style spider legs.
|
|
||||||
* By default, they are { weight: 1.5, color: '#222', opacity: 0.5 }.
|
|
||||||
*/
|
|
||||||
spiderLegPolylineOptions?: PolylineOptions | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Boolean to split the addLayers processing in to small intervals so that the page does not freeze.
|
|
||||||
*/
|
|
||||||
chunkedLoading?: boolean | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Time delay (in ms) between consecutive periods of processing for addLayers. Default to 50ms.
|
|
||||||
*/
|
|
||||||
chunkDelay?: number | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Time interval (in ms) during which addLayers works before pausing to let the rest of the page process.
|
|
||||||
* In particular, this prevents the page from freezing while adding a lot of markers. Defaults to 200ms.
|
|
||||||
*/
|
|
||||||
chunkInterval?: number | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Callback function that is called at the end of each chunkInterval.
|
|
||||||
* Typically used to implement a progress indicator. Defaults to null.
|
|
||||||
*/
|
|
||||||
chunkProgress?:
|
|
||||||
| ((
|
|
||||||
processedMarkers: number,
|
|
||||||
totalMarkers: number,
|
|
||||||
elapsedTime: number,
|
|
||||||
) => void)
|
|
||||||
| undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Options to pass when creating the L.Polygon(points, options) to show the bounds of a cluster.
|
|
||||||
* Defaults to empty
|
|
||||||
*/
|
|
||||||
polygonOptions?: PolylineOptions | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Cluster-related handler functions.
|
|
||||||
*/
|
|
||||||
type AnimationEndEventHandlerFn = (event: LeafletEvent) => void;
|
|
||||||
type SpiderfyEventHandlerFn = (event: MarkerClusterSpiderfyEvent) => void;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Event fired on spiderfy cluster actions.
|
|
||||||
*/
|
|
||||||
interface MarkerClusterSpiderfyEvent extends LeafletEvent {
|
|
||||||
/*
|
|
||||||
* The cluster that fired the event.
|
|
||||||
*/
|
|
||||||
cluster: MarkerCluster;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The markers in the cluster that fired the event.
|
|
||||||
*/
|
|
||||||
markers: Marker[];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Extend existing event handler function map to include cluster events.
|
|
||||||
*/
|
|
||||||
interface LeafletEventHandlerFnMap {
|
|
||||||
/*
|
|
||||||
* Fires when overlapping markers get spiderified.
|
|
||||||
*/
|
|
||||||
spiderfied?: SpiderfyEventHandlerFn | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fires when overlapping markers get unspiderified.
|
|
||||||
*/
|
|
||||||
unspiderfied?: SpiderfyEventHandlerFn | undefined;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fires when marker clustering/unclustering animation has completed.
|
|
||||||
*/
|
|
||||||
animationend?: AnimationEndEventHandlerFn | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Extend Evented to include cluster events.
|
|
||||||
*/
|
|
||||||
interface Evented {
|
|
||||||
on(
|
|
||||||
type: "spiderfied" | "unspiderfied",
|
|
||||||
fn?: SpiderfyEventHandlerFn,
|
|
||||||
context?: any,
|
|
||||||
): this;
|
|
||||||
on(
|
|
||||||
type: "animationend",
|
|
||||||
fn?: AnimationEndEventHandlerFn,
|
|
||||||
context?: any,
|
|
||||||
): this;
|
|
||||||
|
|
||||||
off(
|
|
||||||
type: "spiderfied" | "unspiderfied",
|
|
||||||
fn?: SpiderfyEventHandlerFn,
|
|
||||||
context?: any,
|
|
||||||
): this;
|
|
||||||
off(
|
|
||||||
type: "animationend",
|
|
||||||
fn?: AnimationEndEventHandlerFn,
|
|
||||||
context?: any,
|
|
||||||
): this;
|
|
||||||
|
|
||||||
once(
|
|
||||||
type: "spiderfied" | "unspiderfied",
|
|
||||||
fn?: SpiderfyEventHandlerFn,
|
|
||||||
context?: any,
|
|
||||||
): this;
|
|
||||||
once(
|
|
||||||
type: "animationend",
|
|
||||||
fn?: AnimationEndEventHandlerFn,
|
|
||||||
context?: any,
|
|
||||||
): this;
|
|
||||||
|
|
||||||
addEventListener(
|
|
||||||
type: "spiderfied" | "unspiderfied",
|
|
||||||
fn?: SpiderfyEventHandlerFn,
|
|
||||||
context?: any,
|
|
||||||
): this;
|
|
||||||
addEventListener(
|
|
||||||
type: "animationend",
|
|
||||||
fn?: AnimationEndEventHandlerFn,
|
|
||||||
context?: any,
|
|
||||||
): this;
|
|
||||||
|
|
||||||
removeEventListener(
|
|
||||||
type: "spiderfied" | "unspiderfied",
|
|
||||||
fn?: SpiderfyEventHandlerFn,
|
|
||||||
context?: any,
|
|
||||||
): this;
|
|
||||||
removeEventListener(
|
|
||||||
type: "animationend",
|
|
||||||
fn?: AnimationEndEventHandlerFn,
|
|
||||||
context?: any,
|
|
||||||
): this;
|
|
||||||
|
|
||||||
addOneTimeEventListener(
|
|
||||||
type: "spiderfied" | "unspiderfied",
|
|
||||||
fn?: SpiderfyEventHandlerFn,
|
|
||||||
context?: any,
|
|
||||||
): this;
|
|
||||||
addOneTimeEventListener(
|
|
||||||
type: "animationend",
|
|
||||||
fn?: AnimationEndEventHandlerFn,
|
|
||||||
context?: any,
|
|
||||||
): this;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MarkerClusterGroup extends FeatureGroup {
|
|
||||||
constructor(options?: MarkerClusterGroupOptions);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Bulk methods for adding and removing markers and should be favoured over the
|
|
||||||
* single versions when doing bulk addition/removal of markers.
|
|
||||||
*/
|
|
||||||
addLayers(layers: Layer[], skipLayerAddEvent?: boolean): this;
|
|
||||||
|
|
||||||
removeLayers(layers: Layer[]): this;
|
|
||||||
|
|
||||||
clearLayers(): this;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If you have a marker in your MarkerClusterGroup and you want to get the visible
|
|
||||||
* parent of it
|
|
||||||
*/
|
|
||||||
getVisibleParent(marker: Marker): Marker;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If you have customized the clusters icon to use some data from the contained markers,
|
|
||||||
* and later that data changes, use this method to force a refresh of the cluster icons.
|
|
||||||
*/
|
|
||||||
refreshClusters(
|
|
||||||
clusters?: Marker | Marker[] | LayerGroup | { [index: string]: Layer },
|
|
||||||
): this;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the total number of markers contained within that cluster.
|
|
||||||
*/
|
|
||||||
getChildCount(): number;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the array of total markers contained within that cluster.
|
|
||||||
*/
|
|
||||||
getAllChildMarkers(): Marker[];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns true if the given layer (marker) is in the cluster.
|
|
||||||
*/
|
|
||||||
hasLayer(layer: Layer): boolean;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Zooms to show the given marker (spiderfying if required),
|
|
||||||
* calls the callback when the marker is visible on the map.
|
|
||||||
*/
|
|
||||||
zoomToShowLayer(layer: Layer, callback?: () => void): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create a marker cluster group, optionally given marker cluster group options.
|
|
||||||
*/
|
|
||||||
function markerClusterGroup(
|
|
||||||
options?: MarkerClusterGroupOptions,
|
|
||||||
): MarkerClusterGroup;
|
|
||||||
}
|
|
||||||
|
|||||||
Vendored
+332
@@ -0,0 +1,332 @@
|
|||||||
|
import * as L from "leaflet";
|
||||||
|
|
||||||
|
// For some reason, @types/leaflet.markercluster isn't being recognized
|
||||||
|
// I'm including it here by hand
|
||||||
|
declare module "leaflet" {
|
||||||
|
class MarkerCluster extends Marker {
|
||||||
|
/*
|
||||||
|
* Recursively retrieve all child markers of this cluster.
|
||||||
|
*/
|
||||||
|
getAllChildMarkers(): Marker[];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the count of how many child markers we have.
|
||||||
|
*/
|
||||||
|
getChildCount(): number;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Zoom to the minimum of showing all of the child markers, or the extents of this cluster.
|
||||||
|
*/
|
||||||
|
zoomToBounds(options?: FitBoundsOptions): void;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the cluster bounds.
|
||||||
|
*/
|
||||||
|
getBounds(): LatLngBounds;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Spiderfies the child markers of this cluster.
|
||||||
|
*/
|
||||||
|
spiderfy(): void;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unspiderfies a cluster (opposite of spiderfy).
|
||||||
|
*/
|
||||||
|
unspiderfy(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MarkerClusterGroupOptions extends LayerOptions {
|
||||||
|
/*
|
||||||
|
* The maximum radius that a cluster will cover from the central marker (in pixels). Default 80.
|
||||||
|
* Decreasing will make more, smaller clusters. You can also use a function that accepts
|
||||||
|
* the current map zoom and returns the maximum cluster radius in pixels
|
||||||
|
*/
|
||||||
|
maxClusterRadius?: number | ((zoom: number) => number) | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function used to create the cluster icon
|
||||||
|
*/
|
||||||
|
iconCreateFunction?:
|
||||||
|
| ((cluster: MarkerCluster) => Icon | DivIcon)
|
||||||
|
| undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Map pane where the cluster icons will be added.
|
||||||
|
* Defaults to L.Marker's default (currently 'markerPane')
|
||||||
|
*/
|
||||||
|
clusterPane?: string | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When you click a cluster at any zoom level we spiderfy it
|
||||||
|
* so you can see all of its markers.
|
||||||
|
*/
|
||||||
|
spiderfyOnEveryZoom?: boolean | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When you click a cluster at the bottom zoom level we spiderfy it
|
||||||
|
* so you can see all of its markers.
|
||||||
|
*/
|
||||||
|
spiderfyOnMaxZoom?: boolean | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When you mouse over a cluster it shows the bounds of its markers.
|
||||||
|
*/
|
||||||
|
showCoverageOnHover?: boolean | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When you click a cluster we zoom to its bounds.
|
||||||
|
*/
|
||||||
|
zoomToBoundsOnClick?: boolean | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If set to true, overrides the icon for all added markers to make them appear as a 1 size cluster.
|
||||||
|
*/
|
||||||
|
singleMarkerMode?: boolean | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If set, at this zoom level and below markers will not be clustered. This defaults to disabled.
|
||||||
|
*/
|
||||||
|
disableClusteringAtZoom?: number | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Clusters and markers too far from the viewport are removed from the map
|
||||||
|
* for performance.
|
||||||
|
*/
|
||||||
|
removeOutsideVisibleBounds?: boolean | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Smoothly split / merge cluster children when zooming and spiderfying.
|
||||||
|
* If L.DomUtil.TRANSITION is false, this option has no effect (no animation is possible).
|
||||||
|
*/
|
||||||
|
animate?: boolean | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If set to true (and animate option is also true) then adding individual markers to the
|
||||||
|
* MarkerClusterGroup after it has been added to the map will add the marker and animate it
|
||||||
|
* into the cluster. Defaults to false as this gives better performance when bulk adding markers.
|
||||||
|
* addLayers does not support this, only addLayer with individual Markers.
|
||||||
|
*/
|
||||||
|
animateAddingMarkers?: boolean | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Custom function to calculate spiderfy shape positions
|
||||||
|
*/
|
||||||
|
spiderfyShapePositions?:
|
||||||
|
| ((count: number, centerPoint: Point) => Point[])
|
||||||
|
| undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Increase from 1 to increase the distance away from the center that spiderfied markers are placed.
|
||||||
|
* Use if you are using big marker icons (Default: 1).
|
||||||
|
*/
|
||||||
|
spiderfyDistanceMultiplier?: number | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allows you to specify PolylineOptions to style spider legs.
|
||||||
|
* By default, they are { weight: 1.5, color: '#222', opacity: 0.5 }.
|
||||||
|
*/
|
||||||
|
spiderLegPolylineOptions?: PolylineOptions | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Boolean to split the addLayers processing in to small intervals so that the page does not freeze.
|
||||||
|
*/
|
||||||
|
chunkedLoading?: boolean | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Time delay (in ms) between consecutive periods of processing for addLayers. Default to 50ms.
|
||||||
|
*/
|
||||||
|
chunkDelay?: number | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Time interval (in ms) during which addLayers works before pausing to let the rest of the page process.
|
||||||
|
* In particular, this prevents the page from freezing while adding a lot of markers. Defaults to 200ms.
|
||||||
|
*/
|
||||||
|
chunkInterval?: number | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Callback function that is called at the end of each chunkInterval.
|
||||||
|
* Typically used to implement a progress indicator. Defaults to null.
|
||||||
|
*/
|
||||||
|
chunkProgress?:
|
||||||
|
| ((
|
||||||
|
processedMarkers: number,
|
||||||
|
totalMarkers: number,
|
||||||
|
elapsedTime: number,
|
||||||
|
) => void)
|
||||||
|
| undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Options to pass when creating the L.Polygon(points, options) to show the bounds of a cluster.
|
||||||
|
* Defaults to empty
|
||||||
|
*/
|
||||||
|
polygonOptions?: PolylineOptions | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Cluster-related handler functions.
|
||||||
|
*/
|
||||||
|
type AnimationEndEventHandlerFn = (event: LeafletEvent) => void;
|
||||||
|
type SpiderfyEventHandlerFn = (event: MarkerClusterSpiderfyEvent) => void;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Event fired on spiderfy cluster actions.
|
||||||
|
*/
|
||||||
|
interface MarkerClusterSpiderfyEvent extends LeafletEvent {
|
||||||
|
/*
|
||||||
|
* The cluster that fired the event.
|
||||||
|
*/
|
||||||
|
cluster: MarkerCluster;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The markers in the cluster that fired the event.
|
||||||
|
*/
|
||||||
|
markers: Marker[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extend existing event handler function map to include cluster events.
|
||||||
|
*/
|
||||||
|
interface LeafletEventHandlerFnMap {
|
||||||
|
/*
|
||||||
|
* Fires when overlapping markers get spiderified.
|
||||||
|
*/
|
||||||
|
spiderfied?: SpiderfyEventHandlerFn | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fires when overlapping markers get unspiderified.
|
||||||
|
*/
|
||||||
|
unspiderfied?: SpiderfyEventHandlerFn | undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fires when marker clustering/unclustering animation has completed.
|
||||||
|
*/
|
||||||
|
animationend?: AnimationEndEventHandlerFn | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extend Evented to include cluster events.
|
||||||
|
*/
|
||||||
|
interface Evented {
|
||||||
|
on(
|
||||||
|
type: "spiderfied" | "unspiderfied",
|
||||||
|
fn?: SpiderfyEventHandlerFn,
|
||||||
|
context?: any,
|
||||||
|
): this;
|
||||||
|
on(
|
||||||
|
type: "animationend",
|
||||||
|
fn?: AnimationEndEventHandlerFn,
|
||||||
|
context?: any,
|
||||||
|
): this;
|
||||||
|
|
||||||
|
off(
|
||||||
|
type: "spiderfied" | "unspiderfied",
|
||||||
|
fn?: SpiderfyEventHandlerFn,
|
||||||
|
context?: any,
|
||||||
|
): this;
|
||||||
|
off(
|
||||||
|
type: "animationend",
|
||||||
|
fn?: AnimationEndEventHandlerFn,
|
||||||
|
context?: any,
|
||||||
|
): this;
|
||||||
|
|
||||||
|
once(
|
||||||
|
type: "spiderfied" | "unspiderfied",
|
||||||
|
fn?: SpiderfyEventHandlerFn,
|
||||||
|
context?: any,
|
||||||
|
): this;
|
||||||
|
once(
|
||||||
|
type: "animationend",
|
||||||
|
fn?: AnimationEndEventHandlerFn,
|
||||||
|
context?: any,
|
||||||
|
): this;
|
||||||
|
|
||||||
|
addEventListener(
|
||||||
|
type: "spiderfied" | "unspiderfied",
|
||||||
|
fn?: SpiderfyEventHandlerFn,
|
||||||
|
context?: any,
|
||||||
|
): this;
|
||||||
|
addEventListener(
|
||||||
|
type: "animationend",
|
||||||
|
fn?: AnimationEndEventHandlerFn,
|
||||||
|
context?: any,
|
||||||
|
): this;
|
||||||
|
|
||||||
|
removeEventListener(
|
||||||
|
type: "spiderfied" | "unspiderfied",
|
||||||
|
fn?: SpiderfyEventHandlerFn,
|
||||||
|
context?: any,
|
||||||
|
): this;
|
||||||
|
removeEventListener(
|
||||||
|
type: "animationend",
|
||||||
|
fn?: AnimationEndEventHandlerFn,
|
||||||
|
context?: any,
|
||||||
|
): this;
|
||||||
|
|
||||||
|
addOneTimeEventListener(
|
||||||
|
type: "spiderfied" | "unspiderfied",
|
||||||
|
fn?: SpiderfyEventHandlerFn,
|
||||||
|
context?: any,
|
||||||
|
): this;
|
||||||
|
addOneTimeEventListener(
|
||||||
|
type: "animationend",
|
||||||
|
fn?: AnimationEndEventHandlerFn,
|
||||||
|
context?: any,
|
||||||
|
): this;
|
||||||
|
}
|
||||||
|
|
||||||
|
class MarkerClusterGroup extends FeatureGroup {
|
||||||
|
constructor(options?: MarkerClusterGroupOptions);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bulk methods for adding and removing markers and should be favoured over the
|
||||||
|
* single versions when doing bulk addition/removal of markers.
|
||||||
|
*/
|
||||||
|
addLayers(layers: Layer[], skipLayerAddEvent?: boolean): this;
|
||||||
|
|
||||||
|
removeLayers(layers: Layer[]): this;
|
||||||
|
|
||||||
|
clearLayers(): this;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If you have a marker in your MarkerClusterGroup and you want to get the visible
|
||||||
|
* parent of it
|
||||||
|
*/
|
||||||
|
getVisibleParent(marker: Marker): Marker;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If you have customized the clusters icon to use some data from the contained markers,
|
||||||
|
* and later that data changes, use this method to force a refresh of the cluster icons.
|
||||||
|
*/
|
||||||
|
refreshClusters(
|
||||||
|
clusters?: Marker | Marker[] | LayerGroup | { [index: string]: Layer },
|
||||||
|
): this;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the total number of markers contained within that cluster.
|
||||||
|
*/
|
||||||
|
getChildCount(): number;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the array of total markers contained within that cluster.
|
||||||
|
*/
|
||||||
|
getAllChildMarkers(): Marker[];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns true if the given layer (marker) is in the cluster.
|
||||||
|
*/
|
||||||
|
hasLayer(layer: Layer): boolean;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Zooms to show the given marker (spiderfying if required),
|
||||||
|
* calls the callback when the marker is visible on the map.
|
||||||
|
*/
|
||||||
|
zoomToShowLayer(layer: Layer, callback?: () => void): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a marker cluster group, optionally given marker cluster group options.
|
||||||
|
*/
|
||||||
|
function markerClusterGroup(
|
||||||
|
options?: MarkerClusterGroupOptions,
|
||||||
|
): MarkerClusterGroup;
|
||||||
|
}
|
||||||
Vendored
+17
@@ -0,0 +1,17 @@
|
|||||||
|
import NextAuth from "next-auth";
|
||||||
|
|
||||||
|
declare module "next-auth" {
|
||||||
|
interface User {
|
||||||
|
locale?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Session {
|
||||||
|
user: User;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module "@auth/core/adapters" {
|
||||||
|
interface AdapterUser {
|
||||||
|
locale?: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useSetAtom } from "jotai";
|
import { useSetAtom } from "jotai";
|
||||||
|
import { useSession } from "next-auth/react";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
import { FaGithub, FaRegEnvelope } from "react-icons/fa";
|
import { FaGithub, FaRegEnvelope } from "react-icons/fa";
|
||||||
import { MdOutlinePrivacyTip } from "react-icons/md";
|
import { MdOutlinePrivacyTip } from "react-icons/md";
|
||||||
|
|
||||||
import { burgerMenuIsOpenAtom } from "@/atoms";
|
import { burgerMenuIsOpenAtom } from "@/atoms";
|
||||||
|
import { setUserLocale } from "@/server/setUserLocale";
|
||||||
import { Link, usePathname, useRouter } from "@/utils/routing";
|
import { Link, usePathname, useRouter } from "@/utils/routing";
|
||||||
|
|
||||||
import ThemeSwitcher from "./ThemeSwitcher";
|
import ThemeSwitcher from "./ThemeSwitcher";
|
||||||
@@ -17,14 +19,19 @@ export default function Footer() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
|
const { status } = useSession();
|
||||||
|
|
||||||
const changeLanguage = (lang: string) => {
|
const changeLanguage = (lang: string) => {
|
||||||
|
// Store the user's locale preference if they're authenticated
|
||||||
|
if (status === "authenticated") setUserLocale(lang);
|
||||||
|
|
||||||
|
// Redirect to the same page with the new locale
|
||||||
router.push({ pathname, params: params as any }, { locale: lang });
|
router.push({ pathname, params: params as any }, { locale: lang });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<footer
|
<footer
|
||||||
className="fixed bottom-0 z-30 flex h-12 w-[100vw] flex-col items-center justify-center justify-items-center bg-primary-600 px-5 py-2 text-white dark:bg-gray-700"
|
className="fixed bottom-0 z-[1000] flex h-12 w-[100vw] flex-col items-center justify-center justify-items-center bg-primary-600 px-5 py-2 text-white dark:bg-gray-700"
|
||||||
data-test="footer"
|
data-test="footer"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { Inter, Julius_Sans_One } from "next/font/google";
|
|||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
import Script from "next/script";
|
import Script from "next/script";
|
||||||
|
|
||||||
|
import { LocaleChecker } from "@/components/LocaleChecker";
|
||||||
import "@/css/globals.css";
|
import "@/css/globals.css";
|
||||||
import Providers from "@/providers";
|
import Providers from "@/providers";
|
||||||
|
|
||||||
@@ -70,9 +71,11 @@ export default async function RootLayout({
|
|||||||
<body>
|
<body>
|
||||||
<Providers>
|
<Providers>
|
||||||
<NextIntlClientProvider locale={locale} messages={messages}>
|
<NextIntlClientProvider locale={locale} messages={messages}>
|
||||||
|
<LocaleChecker>
|
||||||
<div className="bg-white font-sans leading-normal tracking-normal dark:bg-gray-800">
|
<div className="bg-white font-sans leading-normal tracking-normal dark:bg-gray-800">
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
|
</LocaleChecker>
|
||||||
|
|
||||||
<Footer />
|
<Footer />
|
||||||
</NextIntlClientProvider>
|
</NextIntlClientProvider>
|
||||||
|
|||||||
@@ -31,4 +31,12 @@ export const {
|
|||||||
pages: {
|
pages: {
|
||||||
signIn: "/auth/sign-in",
|
signIn: "/auth/sign-in",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
callbacks: {
|
||||||
|
session: async ({ session, user }) => {
|
||||||
|
// Add the user's local to the session oject
|
||||||
|
session.user.locale = user.locale;
|
||||||
|
return session;
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
|
import { useSession } from "next-auth/react";
|
||||||
|
import { useLocale } from "next-intl";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
|
||||||
|
import { setUserLocale } from "@/server/setUserLocale";
|
||||||
|
import { usePathname, useRouter } from "@/utils/routing";
|
||||||
|
|
||||||
|
type LocaleCheckerProps = {
|
||||||
|
children?: React.ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const LocaleChecker = ({ children }: LocaleCheckerProps) => {
|
||||||
|
const { data: sessionData, status, update } = useSession();
|
||||||
|
const router = useRouter();
|
||||||
|
const pathname = usePathname();
|
||||||
|
const params = useParams();
|
||||||
|
const locale = useLocale();
|
||||||
|
|
||||||
|
const userLocale = sessionData?.user?.locale;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// If the user preference is not set, we set it to the current locale
|
||||||
|
if (status === "authenticated" && userLocale === undefined) {
|
||||||
|
setUserLocale(locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the user is authenticated and has a preferred locale that is different from the user's locale,
|
||||||
|
// then we update redirect to the user's preference
|
||||||
|
if (
|
||||||
|
status === "authenticated" &&
|
||||||
|
userLocale !== undefined &&
|
||||||
|
userLocale !== locale
|
||||||
|
) {
|
||||||
|
router.push({ pathname, params: params as any }, { locale: userLocale });
|
||||||
|
}
|
||||||
|
}, [locale, sessionData, status]);
|
||||||
|
|
||||||
|
// To avoid flickering, we don't render the children until we have the user's locale
|
||||||
|
if (status === "loading") return null;
|
||||||
|
if (
|
||||||
|
status === "authenticated" &&
|
||||||
|
userLocale !== undefined &&
|
||||||
|
userLocale !== locale
|
||||||
|
)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return children;
|
||||||
|
};
|
||||||
@@ -34,8 +34,6 @@ export const SignInForm = ({ callbackPath }: SignInFormProps) => {
|
|||||||
message: "",
|
message: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(path);
|
|
||||||
|
|
||||||
const form = useForm<SignInFormValues>({
|
const form = useForm<SignInFormValues>({
|
||||||
resolver: zodResolver(signInSchema),
|
resolver: zodResolver(signInSchema),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
"elo": "Calculette Elo",
|
"elo": "Calculette Elo",
|
||||||
"signIn": "Se connecter",
|
"signIn": "Se connecter",
|
||||||
"signOut": "Se déconnecter",
|
"signOut": "Se déconnecter",
|
||||||
"myZones": "Mes Régions",
|
"myZones": "Vos Régions",
|
||||||
"deleteAccount": "Supprimer le compte"
|
"deleteAccount": "Supprimer le compte"
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -220,16 +220,16 @@
|
|||||||
|
|
||||||
"Zones": {
|
"Zones": {
|
||||||
"title": "Vos régions",
|
"title": "Vos régions",
|
||||||
"info": "Vous pouvez définir des zones personnalisées pour recevoir des notifications par e-mail pour les tournois dans ces zones. Ces zones peuvent aussi être utiliser pour filtrer les tournois sur la carte.",
|
"info": "Vous pouvez définir des régions personnalisées pour recevoir des notifications par e-mail pour les tournois dans ces zones. Ces régions peuvent aussi être utiliser pour filtrer les tournois sur la carte.",
|
||||||
"logonRequired": "Vous devez être connecté pour accéder à cette fonctionnalité afin que nous puissions stocker vos régions personnalisées. Vous n'avez pas besoin de créer un compte, connectez-vous simplement avec votre adresse e-mail et nous vous enverrons un lien.",
|
"logonRequired": "Vous devez être connecté pour accéder à cette fonctionnalité afin que nous puissions stocker vos régions personnalisées. Vous n'avez pas besoin de créer un compte, connectez-vous simplement avec votre adresse e-mail et nous vous enverrons un lien.",
|
||||||
|
|
||||||
"noNotifications": "Vous n'avez pas activé les notifications par email pour cette région.",
|
"noNotifications": "Vous n'avez pas activé les notifications par email pour cette région.",
|
||||||
"withNotifications": "Vous allez recevoir des notifications par e-mail pour les nouveaux tournois de cadences <b>{list}</b> dans cette région.",
|
"withNotifications": "Vous allez recevoir des notifications par e-mail pour les nouveaux tournois de cadences <b>{list}</b> dans cette région.",
|
||||||
"addZoneButton": "Ajouter une région",
|
"addZoneButton": "Ajouter une région",
|
||||||
|
|
||||||
"yourZonesSelectGroupHeader": "Your Zones",
|
"yourZonesSelectGroupHeader": "Vos régions",
|
||||||
"ignoreMapOption": "Pas de filtre de région",
|
"ignoreMapOption": "Pas de filtre de région",
|
||||||
"createZoneSelectOption": "Create a new zone",
|
"createZoneSelectOption": "Créer une nouvelle région",
|
||||||
|
|
||||||
"createTitle": "Créer une nouvelle région",
|
"createTitle": "Créer une nouvelle région",
|
||||||
"editTitle": "Modifier région",
|
"editTitle": "Modifier région",
|
||||||
@@ -237,7 +237,7 @@
|
|||||||
"zoneNameLabel": "Nom de la région",
|
"zoneNameLabel": "Nom de la région",
|
||||||
"zoneNamePlaceholder": "Votre nom pour cette région",
|
"zoneNamePlaceholder": "Votre nom pour cette région",
|
||||||
"notificationsLabel": "Notifications",
|
"notificationsLabel": "Notifications",
|
||||||
"notificationsInfo": "Vous pouvez choisir d'activer les notifications pour les cadences qui vous intéressent, et vous recevrez un e-mail lorsqu'un nouveau tournoi est ajouté dans cette zone.",
|
"notificationsInfo": "Vous pouvez choisir d'activer les notifications pour les cadences qui vous intéressent, et vous recevrez un e-mail lorsqu'un nouveau tournoi est ajouté dans cette région.",
|
||||||
|
|
||||||
"createFailure": "Oups, quelque chose s'est mal passé. Veuillez réessayer.",
|
"createFailure": "Oups, quelque chose s'est mal passé. Veuillez réessayer.",
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
import { ObjectId } from "mongodb";
|
|
||||||
|
|
||||||
export type UserModel = {
|
|
||||||
email: string;
|
|
||||||
emailVerified?: Date;
|
|
||||||
locale: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type VerificationModel = {
|
|
||||||
identifier: string;
|
|
||||||
expires: Date;
|
|
||||||
};
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import mongoDB, { MongoClient } from "mongodb";
|
import mongoDB, { MongoClient } from "mongodb";
|
||||||
|
import { User } from "next-auth";
|
||||||
|
|
||||||
import { TournamentModel } from "@/server/models/tournamentModel";
|
import { TournamentModel } from "@/server/models/tournamentModel";
|
||||||
import { UserModel, VerificationModel } from "@/server/models/userModel";
|
|
||||||
import { ZoneModel } from "@/server/models/zoneModel";
|
import { ZoneModel } from "@/server/models/zoneModel";
|
||||||
|
|
||||||
import { ClubModel } from "./models/clubModel";
|
import { ClubModel } from "./models/clubModel";
|
||||||
@@ -9,9 +9,8 @@ import { ClubModel } from "./models/clubModel";
|
|||||||
export const collections: {
|
export const collections: {
|
||||||
tournaments?: mongoDB.Collection<TournamentModel>;
|
tournaments?: mongoDB.Collection<TournamentModel>;
|
||||||
clubs?: mongoDB.Collection<ClubModel>;
|
clubs?: mongoDB.Collection<ClubModel>;
|
||||||
users?: mongoDB.Collection<UserModel>;
|
users?: mongoDB.Collection<User>;
|
||||||
zones?: mongoDB.Collection<ZoneModel>;
|
zones?: mongoDB.Collection<ZoneModel>;
|
||||||
userVerificationTokens?: mongoDB.Collection<VerificationModel>;
|
|
||||||
} = {};
|
} = {};
|
||||||
|
|
||||||
if (!process.env.MONGODB_URI) {
|
if (!process.env.MONGODB_URI) {
|
||||||
@@ -53,9 +52,6 @@ export async function dbConnect() {
|
|||||||
|
|
||||||
const userData: mongoDB.Db = p.db("userData");
|
const userData: mongoDB.Db = p.db("userData");
|
||||||
collections.users = userData.collection("users");
|
collections.users = userData.collection("users");
|
||||||
collections.userVerificationTokens = userData.collection(
|
|
||||||
"userVerificationTokens",
|
|
||||||
);
|
|
||||||
collections.zones = userData.collection("zones");
|
collections.zones = userData.collection("zones");
|
||||||
|
|
||||||
const tournamentData: mongoDB.Db = p.db("tournamentsFranceDB");
|
const tournamentData: mongoDB.Db = p.db("tournamentsFranceDB");
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { ObjectId } from "mongodb";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { auth } from "@/auth";
|
||||||
|
import { collections, dbConnect } from "@/server/mongodb";
|
||||||
|
import { errorLog } from "@/utils/logger";
|
||||||
|
|
||||||
|
import { actionClient } from "./safeAction";
|
||||||
|
|
||||||
|
export const setUserLocale = actionClient
|
||||||
|
.schema(z.string())
|
||||||
|
.action(async (input) => {
|
||||||
|
try {
|
||||||
|
await dbConnect();
|
||||||
|
|
||||||
|
const user = await auth();
|
||||||
|
if (!user?.user) {
|
||||||
|
throw new Error("You must be logged update your locale");
|
||||||
|
}
|
||||||
|
|
||||||
|
await collections.users!.findOneAndUpdate(
|
||||||
|
{ _id: new ObjectId(user.user.id) },
|
||||||
|
{ $set: { locale: input.parsedInput } },
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
errorLog(error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
});
|
||||||
+3
-1
@@ -28,7 +28,9 @@
|
|||||||
"**/*.ts",
|
"**/*.ts",
|
||||||
"**/*.tsx",
|
"**/*.tsx",
|
||||||
".next/types/**/*.ts",
|
".next/types/**/*.ts",
|
||||||
"global.d.ts"
|
"global.d.ts",
|
||||||
|
"leaflet.d.ts",
|
||||||
|
"next-auth.d.ts"
|
||||||
],
|
],
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user