update authorization tokens and add/fix create album endpoint

This commit is contained in:
wisplite
2025-11-22 21:19:44 -06:00
parent 062e0d6066
commit 432a9e5229
7 changed files with 40 additions and 12 deletions
@@ -1,13 +1,36 @@
import Modal from '../../components/Modal'
export default function AlbumCreateModal({ open, onOpenChange, trigger }) {
const handleCreateAlbum = () => {
console.log('Create Album')
import { getServerUrl } from '../../hooks/getConstants'
import { useAccount } from '../../contexts/useAccount'
import { useState } from 'react'
export default function AlbumCreateModal({ open, onOpenChange, trigger, parentId }) {
const { getAccessToken } = useAccount()
const [title, setTitle] = useState('')
const [description, setDescription] = useState('')
const handleCreateAlbum = async () => {
const response = await fetch(`${getServerUrl()}/api/albums/createAlbum`, {
method: 'POST',
headers: {
'Authorization': getAccessToken(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
title: title,
description: description,
parentId: parentId
})
})
const data = await response.json()
if (data.error) {
console.error(data.error)
} else {
onOpenChange(false)
}
}
return (
<Modal open={open} onOpenChange={onOpenChange} trigger={trigger} title="Create Album">
<div className="flex flex-col gap-2">
<input type="text" placeholder="Name" className="w-full px-3 py-2.5 bg-[#141414] border border-[#2B2B2B] rounded-md text-white placeholder-gray-600 focus:outline-none focus:border-[#3B3B3B] transition-colors red-hat-text" />
<textarea type="text" placeholder="Description" className="w-full h-[20vh] px-3 py-2.5 bg-[#141414] border border-[#2B2B2B] rounded-md text-white placeholder-gray-600 focus:outline-none focus:border-[#3B3B3B] transition-colors red-hat-text resize-none" />
<input type="text" placeholder="Name" className="w-full px-3 py-2.5 bg-[#141414] border border-[#2B2B2B] rounded-md text-white placeholder-gray-600 focus:outline-none focus:border-[#3B3B3B] transition-colors red-hat-text" value={title} onChange={(e) => setTitle(e.target.value)} />
<textarea type="text" placeholder="Description" className="w-full h-[20vh] px-3 py-2.5 bg-[#141414] border border-[#2B2B2B] rounded-md text-white placeholder-gray-600 focus:outline-none focus:border-[#3B3B3B] transition-colors red-hat-text resize-none" value={description} onChange={(e) => setDescription(e.target.value)} />
<button className="w-full py-2.5 bg-[#2B2B2B] hover:bg-[#3B3B3B] text-white rounded-md font-medium transition-colors red-hat-mono cursor-pointer mt-2" onClick={handleCreateAlbum}>Create Album</button>
</div>
</Modal>