feat: disable button on submit
This commit is contained in:
parent
6e42f5d55e
commit
92f3166eb1
|
@ -59,8 +59,8 @@ const LocationButton = ({ imageUrl = "#" }: { imageUrl?: string }) => {
|
||||||
<div className='flex flex-col justify-center items-center image-wrapper'>
|
<div className='flex flex-col justify-center items-center image-wrapper'>
|
||||||
<img src={imageUrl} className='blur-lg h-[450px]' />
|
<img src={imageUrl} className='blur-lg h-[450px]' />
|
||||||
|
|
||||||
<div className='flex flex-col justify-center gap-2 overlay'>
|
<div className='flex flex-col justify-center gap-4 overlay'>
|
||||||
<Button size={"lg"} onClick={() => setContentVisible(true)}>
|
<Button size='lg' className='text-md' onClick={() => setContentVisible(true)}>
|
||||||
<LockOpen1Icon className='mr-2 h-4 w-4' />
|
<LockOpen1Icon className='mr-2 h-4 w-4' />
|
||||||
İçeriğin Kilidi Açıldı
|
İçeriğin Kilidi Açıldı
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -73,8 +73,8 @@ const LocationButton = ({ imageUrl = "#" }: { imageUrl?: string }) => {
|
||||||
) : (
|
) : (
|
||||||
<div className='flex flex-col justify-center items-center image-wrapper'>
|
<div className='flex flex-col justify-center items-center image-wrapper'>
|
||||||
<img src={imageUrl} className='blur-lg h-[450px]' />
|
<img src={imageUrl} className='blur-lg h-[450px]' />
|
||||||
<div className='flex flex-col justify-center gap-2 overlay'>
|
<div className='flex flex-col justify-center gap-4 overlay'>
|
||||||
<Button size='lg'>
|
<Button size='lg' className='text-md'>
|
||||||
<LockClosedIcon className='mr-2 h-4 w-4' /> İçerik Kilitli
|
<LockClosedIcon className='mr-2 h-4 w-4' /> İçerik Kilitli
|
||||||
</Button>
|
</Button>
|
||||||
<Card className='p-2'>
|
<Card className='p-2'>
|
||||||
|
@ -87,8 +87,8 @@ const LocationButton = ({ imageUrl = "#" }: { imageUrl?: string }) => {
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
size={"sm"}
|
size='sm'
|
||||||
className='bg-green-700 hover:bg-green-600'
|
className='bg-green-700 hover:bg-green-600 text-md'
|
||||||
onClick={() => startWatchingLocation()}
|
onClick={() => startWatchingLocation()}
|
||||||
>
|
>
|
||||||
Konum İzni Ver
|
Konum İzni Ver
|
||||||
|
|
|
@ -9,20 +9,21 @@ import {
|
||||||
CardHeader,
|
CardHeader,
|
||||||
CardTitle,
|
CardTitle,
|
||||||
} from '@/components/ui/card';
|
} from '@/components/ui/card';
|
||||||
|
|
||||||
import { CalendarIcon } from '@radix-ui/react-icons';
|
import { CalendarIcon } from '@radix-ui/react-icons';
|
||||||
|
|
||||||
import '../styles/locked-page.css';
|
|
||||||
import LockedContent from '@/components/LockedContent';
|
import LockedContent from '@/components/LockedContent';
|
||||||
import { Separator } from '@/components/ui/separator';
|
import { Separator } from '@/components/ui/separator';
|
||||||
|
|
||||||
|
import '../styles/locked-page.css';
|
||||||
|
import type { ContentTable } from '@/lib/db';
|
||||||
|
|
||||||
|
type Content = Omit<ContentTable, 'id' | 'url'>;
|
||||||
|
|
||||||
const { id } = Astro.params;
|
const { id } = Astro.params;
|
||||||
|
|
||||||
const res = await fetch(`http://localhost:4321/api/content?id=${id}`);
|
const res = await fetch(`http://localhost:4321/api/content?id=${id}`);
|
||||||
|
|
||||||
const data = await res.json();
|
const data: Content | null = res.status === 200 ? await res.json() : null;
|
||||||
|
|
||||||
console.log(data);
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout>
|
<Layout>
|
||||||
|
@ -47,7 +48,7 @@ console.log(data);
|
||||||
<CardTitle>Abdurrahman</CardTitle>
|
<CardTitle>Abdurrahman</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<p>{data.description}</p>
|
<p>{data?.description}</p>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
<CardFooter className="gap-2">
|
<CardFooter className="gap-2">
|
||||||
<CalendarIcon />
|
<CalendarIcon />
|
||||||
|
@ -55,16 +56,16 @@ console.log(data);
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<LockedContent imageUrl={data.blob_url} client:load />
|
<LockedContent imageUrl={data?.blob_url} client:load />
|
||||||
|
|
||||||
<div
|
<div
|
||||||
id="map"
|
id="map"
|
||||||
class="w-full h-[450px] rounded"
|
class="w-full h-[450px] rounded"
|
||||||
data-target-location={data.loc}
|
data-target-location={data?.loc}
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button className="w-full">Paylaş</Button>
|
<Button className="w-full text-lg" size="lg">Paylaş</Button>
|
||||||
<div class="flex justify-center">
|
<div class="flex justify-center">
|
||||||
<p class="text-muted-foreground">
|
<p class="text-muted-foreground">
|
||||||
Fotoğrafın kilidi şu ana dek <b>2</b> kez açıldı
|
Fotoğrafın kilidi şu ana dek <b>2</b> kez açıldı
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { Button } from '@/components/ui/button';
|
||||||
import '../styles/locked-page.css';
|
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';
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout>
|
<Layout>
|
||||||
|
@ -95,7 +96,16 @@ import { Textarea } from '@/components/ui/textarea';
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button className="w-full" type="submit" id="submit-button">
|
<Button
|
||||||
|
className="w-full text-lg"
|
||||||
|
type="submit"
|
||||||
|
id="submit-button"
|
||||||
|
size="lg"
|
||||||
|
>
|
||||||
|
<ReloadIcon
|
||||||
|
className="mr-2 h-4 w-4 animate-spin hidden"
|
||||||
|
id="submit-button-reload"
|
||||||
|
/>
|
||||||
Bağlantıyı Oluştur
|
Bağlantıyı Oluştur
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
|
@ -104,21 +114,28 @@ import { Textarea } from '@/components/ui/textarea';
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import type { PutBlobResult } from '@vercel/blob';
|
|
||||||
|
|
||||||
const handleSubmit = async (e: SubmitEvent) => {
|
const handleSubmit = async (e: SubmitEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
const submitButton = document.getElementById(
|
||||||
|
'submit-button'
|
||||||
|
) as HTMLButtonElement;
|
||||||
|
const reloadIcon = document.getElementById(
|
||||||
|
'submit-button-reload'
|
||||||
|
) as HTMLElement;
|
||||||
|
|
||||||
|
submitButton.disabled = true;
|
||||||
|
reloadIcon.classList.toggle('hidden');
|
||||||
|
|
||||||
const formData = new FormData(e.target as HTMLFormElement);
|
const formData = new FormData(e.target as HTMLFormElement);
|
||||||
|
|
||||||
const response = await fetch(`/api/content`, {
|
await fetch(`/api/content`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData,
|
body: formData,
|
||||||
});
|
});
|
||||||
|
|
||||||
const newBlob = (await response.json()) as PutBlobResult;
|
reloadIcon.classList.toggle('hidden');
|
||||||
|
submitButton.disabled = false;
|
||||||
console.log(newBlob);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
document.getElementById('sample-form')!.onsubmit = handleSubmit;
|
document.getElementById('sample-form')!.onsubmit = handleSubmit;
|
Loading…
Reference in New Issue
Block a user