-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(review): Satisfaction modal for advanced repository
- Loading branch information
1 parent
f3f7a5d
commit b53b2f6
Showing
15 changed files
with
341 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/slice-machine/components/ReviewModal/AdvancedRepositoryReviewModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { FC } from "react"; | ||
|
||
import { useDocumentsCount } from "@src/hooks/useDocumentsCount"; | ||
|
||
import { ReviewForm } from "./ReviewForm"; | ||
|
||
export const AdvancedRepositoryReviewModal: FC = () => { | ||
const documentsCount = useDocumentsCount(["published"]); | ||
const isAdvancedRepository = | ||
documentsCount !== undefined && documentsCount >= 20; | ||
|
||
return isAdvancedRepository ? ( | ||
<ReviewForm reviewType="advancedRepository" /> | ||
) : null; | ||
}; |
51 changes: 51 additions & 0 deletions
51
packages/slice-machine/components/ReviewModal/OnboardingReviewModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { FC } from "react"; | ||
import { useSelector } from "react-redux"; | ||
|
||
import { SliceMachineStoreType } from "@src/redux/type"; | ||
import { getLastSyncChange } from "@src/modules/userContext"; | ||
import { selectAllCustomTypes } from "@src/modules/availableCustomTypes"; | ||
import { getLibraries } from "@src/modules/slices"; | ||
import { hasLocal } from "@lib/models/common/ModelData"; | ||
|
||
import { ReviewForm } from "./ReviewForm"; | ||
|
||
export const OnboardingReviewModal: FC = () => { | ||
const { customTypes, libraries, lastSyncChange } = useSelector( | ||
(store: SliceMachineStoreType) => ({ | ||
customTypes: selectAllCustomTypes(store), | ||
libraries: getLibraries(store), | ||
lastSyncChange: getLastSyncChange(store), | ||
}) | ||
); | ||
|
||
const sliceCount = | ||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions | ||
libraries && libraries.length | ||
? libraries.reduce((count, lib) => { | ||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions | ||
if (!lib) return count; | ||
return count + lib.components.length; | ||
}, 0) | ||
: 0; | ||
|
||
const hasSliceWithinCustomType = customTypes.some( | ||
(customType) => | ||
hasLocal(customType) && | ||
customType.local.tabs.some( | ||
(tab) => tab.sliceZone && tab.sliceZone?.value.length > 0 | ||
) | ||
); | ||
|
||
const hasPushedAnHourAgo = Boolean( | ||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions | ||
lastSyncChange && Date.now() - lastSyncChange >= 3600000 | ||
); | ||
|
||
const isOnboardingDone = | ||
sliceCount >= 1 && | ||
customTypes.length >= 1 && | ||
hasSliceWithinCustomType && | ||
hasPushedAnHourAgo; | ||
|
||
return isOnboardingDone ? <ReviewForm reviewType="onboarding" /> : null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.