Skip to content

Commit

Permalink
able to delete portraits now
Browse files Browse the repository at this point in the history
  • Loading branch information
jaaimino committed Oct 30, 2024
1 parent d7b9c46 commit 032abaa
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
26 changes: 23 additions & 3 deletions src/components/operative-card/modals/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function UpdateOperativePotraitModal(props) {
})
}

const handleUpdateOperative = () => {
const handleUploadOperativePortrait = () => {
const formData = new FormData();
formData.append(
"file",
Expand All @@ -28,7 +28,6 @@ export function UpdateOperativePotraitModal(props) {
method: "POST",
body: formData
}).then((data) => {
console.log(data);
if (data?.success) {
notifications.show({
title: 'Upload Succeeded',
Expand All @@ -45,6 +44,26 @@ export function UpdateOperativePotraitModal(props) {
})
};

const handleDeleteOperativePortrait = () => {
request(`/operativeportrait.php?roid=${operative.rosteropid}`, {
method: "DELETE",
}).then((data) => {
if (data?.success) {
notifications.show({
title: 'Delete Succeeded',
message: `Successfully deleted operative portrait.`,
})
modals.close("update-operative-portrait");
onClose(Date.now())
} else {
notifications.show({
title: 'Delete Failed',
message: `${data}`,
})
}
})
};

return (
<>
<Stack>
Expand All @@ -61,7 +80,8 @@ export function UpdateOperativePotraitModal(props) {
Please don't upload inappropriate photos. I look at every uploaded portrait and will delete suggestive, inappropriate, or offensive photos.</Text>
<Group justify="flex-end">
<Button variant="default" onClick={() => modals.close("update-operative-portrait")}>Cancel</Button>
<Button type="submit" onClick={handleUpdateOperative}>Save</Button>
<Button color="red" onClick={handleDeleteOperativePortrait}>Delete Portrait</Button>
<Button type="submit" onClick={handleUploadOperativePortrait}>Save</Button>
</Group>
</Stack>
</>
Expand Down
26 changes: 23 additions & 3 deletions src/pages/roster/modals/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function UpdateRosterPotraitModal(props) {
})
}

const handleUpdateRoster = () => {
const handleUploadRosterPortrait = () => {
const formData = new FormData();
formData.append(
"file",
Expand All @@ -33,7 +33,6 @@ export function UpdateRosterPotraitModal(props) {
method: "POST",
body: formData
}).then((data) => {
console.log(data);
if (data?.success) {
notifications.show({
title: 'Upload Succeeded',
Expand All @@ -50,6 +49,26 @@ export function UpdateRosterPotraitModal(props) {
})
};

const handleDeleteRosterPortrait = () => {
request(`/rosterportrait.php?rid=${roster.rosterid}`, {
method: "DELETE"
}).then((data) => {
if (data?.success) {
notifications.show({
title: 'Delete Succeeded',
message: `Successfully deleted roster portrait.`,
})
modals.close("update-portrait");
onClose(Date.now())
} else {
notifications.show({
title: 'Delete Failed',
message: `${data}`,
})
}
})
};

return (
<>
<Stack>
Expand All @@ -63,7 +82,8 @@ export function UpdateRosterPotraitModal(props) {
/>
<Group justify="flex-end">
<Button variant="default" onClick={() => modals.close("update-portrait")}>Cancel</Button>
<Button type="submit" onClick={handleUpdateRoster}>Save</Button>
<Button color="red" onClick={handleDeleteRosterPortrait}>Delete Portrait</Button>
<Button type="submit" onClick={handleUploadRosterPortrait}>Save</Button>
</Group>
</Stack>
</>
Expand Down

0 comments on commit 032abaa

Please sign in to comment.