Skip to content

Commit 9107e14

Browse files
committed
use attachment url for trainers
1 parent 15bb30f commit 9107e14

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

pages/[lang]/index.tsx

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,16 @@ import ImgUnselectable from 'components/ImgUnselectable';
3333
// Featured course:
3434
const COURSE_ID = 1;
3535

36+
interface Attachment {
37+
file: {
38+
publicUrl: string;
39+
};
40+
}
41+
3642
interface Trainer {
3743
name: string;
3844
avatar_url: string;
45+
attachment: Attachment;
3946
bio: string;
4047
}
4148

@@ -68,6 +75,11 @@ const GET_COURSE = gql`
6875
name
6976
bio
7077
avatar_url
78+
attachment {
79+
file {
80+
publicUrl
81+
}
82+
}
7183
}
7284
}
7385
allFAQS(where: { courses_some: { id: $id } }, sortBy: [id_ASC]) {
@@ -127,7 +139,12 @@ function Landing() {
127139
</button>
128140
);
129141

130-
const trnr: Trainer = { name: '', avatar_url: '', bio: '' };
142+
const trnr: Trainer = {
143+
name: '',
144+
avatar_url: '',
145+
bio: '',
146+
attachment: { file: { publicUrl: '' } },
147+
};
131148
const [trainer, setTrainer] = useState(trnr);
132149

133150
// course id
@@ -296,7 +313,7 @@ function Landing() {
296313
<img
297314
style={{ height: 30, width: 30 }}
298315
alt={trainer.name}
299-
src={trainer.avatar_url}
316+
src={trainer.attachment.file.publicUrl}
300317
className="mr-2 img-fluid rounded-circle"
301318
/>
302319
<span>{trainer.name}</span>
@@ -395,20 +412,27 @@ function Landing() {
395412

396413
export default Landing;
397414

398-
function Trainer({ name, avatar_url, bio, setTrainer }) {
415+
function Trainer({ name, avatar_url, bio, attachment, setTrainer }) {
399416
const openModal = (e) => {
400417
e.preventDefault();
401-
setTrainer({ name, avatar_url, bio });
418+
setTrainer({ name, avatar_url, bio, attachment });
402419
};
403420
return (
404421
<>
405422
<div className="my-3">
406-
<img
407-
alt={name}
408-
src={avatar_url}
409-
className="img-fluid rounded-circle"
410-
style={{ height: 120, margin: '0 auto', cursor: 'pointer' }}
423+
<div
411424
onClick={openModal}
425+
className="rounded-circle"
426+
style={{
427+
background: `url(${
428+
avatar_url || attachment.file.publicUrl
429+
}) no-repeat`,
430+
backgroundSize: 'cover',
431+
height: 120,
432+
width: 120,
433+
margin: '0 auto',
434+
cursor: 'pointer',
435+
}}
412436
/>
413437
<a className="mt-3 h6 d-block" href="" onClick={openModal}>
414438
{name}
@@ -423,6 +447,7 @@ Trainer.propTypes = {
423447
bio: PropTypes.string,
424448
avatar_url: PropTypes.string,
425449
setTrainer: PropTypes.func,
450+
attachment: PropTypes.object,
426451
};
427452

428453
const Cover = styled.div`

0 commit comments

Comments
 (0)