Skip to content

Commit

Permalink
Prettier..
Browse files Browse the repository at this point in the history
  • Loading branch information
theodorsm committed Oct 24, 2023
1 parent 0aee3b0 commit 5b43590
Show file tree
Hide file tree
Showing 40 changed files with 424 additions and 369 deletions.
46 changes: 22 additions & 24 deletions app/actions/CompanyActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,28 @@ export function fetchAdmin(companyId: number): Thunk<any> {
})
);
}
export const fetchEventsForCompany =
({
queryString,
loadNextPage = false,
}: {
queryString: string;
loadNextPage: boolean;
}): Thunk<any> =>
(dispatch, getState) => {
const endpoint = loadNextPage
? getState().events.pagination[queryString].nextPage
: `/events/${queryString}`;
return dispatch(
callAPI({
types: Event.FETCH,
endpoint,
schema: [eventSchema],
meta: {
queryString,
errorMessage: 'Henting av tilknyttede arrangementer feilet',
},
})
);
};
export const fetchEventsForCompany = ({
queryString,
loadNextPage = false,
}: {
queryString: string;
loadNextPage: boolean;
}): Thunk<any> => (dispatch, getState) => {
const endpoint = loadNextPage
? getState().events.pagination[queryString].nextPage
: `/events/${queryString}`;
return dispatch(
callAPI({
types: Event.FETCH,
endpoint,
schema: [eventSchema],
meta: {
queryString,
errorMessage: 'Henting av tilknyttede arrangementer feilet',
},
})
);
};
export function fetchJoblistingsForCompany(companyId: string): Thunk<any> {
return (dispatch) =>
dispatch(
Expand Down
76 changes: 37 additions & 39 deletions app/actions/EventActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,50 +69,48 @@ const getEndpoint = (state, loadNextPage, queryString) => {
return endpoint;
};

export const fetchList =
({
dateAfter,
dateBefore,
refresh = false,
loadNextPage = false,
}: Record<string, any> = {}): Thunk<any> =>
(dispatch, getState) => {
const query: Record<string, any> = {
date_after: dateAfter,
date_before: dateBefore,
};
export const fetchList = ({
dateAfter,
dateBefore,
refresh = false,
loadNextPage = false,
}: Record<string, any> = {}): Thunk<any> => (dispatch, getState) => {
const query: Record<string, any> = {
date_after: dateAfter,
date_before: dateBefore,
};

if (dateBefore && dateAfter) {
query.page_size = 60;
}
if (dateBefore && dateAfter) {
query.page_size = 60;
}

const queryString = createQueryString(query);
const endpoint = getEndpoint(getState(), loadNextPage, queryString);
const queryString = createQueryString(query);
const endpoint = getEndpoint(getState(), loadNextPage, queryString);

if (!endpoint) {
return Promise.resolve(null);
}
if (!endpoint) {
return Promise.resolve(null);
}

if (refresh && !loadNextPage) {
dispatch({
type: Event.CLEAR,
});
}
if (refresh && !loadNextPage) {
dispatch({
type: Event.CLEAR,
});
}

return dispatch(
callAPI({
types: Event.FETCH,
endpoint: endpoint,
schema: [eventSchema],
meta: {
errorMessage: 'Fetching events failed',
queryString,
endpoint,
},
propagateError: true,
})
);
};
return dispatch(
callAPI({
types: Event.FETCH,
endpoint: endpoint,
schema: [eventSchema],
meta: {
errorMessage: 'Fetching events failed',
queryString,
endpoint,
},
propagateError: true,
})
);
};
export function fetchAdministrate(eventId: number): Thunk<any> {
return callAPI({
types: Event.FETCH,
Expand Down
27 changes: 13 additions & 14 deletions app/components/Feed/activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,19 @@ export default class ActivityRenderer extends Component<Props, State> {
(aggregatedActivity.activityCount > activities.length &&
this.state.expanded) ? (
<div className={styles.activityFooter}>
{aggregatedActivity.activities.length > 3 &&
!this.state.expanded && (
<Button
size="small"
submit={false}
onClick={() =>
this.setState({
expanded: true,
})
}
>
Vis mer
</Button>
)}
{aggregatedActivity.activities.length > 3 && !this.state.expanded && (
<Button
size="small"
submit={false}
onClick={() =>
this.setState({
expanded: true,
})
}
>
Vis mer
</Button>
)}
{aggregatedActivity.activityCount > activities.length &&
this.state.expanded &&
`og ${
Expand Down
11 changes: 9 additions & 2 deletions app/components/Form/FileUploadField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ class FileUploadField extends Component<Props> {
static Field: any;

render() {
const { className, style, input, value, meta, placeholder, ...restprops } =
this.props;
const {
className,
style,
input,
value,
meta,
placeholder,
...restprops
} = this.props;
return (
<Flex
alignItems="center"
Expand Down
14 changes: 7 additions & 7 deletions app/components/Form/TimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ const TimePicker = ({ value, onChange }: Props) => {
onChange(newValue.toISOString());
};

const handleChange =
(unit: 'hour' | 'minute') =>
({ currentTarget: { value } }: SyntheticEvent<HTMLInputElement>) => {
if (Number(value) > max[unit] || Number(value) < 0) return;
const newValue = parsedValue.clone().set(unit, Number(value));
onChange(newValue.toISOString());
};
const handleChange = (unit: 'hour' | 'minute') => ({
currentTarget: { value },
}: SyntheticEvent<HTMLInputElement>) => {
if (Number(value) > max[unit] || Number(value) < 0) return;
const newValue = parsedValue.clone().set(unit, Number(value));
onChange(newValue.toISOString());
};

return (
<div className={styles.timePicker}>
Expand Down
26 changes: 13 additions & 13 deletions app/components/PhotoUploadStatus/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,13 @@ const UploadStatusCard = ({
<Tooltip
content={
<Flex column>
{uploadStatus.failedImages.map(
(
name,
index // Since we never remove elements from the list, we can use
) => (
// the index as the key,
<Flex key={index}>{name}</Flex>
)
)}
{uploadStatus.failedImages.map((
name,
index // Since we never remove elements from the list, we can use
) => (
// the index as the key,
<Flex key={index}>{name}</Flex>
))}
</Flex>
}
>
Expand Down Expand Up @@ -102,10 +100,12 @@ const mapStateToProps: (arg0: any) => StateProps = (state) => {
}: {
uploadStatus: UploadStatus;
} = state.galleryPictures;
const lastImage: GalleryPictureEntity | null | undefined =
selectGalleryPictureById(state, {
pictureId: uploadStatus.lastUploadedImage,
});
const lastImage:
| GalleryPictureEntity
| null
| undefined = selectGalleryPictureById(state, {
pictureId: uploadStatus.lastUploadedImage,
});
return {
uploadStatus,
lastImage,
Expand Down
19 changes: 15 additions & 4 deletions app/components/Poll/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,22 @@ class Poll extends Component<Props, State> {
};

render() {
const { poll, handleVote, details, truncate, allowedToViewHiddenResults } =
this.props;
const {
poll,
handleVote,
details,
truncate,
allowedToViewHiddenResults,
} = this.props;
const { truncateOptions, expanded } = this.state;
const { id, title, description, hasAnswered, totalVotes, resultsHidden } =
poll;
const {
id,
title,
description,
hasAnswered,
totalVotes,
resultsHidden,
} = poll;
const options = this.optionsWithPerfectRatios(this.props.poll.options);
// Random ordering breaks SSR
//const orderedOptions = hasAnswered ? options : shuffledOptions;
Expand Down
3 changes: 2 additions & 1 deletion app/components/Search/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ const EXTERNAL_LINKS: Link[] = [
requireLogin: true,
title: 'Varslingsportal',
icon: 'warning-outline',
url: 'https://portal.mittvarsel.no/skjema/abakus/t3fMsqnZcCaeFX2u.9824?lang=no',
url:
'https://portal.mittvarsel.no/skjema/abakus/t3fMsqnZcCaeFX2u.9824?lang=no',
},
{
key: 'bill',
Expand Down
10 changes: 8 additions & 2 deletions app/components/Table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,14 @@ export default class Table extends Component<Props, State> {
chosenProps = { ...props, ...props.columnChoices[columnIndex] };
}

const { dataIndex, title, sorter, filter, search, filterMessage } =
chosenProps;
const {
dataIndex,
title,
sorter,
filter,
search,
filterMessage,
} = chosenProps;
const sortIconName =
this.state.sort.dataIndex === dataIndex
? this.state.sort.direction === 'asc'
Expand Down
2 changes: 1 addition & 1 deletion app/components/Tags/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const tagColors = [
'orange',
] as const;

export type TagColors = (typeof tagColors)[number];
export type TagColors = typeof tagColors[number];

type Props = {
tag: string;
Expand Down
48 changes: 24 additions & 24 deletions app/components/Tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,33 @@ const Tooltip = ({
const triggerRef = useRef<HTMLDivElement>(null);
const arrowRef = useRef<HTMLDivElement>(null);

const {
styles: popperStyles,
attributes,
update,
} = usePopper(triggerRef.current, tooltipRef.current, {
placement: placement || 'top',
modifiers: [
{
name: 'flip',
options: {
fallbackPlacements: ['top', 'bottom', 'left', 'right'],
const { styles: popperStyles, attributes, update } = usePopper(
triggerRef.current,
tooltipRef.current,
{
placement: placement || 'top',
modifiers: [
{
name: 'flip',
options: {
fallbackPlacements: ['top', 'bottom', 'left', 'right'],
},
},
},
{
name: 'arrow',
options: {
element: arrowRef.current,
{
name: 'arrow',
options: {
element: arrowRef.current,
},
},
},
{
name: 'offset',
options: {
offset: [0, 10],
{
name: 'offset',
options: {
offset: [0, 10],
},
},
},
],
});
],
}
);

useEffect(() => {
if (hovered && !disabled && update !== null) {
Expand Down
7 changes: 3 additions & 4 deletions app/reducers/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@ const mutateEvent = produce((newState: State, action: any): void => {
}

if (stateEvent.waitingRegistrations) {
stateEvent.waitingRegistrations =
stateEvent.waitingRegistrations.filter(
(id) => id !== action.payload.id
);
stateEvent.waitingRegistrations = stateEvent.waitingRegistrations.filter(
(id) => id !== action.payload.id
);
}

break;
Expand Down

0 comments on commit 5b43590

Please sign in to comment.