Skip to content

Commit eff3200

Browse files
committed
Merge branch 'develop' of https://github.com/diggerhq/digger into fix/breardon2011/fix-unique
2 parents cea7778 + 9d4d0ad commit eff3200

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

ui/src/api/statesman_orgs.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ export async function syncOrgToStatesman(orgId: string, orgName: string, display
1414
"external_org_id": orgId,
1515
"name": orgName,
1616
"display_name": displayName,
17-
"created_by": adminEmail,
1817
})
1918
})
2019

2120
if (response.status === 409) {
22-
console.log("Organization already exists in statesman")
21+
console.log("Org already exists in statesman")
2322
return response.json();
2423
}
2524

ui/src/api/statesman_units.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export async function createUnit(orgId: string, userId: string, email: string, n
169169
name: name,
170170
}),
171171
});
172-
console.log(response)
172+
173173
if (!response.ok) {
174174
throw new Error(`Failed to create unit: ${response.statusText}`);
175175
}

ui/src/api/statesman_users.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export async function syncUserToStatesman(userId: string, userEmail: string, org
2222
}
2323

2424
if (!response.ok) {
25-
console.log(response.text())
2625
throw new Error(`Failed to sync user: ${response.statusText}`);
2726
}
2827

ui/src/routes/_authenticated/_dashboard/dashboard/units.index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function CreateUnitModal({ onUnitCreated }: { onUnitCreated: () => void }) {
6767
setError(null)
6868

6969
try {
70-
await createUnitFn({
70+
const unit = await createUnitFn({
7171
data: {
7272
userId: user?.id!,
7373
organisationId,
@@ -129,10 +129,14 @@ function CreateUnitModal({ onUnitCreated }: { onUnitCreated: () => void }) {
129129
}
130130

131131
function RouteComponent() {
132-
const { unitsData } = Route.useLoaderData()
133-
const units = unitsData?.units || []
132+
const { unitsData, organisationId, user } = Route.useLoaderData()
133+
const [units, setUnits] = useState(unitsData?.units || [])
134134
const navigate = Route.useNavigate()
135135

136+
async function handleUnitCreated() {
137+
const unitsData = await listUnitsFn({data: {organisationId: organisationId, userId: user?.id || '', email: user?.email || ''}})
138+
setUnits(unitsData.units)
139+
}
136140
return (<>
137141
<div className="container mx-auto p-4">
138142
<div className="mb-6">
@@ -149,7 +153,7 @@ function RouteComponent() {
149153
<CardTitle>Units</CardTitle>
150154
<CardDescription>List of terraform state units and their current status</CardDescription>
151155
</div>
152-
<CreateUnitModal onUnitCreated={() => navigate({ to: '/dashboard/units' })} />
156+
<CreateUnitModal onUnitCreated={handleUnitCreated} />
153157
</CardHeader>
154158
<CardContent>
155159
{units.length === 0 ? (

ui/src/routes/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function Home() {
3232
</h1>
3333
<p className="mt-4 text-lg text-white/70">You're signed in. Head over to your dashboard to continue.</p>
3434
<div className="mt-8 flex items-center gap-4">
35-
<a href="/dashboard/repos" className="inline-flex items-center rounded-md bg-white px-5 py-3 font-medium text-black shadow-lg shadow-white/10 transition hover:bg-white/90">Go to dashboard</a>
35+
<a href="/dashboard/units" className="inline-flex items-center rounded-md bg-white px-5 py-3 font-medium text-black shadow-lg shadow-white/10 transition hover:bg-white/90">Go to dashboard</a>
3636
<a href="/logout" className="inline-flex items-center rounded-md bg-transparent border border-white px-5 py-3 font-medium text-white shadow-lg shadow-white/10 transition hover:bg-white/10">Logout</a>
3737
</div>
3838
</>

0 commit comments

Comments
 (0)