mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2026-03-13 18:21:57 +08:00
Compare commits
20 Commits
dashboard
...
feat/mobil
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3eef8c7a0b | ||
|
|
de54e7d8f8 | ||
|
|
5b87465b5a | ||
|
|
b88304e238 | ||
|
|
4d7a0f5d06 | ||
|
|
1cc34e61c4 | ||
|
|
5a19b890a9 | ||
|
|
df17366517 | ||
|
|
5648b14764 | ||
|
|
6076e8e8b5 | ||
|
|
1a351e3aeb | ||
|
|
4a71075340 | ||
|
|
7c60b8cfea | ||
|
|
128582fa40 | ||
|
|
27c3fcdb40 | ||
|
|
6b552b584a | ||
|
|
1b9628f826 | ||
|
|
0aa093b031 | ||
|
|
b7e5d83105 | ||
|
|
92996383cb |
@@ -4,6 +4,7 @@ import { sponsorHidden } from '../stores/page';
|
||||
import { useStore } from '@nanostores/react';
|
||||
import { X } from 'lucide-react';
|
||||
import { setViewSponsorCookie } from '../lib/jwt';
|
||||
import { isMobile } from '../lib/is-mobile';
|
||||
|
||||
export type PageSponsorType = {
|
||||
company: string;
|
||||
@@ -50,6 +51,7 @@ export function PageSponsor(props: PageSponsorProps) {
|
||||
`${import.meta.env.PUBLIC_API_URL}/v1-get-sponsor`,
|
||||
{
|
||||
href: window.location.pathname,
|
||||
mobile: isMobile() ? 'true' : 'false',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -75,9 +77,15 @@ export function PageSponsor(props: PageSponsorProps) {
|
||||
};
|
||||
|
||||
const clickSponsor = async (sponsorId: string) => {
|
||||
const { response, error } = await httpPatch<{ status: 'ok' }>(
|
||||
const clickUrl = new URL(
|
||||
`${import.meta.env.PUBLIC_API_URL}/v1-view-sponsor/${sponsorId}`,
|
||||
{},
|
||||
);
|
||||
|
||||
const { response, error } = await httpPatch<{ status: 'ok' }>(
|
||||
clickUrl.toString(),
|
||||
{
|
||||
mobile: isMobile() ? true : false,
|
||||
},
|
||||
);
|
||||
|
||||
if (error || !response) {
|
||||
|
||||
27
src/lib/is-mobile.ts
Normal file
27
src/lib/is-mobile.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
export function isAndroid(): boolean {
|
||||
return (
|
||||
typeof navigator !== 'undefined' && /android/i.test(navigator.userAgent)
|
||||
);
|
||||
}
|
||||
|
||||
export function isSmallIOS(): boolean {
|
||||
return (
|
||||
typeof navigator !== 'undefined' && /iPhone|iPod/.test(navigator.userAgent)
|
||||
);
|
||||
}
|
||||
|
||||
export function isLargeIOS(): boolean {
|
||||
return (
|
||||
typeof navigator !== 'undefined' &&
|
||||
(/iPad/.test(navigator.userAgent) ||
|
||||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1))
|
||||
);
|
||||
}
|
||||
|
||||
export function isIOS(): boolean {
|
||||
return isSmallIOS() || isLargeIOS();
|
||||
}
|
||||
|
||||
export function isMobile(): boolean {
|
||||
return isAndroid() || isIOS();
|
||||
}
|
||||
Reference in New Issue
Block a user