Skip to content

Commit 516e514

Browse files
committed
Obtain and display project in JobFormHeader
1 parent a317d2d commit 516e514

File tree

3 files changed

+52
-8
lines changed

3 files changed

+52
-8
lines changed

src/components/job/JobFormHeader.tsx

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
import { Skeleton } from '@heroui/skeleton';
12
import { DeploymentContextType, useDeploymentContext } from '@lib/contexts/deployment';
2-
import { FormType } from '@typedefs/deployment';
3+
import { routePath } from '@lib/routes/route-paths';
4+
import db from '@lib/storage/db';
5+
import { FormType, Project } from '@typedefs/deployment';
6+
import { useLiveQuery } from 'dexie-react-hooks';
7+
import { useEffect } from 'react';
38
import { RiArrowLeftLine } from 'react-icons/ri';
9+
import { useNavigate, useParams } from 'react-router-dom';
410

511
interface Props {
612
steps: string[];
@@ -9,11 +15,49 @@ interface Props {
915
function JobFormHeader({ steps }: Props) {
1016
const { formType, setFormType, step, setStep } = useDeploymentContext() as DeploymentContextType;
1117

18+
const navigate = useNavigate();
19+
const { id } = useParams();
20+
21+
const isValidId = id && !isNaN(parseInt(id)) && isFinite(parseInt(id));
22+
23+
// Only run the query if we have a valid ID
24+
const project: Project | undefined | null = useLiveQuery(
25+
isValidId ? () => db.projects.where('id').equals(parseInt(id)).first() : () => undefined,
26+
[isValidId, id],
27+
null, // Default value returned while data is loading
28+
);
29+
30+
useEffect(() => {
31+
if (project === undefined) {
32+
navigate(routePath.notFound);
33+
}
34+
}, [project]);
35+
36+
if (project === null) {
37+
return (
38+
<div className="col w-full gap-8">
39+
<Skeleton className="min-h-[82.5px] w-full rounded-lg" />
40+
<Skeleton className="min-h-[50px] w-full rounded-lg" />
41+
</div>
42+
);
43+
}
44+
45+
if (project === undefined) {
46+
return <></>;
47+
}
48+
1249
return (
1350
<div className="col w-full gap-8">
1451
<div className="col gap-4">
15-
<div className="big-title text-center">
16-
Deeploy a {formType} {formType === FormType.Service ? '' : 'App'}
52+
<div className="row justify-between">
53+
<div className="row gap-2">
54+
<div className="mt-[1px] h-2.5 w-2.5 rounded-full" style={{ backgroundColor: project.color }}></div>
55+
<div className="big-title max-w-[280px] truncate">{project.name}</div>
56+
</div>
57+
58+
<div className="big-title">
59+
Add a {formType} {formType === FormType.Service ? '' : 'App'} Job
60+
</div>
1761
</div>
1862

1963
<div className="col gap-2.5">
@@ -24,7 +68,7 @@ function JobFormHeader({ steps }: Props) {
2468
></div>
2569
</div>
2670

27-
<div className="flex justify-between">
71+
<div className="row justify-between">
2872
<RiArrowLeftLine
2973
className="-ml-0.5 cursor-pointer text-xl text-slate-500 hover:opacity-50"
3074
onClick={() => {
@@ -37,7 +81,7 @@ function JobFormHeader({ steps }: Props) {
3781
/>
3882

3983
<div
40-
className="cursor-pointer text-sm font-medium text-slate-500 hover:opacity-50"
84+
className="cursor-pointer text-[15px] font-medium text-slate-500 hover:opacity-50"
4185
onClick={() => setFormType(undefined)}
4286
>
4387
Cancel
@@ -50,7 +94,7 @@ function JobFormHeader({ steps }: Props) {
5094
<div className="text-sm font-semibold uppercase text-primary">
5195
Step {step} of {steps.length}
5296
</div>
53-
<div className="text-[22px] font-medium">{steps[step - 1]}</div>
97+
<div className="big-title">{steps[step - 1]}</div>
5498
</div>
5599
</div>
56100
);

src/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ body {
5050
}
5151

5252
.big-title {
53-
@apply text-lg font-semibold lg:text-[22px];
53+
@apply text-lg font-semibold lg:text-[20px];
5454
}
5555

5656
.list {

src/pages/deeploys/CreateProject.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function CreateProject() {
3232
};
3333

3434
const onError = (errors) => {
35-
console.log('[DeeployProject] Validation errors:', errors);
35+
console.log('[CreateProject] Validation errors:', errors);
3636
};
3737

3838
return (

0 commit comments

Comments
 (0)