Skip to content

Commit

Permalink
fix: temporarily hide upload name column (#1770)
Browse files Browse the repository at this point in the history
This allows us to release the blog posts. API can then be deployed separately, and then the frontend (with this change reverted).
  • Loading branch information
Alan Shaw authored Apr 5, 2022
1 parent 3003926 commit d92d7cf
Showing 1 changed file with 38 additions and 37 deletions.
75 changes: 38 additions & 37 deletions packages/website/pages/files.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { API, getNfts, getToken } from '../lib/api.js'
import { useQuery, useQueryClient } from 'react-query'
import { CID } from 'multiformats/cid'
import { VscQuestion, VscEdit, VscLoading, VscSave } from 'react-icons/vsc'
// import { VscQuestion, VscEdit, VscLoading, VscSave } from 'react-icons/vsc'
import { VscQuestion } from 'react-icons/vsc'
import Button from '../components/button.js'
import Tooltip from '../components/tooltip.js'
import Loading from '../components/loading'
Expand Down Expand Up @@ -111,10 +112,10 @@ export default function Files({ user }) {
*/
const TableItem = ({ nft }) => {
// to do, add actual types
const [isRenaming, setRenaming] = useState(false)
const [isLoading, setLoading] = useState(false)
const [renameError, setError] = useState('')
const [renamedValue, setRenamedValue] = useState('')
// const [isRenaming, setRenaming] = useState(false)
// const [isLoading, setLoading] = useState(false)
// const [renameError, setError] = useState('')
// const [renamedValue, setRenamedValue] = useState('')
const [showAllDeals, setShowAllDeals] = useState(false)
const deals = nft.deals
.filter((/** @type {any} */ d) => d.status !== 'queued')
Expand Down Expand Up @@ -198,45 +199,45 @@ export default function Files({ user }) {
}

/** @param {import('react').ChangeEvent<HTMLFormElement>} ev */
const handleRename = async (ev) => {
ev.preventDefault()
const data = new FormData(ev.target)
const fileName = data.get('fileName')
// const handleRename = async (ev) => {
// ev.preventDefault()
// const data = new FormData(ev.target)
// const fileName = data.get('fileName')

if (!fileName || typeof fileName !== 'string') return
if (fileName === nft.name) return setRenaming(false)
// if (!fileName || typeof fileName !== 'string') return
// if (fileName === nft.name) return setRenaming(false)

try {
setLoading(true)
await fetch(`${API}/upload/${nft.cid}`, {
method: 'PATCH',
body: JSON.stringify({
name: fileName,
}),
headers: {
'Content-type': 'application/json; charset=UTF-8',
Authorization: `Bearer ${await getToken()}`,
},
})
setError('')
} catch (e) {
console.error(e)
// @ts-ignore Catch clause variable type annotation must be 'any' or 'unknown' if specified.ts(1196)
setError(e.message)
}
// try {
// setLoading(true)
// await fetch(`${API}/upload/${nft.cid}`, {
// method: 'PATCH',
// body: JSON.stringify({
// name: fileName,
// }),
// headers: {
// 'Content-type': 'application/json; charset=UTF-8',
// Authorization: `Bearer ${await getToken()}`,
// },
// })
// setError('')
// } catch (e) {
// console.error(e)
// // @ts-ignore Catch clause variable type annotation must be 'any' or 'unknown' if specified.ts(1196)
// setError(e.message)
// }

setLoading(false)
setRenaming(false)
setRenamedValue(fileName)
}
// setLoading(false)
// setRenaming(false)
// setRenamedValue(fileName)
// }

return (
<tr className="bg-white bb">
<td data-label="Date" className="nowrap" title={nft.created}>
{/* {nft.created.split('T')[0]} */}
{formatTimestamp(nft.created)}
</td>
<td data-label="Label" className="nowrap" title={nft.label}>
{/* <td data-label="Label" className="nowrap" title={nft.label}>
{!isRenaming ? (
<div
className={clsx(
Expand Down Expand Up @@ -300,7 +301,7 @@ export default function Files({ user }) {
</button>
</form>
)}
</td>
</td> */}
<td data-label="CID" className="nowrap">
<CopyButton
title="Copy CID to Clipboard"
Expand Down Expand Up @@ -453,7 +454,7 @@ export default function Files({ user }) {
<thead>
<tr className="bg-nsgray">
<th>Date</th>
<th>
{/* <th>
<span aria-describedby="label-tooltip">
Label
<Tooltip
Expand All @@ -470,7 +471,7 @@ export default function Files({ user }) {
<VscQuestion size={16} />
</Tooltip>
</span>
</th>
</th> */}
<th>
<span aria-describedby="cid-tooltip">
CID
Expand Down

0 comments on commit d92d7cf

Please sign in to comment.