-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
477 additions
and
153 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 |
---|---|---|
@@ -1,12 +1,23 @@ | ||
import { sqliteTable, real, text, integer } from "drizzle-orm/sqlite-core" | ||
import { sqliteTable, real, text, integer } from "drizzle-orm/sqlite-core"; | ||
|
||
export const powerStatuses = sqliteTable("power_statuses", { | ||
id: text("id").primaryKey(), | ||
latitude: real("latitude").notNull(), | ||
longitude: real("longitude").notNull(), | ||
hasPower: integer("has_power", { mode: "boolean" }).notNull(), | ||
isOn: integer("has_power", { mode: "boolean" }).notNull(), | ||
createdAt: integer("created_at", { mode: "timestamp" }).notNull(), | ||
}) | ||
}); | ||
|
||
export type PowerStatus = typeof powerStatuses.$inferSelect | ||
export type InsertPowerStatus = typeof powerStatuses.$inferInsert | ||
export type PowerStatus = typeof powerStatuses.$inferSelect; | ||
export type InsertPowerStatus = typeof powerStatuses.$inferInsert; | ||
|
||
export const waterStatuses = sqliteTable("water_statuses", { | ||
id: text("id").primaryKey(), | ||
latitude: real("latitude").notNull(), | ||
longitude: real("longitude").notNull(), | ||
isOn: integer("has_water", { mode: "boolean" }).notNull(), | ||
createdAt: integer("created_at", { mode: "timestamp" }).notNull(), | ||
}); | ||
|
||
export type WaterStatus = typeof waterStatuses.$inferSelect; | ||
export type InsertWaterStatus = typeof waterStatuses.$inferInsert; |
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,52 @@ | ||
import { FC } from "react"; | ||
import { type Map } from "leaflet"; | ||
import { twMerge } from "tailwind-merge"; | ||
import TimeAgo from "./time-ago"; | ||
|
||
const StatusHistoryItem: FC<{ | ||
latitude: number; | ||
longitude: number; | ||
isOn: boolean; | ||
createdAt: Date; | ||
map: Map | null; | ||
type: string | "power" | "water"; | ||
}> = ({ latitude, longitude, isOn, createdAt, map, type }) => { | ||
return ( | ||
<button | ||
onClick={() => | ||
map?.flyTo([latitude, longitude], 16, { | ||
animate: true, | ||
duration: 0.8, | ||
}) | ||
} | ||
className={twMerge( | ||
"flex w-full items-center justify-between rounded border border-amber-500/30 bg-amber-400/20 p-2 font-mono text-xs", | ||
type === "water" && "border-cyan-500/30 bg-cyan-200 text-slate-800", | ||
!isOn && "border-slate-800 bg-slate-800 text-yellow-400", | ||
!isOn && type === "water" && "text-white bg-cyan-950", | ||
)} | ||
> | ||
<div | ||
className={twMerge( | ||
"flex w-full flex-row items-center justify-between gap-2 font-sans", | ||
)} | ||
> | ||
{type === "power" && | ||
(isOn ? ( | ||
<span className="mr-2 rounded-full bg-white p-1 text-3xl">💡</span> | ||
) : ( | ||
<span className="mr-2 rounded-full bg-white p-1 text-3xl">🕯️</span> | ||
))} | ||
{type === "water" && | ||
(isOn ? ( | ||
<span className="mr-2 rounded-full bg-white p-1 text-3xl">🚰</span> | ||
) : ( | ||
<span className="mr-2 rounded-full bg-white p-1 text-3xl">🚱</span> | ||
))} | ||
clique pour le voir sur la carte | ||
<TimeAgo date={createdAt} className="ml-auto" /> | ||
</div> | ||
</button> | ||
); | ||
}; | ||
export default StatusHistoryItem; |
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
Oops, something went wrong.