Skip to content

Commit

Permalink
Merge pull request #995 from funmusicplace/various-fixes
Browse files Browse the repository at this point in the history
fix: some more of those fixes
  • Loading branch information
simonv3 authored Jan 29, 2025
2 parents 5aa495f + f8bfe1c commit 33909a8
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 29 deletions.
4 changes: 1 addition & 3 deletions client/src/components/Merch/BuyMerchItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ const BuyMerchItem: React.FC<{
return null;
}

console.log(currentOptions, currentPrice, shippingDestination);

let price = currentPrice;

merch.optionTypes.forEach((ot) =>
Expand Down Expand Up @@ -162,7 +160,7 @@ const BuyMerchItem: React.FC<{
<SelectEl {...methods.register(`merchOptionIds.${idx}`)}>
{optionType.options
.sort((a, b) => {
return a.additionalPrice > b.additionalPrice ? -1 : 1;
return a.additionalPrice < b.additionalPrice ? -1 : 1;
})
.map((o) => (
<option key={o.name} value={o.id}>
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/Widget/TrackWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ const TrackWidget = () => {
return <LoadingBlocks />;
}

console.log("track", track);

return (
<>
{(!track || !track.id) && !isLoading && (
Expand Down
54 changes: 42 additions & 12 deletions client/src/components/common/TextEditor/InsertMirloWidgetButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import { bp } from "../../../constants";
import AutoCompleteTrackGroup from "../AutoCompleteTrackGroup";
import { useTranslation } from "react-i18next";
import BulkTrackUpload from "components/ManageArtist/BulkTrackUpload";
import { InputEl } from "../Input";
import FormComponent from "../FormComponent";
import Box from "../Box";

const InsertMirloWidgetButton: React.FC<{
postId: number;
Expand All @@ -19,6 +22,7 @@ const InsertMirloWidgetButton: React.FC<{
const [isOpen, setIsOpen] = React.useState(false);
const [draftAlbum, setDraftAlbum] = React.useState<TrackGroup>();
const [newSong, setNewSong] = React.useState<Track>();
const [newSongTitle, setNewSongTitle] = React.useState("");
const { addIframe } = useCommands();
const { t } = useTranslation("translation", { keyPrefix: "textEditor" });

Expand Down Expand Up @@ -50,11 +54,34 @@ const InsertMirloWidgetButton: React.FC<{
}));
}, []);

const addNewSong = React.useCallback(async () => {
if (newSong) {
try {
await api.put(`manage/tracks/${newSong.id}`, { title: newSongTitle });
onAdd(newSong.id, "track");
} catch (e) {
console.error(e);
}
}
}, [newSong, newSongTitle]);

const setNewSongDetails = React.useCallback(async (newTrack?: Track) => {
if (newTrack) {
try {
const { result } = await api.get<Track>(`manage/tracks/${newTrack.id}`);
setNewSong(result);
setNewSongTitle(result?.title ?? "");
loadDraft();
} catch (e) {
console.error(e);
}
}
}, []);

const loadDraft = React.useCallback(async () => {
const response = await api.get<TrackGroup>(
`manage/artists/${artistId}/drafts`
);
console.log("response", response);
setDraftAlbum(response.result);
}, []);

Expand Down Expand Up @@ -135,7 +162,7 @@ const InsertMirloWidgetButton: React.FC<{
flex-direction: column;
display: flex;
> span {
> div {
padding: 1rem;
font-weight: bold;
border: 1px dashed var(--mi-darken-xx-background-color);
Expand All @@ -148,23 +175,26 @@ const InsertMirloWidgetButton: React.FC<{
}
`}
>
<span>{newSong.title}</span>
<Button
onClick={() => {
onAdd(newSong.id, "track");
}}
>
<FormComponent>
<label>{t("songTitle")}</label>
<InputEl
value={newSongTitle}
onChange={(e) => setNewSongTitle(e.currentTarget.value)}
/>
<small>{newSong.audio?.originalFilename}</small>
</FormComponent>
{newSongTitle === "" && (
<Box variant="warning">{t("addTitleToUpload")}</Box>
)}
<Button disabled={newSongTitle === ""} onClick={addNewSong}>
{t("addThisSong")}
</Button>
</div>
)}
{!newSong && (
<BulkTrackUpload
trackgroup={draftAlbum}
reload={async (newTrack) => {
setNewSong(newTrack);
loadDraft();
}}
reload={setNewSongDetails}
/>
)}
</>
Expand Down
12 changes: 7 additions & 5 deletions client/src/translation/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,13 @@
"uploadAVideo": "Add a video",
"addUrl": "Insert a video url",
"addVideo": "Add video",
"addThisSong": "Add this song",
"uploadNewSong": "Upload new song",
"useExistingSong": "Use existing song",
"existingSongDescription": "Sharing a song from an existing album or pre-order? Find it here",
"uploadNewSongDescription": "Are you sharing a song that's not on one of your albums? A draft or WIP? Upload it here to share."
"addThisSong": "Add this track",
"songTitle": "Track title",
"uploadNewSong": "Upload new track",
"addTitleToUpload": "Add track title to upload",
"useExistingSong": "Use existing track",
"existingSongDescription": "Sharing a track from an existing album or pre-order? Find it here",
"uploadNewSongDescription": "Are you sharing a track that's not on one of your albums? A draft or WIP? Upload it here to share."
},
"manageLicense": {
"shortLabelForLicense": "What's a unique short label for this license?",
Expand Down
9 changes: 2 additions & 7 deletions src/routers/v1/manage/artists/{artistId}/drafts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ import {
import prisma from "@mirlo/prisma";
import { User } from "@mirlo/prisma/client";

import {
deleteArtist,
findArtistIdForURLSlug,
processSingleArtist,
singleInclude,
} from "../../../../../utils/artist";
import slugify from "slugify";
import { deleteArtist } from "../../../../../utils/artist";

type Params = {
artistId: string;
Expand All @@ -30,6 +24,7 @@ export default function () {
let draftAlbum = await prisma.trackGroup.findFirst({
where: {
isDrafts: true,
artistId: Number(artistId),
},
include: {
tracks: true,
Expand Down

0 comments on commit 33909a8

Please sign in to comment.