feat: add author field to creation form
This commit is contained in:
parent
42b80e3905
commit
9009ffe8ef
|
@ -9,5 +9,6 @@ export interface ContentTable {
|
||||||
url: string
|
url: string
|
||||||
blob_url: string
|
blob_url: string
|
||||||
loc: string
|
loc: string
|
||||||
|
author: string
|
||||||
description: string
|
description: string
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ const data: Content | null = res.status === 200 ? await res.json() : null;
|
||||||
|
|
||||||
<Card className="w-full">
|
<Card className="w-full">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle>Abdurrahman</CardTitle>
|
<CardTitle>{data?.author}</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<p>{data?.description}</p>
|
<p>{data?.description}</p>
|
||||||
|
|
|
@ -9,6 +9,7 @@ export const POST: APIRoute = async ({ request }) => {
|
||||||
const data = await request.formData()
|
const data = await request.formData()
|
||||||
|
|
||||||
const image = data.get("selected-photo") as File
|
const image = data.get("selected-photo") as File
|
||||||
|
const author = data.get("author")
|
||||||
const description = data.get("description")
|
const description = data.get("description")
|
||||||
const geolocation = data.get("geolocation")
|
const geolocation = data.get("geolocation")
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ export const POST: APIRoute = async ({ request }) => {
|
||||||
.values({
|
.values({
|
||||||
url: `${newUrl.slice(0, 3)}-${newUrl.slice(3, 7)}-${newUrl.slice(7)}`,
|
url: `${newUrl.slice(0, 3)}-${newUrl.slice(3, 7)}-${newUrl.slice(7)}`,
|
||||||
blob_url: blob.url,
|
blob_url: blob.url,
|
||||||
|
author: author?.toString() ?? "",
|
||||||
description: description?.toString() ?? "",
|
description: description?.toString() ?? "",
|
||||||
loc: `SRID=4326;POINT(${pos[0]} ${pos[1]})`
|
loc: `SRID=4326;POINT(${pos[0]} ${pos[1]})`
|
||||||
})
|
})
|
||||||
|
@ -76,7 +78,7 @@ export const GET: APIRoute = async ({ request }) => {
|
||||||
try {
|
try {
|
||||||
const content = await db
|
const content = await db
|
||||||
.selectFrom("contents")
|
.selectFrom("contents")
|
||||||
.select(({ fn }) => ["blob_url", fn<string>("ST_AsGeoJSON", ["loc"]).as("loc"), "description"])
|
.select(({ fn }) => ["blob_url", fn<string>("ST_AsGeoJSON", ["loc"]).as("loc"), "description", "author"])
|
||||||
.where("url", "=", contentId)
|
.where("url", "=", contentId)
|
||||||
.executeTakeFirst()
|
.executeTakeFirst()
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import '../styles/locked-page.css';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Textarea } from '@/components/ui/textarea';
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
import { ReloadIcon } from '@radix-ui/react-icons';
|
import { ReloadIcon } from '@radix-ui/react-icons';
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout>
|
<Layout>
|
||||||
|
@ -84,10 +85,21 @@ import { ReloadIcon } from '@radix-ui/react-icons';
|
||||||
>
|
>
|
||||||
3. Fotoğraf Açıklaması
|
3. Fotoğraf Açıklaması
|
||||||
</h2>
|
</h2>
|
||||||
<div class="grid w-full max-w-sm items-center gap-1.5 mt-4">
|
<div class="grid w-full max-w-sm items-center gap-2 mt-4">
|
||||||
|
<div class="grid w-full max-w-sm items-center gap-1.5">
|
||||||
|
<Label htmlFor="location-author">Gönderici</Label>
|
||||||
|
<Input
|
||||||
|
id="location-author"
|
||||||
|
name="author"
|
||||||
|
placeholder="İsminizi buraya yazınız."
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="grid w-full max-w-sm items-center gap-1.5">
|
||||||
|
<Label htmlFor="location-description">Açıklama</Label>
|
||||||
<Textarea
|
<Textarea
|
||||||
placeholder="Açıklamanızı buraya yazınız."
|
placeholder="Açıklamanızı buraya yazınız."
|
||||||
name="description"
|
name="description"
|
||||||
|
id="location-description"
|
||||||
/>
|
/>
|
||||||
<p class="text-sm text-muted-foreground">
|
<p class="text-sm text-muted-foreground">
|
||||||
Bir açıklama girin, yüklediğiniz içeriğin üzerine bu metin
|
Bir açıklama girin, yüklediğiniz içeriğin üzerine bu metin
|
||||||
|
@ -95,6 +107,7 @@ import { ReloadIcon } from '@radix-ui/react-icons';
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className="w-full text-lg"
|
className="w-full text-lg"
|
||||||
|
|
|
@ -22,6 +22,27 @@ var currentLocationIcon = L.icon({
|
||||||
|
|
||||||
let currentLocationMarker;
|
let currentLocationMarker;
|
||||||
|
|
||||||
|
let watchId = -1;
|
||||||
|
function startWatchingLocation() {
|
||||||
|
watchId = navigator.geolocation.watchPosition(
|
||||||
|
(position) => {
|
||||||
|
const pos = {
|
||||||
|
lat: position.coords.latitude,
|
||||||
|
lng: position.coords.longitude
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentLocationMarker) {
|
||||||
|
currentLocationMarker.setLatLng(pos);
|
||||||
|
} else {
|
||||||
|
currentLocationMarker = L.marker(pos, { icon: currentLocationIcon });
|
||||||
|
currentLocationMarker.addTo(map);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
() => null,
|
||||||
|
{ enableHighAccuracy: true, maximumAge: 10000, timeout: 57000 }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function onLocationError(e) {
|
function onLocationError(e) {
|
||||||
alert(e.message);
|
alert(e.message);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +60,10 @@ L.Control.GoToCurrentLocation = L.Control.extend({
|
||||||
locationButton.type = 'button'
|
locationButton.type = 'button'
|
||||||
|
|
||||||
locationButton.addEventListener('click', (ev) => {
|
locationButton.addEventListener('click', (ev) => {
|
||||||
if (currentLocationMarker) {
|
if (watchId === -1) {
|
||||||
|
startWatchingLocation()
|
||||||
|
map.setView(currentLocationMarker.getLatLng(), 12);
|
||||||
|
} else {
|
||||||
map.setView(currentLocationMarker.getLatLng(), 12);
|
map.setView(currentLocationMarker.getLatLng(), 12);
|
||||||
}
|
}
|
||||||
L.DomEvent.stopPropagation(ev)
|
L.DomEvent.stopPropagation(ev)
|
||||||
|
@ -76,28 +100,6 @@ navigator.permissions
|
||||||
() => null,
|
() => null,
|
||||||
{ enableHighAccuracy: true, maximumAge: 10000, timeout: 57000 }
|
{ enableHighAccuracy: true, maximumAge: 10000, timeout: 57000 }
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
permissionStatus.onchange = () => {
|
|
||||||
if (permissionStatus.state === 'granted') {
|
|
||||||
navigator.geolocation.watchPosition(
|
|
||||||
(position) => {
|
|
||||||
const pos = {
|
|
||||||
lat: position.coords.latitude,
|
|
||||||
lng: position.coords.longitude
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentLocationMarker) {
|
|
||||||
currentLocationMarker.setLatLng(pos);
|
|
||||||
} else {
|
|
||||||
currentLocationMarker = L.marker(pos, { icon: currentLocationIcon });
|
|
||||||
currentLocationMarker.addTo(map);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
() => null,
|
|
||||||
{ enableHighAccuracy: true, maximumAge: 10000, timeout: 57000 }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user