|
| 1 | +import { |
| 2 | + _cs, |
| 3 | + encodeDate, |
| 4 | +} from '@togglecorp/fujs'; |
| 5 | +import { |
| 6 | + gql, |
| 7 | + useQuery, |
| 8 | +} from 'urql'; |
| 9 | + |
| 10 | +import DisplayPicture from '#components/DisplayPicture'; |
| 11 | +import TextOutput from '#components/TextOutput'; |
| 12 | +import { |
| 13 | + type StandupConductorsQuery, |
| 14 | + type StandupConductorsQueryVariables, |
| 15 | +} from '#generated/types/graphql'; |
| 16 | + |
| 17 | +import styles from './styles.module.css'; |
| 18 | + |
| 19 | +const STANDUP_CONDUCTORS = gql` |
| 20 | + query StandupConductors($date: Date!){ |
| 21 | + private { |
| 22 | + dailyStandup(date: $date) { |
| 23 | + conductor { |
| 24 | + id |
| 25 | + displayName |
| 26 | + displayPicture |
| 27 | + } |
| 28 | + fallbackConductor { |
| 29 | + id |
| 30 | + displayName |
| 31 | + displayPicture |
| 32 | + } |
| 33 | + } |
| 34 | + } |
| 35 | + } |
| 36 | +`; |
| 37 | + |
| 38 | +const todayDate = encodeDate(new Date()); |
| 39 | + |
| 40 | +function StandupConductors() { |
| 41 | + const [conductorsResponse] = useQuery<StandupConductorsQuery, StandupConductorsQueryVariables>({ |
| 42 | + query: STANDUP_CONDUCTORS, |
| 43 | + variables: { date: todayDate }, |
| 44 | + requestPolicy: 'cache-and-network', |
| 45 | + }); |
| 46 | + |
| 47 | + const standupConductors = conductorsResponse.data?.private.dailyStandup; |
| 48 | + |
| 49 | + return ( |
| 50 | + <div className={styles.conductors}> |
| 51 | + <TextOutput |
| 52 | + className={_cs( |
| 53 | + styles.conductorItem, |
| 54 | + !standupConductors && styles.hidden, |
| 55 | + )} |
| 56 | + label="Standup Lead" |
| 57 | + valueContainerClassName={styles.conductorValue} |
| 58 | + value={( |
| 59 | + <> |
| 60 | + <DisplayPicture |
| 61 | + imageUrl={standupConductors?.conductor?.displayPicture} |
| 62 | + displayName={standupConductors?.conductor?.displayName ?? 'Anonymous'} |
| 63 | + /> |
| 64 | + <span> |
| 65 | + {standupConductors?.conductor?.displayName |
| 66 | + ?? 'Anonymous'} |
| 67 | + </span> |
| 68 | + </> |
| 69 | + )} |
| 70 | + block |
| 71 | + hideLabelColon |
| 72 | + /> |
| 73 | + <TextOutput |
| 74 | + className={_cs( |
| 75 | + styles.conductorItem, |
| 76 | + !standupConductors && styles.hidden, |
| 77 | + )} |
| 78 | + label="Acting Lead" |
| 79 | + valueContainerClassName={styles.conductorValue} |
| 80 | + value={( |
| 81 | + <> |
| 82 | + <DisplayPicture |
| 83 | + imageUrl={standupConductors |
| 84 | + ?.fallbackConductor?.displayPicture} |
| 85 | + displayName={standupConductors?.fallbackConductor?.displayName ?? 'Anonymous'} |
| 86 | + /> |
| 87 | + <span> |
| 88 | + {standupConductors?.fallbackConductor?.displayName |
| 89 | + ?? 'Anonymous'} |
| 90 | + </span> |
| 91 | + </> |
| 92 | + )} |
| 93 | + block |
| 94 | + hideLabelColon |
| 95 | + /> |
| 96 | + </div> |
| 97 | + ); |
| 98 | +} |
| 99 | + |
| 100 | +export default StandupConductors; |
0 commit comments