mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 18:10:39 +09:00
Address Greptile company logo feedback
This commit is contained in:
parent
2d548a9da0
commit
4dfd862f11
5 changed files with 208 additions and 71 deletions
|
|
@ -11,11 +11,19 @@ export const assetsApi = {
|
|||
const safeFile = new File([buffer], file.name, { type: file.type });
|
||||
|
||||
const form = new FormData();
|
||||
form.append("file", safeFile);
|
||||
if (namespace && namespace.trim().length > 0) {
|
||||
form.append("namespace", namespace.trim());
|
||||
}
|
||||
form.append("file", safeFile);
|
||||
return api.postForm<AssetImage>(`/companies/${companyId}/assets/images`, form);
|
||||
},
|
||||
};
|
||||
|
||||
uploadCompanyLogo: async (companyId: string, file: File) => {
|
||||
const buffer = await file.arrayBuffer();
|
||||
const safeFile = new File([buffer], file.name, { type: file.type });
|
||||
|
||||
const form = new FormData();
|
||||
form.append("file", safeFile);
|
||||
return api.postForm<AssetImage>(`/companies/${companyId}/logo`, form);
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ export function CompanySettings() {
|
|||
const logoUploadMutation = useMutation({
|
||||
mutationFn: (file: File) =>
|
||||
assetsApi
|
||||
.uploadImage(selectedCompanyId!, file, "companies")
|
||||
.uploadCompanyLogo(selectedCompanyId!, file)
|
||||
.then((asset) => companiesApi.update(selectedCompanyId!, { logoAssetId: asset.assetId })),
|
||||
onSuccess: (company) => {
|
||||
syncLogoState(company.logoUrl);
|
||||
|
|
@ -160,8 +160,8 @@ export function CompanySettings() {
|
|||
const file = event.target.files?.[0] ?? null;
|
||||
event.currentTarget.value = "";
|
||||
if (!file) return;
|
||||
if (file.size >= 100 * 1024) {
|
||||
setLogoUploadError("Logo image must be smaller than 100 KB.");
|
||||
if (file.size > 100 * 1024) {
|
||||
setLogoUploadError("Logo image must be 100 KB or smaller.");
|
||||
return;
|
||||
}
|
||||
setLogoUploadError(null);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue