Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CSGN-225] Choose the destination of artist consign taps based on your active tab #3402

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions Artsy/App/ARSwitchBoard.m
Expand Up @@ -29,6 +29,7 @@

#import <Emission/ARNewSubmissionFormComponentViewController.h>
#import <Emission/ARShowConsignmentsFlowViewController.h>
#import <Emission/ARSellTabLandingViewController.h>
#import <Emission/ARFairComponentViewController.h>
#import <Emission/ARFairBoothComponentViewController.h>
#import <Emission/ARFairArtworksComponentViewController.h>
Expand Down Expand Up @@ -286,6 +287,10 @@ - (void)updateRoutes
return [[ARNavigationController alloc] initWithRootViewController:submissionVC];
}];

[self.routes addRoute:@"/collections/my-collection/marketing-landing" handler:JLRouteParams {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice route! 🤩

return [[ARSellTabLandingViewController alloc] init];
}];

[self.routes addRoute:@"/conditions-of-sale" handler:JLRouteParams {
// We want to fall back to the default routing unless this query parameter is specified, from Emission.
// This prevents someone from opening a /conditions-of-sale link somewhere not within the Emission Bid Flow (eg
Expand Down
@@ -0,0 +1,15 @@
#import <Emission/ARComponentViewController.h>

NS_ASSUME_NONNULL_BEGIN

@interface ARSellTabLandingViewController : ARComponentViewController

- (instancetype)init NS_DESIGNATED_INITIALIZER;

- (instancetype)initWithEmission:(nullable AREmission *)emission
moduleName:(NSString *)moduleName
initialProperties:(nullable NSDictionary *)initialProperties NS_UNAVAILABLE;

@end

NS_ASSUME_NONNULL_END
@@ -0,0 +1,10 @@
#import "ARSellTabLandingViewController.h"

@implementation ARSellTabLandingViewController

- (instancetype)init
{
return [super initWithEmission:nil moduleName:@"SellTabLanding" initialProperties:nil];
}

@end
2 changes: 2 additions & 0 deletions src/lib/AppRegistry.tsx
Expand Up @@ -21,6 +21,7 @@ import { CitySectionListRenderer } from "./Scenes/City/CitySectionList"
import { CollectionRenderer } from "./Scenes/Collection/Collection"
import { CollectionFullFeaturedArtistListRenderer } from "./Scenes/Collection/Components/FullFeaturedArtistList"
import Consignments from "./Scenes/Consignments"
import { SellTabLanding } from "./Scenes/Consignments/SellTabLanding"
import {
FairArtistsRenderer,
FairArtworksRenderer,
Expand Down Expand Up @@ -281,6 +282,7 @@ register("CitySavedList", CitySavedListRenderer)
register("CitySectionList", CitySectionListRenderer)
register("Collection", CollectionRenderer, { fullBleed: true })
register("Consignments", Consignments)
register("SellTabLanding", SellTabLanding)
register("Conversation", Conversation)
register("Fair", FairRenderer, { fullBleed: true })
register("FairArtists", FairArtists)
Expand Down
10 changes: 8 additions & 2 deletions src/lib/Components/Artist/ArtistConsignButton.tsx
@@ -1,14 +1,15 @@
import { ArrowRightIcon, BorderBox, Box, Flex, Sans } from "@artsy/palette"
import React, { useRef } from "react"
import { NativeModules, TouchableOpacity } from "react-native"
import { createFragmentContainer, graphql } from "react-relay"
import { useTracking } from "react-tracking"
import styled from "styled-components/native"

import { ArtistConsignButton_artist } from "__generated__/ArtistConsignButton_artist.graphql"
import SwitchBoard from "lib/NativeModules/SwitchBoard"
import { TabName, useSelectedTabName } from "lib/NativeModules/TopMenu"
import { Router } from "lib/utils/router"
import { Schema } from "lib/utils/track"
import { NativeModules, TouchableOpacity } from "react-native"

export interface ArtistConsignButtonProps {
artist: ArtistConsignButton_artist
Expand All @@ -17,6 +18,7 @@ export interface ArtistConsignButtonProps {
export const ArtistConsignButton: React.FC<ArtistConsignButtonProps> = props => {
const tracking = useTracking()
const buttonRef = useRef()
const selectedTabName = useSelectedTabName()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌


const {
artist: {
Expand All @@ -35,8 +37,12 @@ export const ArtistConsignButton: React.FC<ArtistConsignButtonProps> = props =>
// @ts-ignore STRICTNESS_MIGRATION
ref={buttonRef}
onPress={() => {
let destination: Router | string = Router.ConsignmentsStartSubmission
const featureFlag = NativeModules?.Emission?.options?.AROptionsMoveCityGuideEnableSales
const destination = featureFlag ? "/sales" : Router.ConsignmentsStartSubmission
if (featureFlag) {
destination =
selectedTabName === TabName.ARSalesTab ? "/collections/my-collection/marketing-landing" : "/sales"
}

tracking.trackEvent({
context_page: Schema.PageNames.ArtistPage,
Expand Down
25 changes: 23 additions & 2 deletions src/lib/NativeModules/TopMenu.tsx
@@ -1,7 +1,28 @@
import { useEffect, useState } from "react"
import { NativeModules } from "react-native"

const { ARTopMenuModule } = NativeModules

export function getSelectedTabName() {
return ARTopMenuModule.getSelectedTabName()
export enum TabName {
ARHomeTab = "ARHomeTab",
ARSearchTab = "ARSearchTab",
ARMessagingTab = "ARMessagingTab",
ARLocalDiscoveryTab = "ARLocalDiscoveryTab",
ARFavoritesTab = "ARFavoritesTab",
ARSalesTab = "ARSalesTab",
Unknown = "Unknown",
jonallured marked this conversation as resolved.
Show resolved Hide resolved
}

export function useSelectedTabName() {
const [selectedTabName, setSelectedTabName] = useState(TabName.Unknown)

useEffect(() => {
async function runEffect() {
const tabName = await ARTopMenuModule.getSelectedTabName()
setSelectedTabName(tabName)
}
runEffect()
}, [])

return selectedTabName
}
11 changes: 11 additions & 0 deletions src/lib/Scenes/Consignments/SellTabLanding.tsx
@@ -0,0 +1,11 @@
import { Theme } from "@artsy/palette"
import React from "react"
import { ConsignmentsHomeQueryRenderer as ConsignmentsHome } from "./v2/Screens/ConsignmentsHome"

export function SellTabLanding() {
jonallured marked this conversation as resolved.
Show resolved Hide resolved
return (
<Theme>
<ConsignmentsHome />
</Theme>
)
}