Skip to content

Commit 58888fc

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/main'
2 parents 58bfe3f + 59f736f commit 58888fc

File tree

18 files changed

+231
-61
lines changed

18 files changed

+231
-61
lines changed
41.8 KB
Binary file not shown.

apps/spuxx-client/src/assets/locales/de.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@ main:
33
page:
44
login:
55
login-via-oidc: Anmelden via auth.spuxx.dev
6+
root:
7+
title: Hallo {name}!
8+
not-found:
9+
title: Hoppla!
10+
text: Diese Seite kann ich nicht finden. Bist Du falsch abgebogen?
11+
back: Bring mich zurück!
612
lists:
713
component:
814
create-list-button:
915
title: Neue Liste
1016
new-list-name: Neue Liste
11-
17+
settings:
18+
title: Einstellungen
1219
layout:
1320
side-nav:
1421
lists:
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { ListItem as Item } from '@/services/api/lists/lists.types';
2+
import { Container } from '@spuxx/solid';
3+
import { Component } from 'solid-js';
4+
5+
interface Props {
6+
item: Item;
7+
}
8+
9+
export const ListItem: Component<Props> = (props) => {
10+
return (
11+
<Container variant="contained" color="surface">
12+
{props.item.text}
13+
</Container>
14+
);
15+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { List } from '@/services/api/lists/lists.types';
2+
import { Component, createEffect, createSignal, For, Show } from 'solid-js';
3+
import { ListItem } from './list-item.component';
4+
5+
interface Props {
6+
list: List;
7+
}
8+
9+
export const ListItems: Component<Props> = (props) => {
10+
const [checkedAmount, setCheckedAmount] = createSignal<number>(0);
11+
createEffect(() => {
12+
const checkedItems = props.list.items?.filter((item) => item.checked) ?? [];
13+
setCheckedAmount(checkedItems.length);
14+
});
15+
16+
return (
17+
<>
18+
<For each={props.list.items}>{(item) => <ListItem item={item} />}</For>
19+
<Show when={checkedAmount() > 0}>{checkedAmount()}</Show>
20+
</>
21+
);
22+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { List } from '@/services/api/lists/lists.types';
2+
import { intl } from '@spuxx/js-utils';
3+
import { Container } from '@spuxx/solid';
4+
import { Component } from 'solid-js';
5+
6+
interface Props {
7+
list: List;
8+
}
9+
10+
export const ListSettings: Component<Props> = (props) => {
11+
return <Container>{intl('lists.component.settings.title')}</Container>;
12+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { List } from '@/services/api/lists/lists.types';
2+
import { Container, Heading, Icon } from '@spuxx/solid';
3+
import { Component } from 'solid-js';
4+
import { ListItems } from './list-items.component';
5+
import { ListSettings } from './list-settings.component';
6+
7+
interface Props {
8+
list: List;
9+
}
10+
11+
export const ListView: Component<Props> = (props) => {
12+
return (
13+
<Container class="text-center">
14+
<Heading level={2}>
15+
<Icon icon={props.list.icon} />
16+
{props.list.name}
17+
</Heading>
18+
<ListItems list={props.list} />
19+
<ListSettings list={props.list} />
20+
</Container>
21+
);
22+
};

apps/spuxx-client/src/features/lists/lists.routes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ListPage } from './pages/list.page';
33

44
export const listsRoutes: RouteProps<string, never>[] = [
55
{
6-
path: '/list/:id',
6+
path: '/lists/:id',
77
component: ListPage,
88
},
99
];
Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
1-
import { Component } from 'solid-js';
1+
import { Api } from '@/services/api';
2+
import { List } from '@/services/api/lists/lists.types';
3+
import { Params, useParams } from '@solidjs/router';
4+
import { HttpRequestStatus } from '@spuxx/js-utils';
5+
import { Container, Icon } from '@spuxx/solid';
6+
import { Component, createEffect, createSignal, Show } from 'solid-js';
7+
import { ListView } from '../components/list-view.component';
28

39
export const ListPage: Component = () => {
4-
return <div>List</div>;
10+
const params = useParams<Params>();
11+
const [list, setList] = createSignal<List | null>(null);
12+
const [status, setStatus] = createSignal<HttpRequestStatus>(
13+
HttpRequestStatus.pending
14+
);
15+
createEffect(async () => {
16+
setStatus(HttpRequestStatus.pending);
17+
const request = Api.findListById({ args: { id: params.id } });
18+
await request.promise;
19+
setStatus(request.status);
20+
setList(request.transformedResult);
21+
});
22+
23+
createEffect(() => {});
24+
25+
return (
26+
<Container class="text-center m-auto">
27+
<Show when={status() === HttpRequestStatus.pending}>
28+
{/* TODO: Move to Loader component in @spuxx/solid? */}
29+
<Icon icon="svg-spinners:ring-resize" class="text-2xl" />
30+
</Show>
31+
<Show when={status() === HttpRequestStatus.success && list()}>
32+
<ListView list={list()!} />
33+
</Show>
34+
</Container>
35+
);
536
};

apps/spuxx-client/src/features/main/main.routes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { RouteProps } from '@solidjs/router';
22
import { RootPage } from './pages/root.page';
33
import { LoginPage } from './pages/login.page';
4+
import { NotFoundPage } from './pages/not-found.page';
45

56
export const mainRoutes: RouteProps<string, never>[] = [
67
{
@@ -11,4 +12,8 @@ export const mainRoutes: RouteProps<string, never>[] = [
1112
path: '/login',
1213
component: LoginPage,
1314
},
15+
{
16+
path: '/*',
17+
component: NotFoundPage,
18+
},
1419
];
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { intl } from '@spuxx/js-utils';
2+
import { ButtonLink, Container, Heading } from '@spuxx/solid';
3+
import { Component } from 'solid-js';
4+
5+
export const NotFoundPage: Component = () => {
6+
return (
7+
<Container class="text-center">
8+
<Heading level={2}>{intl('main.page.not-found.title')}</Heading>
9+
<p>{intl('main.page.not-found.text')}</p>
10+
<br />
11+
<ButtonLink
12+
href="/"
13+
variant="contained"
14+
color="primary"
15+
icon="mdi:arrow-left"
16+
>
17+
{intl('main.page.not-found.back')}
18+
</ButtonLink>
19+
</Container>
20+
);
21+
};

0 commit comments

Comments
 (0)