-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added fetchThumbnail query, updates thumbnail on upload (#53)
* new layout for mentor info card * format and tests * removed import error * circular progress, shows thumbnail or placeholder * prompts upload on image hover (non-functional) * new layout draft * ui changes * test for upload * fixed test * setup for mentor.thumbnailSrc + tests * thumbnailsrc > thumbnail, uploadthumbnail function * mock test for displaying changed image * renamed component * renamed test and removed post request * removed upload tooltip, moved upload button * fixed missing mentor id * fetchThumbnail query, updates thumbnail on upload * removes non-null assertion * Thumbnail size fixed but layout responsive * ran format * added hook to manage thumbnail state * fixes flakey tests (#62) * updates cypress to 7.6 from 7.1 * updates deps * removes only Co-authored-by: Jim Alvarez <[email protected]> Co-authored-by: larry kirschner <[email protected]>
- Loading branch information
1 parent
c5b5596
commit 67f5495
Showing
9 changed files
with
3,810 additions
and
1,871 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
This software is Copyright ©️ 2020 The University of Southern California. All Rights Reserved. | ||
Permission to use, copy, modify, and distribute this software and its documentation for educational, research and non-profit purposes, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and subject to the full license file found in the root of this software deliverable. Permission to make commercial use of this software may be obtained by contacting: USC Stevens Center for Innovation University of Southern California 1150 S. Olive Street, Suite 2300, Los Angeles, CA 90115, USA Email: [email protected] | ||
The full terms of this copyright and license should always be found in the root directory of this software deliverable as "license.txt" and if these terms are not found with this software, please contact the USC Stevens Center for the full license. | ||
*/ | ||
import { uploadThumbnail, fetchThumbnail } from "api"; | ||
import { useState } from "react"; | ||
|
||
export function useWithThumbnail( | ||
mentorId: string, | ||
accessToken: string, | ||
current: string | ||
): [string, (file: File) => void] { | ||
const [thumbnail, setThumbnail] = useState(current); | ||
|
||
function updateThumbnail(file: File): Promise<void> { | ||
return uploadThumbnail(mentorId, file).then(() => { | ||
fetchThumbnail(accessToken).then((src: string) => { | ||
setThumbnail(src); | ||
}); | ||
}); | ||
} | ||
|
||
return [thumbnail, updateThumbnail]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.