(props: {
open: boolean;
setOpen: () => void;
apiKey: string;
setApiKey: (apiKey: string) => void;
})
| 557 | } |
| 558 | |
| 559 | export function EditAPIKeyModal(props: { |
| 560 | open: boolean; |
| 561 | setOpen: () => void; |
| 562 | apiKey: string; |
| 563 | setApiKey: (apiKey: string) => void; |
| 564 | }) { |
| 565 | const [localValue, setLocalValue] = useState(props.apiKey); |
| 566 | return ( |
| 567 | <Modal open={props.open} setOpen={props.setOpen} classNames="max-w-xl"> |
| 568 | <div className="w-full flex flex-col"> |
| 569 | <div |
| 570 | className={ |
| 571 | "flex flex-row gap-x-2 text-gray-300 place-items-center mb-2" |
| 572 | } |
| 573 | > |
| 574 | <CodeBracketIcon className={"h-6 w-6"} /> |
| 575 | <h1 className="text-lg text-gray-300">Edit API Key</h1> |
| 576 | </div> |
| 577 | <p className="text-sm text-gray-400 mb-3"> |
| 578 | API key used to access your API. |
| 579 | </p> |
| 580 | <input |
| 581 | className="rounded-md" |
| 582 | value={localValue} |
| 583 | onChange={(e) => setLocalValue(e.target.value)} |
| 584 | /> |
| 585 | <p className="w-full text-center text-sm text-gray-400 mt-1"> |
| 586 | This is never stored in our database. |
| 587 | </p> |
| 588 | <div className={"flex flex-row justify-end gap-x-2 mt-6"}> |
| 589 | <button |
| 590 | className={"bg-gray-500 rounded px-2 py-1 text-gray-50"} |
| 591 | onClick={props.setOpen} |
| 592 | > |
| 593 | Cancel |
| 594 | </button> |
| 595 | <button |
| 596 | className={classNames( |
| 597 | props.apiKey !== localValue |
| 598 | ? "bg-green-600" |
| 599 | : "bg-gray-600 cursor-not-allowed", |
| 600 | "rounded px-2 py-1 text-gray-50", |
| 601 | )} |
| 602 | onClick={() => { |
| 603 | if (props.apiKey === localValue) return; |
| 604 | localStorage.setItem("userApiKey", localValue); |
| 605 | props.setApiKey(localValue); |
| 606 | props.setOpen(); |
| 607 | }} |
| 608 | > |
| 609 | Confirm |
| 610 | </button> |
| 611 | </div> |
| 612 | </div> |
| 613 | </Modal> |
| 614 | ); |
| 615 | } |
nothing calls this directly
no test coverage detected