-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from dataforgoodfr/fixx-frontend
fix(frontend): correct compile error due to missing /lib folder
- Loading branch information
Showing
11 changed files
with
173 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
}, | ||
"rsc": false, | ||
"aliases": { | ||
"utils": "@/lib/utils", | ||
"utils": "@/libs/utils", | ||
"components": "@/components" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { JetBrains_Mono as FontMono, Inter as FontSans } from "next/font/google" | ||
|
||
export const fontSans = FontSans({ | ||
subsets: ["latin"], | ||
variable: "--font-sans", | ||
}) | ||
|
||
export const fontMono = FontMono({ | ||
subsets: ["latin"], | ||
variable: "--font-mono", | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import { VesselExcursionSegment, VesselExcursionSegments, VesselExcursionSegmentsGeo, VesselPosition } from "@/types/vessel" | ||
import { MapViewState } from "@deck.gl/core" | ||
import { createStore } from "zustand/vanilla" | ||
|
||
export interface ViewState { | ||
longitude: number | ||
latitude: number | ||
zoom: number | ||
pitch?: number | ||
bearing?: number | ||
transitionDuration?: number | ||
transitionInterpolator?: any | ||
} | ||
|
||
export type MapState = { | ||
count: number | ||
viewState: MapViewState | ||
latestPositions: VesselPosition[] | ||
activePosition: VesselPosition | null | ||
trackedVesselIDs: number[] | ||
trackedVesselSegments: VesselExcursionSegments[] | ||
} | ||
|
||
export type MapActions = { | ||
decrementCount: () => void | ||
incrementCount: () => void | ||
setViewState: (viewState: MapViewState) => void | ||
setZoom: (zoom: number) => void | ||
setLatestPositions: (latestPositions: VesselPosition[]) => void | ||
setActivePosition: (activePosition: VesselPosition | null) => void | ||
addTrackedVessel: (vesselID: number, segments: VesselExcursionSegment[]) => void | ||
removeTrackedVessel: (vesselID: number) => void | ||
clearLatestPositions: () => void | ||
cleartrackedVessels: () => void | ||
} | ||
|
||
export type MapStore = MapState & MapActions | ||
|
||
export const defaultInitState: MapState = { | ||
count: 0, | ||
viewState: { | ||
longitude: 3.788086, | ||
latitude: 47.840291, | ||
zoom: 5, | ||
pitch: 20, | ||
bearing: 0, | ||
}, | ||
latestPositions: [], | ||
activePosition: null, | ||
trackedVesselIDs: [], | ||
trackedVesselSegments: [] | ||
} | ||
|
||
export const createMapStore = (initState: MapState = defaultInitState) => { | ||
return createStore<MapStore>()((set) => ({ | ||
...initState, | ||
decrementCount: () => set((state) => ({ count: state.count - 1 })), | ||
incrementCount: () => set((state) => ({ count: state.count + 1 })), | ||
setViewState: (viewState?: MapViewState) => { | ||
set((state) => ({ | ||
...state, | ||
viewState, | ||
})) | ||
}, | ||
setZoom: (zoom: number) => { | ||
set((state) => ({ | ||
...state, | ||
viewState: { ...state.viewState, zoom }, | ||
})) | ||
}, | ||
setLatestPositions: (latestPositions: VesselPosition[]) => { | ||
set((state) => ({ | ||
...state, | ||
latestPositions, | ||
})) | ||
}, | ||
setActivePosition: (activePosition: VesselPosition | null) => { | ||
set((state) => ({ | ||
...state, | ||
activePosition, | ||
})) | ||
}, | ||
addTrackedVessel: (vesselId: number, segments: VesselExcursionSegment[]) => { | ||
set((state) => ({ | ||
...state, | ||
trackedVesselIDs: [...state.trackedVesselIDs, vesselId], | ||
trackedVesselSegments: [...state.trackedVesselSegments, { vesselId, segments }] | ||
})) | ||
}, | ||
removeTrackedVessel: (vesselId: number) => { | ||
set((state) => ({ | ||
...state, | ||
trackedVesselIDs: state.trackedVesselIDs.filter( | ||
(id) => id !== vesselId | ||
), | ||
trackedVesselSegments: state.trackedVesselSegments.filter( | ||
({vesselId}) => vesselId !== vesselId | ||
), | ||
})) | ||
}, | ||
clearLatestPositions: () => { | ||
set((state) => ({ | ||
...state, | ||
latestPositions: [], | ||
})) | ||
}, | ||
cleartrackedVessels: () => { | ||
set((state) => ({ | ||
...state, | ||
trackedVesselIDs: [], | ||
trackedVesselSegments: [] | ||
})) | ||
}, | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Vessel } from "@/types/vessel" | ||
import { createStore } from "zustand/vanilla" | ||
|
||
export type VesselsState = { | ||
count: number; | ||
vessels: Vessel[]; | ||
} | ||
|
||
export type MapActions = { | ||
decrementCount: () => void | ||
incrementCount: () => void | ||
setVessels: (vessels: Vessel[]) => void | ||
} | ||
|
||
export type VesselsStore = VesselsState & MapActions | ||
|
||
export const defaultInitState: VesselsState = { | ||
count: 0, | ||
vessels: [], | ||
} | ||
|
||
export const createVesselsStore = (initState: VesselsState = defaultInitState) => { | ||
return createStore<VesselsStore>()((set) => ({ | ||
...initState, | ||
decrementCount: () => set((state) => ({ count: state.count - 1 })), | ||
incrementCount: () => set((state) => ({ count: state.count + 1 })), | ||
setVessels: (vessels: Vessel[]) => { | ||
set((state) => ({ | ||
...state, | ||
vessels, | ||
})) | ||
} | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { clsx, type ClassValue } from "clsx" | ||
import { twMerge } from "tailwind-merge" | ||
|
||
export function cn(...inputs: ClassValue[]) { | ||
return twMerge(clsx(inputs)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters