Skip to content

Commit

Permalink
[Admin ONG] Fix issues with organization logo (#257)
Browse files Browse the repository at this point in the history
* fix delete organisation logo

* fix update organisation logo
  • Loading branch information
andreiio authored Aug 10, 2023
1 parent 720cb03 commit da8b48f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/OrganizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function destroy(Organization $organization)
public function removeCoverImage(Request $request)
{
$organization = auth()->user()->organization;
$organization->clearMediaCollection('organizationFiles');
$organization->clearMediaCollection('organizationFilesLogo');

return redirect()->back();
}
Expand Down
7 changes: 6 additions & 1 deletion resources/js/Components/form/FileInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@
/** Image preview. */
const preview = ref('');
const isUrl = (url) => url.match(/\.(jpeg|jpg|gif|png)$/) != null;
const isUrl = (form) => {
if (typeof form === 'string') {
return form.match(/\.(jpeg|jpg|gif|png)$/) != null
}
return false
};
/** Component emits. */
const emit = defineEmits(['upload']);
Expand Down
9 changes: 3 additions & 6 deletions resources/js/Pages/AdminOng/Ong/EditOng.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<div class="grid grid-cols-12 px-4 py-6 bg-gray-100">
<dt class="col-span-12 text-base font-medium leading-6 text-gray-700 md:col-span-5">{{ $t('organization_logo_label') }}</dt>
<dt class="flex items-center col-span-12 gap-6 text-base font-medium leading-6 text-gray-700 md:col-span-6">
<img class="flex-shrink-0 w-32 h-32" :src="form.cover_image" alt="" />
<img class="flex-shrink-0 w-32 h-32" :src="logo" alt="" />
<div>
<EditModal
@action="editField"
Expand Down Expand Up @@ -440,16 +440,13 @@
/** Initialize inertia from Object. */
const form = useForm({ ...props.organization });
const clonedOrganization = ({...props.organization});
const logo = ref(form.cover_image);

const editField = () => {

console.log(form);
form.post(route('admin.ong.update', form.id), {
preserveScroll: true,
onSuccess: (response) => {
// console.log(response);

// form.cover_image = response.organization.cover_image;
logo.value = response.props.organization.cover_image
},
onError: () => {},
});
Expand Down

0 comments on commit da8b48f

Please sign in to comment.