Skip to content

Commit c2d5a69

Browse files
Merge pull request #26 from Jamesllllllllll/codex/issue-4-edit-command
Add !edit search result command
2 parents 5bee987 + 6af9418 commit c2d5a69

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

src/components/song-search-panel.tsx

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ export function buildVipRequestCommand(song: SearchSong) {
107107
return buildRequestCommand(song).replace(/^!sr\b/, "!vip");
108108
}
109109

110+
export function buildEditRequestCommand(song: SearchSong) {
111+
return buildRequestCommand(song).replace(/^!sr\b/, "!edit");
112+
}
113+
110114
export function SongSearchPanel(props: {
111115
title: string;
112116
eyebrow?: string;
@@ -122,7 +126,7 @@ export function SongSearchPanel(props: {
122126
const [showAdvanced, setShowAdvanced] = useState(false);
123127
const [copiedCommand, setCopiedCommand] = useState<{
124128
songId: string;
125-
type: "sr" | "vip";
129+
type: "sr" | "edit" | "vip";
126130
} | null>(null);
127131
const [advancedFilters, setAdvancedFilters] = useState({
128132
title: "",
@@ -305,10 +309,17 @@ export function SongSearchPanel(props: {
305309
.sort((a, b) => a - b);
306310
}, [page, totalPages]);
307311

308-
async function copyRequest(song: SearchSong, type: "sr" | "vip" = "sr") {
309-
await navigator.clipboard.writeText(
310-
type === "vip" ? buildVipRequestCommand(song) : buildRequestCommand(song)
311-
);
312+
async function copyRequest(
313+
song: SearchSong,
314+
type: "sr" | "edit" | "vip" = "sr"
315+
) {
316+
const command =
317+
type === "vip"
318+
? buildVipRequestCommand(song)
319+
: type === "edit"
320+
? buildEditRequestCommand(song)
321+
: buildRequestCommand(song);
322+
await navigator.clipboard.writeText(command);
312323
setCopiedCommand({ songId: song.id, type });
313324
window.setTimeout(() => {
314325
setCopiedCommand((current) =>
@@ -820,6 +831,31 @@ export function SongSearchPanel(props: {
820831
: "Copy !sr command"}
821832
</TooltipContent>
822833
</Tooltip>
834+
<Tooltip>
835+
<TooltipTrigger asChild>
836+
<button
837+
type="button"
838+
onClick={() => void copyRequest(song, "edit")}
839+
className={cn(
840+
"flex h-11 min-w-[3.75rem] items-center justify-center rounded-full border border-(--border) bg-(--panel) px-3 text-[11px] font-semibold uppercase tracking-[0.16em] transition-colors",
841+
copiedType === "edit"
842+
? "border-emerald-400 text-emerald-400"
843+
: "text-(--brand)"
844+
)}
845+
>
846+
{copiedType === "edit" ? (
847+
<Check className="h-4 w-4" />
848+
) : (
849+
"!edit"
850+
)}
851+
</button>
852+
</TooltipTrigger>
853+
<TooltipContent>
854+
{copiedType === "edit"
855+
? "Copied !edit command"
856+
: "Copy !edit command"}
857+
</TooltipContent>
858+
</Tooltip>
823859
<Tooltip>
824860
<TooltipTrigger asChild>
825861
<button

0 commit comments

Comments
 (0)