mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-18 13:06:32 +00:00
fix: ui/ux issues (#34)
* fix select first bug for creation * add link to header * fix date and display errors * drop group name requirement
This commit is contained in:
parent
79f7ad40cb
commit
a6e3989aee
13 changed files with 33 additions and 46 deletions
|
@ -23,7 +23,8 @@ tasks:
|
||||||
python3 ./scripts/process-types.py ./frontend/lib/api/types/data-contracts.ts
|
python3 ./scripts/process-types.py ./frontend/lib/api/types/data-contracts.ts
|
||||||
sources:
|
sources:
|
||||||
- "./backend/app/api/**/*"
|
- "./backend/app/api/**/*"
|
||||||
- "./backend/app/internal/types/**/*"
|
- "./backend/internal/repo/**/*"
|
||||||
|
- "./backend/internal/services/**/*"
|
||||||
- "./scripts/process-types.py"
|
- "./scripts/process-types.py"
|
||||||
generates:
|
generates:
|
||||||
- "./frontend/lib/api/types/data-contracts.ts"
|
- "./frontend/lib/api/types/data-contracts.ts"
|
||||||
|
|
|
@ -1531,9 +1531,6 @@ const docTemplate = `{
|
||||||
"email": {
|
"email": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"groupName": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1523,9 +1523,6 @@
|
||||||
"email": {
|
"email": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"groupName": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
|
@ -322,8 +322,6 @@ definitions:
|
||||||
properties:
|
properties:
|
||||||
email:
|
email:
|
||||||
type: string
|
type: string
|
||||||
groupName:
|
|
||||||
type: string
|
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
password:
|
password:
|
||||||
|
|
|
@ -28,7 +28,6 @@ type (
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
GroupName string `json:"groupName"`
|
|
||||||
}
|
}
|
||||||
UserAuthTokenDetail struct {
|
UserAuthTokenDetail struct {
|
||||||
Raw string `json:"raw"`
|
Raw string `json:"raw"`
|
||||||
|
@ -46,7 +45,6 @@ func (svc *UserService) RegisterUser(ctx context.Context, data UserRegistration)
|
||||||
log.Debug().
|
log.Debug().
|
||||||
Str("name", data.Name).
|
Str("name", data.Name).
|
||||||
Str("email", data.Email).
|
Str("email", data.Email).
|
||||||
Str("groupName", data.GroupName).
|
|
||||||
Str("groupToken", data.GroupToken).
|
Str("groupToken", data.GroupToken).
|
||||||
Msg("Registering new user")
|
Msg("Registering new user")
|
||||||
|
|
||||||
|
@ -57,7 +55,7 @@ func (svc *UserService) RegisterUser(ctx context.Context, data UserRegistration)
|
||||||
)
|
)
|
||||||
|
|
||||||
if data.GroupToken == "" {
|
if data.GroupToken == "" {
|
||||||
group, err = svc.repos.Groups.GroupCreate(ctx, data.GroupName)
|
group, err = svc.repos.Groups.GroupCreate(ctx, "Home")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Err(err).Msg("Failed to create group")
|
log.Err(err).Msg("Failed to create group")
|
||||||
return repo.UserOut{}, err
|
return repo.UserOut{}, err
|
||||||
|
|
|
@ -68,11 +68,13 @@
|
||||||
|
|
||||||
<BaseContainer cmp="header" class="py-6 max-w-none">
|
<BaseContainer cmp="header" class="py-6 max-w-none">
|
||||||
<BaseContainer>
|
<BaseContainer>
|
||||||
<h2 class="mt-1 text-4xl font-bold tracking-tight text-neutral-content sm:text-5xl lg:text-6xl flex">
|
<NuxtLink to="/home">
|
||||||
HomeB
|
<h2 class="mt-1 text-4xl font-bold tracking-tight text-neutral-content sm:text-5xl lg:text-6xl flex">
|
||||||
<AppLogo class="w-12 -mb-4" />
|
HomeB
|
||||||
x
|
<AppLogo class="w-12 -mb-4" />
|
||||||
</h2>
|
x
|
||||||
|
</h2>
|
||||||
|
</NuxtLink>
|
||||||
<div class="ml-1 mt-2 text-lg text-neutral-content/75 space-x-2">
|
<div class="ml-1 mt-2 text-lg text-neutral-content/75 space-x-2">
|
||||||
<template v-for="link in links">
|
<template v-for="link in links">
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
|
|
|
@ -37,13 +37,22 @@
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const api = useUserApi();
|
||||||
|
const toast = useNotifier();
|
||||||
|
|
||||||
|
const locationsStore = useLocationStore();
|
||||||
|
const locations = computed(() => locationsStore.locations);
|
||||||
|
|
||||||
|
const labelStore = useLabelStore();
|
||||||
|
const labels = computed(() => labelStore.labels);
|
||||||
|
|
||||||
const submitBtn = ref(null);
|
const submitBtn = ref(null);
|
||||||
|
|
||||||
const modal = useVModel(props, "modelValue");
|
const modal = useVModel(props, "modelValue");
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const focused = ref(false);
|
const focused = ref(false);
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
location: {} as LocationOut,
|
location: locations.value && locations.value.length > 0 ? locations.value[0] : ({} as LocationOut),
|
||||||
name: "",
|
name: "",
|
||||||
description: "",
|
description: "",
|
||||||
color: "", // Future!
|
color: "", // Future!
|
||||||
|
@ -65,14 +74,6 @@
|
||||||
focused.value = true;
|
focused.value = true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const api = useUserApi();
|
|
||||||
const toast = useNotifier();
|
|
||||||
|
|
||||||
const locationsStore = useLocationStore();
|
|
||||||
const locations = computed(() => locationsStore.locations);
|
|
||||||
|
|
||||||
const labelStore = useLabelStore();
|
|
||||||
const labels = computed(() => labelStore.labels);
|
|
||||||
|
|
||||||
async function create() {
|
async function create() {
|
||||||
if (!form.location) {
|
if (!form.location) {
|
||||||
|
@ -88,7 +89,7 @@
|
||||||
|
|
||||||
const { error } = await api.items.create(out);
|
const { error } = await api.items.create(out);
|
||||||
if (error) {
|
if (error) {
|
||||||
toast.error("Couldn't create label");
|
toast.error("Couldn't create item");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nullDate(dt)) {
|
if (!validDate(dt)) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,10 +35,6 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function nullDate(dt: Date) {
|
|
||||||
return dt.getFullYear() === 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
date: {
|
date: {
|
||||||
type: [Date, String],
|
type: [Date, String],
|
||||||
|
|
|
@ -8,7 +8,6 @@ function userFactory(): UserRegistration {
|
||||||
email: faker.internet.email(),
|
email: faker.internet.email(),
|
||||||
password: faker.internet.password(),
|
password: faker.internet.password(),
|
||||||
name: faker.name.firstName(),
|
name: faker.name.firstName(),
|
||||||
groupName: faker.animal.cat(),
|
|
||||||
token: "",
|
token: "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,10 @@ export async function sharedUserClient(): Promise<UserClient> {
|
||||||
return userClient(cache.token);
|
return userClient(cache.token);
|
||||||
}
|
}
|
||||||
const testUser = {
|
const testUser = {
|
||||||
groupName: "test-group",
|
|
||||||
email: "__test__@__test__.com",
|
email: "__test__@__test__.com",
|
||||||
name: "__test__",
|
name: "__test__",
|
||||||
password: "__test__",
|
password: "__test__",
|
||||||
|
token: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
const api = client();
|
const api = client();
|
||||||
|
|
|
@ -219,7 +219,6 @@ export interface ServerValidationError {
|
||||||
|
|
||||||
export interface UserRegistration {
|
export interface UserRegistration {
|
||||||
email: string;
|
email: string;
|
||||||
groupName: string;
|
|
||||||
name: string;
|
name: string;
|
||||||
password: string;
|
password: string;
|
||||||
token: string;
|
token: string;
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
const username = ref("");
|
const username = ref("");
|
||||||
const email = ref("");
|
const email = ref("");
|
||||||
const groupName = ref("");
|
|
||||||
const password = ref("");
|
const password = ref("");
|
||||||
const canRegister = ref(false);
|
const canRegister = ref(false);
|
||||||
|
|
||||||
|
@ -50,7 +49,6 @@
|
||||||
name: username.value,
|
name: username.value,
|
||||||
email: email.value,
|
email: email.value,
|
||||||
password: password.value,
|
password: password.value,
|
||||||
groupName: groupName.value,
|
|
||||||
token: groupToken.value,
|
token: groupToken.value,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -152,8 +150,7 @@
|
||||||
</h2>
|
</h2>
|
||||||
<FormTextField v-model="email" label="Set your email?" />
|
<FormTextField v-model="email" label="Set your email?" />
|
||||||
<FormTextField v-model="username" label="What's your name?" />
|
<FormTextField v-model="username" label="What's your name?" />
|
||||||
<FormTextField v-if="groupToken == ''" v-model="groupName" label="Name your group" />
|
<div v-if="!(groupToken == '')" class="pt-4 pb-1 text-center">
|
||||||
<div v-else class="pt-4 pb-1 text-center">
|
|
||||||
<p>You're Joining an Existing Group!</p>
|
<p>You're Joining an Existing Group!</p>
|
||||||
<button type="button" class="text-xs underline" @click="groupToken = ''">
|
<button type="button" class="text-xs underline" @click="groupToken = ''">
|
||||||
Don't Want To Join a Group?
|
Don't Want To Join a Group?
|
||||||
|
|
|
@ -177,14 +177,14 @@
|
||||||
if (preferences.value.showEmpty) {
|
if (preferences.value.showEmpty) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return item.value?.purchaseFrom || item.value?.purchasePrice;
|
return item.value?.purchaseFrom || item.value?.purchasePrice !== "0";
|
||||||
});
|
});
|
||||||
|
|
||||||
const purchaseDetails = computed<(Detail | DateDetail)[]>(() => {
|
const purchaseDetails = computed<Array<Detail | DateDetail>>(() => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: "Purchase From",
|
name: "Purchase From",
|
||||||
label: item.value?.purchaseFrom || "",
|
text: item.value?.purchaseFrom || "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Purchase Price",
|
name: "Purchase Price",
|
||||||
|
@ -193,18 +193,19 @@
|
||||||
{
|
{
|
||||||
name: "Purchase Date",
|
name: "Purchase Date",
|
||||||
text: item.value.purchaseTime,
|
text: item.value.purchaseTime,
|
||||||
|
type: "date",
|
||||||
},
|
},
|
||||||
] as (Detail | DateDetail)[];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
const showSold = computed(() => {
|
const showSold = computed(() => {
|
||||||
if (preferences.value.showEmpty) {
|
if (preferences.value.showEmpty) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return item.value?.soldTo || item.value?.soldPrice;
|
return item.value?.soldTo || item.value?.soldPrice !== "0";
|
||||||
});
|
});
|
||||||
|
|
||||||
const soldDetails = computed<Array<Detail>>(() => {
|
const soldDetails = computed<Array<Detail | DateDetail>>(() => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: "Sold To",
|
name: "Sold To",
|
||||||
|
@ -217,8 +218,9 @@
|
||||||
{
|
{
|
||||||
name: "Sold At",
|
name: "Sold At",
|
||||||
text: item.value?.soldTime || "",
|
text: item.value?.soldTime || "",
|
||||||
|
type: "date",
|
||||||
},
|
},
|
||||||
] as Detail[];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
const confirm = useConfirm();
|
const confirm = useConfirm();
|
||||||
|
|
Loading…
Reference in a new issue