Skip to content
This repository was archived by the owner on Sep 22, 2025. It is now read-only.

Commit a5cc1b1

Browse files
committed
Merge branch 'staging' of https://github.com/EqualifyEverything/equalify-dashboard into staging
2 parents cc05cfc + c52c936 commit a5cc1b1

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

src/components/modals/Modal.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import * as Dialog from '@radix-ui/react-dialog';
22

3-
export const Modal = ({ open, setOpen, children, className = '' }) => (
3+
export const Modal = ({ open, setOpen, title, children, className = '' }) => (
44
<Dialog.Root open={open} onOpenChange={(value) => { setOpen(value) }}>
55
<Dialog.Portal>
66
<Dialog.Overlay className="bg-[#0009] data-[state=open]:animate-overlayShow fixed inset-0" />
77
<Dialog.Content className={`data-[state=open]:animate-contentShow fixed top-[30%] left-[50%] max-h-[85vh] w-[90vw] max-w-[770px] translate-x-[-50%] translate-y-[-50%] rounded-[6px] bg-background p-[10px] sm:p-[25px] shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] focus:outline-none ${className} z-40`}>
8-
<Dialog.Description className="text-text mt-1">
9-
{children}
10-
</Dialog.Description>
8+
<Dialog.Title id='modal-title' className='text-2xl'>{title}</Dialog.Title>
119
<Dialog.Close asChild>
1210
<button
1311
className="text-text absolute top-4 right-4 inline-flex h-6 w-6 items-center justify-center hover:opacity-50"
@@ -16,6 +14,9 @@ export const Modal = ({ open, setOpen, children, className = '' }) => (
1614
{`×`}
1715
</button>
1816
</Dialog.Close>
17+
<Dialog.Description className="text-text mt-1">
18+
{children}
19+
</Dialog.Description>
1920
</Dialog.Content>
2021
</Dialog.Portal>
2122
</Dialog.Root>

src/routes/protected/reports/message-details.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { QueryClient, useQuery } from '@tanstack/react-query';
22
import { ColumnDef } from '@tanstack/react-table';
3-
import { useState } from 'react';
3+
import { useEffect, useState } from 'react';
44
import { Link, LoaderFunctionArgs, useLoaderData } from 'react-router-dom';
55

66
import Timeline from '~/components/charts/timeline';
@@ -9,7 +9,6 @@ import { DataTable } from '~/components/tables';
99
import { messageDetailsQuery } from '~/queries';
1010
import { assertNonNull } from '~/utils/safety';
1111
import { post } from 'aws-amplify/api';
12-
import { InfoDialog } from '~/components/dialogs';
1312
import { Modal } from '~/components/modals';
1413

1514
interface Node {
@@ -24,6 +23,7 @@ interface Node {
2423
* @param queryClient - The Query Client instance.
2524
* @returns Loader function to be used with React Router.
2625
*/
26+
let suggestIndex = 0;
2727
export const messageDetailsLoader =
2828
(queryClient: QueryClient) =>
2929
async ({ params }: LoaderFunctionArgs) => {
@@ -60,7 +60,8 @@ const MessageDetails = () => {
6060

6161
const [suggestIssueResponse, setSuggestIssueResponse] = useState(null);
6262
const [open, setOpen] = useState(false);
63-
const suggestIssue = async ({ codeSnippet, pageUrl }) => {
63+
const suggestIssue = async ({ codeSnippet, pageUrl, index }) => {
64+
suggestIndex = index;
6465
setSuggestIssueResponse(null);
6566
setOpen(true);
6667
const response = await (await post({
@@ -81,6 +82,15 @@ const MessageDetails = () => {
8182
// if (!window.open(response?.url)) { window.location.href = response?.url }
8283
}
8384

85+
useEffect(() => {
86+
if (!open) {
87+
document.querySelector(`#suggest-${suggestIndex}`)?.focus();
88+
}
89+
else {
90+
document.querySelector(`#modal-title`)?.focus();
91+
}
92+
}, [open])
93+
8494
const NodeColumns: ColumnDef<Node>[] = [
8595
{
8696
accessorKey: 'codeSnippet',
@@ -105,8 +115,9 @@ const MessageDetails = () => {
105115
header: 'Action',
106116
cell: ({ row }) => (
107117
<button
118+
id={`suggest-${row.index}`}
108119
className={`inline-flex h-9 items-center justify-end gap-2 place-self-end whitespace-nowrap rounded-md px-2 py-3 text-white shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[#0d6efd] focus-visible:ring-offset-2 max-sm:w-fit max-sm:px-1 ml-2 bg-[#0d6efd] hover:opacity-50 text-xs`}
109-
onClick={() => suggestIssue({ codeSnippet: row.getValue('codeSnippet'), pageUrl: row.getValue('pageUrl') })}
120+
onClick={() => suggestIssue({ codeSnippet: row.getValue('codeSnippet'), pageUrl: row.getValue('pageUrl'), index: row.index })}
110121
>
111122
Suggest Issue
112123
<svg
@@ -200,11 +211,9 @@ const MessageDetails = () => {
200211
<Modal
201212
open={open}
202213
setOpen={setOpen}
214+
title={`Suggest Issue`}
203215
>
204-
<h1 className='text-2xl'>Suggest Issue</h1>
205-
{!suggestIssueResponse && <div>
206-
<h2>Generating issue... (ETA: 1 min)</h2>
207-
</div>}
216+
<div role='status'>{!suggestIssueResponse ? `Generating issue... (1 min)` : `Issue generated`}</div>
208217
{suggestIssueResponse && <div className='overflow-y-scroll max-h-[500px]'>
209218
{JSON.stringify({ suggestIssueResponse: suggestIssueResponse?.how_to_implement })}
210219
</div>}

0 commit comments

Comments
 (0)