Skip to content

Commit

Permalink
190 ticket dr 07 add reveal your nft collection cta in back office as…
Browse files Browse the repository at this point in the history
… well as both deploy cta (#222)

* 🐛 fix(DataTable.stories.tsx): update play function to include assertions for onSortingChange and onColumnFiltersChange callbacks
✨ feat(DataTable.tsx): add support for initialRowSelection, initialColumnFilters, initialSorting props to set initial state of row selection, column filters, and sorting
🔧 chore(DataTable.tsx): add useEffect hooks to trigger onRowSelectionChange, onColumnFiltersChange, and onSortingChange callbacks when state changes

🔧 fix(EventPassNftDelayedInfos.tsx): remove border styling from AccordionContent to improve visual consistency
🔧 fix(EventPassNftsInfos.tsx): remove border styling from AccordionContent to improve visual consistency
🔧 fix(EventPassSaleParameters.tsx): remove border styling from AccordionContent to improve visual consistency

🐛 fix(DataTable.tsx): fix class name in DataTable component to correctly apply flex-grow style
🐛 fix(DataTableColumnHeader.tsx): add missing conditional rendering for DropdownMenuSeparator to improve UI consistency

🐛 fix(EventSheet.stories.tsx): import eventPassNftFiles from the correct file path to fix undefined variable error
🐛 fix(EventsTable.stories.tsx): increase the padding-bottom of the table to prevent content overflow on smaller screens
✨ feat(EventsTable.stories.tsx): add a new story for selecting more items in the table to showcase the functionality

🚀 feat(EventPassNftFilesTable): add EventPassNftFilesTable component to display a table of event pass NFT files
🔧 chore(EventPassNftFilesTable): refactor EventPassNftFilesTable to accept className prop for custom styling
🔧 chore(EventPassNftFilesTableClient): refactor EventPassNftFilesTableClient to accept className prop for custom styling
🔧 chore(DataTable): remove console.log statements from DataTable component

🔧 fix(DataTable.stories.tsx): import Delete icon from @ui/icons to fix missing import error
✨ feat(DataTable.stories.tsx): add DataTableWithSelectedRowsAndActions story to showcase DataTable with selected rows and actions
🔧 fix(DataTableToolbar.tsx): import AutoAnimate component from ../auto-animate/AutoAnimate to fix missing import error
✨ feat(DataTableToolbar.tsx): add support for menuActions prop in DataTableToolbar component to display dropdown menu actions
🔧 fix(DropdownMenuActions.tsx): import cn function from @ui/shared to fix missing import error
✨ feat(DropdownMenuActions.tsx): add support for ping prop in DropdownMenuActions component to display ping badge

🐛 fix(getEventPassNftFiles.tsx): change cache key to include all props to ensure unique cache key for each combination of props
✨ feat(deleteEventPassFiles.ts): add new action to delete event pass files and trigger cache revalidation
🚚 chore(EventPassNftFilesTable.stories.tsx): move imports to the top and remove unused imports
🚚 chore(EventPassNftFilesTable.tsx): remove unused import and add missing line break
🚚 chore(EventPassNftFilesTableClient.tsx): remove unused imports and add missing line breaks
🚚 chore(examples.tsx): move eventPassNftVIP to a separate file and import it in EventSheet/examples.tsx
🚚 chore(en.json): add missing translation for search placeholder and menu actions label in EventPassNftFilesTable
🚚 chore(fr.json): add missing translation for search placeholder in EventPassNftFilesTable

🔧 chore(jest.config.ts): remove unnecessary transform configuration to simplify the jest configuration
🔧 chore(deleteEventPassFiles.spec.ts): refactor deleteEventPassFiles test to use mocks and improve readability
🔧 chore(deleteEventPassFiles.ts): add validation to check if any files are selected before deleting them to prevent unnecessary API calls

🔧 chore(deleteEventPassFile.spec.ts): add unit tests for deleteEventPassFile function
✨ feat(deleteEventPassFile.ts): implement deleteEventPassFile function to delete event pass file and revalidate cache
🔧 chore(EventPassNftFilesTableClient.tsx): integrate deleteEventPassFile function to delete event pass file when delete action is triggered

🔨 chore(ui): add DialogClose component to Dialog module for better modularity and reusability
🔨 chore(ui): add children prop to DataTable component to allow rendering custom content when there are no results

🚀 feat(EventPassFilesUploader): add EventPassFilesUploader component to allow users to upload files for an event pass
🚀 feat(EventPassFilesUploaderClient): add EventPassFilesUploaderClient component to handle the file uploading logic
🔥 chore(EventPassNftFilesUploader): remove unused EventPassNftFilesUploader component
🔧 chore(tsconfig.spec.json): add types folder to spec tsconfig
🌐 chore(i18n): add translations for EventPassFilesUploader component in English and French
🔧 chore(uploader-provider): refactor UploaderProvider to use sessionReady instead of uploader flag

🔨 refactor(EventPassNftFilesTable.tsx): remove unused imports and variables to improve code cleanliness and maintainability
🔨 refactor(EventPassNftFilesTable.tsx): remove unnecessary async keyword from EventPassNftFilesTable function

🐛 fix(getEventPassNftFiles.tsx): remove redundant folderPath variable assignment to improve code readability
🐛 fix(EventPassFilesUploader.stories.tsx): import missing dependencies to fix compilation errors
✨ feat(EventPassFilesUploader.stories.tsx): add new story for displaying skeleton loader when session is not ready
✨ feat(EventPassFilesUploaderClient.tsx): add UploaderSkeleton component to display skeleton loader when session is not ready
✨ feat(EventPassNftFilesTable.stories.tsx): add new stories for scenarios with no files and no files upload modal

🐛 fix(Ping.tsx): add pointer-events-none class to Ping component to prevent it from capturing mouse events
✨ feat(icons.tsx): add Upload icon component to be used for uploading functionality

🐛 fix(DataTable.stories.tsx): add test case for DataTableWithToolbarSearchNoResult to verify no results message is displayed when searching with dummy test
🐛 fix(DataTable.stories.tsx): add test case for DataTableWithNoData to verify no results message and absence of filter and pagination controls when data is empty
🐛 fix(DataTable.tsx): update conditional rendering of DataTableToolbar and DataTablePagination to only render when data is not empty

🐛 fix(EventPassNftFilesTable/examples.tsx): rename eventPassNftVIP to eventPassNftVIPWithContract for clarity and consistency
🐛 fix(EventPassNftFilesTable/examples.tsx): add eventPassNftVipNoContractDelayedReveal to provide an example of a delayed pass with no contract
🐛 fix(EventSheet/EventSheet.stories.tsx): remove unnecessary code for deleting a file in the Default story
✨ feat(EventSheet/examples.tsx): add eventPassNftVIPWithContract and eventPassNftVipNoContractDelayedReveal to provide examples of event passes with different configurations

🔧 fix(EventPassFilesUploader.stories.tsx): update import of eventPassNftVIP to eventPassNftVIPWithContract to reflect changes in EventPassNftFilesTable
🔧 fix(EventPassFilesUploader.tsx): add buttonClassName prop to EventPassFilesUploader component to allow custom styling of the trigger button
🎨 chore(EventPassFilesUploader.tsx): import Upload icon from @ui/icons to use as the trigger button icon

🐛 fix(EventPassNftFiles.tsx): add missing import for EventPassFilesUploader component
✨ feat(EventPassNftFiles.tsx): add support for uploading event pass files and display them in a table
🐛 fix(EventPassNftFilesTable.stories.tsx): fix import statements and add missing import for deleteEventPassFile action
✨ feat(EventPassNftFilesTable.stories.tsx): add stories for different scenarios of event pass files table
🐛 fix(EventPassNftFilesTableClient.tsx): fix import statements and add missing import for Download icon
✨ feat(EventPassNftFilesTableClient.tsx): add support for downloading event pass files and display them in a table
🐛 fix(en.json): add missing translations for downloading files in event pass files table
🐛 fix(fr.json): add missing translations for downloading files in event pass files table

🔧 fix(DataTable.tsx): update rowSelection when data or table state changes to ensure correct selection
🔧 fix(DataTableToolbar.tsx): update numSelectedItems calculation to use getFilteredSelectedRowModel() for accurate count
🔇 chore(DataTableViewOptions.tsx): remove console.log statement

📦 chore(getEventPassNftFiles.ts): add new file getEventPassNftFiles.ts to handle fetching event pass NFT files
🐛 fix(deleteEventPassFile.ts): change fileName parameter to filePath to improve semantics
📦 chore(resetEventPassNftFiles.ts): add new file resetEventPassNftFiles.ts to handle resetting event pass NFT files

🔧 chore(EventPassFilesUploader.tsx): organize imports and remove unused import to improve code readability and maintainability
🔧 chore(EventPassFilesUploaderClient.tsx): organize imports and remove unused import to improve code readability and maintainability
🔧 chore(EventPassFilesUploaderClient.tsx): add missing dependencies to useEffect hook to prevent unnecessary re-renders and improve performance
🔧 chore(EventPassFilesUploaderClient.tsx): replace deprecated revalidateTag function with resetEventPassNftFiles action to reset event pass NFT files and trigger revalidation

🐛 fix(EventPassNftFiles.tsx): add missing className and remove unused buttonClassName to fix styling issue
🐛 fix(EventPassNftFilesTable.stories.tsx): change fileName to filePath to match the actual file path
🐛 fix(EventPassNftFilesTable.tsx): change accessorKey from filePath to fileName to display the correct file name
🐛 fix(EventPassNftFilesTableClient.tsx): change accessorKey from filePath to fileName to display the correct file name
🐛 fix(EventPassNftFilesTableClient.tsx): add missing eventSlug and locale props to resetEventPassNftFiles action
✨ feat(EventPassNftFilesTableClient.tsx): add support for row selection and delete multiple files at once
✨ feat(EventPassNftFilesTableClient.tsx): add support for resetting event pass nft files after deletion
🐛 fix(EventPassNftFilesTable/examples.tsx): add fileName property to match the actual file name
🐛 fix(EventPassCardContentNormal.tsx): add missing eventSlug prop to EventPassNftFiles component
🌐 update(en.json): update description message in EventPassFilesUploader to include the number of files remaining
🌐 update(fr.json): update description message in EventPassFilesUploader to include the number of files remaining

🔧 fix(EventPassFilesUploaderClient.tsx): remove unused imports and commented code
🔧 fix(EventPassFilesUploaderClient.tsx): remove unused function parameters and console.log statements
🔧 fix(EventPassFilesUploaderClient.tsx): remove unused import and action
🔧 fix(EventPassFilesUploaderClient.tsx): remove unused function and useEffect dependency
🔧 fix(EventPassFilesUploaderClient.tsx): remove unused function onUpdate
🔧 fix(index.ts): increase number of retries and minTimeout for executeJobWithRetry function
🔧 fix(index.tsx): remove unused imports and interfaces from uploader-provider
🚀 chore(package.json): add @bytescale/upload-widget dependency

🔥 refactor(events-api): remove unused getEventPassNftFiles function

🔥 refactor(getEventPassFileCount): remove unused getEventPassFileCount function

✨ feat(getEventPassNftFiles): add getEventPassNftFiles function to retrieve event pass NFT files

✨ feat(checkEventPassNftFilesHash): add checkEventPassNftFilesHash function to check for duplicate NFT files

🔧 chore(EventPassCardFooter): update import path for getEventPassNftFiles

🔧 chore(EventPassFilesUploader): update import path for getEventPassNftFiles

🔧 chore(EventPassFilesUploaderClient): update import paths for checkEventPassNftFilesHash and getEventPassNftFiles

🔧 chore(EventPassNftFilesTable): update import path for getEventPassNftFiles

🚀 feat(checkEventPassNftFilesHash.spec.ts): add unit tests for checkEventPassNftFilesHash function to ensure its correctness and reliability

🐛 fix(checkEventPassFilesHash.ts): add missing type definition for DuplicatesType to improve code readability and maintainability
🐛 fix(EventPassFilesUploader.stories.tsx): add missing eventSlug prop to Default story to fix compilation error
✨ feat(EventPassFilesUploaderClient.tsx): add support for displaying missing files number and duplicates in the UI to improve user experience
✨ feat(EventPassNftFiles.tsx): wrap EventPassFilesUploader component with NextIntlClientProvider to enable translation support
🐛 fix(EventPassNftFilesTableClient.tsx): remove unnecessary maxFileCount prop from EventPassFilesUploader component to fix compilation error
🌐 chore(en.json): add missing translation for missing files number in EventPassFilesUploader component
🌐 chore(fr.json): add missing translation for missing files number in EventPassFilesUploader component

* 🐛 fix(server.ts): change port variable case from lowercase port to uppercase PORT to improve semantics
✨ feat(server.ts): add support for process.env.PORT environment variable to be able to run app on a configurable port
🐛 fix(index.ts): import FileSummary from @bytescale/sdk to fix missing import error
🐛 fix(checkEventPassFilesHash.ts): change DuplicatesType type to Array<Array<string>> to fix type error
🐛 fix(EventPassFilesUploader.stories.tsx): import getPass from '../../actions/getEventPassNftFiles' to fix missing import error
🐛 fix(EventPassFilesUploader.tsx): add className prop to ButtonSkeleton component to fix styling issue
🐛 fix(EventPassFilesUploaderClient.tsx): remove unused imports and fix missing import error
🐛 fix(EventPassFilesUploaderClient.tsx): remove unused variables and fix missing import error
🐛 fix(EventPassNftFilesTable.stories.tsx): import checkPass from '../../actions/checkEventPassFilesHash' and getPass from '../../actions/getEventPassNftFiles' to fix missing import error
🐛 fix(EventPassNftFilesTableClient.tsx): import Alert from '@ui/components' to fix missing import error
🐛 fix(EventPassNftFilesTableClient.tsx): import DuplicatesType and checkEventPassNftFilesHash from '../../actions/checkEventPassFilesHash' to fix missing import error
🐛 fix(EventPassNftFilesTableClient.tsx): import useEffect and useState from 'react' to fix missing import error
🐛 fix(EventPassNftFilesTableClient.tsx): import EventPassFileWithName from '@features/back-office/events-types' to fix missing import error
🐛 fix(EventSheet.stories.tsx): import getPass from '../../actions/getEventPassNftFiles' to fix missing import error
🐛 fix(en.json): add missing translation for duplicates-alert
🐛 fix(fr.json): add missing translation for duplicates-alert
🐛 fix(DataTable.tsx): add useEffect to update rowSelection state when initialRowSelection prop changes

* 🐛 fix(EventPassFilesUploaderClient.tsx): set missing files number based on eventPassPricing maxAmount if available
🐛 fix(EventPassNftFilesTableClient.tsx): clear duplicates state when there are no duplicates
✨ feat(EventPassCardContentDelayedReveal.tsx): pass event slug to EventPassCardFilesUploader
🌐 chore(i18n): update duplicates-alert message to include line breaks for better readability in English and French translations

* 🔧 chore(.eslintrc.json): add 'jsx-a11y' plugin to improve accessibility linting
🔧 chore(.eslintrc.json): update 'extends' property to include 'jsx-a11y' plugin
🔧 chore(.eslintrc.json): update 'import/parsers' property to include '.ts' and '.tsx' extensions for '@typescript-eslint/parser'
🔧 chore(.eslintrc.json): update 'files' property to include '*.ts' and '*.tsx' extensions for 'plugin:@nx/eslint-plugin/typescript'
🔧 chore(.eslintrc.json): update 'files' property to include '*.js' and '*.jsx' extensions for 'plugin:@nx/eslint-plugin/javascript'
🔧 chore(.eslintrc.json): update 'files' property to include '*.json' extension for 'plugin:json/recommended'
🔧 chore(.eslintrc.json): update 'files' property to include '**/*.md' extension for 'processor:markdown/markdown'
🐛 fix(global-error.tsx): add 'lang="en"' attribute to html tag for better language support
🐛 fix(not-found.tsx): add 'lang="en"' attribute to html tag for better language support
🐛 fix(global-error.tsx): add 'lang="en"' attribute to html tag for better language support
🐛 fix(not-found.tsx): add 'lang="en"' attribute to html tag for better language support
🐛 fix(EventPassDeployButtonClient.tsx): add missing import statements and fix formatting
🐛 fix(EventPassCard.tsx): pass 'eventSlug' and 'eventPassType' props to EventPassDeployButtonClient
🐛 fix(DiscordWidget.tsx): add 'title' attribute to iframe for better accessibility
🐛 fix(authProvider.tsx): add 'chainId' and 'chainConfig' properties to AuthContextValue
🐛 fix(safeAuthSetup.tsx): add 'chainConfig' and 'chainId' properties to UseSafeAuthProps

* 🐛 fix(server.ts): change port variable case from lowercase port to uppercase PORT to improve semantics
✨ feat(server.ts): add support for process.env.PORT environment variable to be able to run app on a configurable port
🐛 fix(EventPassCardFooter.tsx): import checkEventPassNftFilesHash to fix missing import error
✨ feat(EventPassCardFooter.tsx): add logic to check for duplicate files before deploying the contract
🐛 fix(EventPassNftFilesTable.stories.tsx): fix import statements and remove unnecessary mocks
✨ feat(EventPassNftFilesTable.stories.tsx): add story for displaying error message when there are duplicate files
✨ feat(EventSheet.stories.tsx): add story for testing click on deploy button
🌐 chore(i18n): update English and French translations for new error message
🐛 fix(HelperText.tsx): add space-y-1 class to HelperText component to fix spacing issue
🐛 fix(Popover.tsx): add missing children prop to PopoverTitle component

* 🐛 fix(renameEventPassNftFiles.spec.ts): add missing import statements for dependencies used in the test file
✨ feat(renameEventPassNftFiles.spec.ts): add unit tests for the renameEventPassNftFiles function to ensure correct file renaming and handling of edge cases
🐛 fix(renameEventPassNftFiles.ts): fix typo in import statement
✨ feat(renameEventPassNftFiles.ts): add function to rename event pass NFT files with modified file paths and delete original files
🐛 fix(EventPassDeployButtonClient.tsx): add missing import statements for checkEventPassNftFilesHash and getEventPassNftFiles functions
✨ feat(EventPassDeployButtonClient.tsx): add logic to deploy event pass contract with error handling and file validation before deployment

* 🐛 fix(EventPassDeployButtonClient.tsx): remove unused imports and update function name to improve code readability
✨ feat(EventPassDeployButtonClient.tsx): add support for renaming event pass NFT files before deployment to improve file management
✨ feat(EventPassDeployButtonClient.tsx): add support for deploying event pass NFT collection using a wrapper function for better code organization
🐛 fix(authProvider.tsx): add getSigner function to retrieve the signer object for authentication
🐛 fix(safeAuthSetup.tsx): update getSigner function to use ethers5 instead of ethers6 for compatibility with thirdweb library

* 🚀 feat(deployCollectionWrapper.ts): add deployCollectionWrapper function to handle the deployment of NFT collections
🚚 chore(EventPassDeployButtonClient.tsx): move deployCollectionWrapper to actions folder for better organization
🚚 chore(EventSheet.stories.tsx): move deployCollectionWrapper and renameEventPassNftFiles to actions folder for better organization
🔧 chore(EventSheet.stories.tsx): mock renameEventPassNftFiles and deployCollectionWrapper functions for testing purposes
🔧 chore(EventSheet.stories.tsx): add organizerId prop to args in EventSheetExample for testing purposes
🔧 chore(EventSheet.stories.tsx): mock getSigner and provider properties in useAuthContext for testing purposes
🔧 chore(EventSheet.stories.tsx): add test case for clicking on deploy button and assert that deployCollectionWrapper is called with the correct arguments

* 🐛 fix(getEventWithPassesOrganizer): add next tags to improve caching and invalidation strategy
✨ feat(resetEventPassNftFiles): add function to reset event pass NFT files and revalidate path
✨ feat(resetEventPasses): add function to reset event passes and revalidate path
🐛 fix(EventPassCardFooter): add missing import for useToast and getErrorMessage
✨ feat(EventPassCardFooter): add support for internationalization using NextIntlClientProvider and useLocale
🐛 fix(EventPassDeployButtonClient): add missing import for useToast and getErrorMessage
✨ feat(EventPassDeployButtonClient): add success and error toasts after deploying contract and reset event pass NFT files and event passes
🐛 fix(EventPassFilesUploader): add missing import for HelperText
✨ feat(EventPassFilesUploader): add support for disabling upload button when maximum file count is reached and display disabled reason
🐛 fix(EventSheet): add missing import for render
✨ feat(EventSheet): add success and error toasts after deploying contract
🐛 fix(useSafeAuth): remove unnecessary line break
🐛 fix(en.json): add missing translation for error title in EventPassDeployButtonClient
✨ feat(en.json): add translations for success and error titles in EventPassDeployButtonClient
🐛 fix(fr.json): add missing translation for success title in EventPassDeployButtonClient
✨ feat(fr.json): add translation for success title in EventPassDeployButtonClient
🐛 fix(safeAuthSetup): remove unnecessary line break

* 🔀 chore(next.config.js): update module imports to include new features and dependencies

* 🔨 refactor(action.ts): remove unused imports and functions for better code organization and readability
🔨 refactor(index.ts): remove unused imports and update type definitions for better code organization and readability
🔨 refactor(index.ts): remove unnecessary null checks and improve error handling for better code reliability
🔨 refactor(index.ts): update type definitions and remove unused variables for better code organization and readability

* 🔀 chore(nft-event-pass): rename eventPass library to event-pass for consistency and clarity

* 🔧 chore(.eslintrc.json): reformat and optimize ESLint configuration file for better readability and maintainability

* 🔧 chore(build-and-e2e-tests.yml): update workflow to use environment variables for conditional steps
🔧 chore(build-and-e2e-tests.yml): update workflow to use environment variables for conditional steps

* 🐛 fix(globalSetupHasura.ts): update hasuraUrl variable to use '9696' port when NODE_ENV is 'test' to align with test environment configuration
🐛 fix(globalSetupHasura.ts): update logger.debug message to include the hasuraUrl variable for better debugging
  • Loading branch information
sebpalluel authored Dec 22, 2023
1 parent b17569e commit 2d709a9
Show file tree
Hide file tree
Showing 96 changed files with 2,326 additions and 323 deletions.
11 changes: 9 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"root": true,
"plugins": ["@nx/eslint-plugin", "markdown", "sonarjs", "tailwindcss"],
"plugins": [
"@nx/eslint-plugin",
"markdown",
"sonarjs",
"tailwindcss",
"jsx-a11y"
],
"extends": [
"eslint-config-prettier",
"plugin:import/recommended",
Expand All @@ -10,7 +16,8 @@
"plugin:sonarjs/recommended",
"plugin:storybook/recommended",
"plugin:playwright/recommended",
"plugin:tailwindcss/recommended"
"plugin:tailwindcss/recommended",
"plugin:jsx-a11y/recommended"
],
"settings": {
"import/resolver": {
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/build-and-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:

env:
NODE_OPTIONS: '--max_old_space_size=4096'
web: 'false'
back-office: 'false'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -41,17 +43,16 @@ jobs:
id: check
run: |
affected=$(pnpm nx affected -t=build)
echo "::set-output name=back-office::$(echo $affected | grep -q 'back-office:build:production' && echo true || echo false)"
echo "::set-output name=web::$(echo $affected | grep -q 'web:build:production' && echo true || echo false)"
echo "back-office=$(echo $affected | grep -q 'back-office:build:production' && echo true || echo false)" >> $GITHUB_ENV
echo "web=$(echo $affected | grep -q 'web:build:production' && echo true || echo false)" >> $GITHUB_ENV
- name: Launch docker services
if: steps.check.outputs.back-office == 'true' || steps.check.outputs.web == 'true'
if: ${{ env.back-office == 'true' || env.web == 'true' }}
run: pnpm docker:services

- name: Run e2e tests for back-office
if: steps.check.outputs.back-office == 'true'
if: ${{ env.back-office == 'true' }}
run: pnpm nx run back-office:e2e --skipInstall

- name: Run e2e tests for web
if: steps.check.outputs.web == 'true'
if: ${{ env.web == 'true' }}
run: pnpm nx run web:e2e --skipInstall
2 changes: 1 addition & 1 deletion apps/back-office/app/global-error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function Error({
}, [error]);

return (
<html>
<html lang="en">
<body>{/* <UIError error={error} reset={reset} /> */}</body>
</html>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/back-office/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function NotFound() {
return (
<html>
<html lang="en">
<body>Not Found</body>
</html>
);
Expand Down
10 changes: 10 additions & 0 deletions apps/back-office/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,16 @@ const nextConfig = {
'@features/appNav',
'@features/back-office/appNav',
'@features/back-office/events',
'@features/back-office/events-api',
'@features/back-office/roles',
'@features/back-office/roles-actions',
'@features/back-office/roles-api',
'@features/kyc',
'@features/kyc/server',
'@features/navigation',
'@features/pass',
'@features/pass-api',
'@features/pass-actions',
'@features/organizer/event',
'@features/organizer/event/server',
'@features/settings',
Expand All @@ -108,6 +115,9 @@ const nextConfig = {
'@gql/anonymous/react-query',
'@gql/anonymous/types',
'@gql/shared/types',
'@nft/thirdweb-admin',
'@nft/thirdweb-organizer',
'@nft/event-pass',
],
// https://vercel.com/docs/concepts/deployments/skew-protection#enabling-skew-protection
useDeploymentId: true,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/global-error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function Error({
}, [error]);

return (
<html>
<html lang="en">
<body>{}</body>
</html>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function NotFound() {
return (
<html>
<html lang="en">
<body>Not Found</body>
</html>
);
Expand Down
4 changes: 0 additions & 4 deletions libs/features/back-office/events-api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export { getEventPassDelayedRevealedFromEventPassIdOrganizer } from './lib/getEventPassDelayedRevealedFromEventPassIdOrganizer';
export {
getEventPassNftFiles,
type GetEventPassNftFilesProps,
} from './lib/getEventPassNftFiles';
export { getEventWithPassesOrganizer } from './lib/getEventWithPassesOrganizer';
export { getEventsFromOrganizerIdTable } from './lib/getEventsFromOrganizerIdTable';
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ export const getEventPassNftFiles = cacheWithDynamicKeys(
const folderPath = getEventPassOrganizerFolderPath(props);
const list = await folder.listFolder({
accountId: env.UPLOAD_ACCOUNT_ID,
folderPath: folderPath,
folderPath,
});
return list.items.filter((item): item is FileSummary => 'filePath' in item);
},
(props: [GetEventPassNftFilesProps]) => [
props[0].organizerId,
props[0].eventId,
props[0].eventPassId,
'getEventPassNftFiles',
`${props[0].organizerId}-${props[0].eventId}-${props[0].eventPassId}-getEventPassNftFiles`,
],
);
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ interface GetEventWithPassesOrganizer {

export const getEventWithPassesOrganizer = cache(
async ({ slug, locale }: GetEventWithPassesOrganizer) => {
const data = await adminSdk.GetEventWithPassesOrganizer({
slug,
locale: locale as Locale,
stage: env.HYGRAPH_STAGE as Stage,
});
const data = await adminSdk.GetEventWithPassesOrganizer(
{
slug,
locale: locale as Locale,
stage: env.HYGRAPH_STAGE as Stage,
},
{
next: {
tags: [`${slug}-getEventWithPassesOrganizer`],
},
},
);
return data?.event;
},
);
5 changes: 5 additions & 0 deletions libs/features/back-office/events-types/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { FileSummary } from '@bytescale/sdk';
import type {
GetEventWithPassesOrganizerQuery,
GetEventsFromOrganizerIdTableQuery,
Expand All @@ -16,3 +17,7 @@ export type EventPass = EventFromOrganizerWithPasses['eventPasses'][0];
export type EventPassDelayedRevealed = NonNullable<
EventPass['eventPassDelayedRevealed']
>;

export interface EventPassFileWithName extends FileSummary {
fileName: string;
}
4 changes: 0 additions & 4 deletions libs/features/back-office/events/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
export default {
displayName: 'features-back-office-events',
preset: '../../../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../../../coverage/libs/features/back-office/events',
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use server';
import env from '@env/server';
import { GetEventPassOrganizerFolderPath } from '@features/pass-common';
import { FileWrapper } from '@file-upload/admin';
import { cacheWithDynamicKeys } from '@next/cache';

import crypto from 'crypto';

export type CheckEventPassNftFilesHashProps =
GetEventPassOrganizerFolderPath & {
filesPath: string[];
};

export const checkEventPassNftFilesHash = cacheWithDynamicKeys(
async ({ filesPath }: CheckEventPassNftFilesHashProps) => {
const fileWrapper = new FileWrapper();
const filesContent = await Promise.all(
filesPath.map((filePath) =>
fileWrapper
.downloadFile({
accountId: env.UPLOAD_ACCOUNT_ID,
filePath,
})
.then(async (response) => {
const blob = await response.blob();
const arrayBuffer = await blob.arrayBuffer();
const hash = crypto
.createHash('sha256')
.update(Buffer.from(arrayBuffer))
.digest('hex');
return { hash, path: filePath };
}),
),
);
const hashMap = new Map();
for (const file of filesContent) {
const existingFiles = hashMap.get(file.hash) || [];
existingFiles.push(file.path);
hashMap.set(file.hash, existingFiles);
}
return Array.from(hashMap.values()).filter((paths) => paths.length > 1);
},
(props: [CheckEventPassNftFilesHashProps]) => [
`${props[0].organizerId}-${props[0].eventId}-${props[0].eventPassId}-getEventPassNftFiles`,
],
);

export type DuplicatesType = Array<Array<string>>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { FileWrapper } from '@file-upload/admin';
import crypto from 'crypto';
import { unstable_cache } from 'next/cache';
import { checkEventPassNftFilesHash } from './checkEventPassFilesHash';

jest.mock('@file-upload/admin');
jest.mock('crypto');
jest.mock('next/cache');

describe('checkEventPassNftFilesHash', () => {
beforeAll(() => {
(unstable_cache as jest.Mock).mockImplementation(
(fn) =>
(...args) =>
fn(...args),
);
const mockArrayBuffer = new ArrayBuffer(8);
const mockBlob = new Blob(['file content']);
mockBlob.arrayBuffer = jest.fn().mockResolvedValue(mockArrayBuffer); // Mock arrayBuffer method

const mockResponse = { blob: jest.fn().mockResolvedValue(mockBlob) };

FileWrapper.prototype.downloadFile = jest
.fn()
.mockResolvedValue(mockResponse);
});
it('should return duplicate file paths', async () => {
const mockFilesPath = ['path1', 'path2'];
const mockProps = {
organizerId: 'org1',
eventId: 'event1',
eventPassId: 'pass1',
filesPath: mockFilesPath,
};
(crypto.createHash as jest.Mock).mockReturnValue({
update: jest.fn().mockReturnThis(),
digest: jest.fn().mockReturnValue('hash1'),
});

const result = await checkEventPassNftFilesHash(mockProps);

expect(result).toEqual([mockFilesPath]);
});
it('should return empty array when no duplicate file paths', async () => {
const mockFilesPath = ['path1', 'path2'];
const mockProps = {
organizerId: 'org1',
eventId: 'event1',
eventPassId: 'pass1',
filesPath: mockFilesPath,
};

(crypto.createHash as jest.Mock).mockReturnValue({
update: jest.fn().mockReturnThis(),
digest: jest
.fn()
.mockReturnValueOnce('hash1')
.mockReturnValueOnce('hash2'),
});

const result = await checkEventPassNftFilesHash(mockProps);

expect(result).toEqual([]);
});

it('should return duplicate separate entries for each files that have paths that have the same hash', async () => {
const mockFilesPath = [
'path1',
'path2',
'path3',
'path4',
'path5',
'path6',
];
const mockProps = {
organizerId: 'org1',
eventId: 'event1',
eventPassId: 'pass1',
filesPath: mockFilesPath,
};

(crypto.createHash as jest.Mock).mockReturnValue({
update: jest.fn().mockReturnThis(),
digest: jest
.fn()
.mockReturnValueOnce('hash1')
.mockReturnValueOnce('hash2')
.mockReturnValueOnce('hash1')
.mockReturnValueOnce('hash1')
.mockReturnValueOnce('hash2')
.mockReturnValueOnce('hash3'),
});

const result = await checkEventPassNftFilesHash(mockProps);

expect(result).toEqual([
['path1', 'path3', 'path4'],
['path2', 'path5'],
]);
});
});
Loading

0 comments on commit 2d709a9

Please sign in to comment.