-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented Recent Documents & Added Fixes
- Loading branch information
1 parent
c0cd272
commit d04268d
Showing
35 changed files
with
253 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.recent { | ||
li { | ||
list-style: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { DocumentResource } from '@notespace/shared/src/workspace/types/resource'; | ||
import useLoading from '@ui/hooks/useLoading'; | ||
import { Link } from 'react-router-dom'; | ||
import { formatTimePassed } from '@/utils/utils'; | ||
import { useCommunication } from '@/contexts/communication/useCommunication'; | ||
import useError from '@/contexts/error/useError'; | ||
import './Recent.scss'; | ||
|
||
function Recent() { | ||
const [documents, setDocuments] = useState<DocumentResource[]>([]); | ||
const { http } = useCommunication(); | ||
const { publishError } = useError(); | ||
const { loading, startLoading, stopLoading, spinner } = useLoading(); | ||
|
||
useEffect(() => { | ||
async function fetchRecentDocuments() { | ||
try { | ||
startLoading(); | ||
const documents = await http.get('/recent'); | ||
console.log(documents); | ||
setDocuments(documents); | ||
console.log(documents[0].updatedAt, formatTimePassed(documents[0].updatedAt)); | ||
} catch (e) { | ||
publishError(e as Error); | ||
} finally { | ||
stopLoading(); | ||
} | ||
} | ||
fetchRecentDocuments(); | ||
}, [http, publishError, startLoading, stopLoading]); | ||
|
||
return ( | ||
<div className="recent"> | ||
<h2>Recent Documents</h2> | ||
{loading ? ( | ||
spinner | ||
) : documents.length > 0 ? ( | ||
<ul> | ||
{documents.map(doc => ( | ||
<li key={doc.id}> | ||
<Link to={`/workspaces/${doc.workspace}/${doc.id}`}> | ||
{doc.name} edited {formatTimePassed(doc.updatedAt)} | ||
</Link> | ||
</li> | ||
))} | ||
</ul> | ||
) : ( | ||
<p>No recent documents</p> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default Recent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.