Skip to content

Commit bf4b81b

Browse files
committed
Add ship check for min 2h and description/url
1 parent e30651f commit bf4b81b

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

src/app.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233

234234
&:disabled,
235235
&.disabled {
236-
@apply cursor-not-allowed opacity-80 hover:outline-0;
236+
@apply cursor-not-allowed opacity-70 hover:outline-0;
237237
}
238238

239239
&.red {

src/routes/dashboard/projects/[id]/ship/+page.server.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ export async function load({ params, locals }) {
4646
throw error(404);
4747
}
4848

49-
// Make sure it has actual devlogs before shipping
50-
if (queriedProject.devlogCount == 0) {
51-
return error(400, { message: 'project has no devlogs' });
52-
}
53-
5449
return {
5550
project: queriedProject
5651
};
@@ -67,6 +62,8 @@ export const actions = {
6762
const [queriedProject] = await db
6863
.select({
6964
id: project.id,
65+
description: project.description,
66+
url: project.url,
7067
timeSpent: sql<number>`COALESCE(SUM(${devlog.timeSpent}), 0)`,
7168
devlogCount: sql<number>`COALESCE(COUNT(${devlog.id}), 0)`
7269
})
@@ -80,16 +77,20 @@ export const actions = {
8077
or(eq(project.status, 'building'), eq(project.status, 'rejected'))
8178
)
8279
)
83-
.groupBy(project.id)
80+
.groupBy(project.id, project.description, project.url)
8481
.limit(1);
8582

8683
if (!queriedProject) {
8784
return error(404, { message: 'project not found' });
8885
}
8986

90-
// Make sure it has actual devlogs before shipping
91-
if (queriedProject.devlogCount == 0) {
92-
return error(400, { message: 'project has no devlogs' });
87+
// Make sure it has atleast 2h
88+
if (queriedProject.timeSpent < 120) {
89+
return error(400, { message: 'minimum 2h needed to ship' });
90+
}
91+
92+
if (queriedProject.description == '' || queriedProject.url == '') {
93+
return error(400, { message: 'project must have a description and Printables url' });
9394
}
9495

9596
await db

src/routes/dashboard/projects/[id]/ship/+page.svelte

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@
2424
clickable={false}
2525
/>
2626
<p class="mt-3">
27-
Are you sure you want to ship "{data.project.name}"? You won't be able to edit it or journal again
28-
unless it gets rejected.
27+
{#if data.project.timeSpent < 120}
28+
You need at least 2h to ship
29+
{:else if data.project.description == '' || data.project.url == ''}
30+
Project must have a description and Printables URL to ship
31+
{:else}
32+
Are you sure you want to ship "{data.project.name}"? You won't be able to edit it or journal
33+
again unless it gets rejected.
34+
{/if}
2935
</p>
3036
<form
3137
method="POST"
@@ -39,7 +45,13 @@
3945
}}
4046
>
4147
<a href={`/dashboard/projects/${data.project.id}`} class="button sm primary">Cancel</a>
42-
<button class="button sm orange" disabled={formPending}>
48+
<button
49+
class="button sm orange"
50+
disabled={formPending ||
51+
data.project.timeSpent < 120 ||
52+
data.project.url == '' ||
53+
data.project.description == ''}
54+
>
4355
<Ship />
4456
Ship
4557
</button>

0 commit comments

Comments
 (0)