-
Notifications
You must be signed in to change notification settings - Fork 31
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
1 parent
f06e237
commit d951960
Showing
1 changed file
with
99 additions
and
86 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,86 +1,99 @@ | ||
import { useJSON } from '~/utils/useJSON' | ||
import { RequestHookResult } from '~/types/hooks' | ||
import { | ||
isGold, | ||
isSilver, | ||
isBronze, | ||
isBacker, | ||
sponsorsSortFn, | ||
sponsorsMapFn, | ||
} from './utils' | ||
import { SponsorsResponse, Sponsors, Sponsor } from './types' | ||
import { CONFIG } from '~/constants' | ||
import uniqBy from 'lodash/uniqBy' | ||
|
||
export { Sponsor } | ||
|
||
const SPONSORS_URL = `${CONFIG.apiURL}/sponsors?v2` | ||
|
||
export function useSponsors(): RequestHookResult<Sponsors> { | ||
const [result, meta] = useJSON<SponsorsResponse>(SPONSORS_URL) | ||
|
||
if (result) { | ||
return [ | ||
{ | ||
gold: uniqBy( | ||
result.data.account.orders.nodes | ||
.filter(isGold) | ||
.sort(sponsorsSortFn) | ||
.map(sponsorsMapFn), | ||
'id' | ||
), | ||
silver: uniqBy( | ||
(Date.now() < +new Date(2024, 3, 3) | ||
? [ | ||
{ | ||
id: 'slotzilla', | ||
url: 'https://www.slotozilla.com/de/', | ||
imageUrl: | ||
'https://firebasestorage.googleapis.com/v0/b/date-fns-org.appspot.com/o/sponsors%2Fslotzilla.png?alt=media&token=99f2558a-4714-4c57-bdb9-ad0aaf35eca2', | ||
name: 'Slotzilla', | ||
}, | ||
] | ||
: [] | ||
).concat( | ||
(Date.now() < +new Date(2024, 2, 10) | ||
? [ | ||
{ | ||
id: 'automatenspiele', | ||
url: | ||
'https://automatenspielex.com/online-casino-bonus/ohne-einzahlung', | ||
imageUrl: | ||
'https://firebasestorage.googleapis.com/v0/b/date-fns-org.appspot.com/o/sponsors%2Fautomatenspiele.png?alt=media&token=a722fa3f-9514-4932-a4f7-8b13246dcada', | ||
name: 'bonus ohne einzahlung', | ||
}, | ||
] | ||
: [] | ||
).concat( | ||
result.data.account.orders.nodes | ||
.filter(isSilver) | ||
.sort(sponsorsSortFn) | ||
.map(sponsorsMapFn) | ||
) | ||
), | ||
'id' | ||
), | ||
bronze: uniqBy( | ||
result.data.account.orders.nodes | ||
.filter(isBronze) | ||
.sort(sponsorsSortFn) | ||
.map(sponsorsMapFn), | ||
'id' | ||
), | ||
backers: uniqBy( | ||
result.data.account.orders.nodes | ||
.filter(isBacker) | ||
.sort(sponsorsSortFn) | ||
.map(sponsorsMapFn), | ||
'id' | ||
), | ||
}, | ||
meta, | ||
] | ||
} | ||
|
||
return [result, meta] | ||
} | ||
import { useJSON } from '~/utils/useJSON' | ||
import { RequestHookResult } from '~/types/hooks' | ||
import { | ||
isGold, | ||
isSilver, | ||
isBronze, | ||
isBacker, | ||
sponsorsSortFn, | ||
sponsorsMapFn, | ||
} from './utils' | ||
import { SponsorsResponse, Sponsors, Sponsor } from './types' | ||
import { CONFIG } from '~/constants' | ||
import uniqBy from 'lodash/uniqBy' | ||
|
||
export { Sponsor } | ||
|
||
const SPONSORS_URL = `${CONFIG.apiURL}/sponsors?v2` | ||
|
||
export function useSponsors(): RequestHookResult<Sponsors> { | ||
const [result, meta] = useJSON<SponsorsResponse>(SPONSORS_URL) | ||
|
||
if (result) { | ||
return [ | ||
{ | ||
gold: uniqBy( | ||
result.data.account.orders.nodes | ||
.filter(isGold) | ||
.sort(sponsorsSortFn) | ||
.map(sponsorsMapFn), | ||
'id' | ||
), | ||
silver: uniqBy( | ||
(Date.now() < +new Date(2024, 3, 28) | ||
? [ | ||
{ | ||
id: 'gamblewamble', | ||
url: 'https://gamblewamble.com/', | ||
imageUrl: | ||
'https://firebasestorage.googleapis.com/v0/b/date-fns-org.appspot.com/o/sponsors%2Fgamblewamble.png?alt=media&token=44a3705d-df0a-4697-8a61-56c135685c43', | ||
name: 'zugelassene online casinos deutschland', | ||
}, | ||
] | ||
: [] | ||
).concat( | ||
(Date.now() < +new Date(2024, 3, 3) | ||
? [ | ||
{ | ||
id: 'slotzilla', | ||
url: 'https://www.slotozilla.com/de/', | ||
imageUrl: | ||
'https://firebasestorage.googleapis.com/v0/b/date-fns-org.appspot.com/o/sponsors%2Fslotzilla.png?alt=media&token=99f2558a-4714-4c57-bdb9-ad0aaf35eca2', | ||
name: 'Slotzilla', | ||
}, | ||
] | ||
: [] | ||
).concat( | ||
(Date.now() < +new Date(2024, 2, 10) | ||
? [ | ||
{ | ||
id: 'automatenspiele', | ||
url: | ||
'https://automatenspielex.com/online-casino-bonus/ohne-einzahlung', | ||
imageUrl: | ||
'https://firebasestorage.googleapis.com/v0/b/date-fns-org.appspot.com/o/sponsors%2Fautomatenspiele.png?alt=media&token=a722fa3f-9514-4932-a4f7-8b13246dcada', | ||
name: 'bonus ohne einzahlung', | ||
}, | ||
] | ||
: [] | ||
).concat( | ||
result.data.account.orders.nodes | ||
.filter(isSilver) | ||
.sort(sponsorsSortFn) | ||
.map(sponsorsMapFn) | ||
) | ||
) | ||
), | ||
'id' | ||
), | ||
bronze: uniqBy( | ||
result.data.account.orders.nodes | ||
.filter(isBronze) | ||
.sort(sponsorsSortFn) | ||
.map(sponsorsMapFn), | ||
'id' | ||
), | ||
backers: uniqBy( | ||
result.data.account.orders.nodes | ||
.filter(isBacker) | ||
.sort(sponsorsSortFn) | ||
.map(sponsorsMapFn), | ||
'id' | ||
), | ||
}, | ||
meta, | ||
] | ||
} | ||
|
||
return [result, meta] | ||
} |