(id: number)
| 47 | }, [packId]); |
| 48 | |
| 49 | async function getData(id: number) { |
| 50 | try { |
| 51 | const pack = await getPack(id); |
| 52 | const { items, userId, title } = pack; |
| 53 | if (user && user.id !== userId) { |
| 54 | history.push(getPackPath(id, title)); |
| 55 | return; |
| 56 | } |
| 57 | setPackData(pack); |
| 58 | setPackItems(items); |
| 59 | setLoading(false); |
| 60 | } catch (e) { |
| 61 | alertError({ message: 'Unable to retrieve pack information.' }) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | const addItem = (item: Item) => { |
| 66 | const items = Object.assign([], [...packItems, { ...item, packItem: { notes: '', quantity: 1, worn: false } }]); |
no test coverage detected