Skip to content

Commit 9763117

Browse files
committed
feat: clean up new project page
1 parent b6d3eb2 commit 9763117

File tree

3 files changed

+26
-34
lines changed

3 files changed

+26
-34
lines changed

frontend/app/components/admin/DateRangeField.vue

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
<script setup lang="ts">
22
import { parseDate, type DateValue } from '@internationalized/date'
33
4+
const props = defineProps<{
5+
placeholder?: string
6+
}>()
7+
48
const start = defineModel<string>('start')
59
const end = defineModel<string>('end')
610
711
const isOpen = ref(false)
812
913
function toDateString(dateStr: string | undefined): string | undefined {
10-
if (!dateStr) return undefined
14+
if (!dateStr || dateStr.trim() === '') return undefined
1115
// Handle both ISO timestamps and date-only strings
1216
return dateStr.split('T')[0]
1317
}
1418
1519
function toCalendarDate(dateStr: string | undefined): DateValue | undefined {
16-
if (!dateStr) return undefined
20+
if (!dateStr || dateStr.trim() === '') return undefined
1721
const dateOnly = toDateString(dateStr)
1822
if (!dateOnly) return undefined
1923
try {
@@ -76,9 +80,9 @@ const range = computed<{ start: DateValue; end: DateValue } | undefined>({
7680
})
7781
7882
function formatDate(dateStr: string | undefined) {
79-
if (!dateStr) return ''
83+
if (!dateStr || dateStr.trim() === '') return undefined
8084
const dateOnly = toDateString(dateStr)
81-
if (!dateOnly) return ''
85+
if (!dateOnly) return undefined
8286
const date = new Date(dateOnly + 'T00:00:00')
8387
return date.toLocaleDateString('en-US', {
8488
month: 'short',
@@ -100,19 +104,14 @@ const displayValue = computed(() => {
100104
if (endFormatted) {
101105
return endFormatted
102106
}
103-
return ''
107+
return props.placeholder || 'Select a date range'
104108
})
105109
</script>
106110

107111
<template>
108112
<UFormField label="Project duration">
109113
<UPopover v-model:open="isOpen" :ui="{ content: 'p-1' }">
110-
<UInput
111-
:model-value="displayValue"
112-
placeholder="Select date range"
113-
readonly
114-
icon="lucide:calendar"
115-
/>
114+
<UInput :model-value="displayValue" readonly icon="lucide:calendar" />
116115
<template #content>
117116
<UCalendar v-model="range" range />
118117
</template>

frontend/app/pages/admin/projects/[projectId]/edit.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ async function updateProject(event: FormSubmitEvent<Schema>) {
173173
</UFormField>
174174
<UButton type="submit" size="lg" block>Save changes</UButton>
175175
</UForm>
176-
<pre>{{ state }}</pre>
177176
</UContainer>
178177
</div>
179178
</template>

frontend/app/pages/admin/projects/new.vue

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -90,38 +90,32 @@ async function createProject(event: FormSubmitEvent<Schema>) {
9090
/>
9191
</UContainer>
9292
</div>
93-
<UContainer>
93+
<UContainer class="py-12">
9494
<UForm
9595
:state
9696
:schema="schema"
97-
class="space-y-6 py-12"
97+
class="flex max-w-md flex-col gap-6"
9898
@submit.prevent="createProject"
9999
>
100-
<UFormField name="name" label="Name" required>
101-
<UInput
102-
v-model="state.name"
103-
placeholder="New project"
104-
size="xl"
105-
type="text"
106-
autofocus
107-
required
108-
/>
100+
<UFormField name="name" label="Name">
101+
<UInput v-model="state.name" size="xl" required class="w-full" />
109102
</UFormField>
110-
<UFormField name="description" label="Description">
111-
<UTextarea v-model="state.description" class="w-sm" autoresize />
103+
<UFormField
104+
name="description"
105+
label="Description"
106+
hint="(optional)"
107+
help="This is only for admins to have better context"
108+
>
109+
<UTextarea v-model="state.description" class="w-full" autoresize />
112110
</UFormField>
113-
<div class="flex gap-4">
114-
<UFormField name="startDate" label="Starts at" required>
115-
<UInput v-model="state.startDate" type="date" required />
116-
</UFormField>
117-
<UFormField name="endDate" label="Ends at" required>
118-
<UInput v-model="state.endDate" type="date" required />
119-
</UFormField>
120-
</div>
111+
<DateRangeField
112+
v-model:start="state.startDate"
113+
v-model:end="state.endDate"
114+
/>
121115
<UFormField label="Accent color">
122116
<ColorPickerInput v-model="state.branding.colors.primary" />
123117
</UFormField>
124-
<UButton type="submit">Create project</UButton>
118+
<UButton type="submit" size="lg" block>Create project</UButton>
125119
</UForm>
126120
</UContainer>
127121
</div>

0 commit comments

Comments
 (0)