feat(settings): connect status and color updates to profile API endpoint
All checks were successful
Deploy Waveform to VPS / deploy (push) Successful in 1m18s
All checks were successful
Deploy Waveform to VPS / deploy (push) Successful in 1m18s
This commit is contained in:
parent
ca9b35f8dd
commit
00b11f2113
1 changed files with 20 additions and 2 deletions
|
|
@ -37,13 +37,31 @@ export function SettingsView({ userId, currentUser }: SettingsViewProps) {
|
||||||
];
|
];
|
||||||
|
|
||||||
/** Updates local status state on user selection. */
|
/** Updates local status state on user selection. */
|
||||||
const handleStatusChange = (newStatus: UserStatus) => {
|
const handleStatusChange = async (newStatus: UserStatus) => {
|
||||||
setSelectedStatus(newStatus);
|
setSelectedStatus(newStatus);
|
||||||
|
try {
|
||||||
|
await fetch("/api/users/profile", {
|
||||||
|
method: "PATCH",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ status: newStatus }),
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to update status", err);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Updates local avatar color state on user selection. */
|
/** Updates local avatar color state on user selection. */
|
||||||
const handleColorChange = (newColor: string) => {
|
const handleColorChange = async (newColor: string) => {
|
||||||
setSelectedColor(newColor);
|
setSelectedColor(newColor);
|
||||||
|
try {
|
||||||
|
await fetch("/api/users/profile", {
|
||||||
|
method: "PATCH",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ color: newColor }),
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to update color", err);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!currentUser) return null;
|
if (!currentUser) return null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue