Skip to content

Commit f554c29

Browse files
committed
Merge branch 'master' into 3884-add-lending-to-events
2 parents fdfd487 + b842a7d commit f554c29

File tree

9 files changed

+208
-108
lines changed

9 files changed

+208
-108
lines changed

lego-webapp/components/Form/SelectInput.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ const SelectInput = <
124124
options={options}
125125
isOptionDisabled={isOptionDisabled}
126126
isLoading={fetching}
127-
styles={selectStyle ?? (selectStyles as StylesConfig<Option, IsMulti>)}
127+
styles={
128+
selectStyle ?? (selectStyles as StylesConfig<Option, IsMulti>)
129+
}
128130
theme={selectTheme}
129131
onInputChange={(value) => {
130132
onSearch?.(value);

lego-webapp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@reduxjs/toolkit": "^2.6.0",
2828
"@sentry/node": "^9.2.0",
2929
"@sentry/react": "^9.1.0",
30-
"@stripe/react-stripe-js": "^3.1.1",
30+
"@stripe/react-stripe-js": "^5.3.0",
3131
"@stripe/stripe-js": "^5.7.0",
3232
"@types/lodash-es": "^4.17.12",
3333
"@types/zxcvbn": "^4.4.5",

lego-webapp/pages/events/src/EventEditor/EditorSection/LendingSection.tsx

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ import { usePreparedEffect } from '@webkom/react-prepare';
22
import { Field } from 'react-final-form';
33
import { SelectInput, TextInput } from '~/components/Form';
44
import { type EditingEvent } from '~/pages/events/utils';
5-
import { fetchAllLendableObjects, fetchAvailableLendableObjectIdsByDate } from '~/redux/actions/LendableObjectActions';
5+
import {
6+
fetchAllLendableObjects,
7+
fetchAvailableLendableObjectIdsByDate,
8+
} from '~/redux/actions/LendableObjectActions';
69
import { useAppDispatch, useAppSelector } from '~/redux/hooks';
710
import {
811
selectAllLendableObjects,
912
selectAvailableLendableObjectIds,
1013
} from '~/redux/slices/lendableObjects';
11-
import type { FormatOptionLabelMeta, StylesConfig } from 'react-select';
1214
import styles from '../EventEditor.module.css';
1315
import type { EntityId } from '@reduxjs/toolkit';
16+
import type { FormatOptionLabelMeta, StylesConfig } from 'react-select';
1417

1518
type Props = {
1619
values: EditingEvent;
@@ -55,23 +58,22 @@ const LendingSection: React.FC<Props> = ({ values }) => {
5558
const availabilityKnown = availableLendableObjectIds !== null;
5659
const lendingObjectOptions: LendingObjectOption[] = availableObjects.map(
5760
(obj) => ({
58-
label: obj.title,
59-
value: obj.id,
60-
isAvailable: !availabilityKnown || availableObjectIds.has(obj.id),
61+
label: obj.title,
62+
value: obj.id,
63+
isAvailable: !availabilityKnown || availableObjectIds.has(obj.id),
6164
}),
6265
);
6366

64-
const lendingSelectStyle: StylesConfig<
65-
LendingObjectOption,
66-
true
67-
> = {
67+
const lendingSelectStyle: StylesConfig<LendingObjectOption, true> = {
6868
option: (base, state) => ({
6969
...base,
7070
display: 'flex',
7171
alignItems: 'center',
7272
justifyContent: 'space-between',
7373
gap: '0.75rem',
74-
color: state.data.isAvailable ? 'var(--lego-font-color)' : 'var(--placeholder-color)',
74+
color: state.data.isAvailable
75+
? 'var(--lego-font-color)'
76+
: 'var(--placeholder-color)',
7577
fontWeight: state.data.isAvailable ? 500 : 400,
7678
opacity: state.data.isAvailable ? 1 : 0.65,
7779
}),
@@ -90,9 +92,28 @@ const LendingSection: React.FC<Props> = ({ values }) => {
9092
}
9193

9294
return (
93-
<div style={{ display: 'flex', width: '100%', justifyContent: 'space-between', gap: '0.75rem' }}>
94-
<span style={{ textDecoration: option.isAvailable ? 'none' : 'line-through' }}>{option.label}</span>
95-
<span style={{ fontSize: '12px', color: 'var(--placeholder-color)', textDecoration: 'none' }}>
95+
<div
96+
style={{
97+
display: 'flex',
98+
width: '100%',
99+
justifyContent: 'space-between',
100+
gap: '0.75rem',
101+
}}
102+
>
103+
<span
104+
style={{
105+
textDecoration: option.isAvailable ? 'none' : 'line-through',
106+
}}
107+
>
108+
{option.label}
109+
</span>
110+
<span
111+
style={{
112+
fontSize: '12px',
113+
color: 'var(--placeholder-color)',
114+
textDecoration: 'none',
115+
}}
116+
>
96117
Ikke tilgjengelig i den valgte perioden
97118
</span>
98119
</div>

lego-webapp/pages/lending/ItemIndex.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@ import {
88
Image,
99
} from '@webkom/lego-bricks';
1010
import cx from 'classnames';
11-
import {
12-
Contact,
13-
ImageOff,
14-
Package,
15-
Tag,
16-
FolderOpen,
17-
Plus,
18-
} from 'lucide-react';
11+
import { Contact, ImageOff, Package, FolderOpen, Plus } from 'lucide-react';
1912
import { useMemo } from 'react';
2013
import EmptyState from '~/components/EmptyState';
2114
import { readmeIfy } from '~/components/ReadmeLogo';

lego-webapp/redux/actions/LendableObjectActions.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { LendableObjects } from '~/redux/actionTypes';
22
import callAPI from '~/redux/actions/callAPI';
33
import { lendableObjectSchema } from '~/redux/schemas';
44
import type { EntityId } from '@reduxjs/toolkit';
5+
import type { Dateish } from 'app/models';
56
import type {
67
CreateLendableObject,
78
DetailLendableObject,
89
EditLendableObject,
910
ListLendableObject,
1011
} from '~/redux/models/LendableObject';
11-
import { Dateish } from 'app/models';
1212

1313
export const fetchAllLendableObjects = () =>
1414
callAPI<ListLendableObject[]>({
@@ -24,7 +24,6 @@ export const fetchAllLendableObjects = () =>
2424
propagateError: true,
2525
});
2626

27-
2827
export const fetchAvailableLendableObjectIdsByDate = (
2928
start_date: string | Dateish,
3029
end_date: string | Dateish,

lego-webapp/redux/models/LendableObject.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ export type ListLendableObject = Pick<
2525
| 'canLend'
2626
| 'availability'
2727
| 'category'
28-
> & { responsibleGroups: EntityId[], available?: boolean /* Currently used by event management to show availability of lending objects in given timeframe */ };
28+
> & {
29+
responsibleGroups: EntityId[];
30+
available?: boolean /* Currently used by event management to show availability of lending objects in given timeframe */;
31+
};
2932

3033
export type DetailLendableObject = ListLendableObject &
3134
Pick<LendableObject, 'actionGrant'> &

lego-webapp/redux/slices/feedActivities.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { type AnyAction, createSlice } from '@reduxjs/toolkit';
1+
import { type AnyAction, createSlice, EntityId } from '@reduxjs/toolkit';
22
import { createSelector } from 'reselect';
33
import { Feed } from '~/redux/actionTypes';
44
import createLegoAdapter from '~/redux/legoAdapter/createLegoAdapter';
55
import { EntityType } from '~/redux/models/entities';
6-
import type { EntityId } from '@reduxjs/toolkit';
76
import type { RootState } from '~/redux/rootReducer';
87

98
const legoAdapter = createLegoAdapter(EntityType.FeedActivities);

lego-webapp/redux/slices/lendableObjects.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import { createSlice } from '@reduxjs/toolkit';
1+
import { createSlice, type AnyAction, type EntityId } from '@reduxjs/toolkit';
22
import { createSelector } from 'reselect';
33
import { LendableObjects } from '~/redux/actionTypes';
44
import createLegoAdapter from '~/redux/legoAdapter/createLegoAdapter';
55
import { EntityType } from '~/redux/models/entities';
6-
import type { EntityId } from '@reduxjs/toolkit';
7-
import type { AnyAction } from '@reduxjs/toolkit';
86
import { selectPaginationNext } from '~/redux/slices/selectors';
97
import type { ListLendableObject } from '~/redux/models/LendableObject';
108
import type { RootState } from '~/redux/rootReducer';
@@ -21,18 +19,24 @@ const lendableObjectsSlice = createSlice({
2119
fetchActions: [LendableObjects.FETCH],
2220
deleteActions: [LendableObjects.DELETE],
2321
extraCases: (addCase) => {
24-
addCase(LendableObjects.FETCH_AVAILABLE.SUCCESS, (state, action: AnyAction) => {
25-
state.availableIds = action.payload;
26-
});
27-
addCase(LendableObjects.FETCH_AVAILABILITY.SUCCESS, (state, action: AnyAction) => {
28-
const id = action.meta.id;
29-
legoAdapter.updateOne(state, {
30-
id,
31-
changes: {
32-
availability: action.payload,
33-
},
34-
});
35-
});
22+
addCase(
23+
LendableObjects.FETCH_AVAILABLE.SUCCESS,
24+
(state, action: AnyAction) => {
25+
state.availableIds = action.payload;
26+
},
27+
);
28+
addCase(
29+
LendableObjects.FETCH_AVAILABILITY.SUCCESS,
30+
(state, action: AnyAction) => {
31+
const id = action.meta.id;
32+
legoAdapter.updateOne(state, {
33+
id,
34+
changes: {
35+
availability: action.payload,
36+
},
37+
});
38+
},
39+
);
3640
},
3741
}),
3842
});

0 commit comments

Comments
 (0)