-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 'Add import/export link lists' (#26) from 20240330…
…-slides-nostr-check into main
- Loading branch information
Showing
12 changed files
with
453 additions
and
51 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,98 @@ | ||
import React, {useState} from 'react'; | ||
import {Modal} from '../Modal'; | ||
import {saveList} from '../../nostr/nostr'; | ||
|
||
export const ExportLinksModal = ({ | ||
close, | ||
roomId, | ||
textColor, | ||
roomColor, | ||
roomLinks, | ||
}) => { | ||
const dt = new Date(); | ||
const shortdate = dt.toISOString().replaceAll(':','-').replaceAll('T','.').replaceAll('-','').slice(0,13); | ||
const [dTagValue, setDTagValue] = useState(`cornychat-${roomId}`); | ||
const [name, setName] = useState(''); | ||
const [about, setAbout] = useState(''); | ||
const [displayError, setDisplayError] = useState(false); | ||
const [errorMsg, setErrorMsg] = useState(''); | ||
|
||
async function saveit() { | ||
let dTag = dTagValue; | ||
if (dTag.length == 0) { | ||
dTag = shortdate; | ||
} | ||
let imageUrl = jamConfig.urls.jam.replaceAll('/localhost/','/cornychat.com/') + '/img/cornychat-links.png'; | ||
let result = await saveList(dTag, name, about, imageUrl, 31388, roomLinks); | ||
if (!result[0]) { | ||
setErrorMsg(result[1]); | ||
setDisplayError(true); | ||
} else { | ||
close(); | ||
alert('Link List published to relays'); | ||
return; | ||
} | ||
} | ||
|
||
return ( | ||
<Modal close={close}> | ||
<div className="bg-white p-6 rounded-lg"> | ||
<h2 className="text-2xl font-bold">Export Links</h2> | ||
<p> | ||
Unique ID | ||
</p> | ||
<div className="p-2 text-gray-500 italic"> | ||
{`Using the same ID of a prior export will overwrite it.`} | ||
</div> | ||
<input | ||
type="text" | ||
className="w-full p-2 border border-gray-300 mb-4" | ||
placeholder="Unique ID (using the same of prior export will overwrite it)" | ||
value={dTagValue} | ||
onChange={e => { | ||
setDTagValue(e.target.value); | ||
}} | ||
/> | ||
<p> | ||
Name | ||
</p> | ||
<input | ||
type="text" | ||
className="w-full p-2 border border-gray-300 mb-4" | ||
placeholder="Name" | ||
value={name} | ||
onChange={e => { | ||
setName(e.target.value); | ||
}} | ||
/> | ||
<p> | ||
About | ||
</p> | ||
<input | ||
type="text" | ||
className="w-full p-2 border border-gray-300 mb-4" | ||
placeholder="About (optional)" | ||
value={about} | ||
onChange={e => { | ||
setAbout(e.target.value); | ||
}} | ||
/> | ||
<button | ||
className="py-2 px-4 rounded text-center w-full" | ||
style={{ | ||
backgroundColor: roomColor.buttons.primary, | ||
color: textColor, | ||
}} | ||
onClick={async () => { | ||
await saveit(); | ||
}} | ||
> | ||
Save | ||
</button> | ||
<div className="mt-5"> | ||
{displayError ? <p className="text-red-500">{errorMsg}</p> : null} | ||
</div> | ||
</div> | ||
</Modal> | ||
); | ||
}; |
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.