Working empty version

This commit is contained in:
Sean Edmunds
2024-08-28 17:06:37 -05:00
parent 7990f164d6
commit 18db0c17ff
18 changed files with 198 additions and 238 deletions

View File

@@ -13,9 +13,13 @@ import { useLocalStorage } from '@mantine/hooks';
export default function Homepage({ theme }: any) {
const { data, isFetching } = useQueryAPI({ endpoint: 'api/messages' });
const [displayedGreeting, setDisplayedGreeting] = useState('');
const [contentType, setContentType] = useLocalStorage<any>({
key: 'contenttype',
defaultValue: 'All',
const [appFilter, setAppFilter] = useLocalStorage<[any]>({
key: 'appFilter',
defaultValue: ['All'],
});
const [bookmarkFilter, setBookmarkFilter] = useLocalStorage<[any]>({
key: 'bookmarkFilter',
defaultValue: ['All'],
});
function date() {
const currentDate = new Date();
@@ -33,18 +37,18 @@ export default function Homepage({ theme }: any) {
const greet = Math.floor(currentTime.getHours() / 6);
const easterEggChance = Math.floor(Math.random() * 100);
let timeBased: any = [];
let easterEggs: any = [];
let customGreetings: any = [];
for (const l of list) {
if (l.easteregg === 'N') {
if (l.customGreeting === 0) {
timeBased = timeBased.concat(l);
} else {
easterEggs = easterEggs.concat(l);
customGreetings = customGreetings.concat(l);
}
}
if (easterEggChance > 10 || easterEggs.length === 0) {
if (easterEggChance > 10 || customGreetings.length === 0) {
return timeBased[greet].message;
}
return easterEggs[Math.floor(Math.random() * easterEggs.length)].message;
return customGreetings[Math.floor(Math.random() * customGreetings.length)].message;
}
useEffect(() => {
@@ -57,12 +61,14 @@ export default function Homepage({ theme }: any) {
<Stack gap={0} className={stackClasses.containerStack} justify='center'>
<Search />
<Header date={date()} greet={displayedGreeting} />
<Applications contentType={contentType} />
<Bookmarks contentType={contentType} />
<Applications contentType={appFilter} />
<Bookmarks contentType={bookmarkFilter} />
<SettingsButton
theme={theme}
contentType={contentType}
setContentType={setContentType}
setAppFilter={setAppFilter}
appFilter={appFilter}
setBookmarkFilter={setBookmarkFilter}
bookmarkFilter={bookmarkFilter}
/>
</Stack>
);