Skip to content

Commit

Permalink
Merge pull request #168 from joshtyf/refactor/fix-service-request-inf…
Browse files Browse the repository at this point in the history
…o-page

Fix service request info page
  • Loading branch information
joshtyf authored Jun 1, 2024
2 parents 3eefe96 + 5af34e9 commit 602375d
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 645 deletions.
60 changes: 39 additions & 21 deletions backend/database/mongo_seed/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,9 @@ func main() {
CreatedOn: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
LastUpdated: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
FormData: models.FormData{
"param": "test_param",
"method": "get",
"key": "test_key",
"value": "test_value",
"token": "test_token",
"field1": "test sr 1",
"field2": "Option 1",
"field3": []string{"Option 1"},
},
}

Expand All @@ -341,11 +339,9 @@ func main() {
CreatedOn: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
LastUpdated: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
FormData: models.FormData{
"param": "test_param",
"method": "post",
"key": "test_key",
"value": "test_value",
"token": "test_token",
"field1": "test sr 2",
"field2": "Option 2",
"field3": []string{"Option 1", "Option 2"},
},
}

Expand All @@ -366,7 +362,9 @@ func main() {
CreatedOn: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
LastUpdated: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
FormData: models.FormData{
"param": "test_param",
"field1": "test sr 3",
"field2": "Option 3",
"field3": []string{"Option 1", "Option 2", "Option 3"},
},
}

Expand All @@ -387,7 +385,9 @@ func main() {
CreatedOn: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
LastUpdated: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
FormData: models.FormData{
"param": "test_param",
"field1": "test sr 4",
"field2": "Option 1",
"field3": []string{"Option 2"},
},
}

Expand All @@ -408,7 +408,9 @@ func main() {
CreatedOn: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
LastUpdated: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
FormData: models.FormData{
"param": "test_param",
"field1": "test sr 5",
"field2": "Option 1",
"field3": []string{"Option 2", "Option 3"},
},
}

Expand All @@ -429,7 +431,9 @@ func main() {
CreatedOn: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
LastUpdated: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
FormData: models.FormData{
"param": "test_param",
"field1": "test sr 6",
"field2": "Option 1",
"field3": []string{"Option 3"},
},
}

Expand All @@ -450,7 +454,9 @@ func main() {
CreatedOn: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
LastUpdated: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
FormData: models.FormData{
"param": "test_param",
"field1": "test sr 7",
"field2": "Option 1",
"field3": []string{},
},
}

Expand All @@ -471,7 +477,9 @@ func main() {
CreatedOn: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
LastUpdated: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
FormData: models.FormData{
"param": "test_param",
"field1": "test sr 8",
"field2": "Option 1",
"field3": []string{"Option 1"},
},
}

Expand All @@ -492,7 +500,9 @@ func main() {
CreatedOn: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
LastUpdated: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
FormData: models.FormData{
"param": "test_param",
"field1": "test sr 9",
"field2": "Option 1",
"field3": []string{"Option 1"},
},
}

Expand All @@ -513,7 +523,9 @@ func main() {
CreatedOn: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
LastUpdated: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
FormData: models.FormData{
"param": "test_param",
"field1": "test sr 10",
"field2": "Option 1",
"field3": []string{"Option 1"},
},
}

Expand All @@ -534,7 +546,9 @@ func main() {
CreatedOn: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
LastUpdated: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
FormData: models.FormData{
"param": "test_param",
"field1": "test sr 11",
"field2": "Option 1",
"field3": []string{"Option 1"},
},
}

Expand All @@ -555,7 +569,9 @@ func main() {
CreatedOn: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
LastUpdated: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
FormData: models.FormData{
"param": "test_param",
"field1": "test sr 12",
"field2": "Option 1",
"field3": []string{"Option 1"},
},
}

Expand All @@ -576,7 +592,9 @@ func main() {
CreatedOn: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
LastUpdated: time.Date(2024, time.January, 1, 1, 0, 0, 0, time.UTC),
FormData: models.FormData{
"param": "test_param",
"field1": "test sr 13",
"field2": "Option 1",
"field3": []string{"Option 1"},
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export default function AdminServiceRequestActions({
disabled={serviceRequest.status !== ServiceRequestStatus.PENDING}
onClick={() => setOpenRejectConfirmationDialog(true)}
>
{/* TODO: Add on click logic*/}
<Button variant="ghost" className="text-red-700 hover:text-red-500">
Reject
</Button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,226 +1,9 @@
import { toast } from "@/components/ui/use-toast"
import useOrganizationId from "@/hooks/use-organization-id"
import { getAllServiceRequestForAdmin } from "@/lib/service"
import { FormFieldType, JsonFormComponents } from "@/types/json-form-components"
import { StepStatus } from "@/types/pipeline"
import { ServiceRequest, ServiceRequestStatus } from "@/types/service-request"
import { useQuery } from "@tanstack/react-query"
import { useMemo } from "react"

const DUMMY_PIPELINE_FORM: JsonFormComponents = {
fields: [
{
name: "input",
title: "Input",
description: "",
type: FormFieldType.INPUT,
required: true,
placeholder: "Enter text...",
min_length: 1,
},
{
name: "select",
title: "Select",
description: "",
type: FormFieldType.SELECT,
required: true,
placeholder: "Select an option",
options: ["Option 1", "Option 2", "Option 3"],
default: "Option 1",
},
{
name: "checkbox",
title: "Checkbox",
description: "",
type: FormFieldType.CHECKBOXES,
options: ["Option 1", "Option 2", "Option 3"],
},
],
}

const DUMMY_SERVICE_REQUESTS: ServiceRequest[] = [
{
id: "1",
user_id: "123456", // DUMMY
pipeline_id: "65d48c02d62a1281c4f4ba3e",
pipeline_name: "Service 1",
pipeline_version: "0",
status: ServiceRequestStatus.PENDING,
created_on: "2024-02-21T19:50:01",
created_by: "User 1",
last_updated: "2024-02-21T19:50:01",
remarks: "",
pipeline: {
form: DUMMY_PIPELINE_FORM,
},
form_data: {},
first_step_name: "Approval",
steps: {
Approval: {
name: "Approval",
status: StepStatus.STEP_RUNNING,
next_step_name: "Create EC2",
},

"Create EC2": {
name: "Create EC2",
status: StepStatus.STEP_NOT_STARTED,
next_step_name: "",
},
},
},
{
id: "2",
user_id: "123456", // DUMMY
pipeline_id: "65d48c02d62a1281c4f4ba3e",
pipeline_name: "Service 1",
pipeline_version: "0",
status: ServiceRequestStatus.PENDING,
created_on: "2024-02-21T18:50:01",
created_by: "User 2",
last_updated: "2024-02-21T18:50:01",
remarks: "",
pipeline: {
form: DUMMY_PIPELINE_FORM,
},
first_step_name: "Approval",
form_data: {},
steps: {
Approval: {
name: "Approval",
status: StepStatus.STEP_RUNNING,
next_step_name: "Create EC2",
},

"Create EC2": {
name: "Create EC2",
status: StepStatus.STEP_NOT_STARTED,
next_step_name: "",
},
},
},
{
id: "3",
user_id: "123456", // DUMMY
pipeline_id: "65d48c02d62a1281c4f4ba3e",
pipeline_name: "Service 1",
pipeline_version: "0",
status: ServiceRequestStatus.PENDING,
created_on: "2024-02-21T17:00:00",
created_by: "User 3",
last_updated: "2024-02-21T17:00:00",
remarks: "",
pipeline: {
form: DUMMY_PIPELINE_FORM,
},
first_step_name: "Approval",
form_data: {},
steps: {
Approval: {
name: "Approval",
status: StepStatus.STEP_RUNNING,
next_step_name: "Create EC2",
},

"Create EC2": {
name: "Create EC2",
status: StepStatus.STEP_NOT_STARTED,
next_step_name: "",
},
},
},
{
id: "4",
user_id: "123456", // DUMMY
pipeline_id: "65d48c02d62a1281c4f4ba3e",
pipeline_name: "Service 1",
pipeline_version: "0",
status: ServiceRequestStatus.FAILED,
created_on: "2024-02-21T00:00:00",
created_by: "User 4",
last_updated: "2024-02-21T00:00:00",
remarks: "",
pipeline: {
form: DUMMY_PIPELINE_FORM,
},
first_step_name: "Approval",
form_data: {},
steps: {
Approval: {
name: "Approval",
status: StepStatus.STEP_COMPLETED,
next_step_name: "Create EC2",
},

"Create EC2": {
name: "Create EC2",
status: StepStatus.STEP_RUNNING,
next_step_name: "",
},
},
},
{
id: "5",
user_id: "123456", // DUMMY
pipeline_id: "65d48c02d62a1281c4f4ba3e",
pipeline_name: "Service 1",
pipeline_version: "0",
status: ServiceRequestStatus.FAILED,
created_on: "2024-02-20T00:00:00",
created_by: "User 1",
last_updated: "2024-02-20T00:00:00",
remarks: "",
pipeline: {
form: DUMMY_PIPELINE_FORM,
},
first_step_name: "Approval",
form_data: {},
steps: {
Approval: {
name: "Approval",
status: StepStatus.STEP_FAILED,
next_step_name: "Create EC2",
},

"Create EC2": {
name: "Create EC2",
status: StepStatus.STEP_NOT_STARTED,
next_step_name: "",
},
},
},
{
id: "6",
user_id: "123456", // DUMMY
pipeline_id: "65d48c02d62a1281c4f4ba3e",
pipeline_name: "Service 1",
pipeline_version: "0",
status: ServiceRequestStatus.RUNNING,
created_on: "2024-02-10T00:00:00",
created_by: "User 2",
last_updated: "2024-02-10T00:00:00",
remarks: "",
pipeline: {
form: DUMMY_PIPELINE_FORM,
},
first_step_name: "Approval",
form_data: {},
steps: {
Approval: {
name: "Approval",
status: StepStatus.STEP_COMPLETED,
next_step_name: "Create EC2",
},

"Create EC2": {
name: "Create EC2",
status: StepStatus.STEP_RUNNING,
next_step_name: "",
},
},
},
]

interface UseOrgServiceRequestsOptions {
page: number
pageSize: number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export const orgServiceRequestColumns: ColumnDef<ServiceRequest>[] = [
<AdminServiceRequestActions
serviceRequest={serviceRequest}
approveRequest={(serviceRequestId: string) => {
// TODO: Replace with actual approval action
approveServiceRequest(serviceRequestId)
.then(() => {
toast({
Expand Down
Loading

0 comments on commit 602375d

Please sign in to comment.