Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
proxy-manager-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aolda
proxy-manager-frontend
Commits
2a04d6be
Commit
2a04d6be
authored
2 months ago
by
한동현
Browse files
Options
Downloads
Patches
Plain Diff
feat: 라우팅 삭제 API 연동
parent
3c342280
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pages/routing/List.tsx
+47
-5
47 additions, 5 deletions
src/pages/routing/List.tsx
with
47 additions
and
5 deletions
src/pages/routing/List.tsx
+
47
−
5
View file @
2a04d6be
...
@@ -11,16 +11,27 @@ import { Badge } from '@/components/ui/badge';
...
@@ -11,16 +11,27 @@ import { Badge } from '@/components/ui/badge';
import
{
Skeleton
}
from
'
@/components/ui/skeleton
'
;
import
{
Skeleton
}
from
'
@/components/ui/skeleton
'
;
import
{
useAuthStore
}
from
'
@/stores/authStore
'
;
import
{
useAuthStore
}
from
'
@/stores/authStore
'
;
import
{
Routing
}
from
'
@/types/routing
'
;
import
{
Routing
}
from
'
@/types/routing
'
;
import
{
AlertDialog
,
AlertDialogContent
,
AlertDialogAction
,
AlertDialogCancel
,
AlertDialogHeader
,
AlertDialogTitle
,
AlertDialogDescription
,
AlertDialogFooter
,
}
from
'
@/components/ui/alert-dialog
'
;
export
default
function
RoutingList
()
{
export
default
function
RoutingList
()
{
const
{
authFetch
,
selectedProject
}
=
useAuthStore
();
const
{
authFetch
,
selectedProject
}
=
useAuthStore
();
const
[
routings
,
setRoutings
]
=
useState
<
Routing
[]
|
null
>
(
null
);
const
[
routings
,
setRoutings
]
=
useState
<
Routing
[]
|
null
>
(
null
);
const
[
selectedRouting
,
setSelectedRouting
]
=
useState
<
Routing
|
null
>
(
null
);
useEffect
(()
=>
{
useEffect
(()
=>
{
authFetch
(
`/api/routings?projectId=
${
selectedProject
?.
id
}
`
)
authFetch
(
`/api/routings?projectId=
${
selectedProject
?.
id
}
`
)
.
then
((
response
)
=>
{
.
then
((
response
)
=>
{
if
(
!
response
.
ok
)
{
if
(
!
response
.
ok
)
{
toast
.
error
(
'
포트포워딩
정보를 조회할 수 없습니다.
'
);
toast
.
error
(
'
라우팅
정보를 조회할 수 없습니다.
'
);
return
{
contents
:
[]
};
return
{
contents
:
[]
};
}
}
...
@@ -31,6 +42,24 @@ export default function RoutingList() {
...
@@ -31,6 +42,24 @@ export default function RoutingList() {
});
});
},
[
authFetch
,
selectedProject
]);
},
[
authFetch
,
selectedProject
]);
const
handleDelete
=
()
=>
{
if
(
selectedRouting
===
null
)
throw
Error
(
'
selectedRouting is null
'
);
authFetch
(
`/api/routing?routingId=
${
selectedRouting
.
id
}
`
,
{
method
:
'
DELETE
'
,
}).
then
((
response
)
=>
{
if
(
!
response
.
ok
)
{
console
.
error
(
response
);
toast
.
error
(
'
라우팅 설정 삭제에 실패했습니다
'
);
}
else
{
toast
.
warning
(
'
라우팅 설정이 삭제되었습니다
'
);
setRoutings
((
prev
)
=>
prev
!
.
filter
((
routing
)
=>
routing
.
id
!==
selectedRouting
.
id
));
}
});
setSelectedRouting
(
null
);
};
return
(
return
(
<
div
className
=
"flex flex-1 flex-col gap-4 p-6"
>
<
div
className
=
"flex flex-1 flex-col gap-4 p-6"
>
<
div
className
=
"flex justify-between mb-2"
>
<
div
className
=
"flex justify-between mb-2"
>
...
@@ -147,10 +176,8 @@ export default function RoutingList() {
...
@@ -147,10 +176,8 @@ export default function RoutingList() {
<
Pencil
/>
<
Pencil
/>
</
Link
>
</
Link
>
</
Button
>
</
Button
>
<
Button
variant
=
"secondary"
className
=
"size-8"
>
<
Button
variant
=
"secondary"
className
=
"size-8"
onClick
=
{
()
=>
setSelectedRouting
(
routing
)
}
>
<
Link
to
=
{
`./delete/
${
routing
.
id
}
`
}
>
<
Trash
/>
<
Trash
/>
</
Link
>
</
Button
>
</
Button
>
</
div
>
</
div
>
</
TableCell
>
</
TableCell
>
...
@@ -161,6 +188,21 @@ export default function RoutingList() {
...
@@ -161,6 +188,21 @@ export default function RoutingList() {
</
Table
>
</
Table
>
</
CardContent
>
</
CardContent
>
</
Card
>
</
Card
>
<
AlertDialog
open
=
{
selectedRouting
!==
null
}
onOpenChange
=
{
(
open
)
=>
open
||
setSelectedRouting
(
null
)
}
>
<
AlertDialogContent
>
<
AlertDialogHeader
>
<
AlertDialogTitle
>
웹 라우팅 설정 삭제
</
AlertDialogTitle
>
<
AlertDialogDescription
>
정말 '
{
selectedRouting
?.
name
}
' 라우팅 설정을 삭제하시겠습니까?
</
AlertDialogDescription
>
</
AlertDialogHeader
>
<
AlertDialogFooter
>
<
AlertDialogCancel
>
취소
</
AlertDialogCancel
>
<
AlertDialogAction
onClick
=
{
handleDelete
}
>
삭제
</
AlertDialogAction
>
</
AlertDialogFooter
>
</
AlertDialogContent
>
</
AlertDialog
>
</
div
>
</
div
>
);
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment