Skip to content

Commit

Permalink
change setpackidparam
Browse files Browse the repository at this point in the history
  • Loading branch information
Isthisanmol committed Sep 8, 2024
1 parent 3835e11 commit 263d81b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/app/modules/pack/widgets/PackContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ export default function PackContainer({ isCreatingTrip = false }) {
}, [refetch]);

useEffect(() => {
if (packs.length > oldPacks.length) {
if (packs.length > oldPacks.length && isCreatingTrip) {
const newPack = packs.find((pack) => !oldPacks.includes(pack.id));
setCurrentPackId(newPack?.id);
setPackIdParam(newPack?.id);
oldPacks.push(newPack?.id);
}
}, packs);
Expand All @@ -59,12 +60,12 @@ export default function PackContainer({ isCreatingTrip = false }) {

const dataValues = packs?.map((item) => item?.name) ?? [];

useEffect(() => {
const firstPack = packs.find(({ id }) => !!id);
if (!packIdParam && firstPack?.id && isCreatingTrip) {
setPackIdParam(firstPack.id);
}
}, [packIdParam, packs, isCreatingTrip]);
// useEffect(() => {
// const firstPack = packs.find(({ id }) => !!id);
// if (!packIdParam && firstPack?.id && isCreatingTrip) {
// setPackIdParam(firstPack.id);
// }
// }, [packIdParam, packs, isCreatingTrip]);

return dataValues?.length > 0 ? (
<View style={styles.mainContainer}>
Expand Down

0 comments on commit 263d81b

Please sign in to comment.