Skip to content

Commit

Permalink
[frontend] feat: Adding NoteFormModal component (#29)
Browse files Browse the repository at this point in the history
* [frontend] feat: Adding NoteFormModal component
  • Loading branch information
helloitsdave authored Mar 3, 2024
1 parent 9c6c877 commit 658b387
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
26 changes: 11 additions & 15 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from "react";
import { Button, Modal } from "antd";
import { Button } from "antd";
import "./App.css";
import NoteForm from "./components/NoteForm";
import NoteFormModal from "./components/NoteFormModal";
import NoteGrid from "./components/NoteGrid";
import Spinner from "./components/Spinner";
import type NoteType from "./types/note";
Expand Down Expand Up @@ -97,19 +97,15 @@ function App() {
{connectionIssue && (
<h3 className="connection-warning">Warning: API Connection Issue</h3>
)}
<Modal
title="Note Form"
open={isModalVisible}
onCancel={handleCancel}
footer={null}
>
<NoteForm
onCancel={handleCancel}
selectedNote={selectedNote}
addNote={addNote}
updateNote={updateNote}
/>
</Modal>

<NoteFormModal
isModalVisible={isModalVisible}
handleCancel={handleCancel}
selectedNote={selectedNote}
addNote={addNote}
updateNote={updateNote}
/>

{isDataLoading ? (
<Spinner />
) : (
Expand Down
32 changes: 32 additions & 0 deletions frontend/src/components/NoteFormModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

import { Modal } from "antd";
import NoteForm from "./NoteForm";
import type NoteType from "../types/note";

interface ModalNoteFormProps {
addNote: (newNote: NoteType) => void;
updateNote: (updatedNote: NoteType) => void;
selectedNote: NoteType | null;
handleCancel: () => void;
isModalVisible: boolean;
}

const ModalNoteForm: React.FC<ModalNoteFormProps> = (props) => {
return (
<Modal
title="Note Form"
open={props.isModalVisible}
onCancel={props.handleCancel}
footer={null}
>
<NoteForm
onCancel={props.handleCancel}
selectedNote={props.selectedNote}
addNote={props.addNote}
updateNote={props.updateNote}
/>
</Modal>
);
}

export default ModalNoteForm;

1 comment on commit 658b387

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

100.00%

Coverage Report
FileBranchesFuncsLinesUncovered Lines
src
   App.tsx100%100%100%
src/api
   apiService.ts100%100%100%
src/components
   Note.tsx100%100%100%
   NoteForm.tsx100%100%100%
   NoteFormModal.tsx100%100%100%
   NoteGrid.tsx100%100%100%
   Spinner.tsx100%100%100%

Please sign in to comment.