id
stringlengths 12
53
| messages
listlengths 3
3
|
|---|---|
code_b2b-organizations_7302756c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/setCurrentOrganization.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation CurrentOrganization($orgId: ID!, $costId: ID!) {\n setCurrentOrganization(orgId: $orgId, costId: $costId)\n @context(provider: \"vtex.storefront-permissions\") {\n status\n message\n }\n}\n\n```"
}
] |
code_b2b-organizations_4d1db77b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/impersonateUser.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation ImpersonateUser($clId: ID, $userId: ID) {\n impersonateUser(clId: $clId, userId: $userId)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n status\n message\n }\n}\n\n```"
}
] |
code_b2b-organizations_0cd16c10
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/updateCostCenter.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation UpdateCostCenter($id: ID!, $input: CostCenterInput!) {\n updateCostCenter(id: $id, input: $input)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n status\n message\n }\n}\n\n```"
}
] |
code_b2b-organizations_09aa6607
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getPaymentTerms.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetPaymentTerms {\n getPaymentTerms\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n name\n }\n}\n\n```"
}
] |
code_b2b-organizations_d966ab29
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/removeUser.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation RemoveUser($id: ID!, $userId: ID, $email: String!, $clId: ID!) {\n removeUser(id: $id, userId: $userId, email: $email, clId: $clId)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n status\n }\n}\n\n```"
}
] |
code_b2b-organizations_d2a6d53d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/updateOrganizationRequest.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation UpdateOrganizationRequest($id: ID!, $status: String!, $notes: String) {\n updateOrganizationRequest(id: $id, status: $status, notes: $notes)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n status\n message\n }\n}\n\n```"
}
] |
code_b2b-organizations_f966e21c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getOrganizations.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetOrganizations(\n $status: [String]\n $search: String\n $page: Int\n $pageSize: Int\n $sortOrder: String\n $sortedBy: String\n) {\n getOrganizations(\n status: $status\n search: $search\n page: $page\n pageSize: $pageSize\n sortOrder: $sortOrder\n sortedBy: $sortedBy\n ) @context(provider: \"vtex.b2b-organizations-graphql\") {\n pagination {\n total\n }\n data {\n id\n name\n status\n }\n }\n}\n\n```"
}
] |
code_b2b-organizations_ad5bfcb1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getCostCenter.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetCostCenter($id: ID!) {\n getCostCenterById(id: $id)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n name\n organization\n paymentTerms {\n id\n name\n }\n addresses {\n addressId\n addressType\n addressQuery\n postalCode\n country\n receiverName\n city\n state\n street\n number\n complement\n neighborhood\n geoCoordinates\n reference\n }\n phoneNumber\n businessDocument\n customFields {\n name\n type\n value\n dropdownValues {\n value\n label\n }\n useOnRegistration\n }\n stateRegistration\n }\n}\n\n```"
}
] |
code_b2b-organizations_d77d4d91
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/checkCustomerSchema.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery CheckCustomerSchema {\n checkCustomerSchema @context(provider: \"vtex.storefront-permissions\")\n}\n\n```"
}
] |
code_b2b-organizations_b2676a39
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getPermissions.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetPermissions {\n checkUserPermission @context(provider: \"vtex.storefront-permissions\") {\n role {\n id\n name\n slug\n }\n permissions\n }\n}\n\n```"
}
] |
code_b2b-organizations_11aeb498
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/saveUser.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation SaveUser(\n $id: ID\n $roleId: ID!\n $userId: ID\n $orgId: ID\n $costId: ID\n $clId: ID\n $canImpersonate: Boolean = false\n $name: String!\n $email: String!\n) {\n saveUser(\n id: $id\n roleId: $roleId\n userId: $userId\n orgId: $orgId\n costId: $costId\n clId: $clId\n canImpersonate: $canImpersonate\n name: $name\n email: $email\n ) @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n status\n }\n}\n\n```"
}
] |
code_b2b-organizations_cd2638ac
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/updateB2BSettings.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation saveB2BSettings($input: B2BSettingsInput) {\n saveB2BSettings(input: $input)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n status\n }\n}\n\n```"
}
] |
code_b2b-organizations_76359e1b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getCostCentersByOrganizationId.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetCostCentersByOrganizationId(\n $id: ID\n $search: String\n $page: Int\n $pageSize: Int\n $sortOrder: String\n $sortedBy: String\n) {\n getCostCentersByOrganizationId(\n id: $id\n search: $search\n page: $page\n pageSize: $pageSize\n sortOrder: $sortOrder\n sortedBy: $sortedBy\n ) @context(provider: \"vtex.b2b-organizations-graphql\") {\n pagination {\n total\n }\n data {\n id\n name\n addresses {\n country\n }\n customFields {\n name\n type\n value\n dropdownValues {\n value\n label\n }\n useOnRegistration\n }\n }\n }\n}\n\n```"
}
] |
code_b2b-organizations_de090d4d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getSellers.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetSellers {\n getSellers @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n name\n email\n }\n}\n\n```"
}
] |
code_b2b-organizations_14601cd5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getCostCentersByOrganizationIdStorefront.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetCostCentersByOrganizationIdStorefront(\n $id: ID\n $search: String\n $page: Int\n $pageSize: Int\n $sortOrder: String\n $sortedBy: String\n) {\n getCostCentersByOrganizationIdStorefront(\n id: $id\n search: $search\n page: $page\n pageSize: $pageSize\n sortOrder: $sortOrder\n sortedBy: $sortedBy\n ) @context(provider: \"vtex.b2b-organizations-graphql\") {\n pagination {\n total\n }\n data {\n id\n name\n addresses {\n country\n }\n }\n }\n}\n\n```"
}
] |
code_b2b-organizations_c6dcc74a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getCollections.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetCollections(\n $searchKey: String\n $page: Int\n $pageSize: Int\n $ascending: Boolean\n) {\n collections(\n searchKey: $searchKey\n page: $page\n pageSize: $pageSize\n ascending: $ascending\n ) @context(provider: \"vtex.catalog-graphql\") {\n items {\n id\n name\n }\n paging {\n total\n }\n }\n}\n\n```"
}
] |
code_b2b-organizations_12a005c8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getUsers.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetUsers(\n $organizationId: ID\n $costCenterId: ID\n $page: Int\n $pageSize: Int\n $search: String\n $sortOrder: String\n $sortedBy: String\n) {\n getUsersPaginated(\n organizationId: $organizationId\n costCenterId: $costCenterId\n page: $page\n pageSize: $pageSize\n search: $search\n sortOrder: $sortOrder\n sortedBy: $sortedBy\n ) @context(provider: \"vtex.b2b-organizations-graphql\") {\n data {\n id\n roleId\n userId\n clId\n orgId\n costId\n name\n email\n canImpersonate\n role {\n name\n slug\n }\n organizationName\n costCenterName\n }\n pagination {\n total\n }\n }\n}\n\n```"
}
] |
code_b2b-organizations_ba573ac6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getB2BCustomFields.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetB2BCustomFields {\n getB2BSettings @context(provider: \"vtex.b2b-organizations-graphql\") {\n organizationCustomFields {\n name\n type\n dropdownValues {\n value\n label\n }\n useOnRegistration\n }\n costCenterCustomFields {\n name\n type\n dropdownValues {\n value\n label\n }\n useOnRegistration\n }\n }\n}\n\n```"
}
] |
code_b2b-organizations_46cfb7c7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getOrganization.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetOrganization($id: ID) {\n getOrganizationById(id: $id)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n name\n tradeName\n status\n created\n collections {\n id\n name\n }\n paymentTerms {\n id\n name\n }\n priceTables\n salesChannel\n costCenters\n sellers {\n id\n name\n }\n customFields {\n name\n value\n type\n dropdownValues {\n value\n label\n }\n useOnRegistration\n }\n permissions {\n createQuote\n }\n }\n}\n\n```"
}
] |
code_b2b-organizations_33c03b04
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/updateSalesChannels.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation UpdateSalesChannels($channels: [SalesChannelsInput]!) {\n saveSalesChannels(channels: $channels)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n status\n message\n }\n}\n\n```"
}
] |
code_b2b-organizations_4693bc7e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getMarketingTags.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetMarketingTags($costId: ID!) {\n getMarketingTags(costId: $costId)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n tags\n }\n}\n\n```"
}
] |
code_b2b-organizations_171950f0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/createCostCenter.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation CreateCostCenter($organizationId: ID, $input: CostCenterInput!) {\n createCostCenter(organizationId: $organizationId, input: $input)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n }\n}\n\n```"
}
] |
code_b2b-organizations_f8c03b69
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/updateOrganization.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation UpdateOrganization(\n $id: ID!\n $name: String!\n $tradeName: String\n $status: String!\n $collections: [CollectionInput]\n $paymentTerms: [PaymentTermInput]\n $priceTables: [String]\n $salesChannel: String\n $sellers: [SellerInput]\n $customFields: [CustomFieldInput]\n) {\n updateOrganization(\n id: $id\n name: $name\n tradeName: $tradeName\n status: $status\n collections: $collections\n paymentTerms: $paymentTerms\n priceTables: $priceTables\n salesChannel: $salesChannel\n sellers: $sellers\n customFields: $customFields\n ) @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n status\n message\n }\n}\n\n```"
}
] |
code_b2b-organizations_8317f0a9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/createOrganizationRequest.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation CreateOrganizationRequest($input: OrganizationInput!) {\n createOrganizationRequest(input: $input)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n status\n }\n}\n\n```"
}
] |
code_b2b-organizations_cde4d801
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getAccount.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetAccount {\n getAccount {\n id\n name\n }\n}\n\n```"
}
] |
code_b2b-organizations_6bf962c5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getPriceTables.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetPriceTables {\n priceTables @context(provider: \"vtex.admin-graphql\")\n}\n\n```"
}
] |
code_b2b-organizations_298d7670
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getBinding.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetBinding($email: String!) {\n getBinding(email: $email) @context(provider: \"vtex.b2b-organizations-graphql\")\n}\n\n```"
}
] |
code_b2b-organizations_4b960c52
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/impersonateB2BUser.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation ImpersonateB2BUser($id: ID!) {\n impersonateB2BUser(id: $id)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n status\n message\n }\n}\n\n```"
}
] |
code_b2b-organizations_5d873b95
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getLogistics.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery Logistics {\n logistics @context(provider: \"vtex.store-graphql\") {\n shipsTo\n }\n}\n\n```"
}
] |
code_b2b-organizations_34d8f653
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/userWidgetQuery.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery userWidgetQuery($orgId: ID) {\n getActiveOrganizationsByEmail\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n costCenterName\n costId\n organizationName\n organizationStatus\n orgId\n role {\n id\n name\n }\n }\n\n checkUserPermission @context(provider: \"vtex.storefront-permissions\") {\n role {\n id\n name\n slug\n }\n permissions\n }\n\n getOrganizationByIdStorefront(id: $orgId)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n name\n status\n paymentTerms {\n id\n name\n }\n }\n\n getCostCenterByIdStorefront(id: $orgId)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n name\n organization\n paymentTerms {\n id\n name\n }\n addresses {\n addressId\n addressType\n addressQuery\n postalCode\n country\n receiverName\n city\n state\n street\n number\n complement\n neighborhood\n geoCoordinates\n reference\n }\n phoneNumber\n businessDocument\n stateRegistration\n }\n\n checkImpersonation @context(provider: \"vtex.storefront-permissions\") {\n email\n }\n\n getB2BSettings @context(provider: \"vtex.b2b-organizations-graphql\") {\n uiSettings {\n showModal\n fullImpersonation\n }\n }\n}\n\n```"
}
] |
code_b2b-organizations_bf862fb2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getSalesChannels.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetSalesChannels {\n salesChannels @context(provider: \"vtex.admin-graphql\") {\n id\n name\n }\n}\n\n```"
}
] |
code_b2b-organizations_792cb853
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/getSelectedChannels.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery GetSelectedChannels {\n getSalesChannels @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n name\n }\n}\n\n```"
}
] |
code_b2b-organizations_479c4093
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/createOrganization.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nmutation CreateOrganization($input: OrganizationInput!) {\n createOrganization(input: $input)\n @context(provider: \"vtex.b2b-organizations-graphql\") {\n id\n }\n}\n\n```"
}
] |
code_b2b-organizations_ee82bdc4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/graphql/checkImpersonation.graphql from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\nquery CheckImpersonation {\n checkImpersonation @context(provider: \"vtex.storefront-permissions\") {\n email\n }\n}\n\n```"
}
] |
code_b2b-organizations_d1a60c51
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/hooks/useClosedAlerts.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport useLocalStorage from './useLocalStorage'\n\nconst useClosedAlerts = () => {\n const [closedAlerts, setClosedAlerts] = useLocalStorage(\n 'bulk-import-closed-alerts',\n [] as string[]\n )\n\n const addClosedAlert = (importId: string) => {\n if (closedAlerts.find(alertId => alertId === importId)) {\n return\n }\n\n setClosedAlerts([...closedAlerts, importId])\n }\n\n const removeClosedAlert = (importId: string) => {\n const filteredAlerts = closedAlerts.filter(alertId => alertId !== importId)\n\n setClosedAlerts(filteredAlerts)\n }\n\n return { closedAlerts, addClosedAlert, removeClosedAlert }\n}\n\nexport default useClosedAlerts\n\n```"
}
] |
code_b2b-organizations_1c1f7572
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/hooks/useOrgPermission.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport useSWR from 'swr'\nimport { useFullSession } from 'vtex.session-client'\n\nimport { checkUserAdminPermission } from '../services'\nimport type { ORGANIZATION_EDIT } from '../utils/constants'\nimport { ORGANIZATION_VIEW } from '../utils/constants'\n\ninterface UseOrgPermissionParams {\n resourceCode?: typeof ORGANIZATION_EDIT | typeof ORGANIZATION_VIEW\n}\n\nexport function useOrgPermission({\n resourceCode = ORGANIZATION_VIEW,\n}: UseOrgPermissionParams) {\n const fullSession = useFullSession({\n variables: {\n items: ['authentication.adminUserEmail', 'account.accountName'],\n },\n })\n\n const account =\n fullSession.data?.session?.namespaces?.account?.accountName?.value\n\n const userEmail =\n fullSession.data?.session?.namespaces?.authentication?.adminUserEmail?.value\n\n const { data, isLoading, isValidating, error } = useSWR<{ data: boolean }>(\n userEmail && account ? `/granted?${resourceCode}` : null,\n () =>\n checkUserAdminPermission({\n account,\n userEmail,\n resourceCode,\n }),\n {\n dedupingInterval: 0,\n }\n )\n\n return {\n data,\n error,\n isLoading,\n isValidating,\n }\n}\n\n```"
}
] |
code_b2b-organizations_f14c4466
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/hooks/useTranslate.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useIntl } from 'react-intl'\nimport type { ReactNode } from 'react'\n\nimport type { BulkImportMessageKey } from '../bulkImport/messages'\nimport { bulkUploadMessages, hasTranslation } from '../bulkImport/messages'\n\nexport type TranslateFunction = (\n key: BulkImportMessageKey,\n data?: Record<string, unknown>\n) => ReactNode\n\nconst useTranslate = () => {\n const { formatMessage, ...intl } = useIntl()\n\n const translate: TranslateFunction = (descriptor, values) => {\n return hasTranslation(descriptor)\n ? formatMessage(\n bulkUploadMessages[descriptor],\n values as Record<string, string | number>\n )\n : null\n }\n\n return { translate, formatMessage, ...intl }\n}\n\nexport default useTranslate\n\n```"
}
] |
code_b2b-organizations_97057e75
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/hooks/useBulkImportsQuery.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport useSWR from 'swr'\nimport { useState } from 'react'\n\nimport type { Session } from '../modules/session'\nimport { useSessionResponse } from '../modules/session'\nimport { getBulkImportList } from '../services'\n\ntype UseBulkImportQueryProps = {\n shouldPoll?: boolean\n}\n\nconst useBulkImportQuery = (\n { shouldPoll: initialShouldPoll }: UseBulkImportQueryProps = {\n shouldPoll: false,\n }\n) => {\n const session = useSessionResponse() as Session\n\n const [shouldPoll, setShouldPoll] = useState(initialShouldPoll)\n\n const account = session?.namespaces?.account?.accountName?.value\n\n return useSWR(\n account ? '/buyer-orgs' : null,\n () => getBulkImportList(account),\n {\n refreshInterval: shouldPoll ? 30 * 1000 : 0, // 30 seconds\n onError: errorData => {\n const status = errorData?.response?.status ?? 0\n\n if (status >= 400 && status < 500) {\n setShouldPoll(false)\n }\n },\n }\n )\n}\n\nexport default useBulkImportQuery\n\n```"
}
] |
code_b2b-organizations_9f256ca8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/hooks/useSelectSeller.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useProduct, useProductDispatch } from 'vtex.product-context'\nimport { useCallback, useMemo, useRef, useState } from 'react'\nimport type { Item } from 'vtex.product-context/react/ProductTypes'\n\nimport useSeller from './useSeller'\n\nconst SELECT_ITEM_EVENT = 'SET_SELECTED_ITEM'\n\nexport const useSelectSeller = () => {\n const { seller } = useSeller()\n const productContext = useProduct()\n const { product } = productContext ?? {}\n const latestItem = useRef((null as unknown) as Item)\n const [loading, setLoading] = useState(true)\n const productDispatch = useProductDispatch()\n\n const addSellerDefaultToItem = useCallback(\n itemSeller => ({\n ...itemSeller,\n sellerDefault: seller?.includes(itemSeller.sellerId),\n }),\n [seller]\n )\n\n const currentSelectedItem = useMemo(\n () =>\n product?.items?.find(item =>\n item.sellers?.find(\n itemSeller =>\n seller?.includes(itemSeller.sellerId) &&\n itemSeller.commertialOffer.AvailableQuantity > 0\n )\n ) ?? null,\n\n [seller, product]\n )\n\n const selectSeller = ({\n selectedItem,\n }: {\n selectedItem: Item | null | undefined\n }) => {\n if (!currentSelectedItem || !selectedItem) {\n return\n }\n\n // just to keep the dependency\n setLoading(true)\n const { sellers } = (currentSelectedItem as unknown) as Item\n const selectedItemWithSeller = {\n ...((currentSelectedItem as unknown) as Item),\n sellers: sellers.map(addSellerDefaultToItem),\n }\n\n if (\n JSON.stringify(latestItem.current) ===\n JSON.stringify(selectedItemWithSeller)\n ) {\n return\n }\n\n productDispatch?.({\n type: SELECT_ITEM_EVENT,\n args: {\n item: selectedItemWithSeller,\n },\n })\n setLoading(false)\n latestItem.current = selectedItemWithSeller\n }\n\n return { loading, seller, currentSelectedItem, selectSeller }\n}\n\n```"
}
] |
code_b2b-organizations_ae374f5d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/hooks/useScroll.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useCallback, useEffect, useRef } from 'react'\n\nimport { useDebounceFunction } from './useDebounce'\n\ntype UseScrollArgs = Readonly<{ onScrollEnd: () => void }>\n\nconst SCROLL_DELAY = 150\nconst SCROLL_END_TOLERANCE = 10\n\nexport function useScroll<T extends HTMLElement>({\n onScrollEnd,\n}: UseScrollArgs) {\n const ref = useRef<T>(null)\n const onScrollEndDebounced = useDebounceFunction(onScrollEnd, SCROLL_DELAY)\n\n const handleScroll = useCallback(() => {\n if (!ref.current) return\n\n const scrollTop: number = Math.ceil(ref.current.scrollTop)\n const scrollHeight: number = Math.round(ref.current.scrollHeight)\n const clientHeight: number = Math.round(ref.current.clientHeight)\n\n const isScrollEnd =\n scrollTop + SCROLL_END_TOLERANCE >= scrollHeight - clientHeight\n\n if (isScrollEnd) {\n onScrollEndDebounced()\n }\n }, [onScrollEndDebounced])\n\n useEffect(() => {\n if (!ref.current) return\n\n ref.current.addEventListener('scroll', handleScroll)\n }, [handleScroll])\n\n useEffect(\n () => () => ref.current?.removeEventListener('scroll', handleScroll),\n []\n )\n\n return ref\n}\n\n```"
}
] |
code_b2b-organizations_c050bb27
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/hooks/useErrorCount.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useCallback } from 'react'\n\nimport type { ValidationResult } from '../types/BulkImport'\n\nconst useErrorCount = () => {\n return useCallback((errorRowReportDataList: ValidationResult[] = []) => {\n return errorRowReportDataList.reduce(\n (acc, error) => acc + error.invalidRows,\n 0\n )\n }, [])\n}\n\nexport default useErrorCount\n\n```"
}
] |
code_b2b-organizations_946b83c9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/hooks/useLocalStorage.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useState } from 'react'\n\nconst useLocalStorage = <T>(key: string, initialValue: T) => {\n const storedValue = localStorage.getItem(key)\n\n const [value, setValue] = useState(\n (storedValue ? JSON.parse(storedValue) : initialValue) as T\n )\n\n const setStoredValue = (newValue: T) => {\n setValue(newValue)\n localStorage.setItem(key, JSON.stringify(newValue))\n }\n\n return [value, setStoredValue] as const\n}\n\nexport default useLocalStorage\n\n```"
}
] |
code_b2b-organizations_70ac31ae
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/hooks/useSeller.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useEffect, useState } from 'react'\nimport { useProduct } from 'vtex.product-context'\n\nconst decode = (str: string): string =>\n Buffer.from(str, 'base64').toString('binary')\n\nexport default function useSeller() {\n const [seller, setSeller] = useState<string[] | null>(null)\n const productContext = useProduct()\n const { selectedItem, product } = productContext ?? {}\n\n useEffect(() => {\n try {\n const { facets } = JSON.parse(decode(window?.__RUNTIME__?.segmentToken))\n\n if (facets) {\n const facetsList = facets.split(';')\n const sellerFacet = facetsList.filter((facet: string) =>\n facet.includes('private-seller')\n )\n\n const sellers = sellerFacet.map((facet: string) => {\n const [, value] = facet?.split('=') ?? []\n\n return value\n })\n\n if (sellers?.length) {\n setSeller(sellers)\n }\n }\n } catch (e) {\n console.error(e)\n }\n }, [selectedItem, product])\n\n return { seller }\n}\n\n```"
}
] |
code_b2b-organizations_18f8286c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/hooks/useDebounce.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useCallback, useEffect, useRef, useState } from 'react'\n\nexport function useDebounceValue<T>(value: T, delay: number) {\n const [debounced, setDebounced] = useState(value)\n\n useEffect(() => {\n const timer = setTimeout(() => setDebounced(value), delay)\n\n return () => clearTimeout(timer)\n }, [value, delay])\n\n return debounced\n}\n\nexport const useDebounceFunction = <T extends unknown[]>(\n fn: (...args: T) => void,\n delay: number\n) => {\n const timerRef = useRef<number>()\n const fnRef = useRef(fn)\n\n useEffect(() => {\n fnRef.current = fn\n }, [fn])\n\n const fnDebounced = useCallback(\n (...args: T) => {\n window.clearTimeout(timerRef.current)\n timerRef.current = window.setTimeout(() => fnRef.current(...args), delay)\n },\n [delay]\n )\n\n useEffect(() => () => window.clearTimeout(timerRef.current), [])\n\n return fnDebounced\n}\n\n```"
}
] |
code_b2b-organizations_5092e2e3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/hooks/useStartBulkImport.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport useSWRMutation from 'swr/mutation'\n\nimport { startBulkImport } from '../services'\n\nconst useStartBulkImport = () => {\n const { trigger, ...data } = useSWRMutation(\n '/buyer-orgs',\n (_, { arg }: { arg: { importId: string } }) => startBulkImport(arg.importId)\n )\n\n return { startBulkImport: trigger, ...data }\n}\n\nexport default useStartBulkImport\n\n```"
}
] |
code_b2b-organizations_0ef4094d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/hooks/useValidateBulkImport.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport useSWRMutation from 'swr/mutation'\n\nimport { validateBulkImport } from '../services'\n\nconst useValidateBulkImport = ({ onSuccess }: { onSuccess?: () => void }) => {\n const { trigger } = useSWRMutation(\n '/buyer-orgs/start',\n (_, { arg }: { arg: { importId: string } }) =>\n validateBulkImport(arg.importId),\n {\n onSuccess,\n }\n )\n\n return { startBulkImportValidation: trigger }\n}\n\nexport default useValidateBulkImport\n\n```"
}
] |
code_b2b-organizations_70707f8d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/hooks/index.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport { default as useTranslate } from './useTranslate'\nexport { default as useBulkImportsQuery } from './useBulkImportsQuery'\n\n```"
}
] |
code_b2b-organizations_bb4b07f2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/hooks/useBulkImportDetailsQuery.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport useSWR from 'swr'\n\nimport { getBulkImportDetails } from '../services'\nimport type { BulkImportDetails } from '../services/getBulkImportDetails'\n\nexport type UseBulkImportDetailsQueryProps = {\n importId?: string\n onSuccess?: (data: BulkImportDetails) => void\n refreshInterval?: number\n}\n\nconst useBulkImportDetailsQuery = ({\n importId,\n onSuccess = () => {},\n refreshInterval = 0,\n}: UseBulkImportDetailsQueryProps) => {\n return useSWR(\n importId ? `/buyer-orgs/${importId}` : null,\n () => getBulkImportDetails(importId),\n {\n refreshInterval,\n revalidateOnFocus: false,\n onSuccess,\n }\n )\n}\n\nexport default useBulkImportDetailsQuery\n\n```"
}
] |
code_b2b-organizations_d9f1de46
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/modules/session.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useState, useEffect } from 'react'\n\ninterface KeyValue {\n value: string\n}\n\nexport interface Session {\n type?: 'Session'\n id: string\n namespaces: {\n store: {\n channel: string\n }\n profile: {\n isAuthenticated: KeyValue\n email?: KeyValue\n }\n account: {\n accountName: KeyValue\n }\n authentication: {\n storeUserEmail: KeyValue\n }\n }\n}\n\ninterface SessionUnauthorized {\n type: 'Unauthorized'\n message: string\n}\n\ninterface SessionForbidden {\n type: 'Forbidden'\n message: string\n}\n\ninterface SessionPromise {\n response: Session | SessionUnauthorized | SessionForbidden\n}\n\nexport function getSession() {\n return window &&\n (window as any).__RENDER_8_SESSION__ &&\n (window as any).__RENDER_8_SESSION__.sessionPromise\n ? ((window as any).__RENDER_8_SESSION__.sessionPromise as Promise<\n SessionPromise\n >)\n : null\n}\n\nexport const useSessionResponse = () => {\n const [session, setSession] = useState<\n Session | SessionUnauthorized | SessionForbidden\n >()\n\n const sessionPromise = getSession()\n\n useEffect(() => {\n if (!sessionPromise) {\n return\n }\n\n sessionPromise.then(sessionResponse => {\n const { response } = sessionResponse\n\n setSession(response)\n })\n }, [sessionPromise])\n\n return session\n}\n\n```"
}
] |
code_b2b-organizations_1c7b4a9a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/modules/formValidators.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n// https://regex101.com/r/926sxf/1\n// If you change the regex, don't forget to go to the link above, update it there and save.\nconst EMAIL_REGEX = /^[A-z0-9\"+_-]+(?:\\.[A-z0-9+_-]+)*@(?:[A-z0-9](?:[A-z0-9-]*[A-z0-9])?\\.)+[A-z0-9](?:[A-z0-9-]*[A-z0-9])?$/\n\n// https://regex101.com/r/5dVM9R/1\n// If you change the regex, don't forget to go to the link above, update it there and save.\n// eslint-disable-next-line no-useless-escape\nconst PHONE_REGEX = /^([0-9]|\\(|\\)|\\+|\\ |\\-)+$/\n\nexport function validateEmail(email: string) {\n return EMAIL_REGEX.test(email)\n}\n\nexport function validatePhoneNumber(phone: string) {\n return PHONE_REGEX.test(phone)\n}\n\nexport function validateUserName(name: string) {\n return name.length > 0\n}\n\n```"
}
] |
code_b2b-organizations_99c5d918
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/services/orgPermissionClient.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport axios from 'axios'\n\nimport { B2B_LM_PRODUCT_CODE } from '../utils/constants'\n\nconst LICENSE_MANAGER_BASE_URL = `/api/license-manager/pvt/accounts/`\n\nconst orgPermissionClient = axios.create()\n\norgPermissionClient.defaults.baseURL = LICENSE_MANAGER_BASE_URL\n\ninterface CheckUserAdminPermissionParams {\n account: string\n userEmail: string\n resourceCode: string\n}\n\nconst checkUserAdminPermission = async ({\n account,\n userEmail,\n resourceCode,\n}: CheckUserAdminPermissionParams) => {\n const checkOrgPermission = await orgPermissionClient.get(\n `${account}/products/${B2B_LM_PRODUCT_CODE}/logins/${userEmail}/resources/${resourceCode}/granted`\n )\n\n return checkOrgPermission.data\n}\n\nexport default checkUserAdminPermission\n\n```"
}
] |
code_b2b-organizations_5b508487
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/services/uploadBulkImportFile.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { AxiosRequestConfig } from 'axios'\n\nimport bulkImportClient from '.'\nimport type {\n BulkImportUploadError,\n ImportDetails,\n UploadFileData,\n} from '../types/BulkImport'\n\nconst uploadBulkImportFile = async (file: File): Promise<UploadFileData> => {\n const formData = new FormData()\n\n formData.append('file', file)\n\n try {\n const importListResponse = await bulkImportClient.post<ImportDetails>(\n `/buyer-orgs`,\n formData,\n {\n headers: {\n 'Content-Type': 'multipart/form-data',\n },\n } as AxiosRequestConfig<FormData>\n )\n\n return {\n status: 'success',\n data: {\n fileData: importListResponse.data,\n },\n }\n } catch (error) {\n const errorData = error?.response?.data as BulkImportUploadError\n\n return {\n status: 'error',\n showReport: errorData?.error === 'FieldValidationError',\n data: { ...errorData, fileName: file.name },\n }\n }\n}\n\nexport default uploadBulkImportFile\n\n```"
}
] |
code_b2b-organizations_8819e27a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/services/getBulkImportList.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { ImportDetails } from '../types/BulkImport'\nimport bulkImportClient from '.'\n\nconst statusMap = {\n InProgress: 'pending',\n Completed: 'success',\n CompletedWithError: 'error',\n} as const\n\nconst getBulkImportList = async (account: string) => {\n const importListResponse = await bulkImportClient.get(\n `/buyer-orgs?an=${account}`\n )\n\n const importListData = importListResponse.data as ImportDetails[]\n\n return importListData\n .filter(item =>\n ['InProgress', 'Completed', 'CompletedWithError'].some(\n status => status === item.importState\n )\n )\n .map(item => ({\n importId: item.importId,\n progress: Number(item.percentage),\n status: statusMap[item.importState as keyof typeof statusMap],\n importedAt: new Date(item.importedAt),\n file: {\n name: item.fileName,\n },\n }))\n .sort(\n (currentImport, nextImport) =>\n nextImport.importedAt.getTime() - currentImport.importedAt.getTime()\n )\n .slice(0, 1)\n}\n\nexport default getBulkImportList\n\n```"
}
] |
code_b2b-organizations_d7de8f05
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/services/bulkImportClient.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport axios from 'axios'\n\nexport const BULK_IMPORT_BASE_URL = `/api/b2b/import`\n\nconst bulkImportClient = axios.create()\n\nbulkImportClient.defaults.baseURL = BULK_IMPORT_BASE_URL\n\nexport default bulkImportClient\n\n```"
}
] |
code_b2b-organizations_9a602eaf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/services/getBulkImportDetails.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport bulkImportClient from '.'\nimport type { ImportDetails, ImportReportData } from '../types/BulkImport'\n\nexport type BulkImportDetails = Omit<ImportDetails, 'percentage'> & {\n importReportList: ImportReportData[]\n percentage: number\n}\n\nconst getBulkImportDetails = async (\n importId?: string\n): Promise<BulkImportDetails> => {\n const importListResponse = await bulkImportClient.get<ImportDetails>(\n `/buyer-orgs/${importId}`\n )\n\n const { data } = importListResponse\n\n const { importResult } = data\n\n const importList = importResult?.imports ?? []\n\n const [totalSuccess, totalError] = importList.reduce(\n ([successAcc, errorAcc], { importedRows, rowsWithError }) => {\n return [successAcc + importedRows, errorAcc + rowsWithError]\n },\n [0, 0] as [number, number]\n )\n\n const percentage = (totalSuccess * 100) / (totalSuccess + totalError)\n\n const fullPercentage = Math.round((percentage + Number.EPSILON) * 100) / 100\n\n return {\n ...data,\n importReportList: importList.map(\n ({ importedRows, rowsWithError, name }) => ({\n title: name,\n success: {\n percentage: fullPercentage,\n imports: importedRows,\n },\n error: {\n percentage: 100 - fullPercentage,\n imports: rowsWithError,\n },\n })\n ),\n percentage: fullPercentage,\n }\n}\n\nexport default getBulkImportDetails\n\n```"
}
] |
code_b2b-organizations_b04b5dea
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/services/validateBulkImport.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport bulkImportClient from '.'\n\nconst validateBulkImport = async (importId?: string): Promise<unknown> => {\n return bulkImportClient.post(`/buyer-orgs/validate/${importId}`)\n}\n\nexport default validateBulkImport\n\n```"
}
] |
code_b2b-organizations_ea7235aa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/services/index.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport { default } from './bulkImportClient'\nexport { default as getBulkImportList } from './getBulkImportList'\nexport { default as getBulkImportDetails } from './getBulkImportDetails'\nexport { default as uploadBulkImportFile } from './uploadBulkImportFile'\nexport { default as startBulkImport } from './startBulkImport'\nexport { default as validateBulkImport } from './validateBulkImport'\nexport { default as checkUserAdminPermission } from './orgPermissionClient'\n\n```"
}
] |
code_b2b-organizations_a61f2546
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/services/startBulkImport.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { ImportDetails } from '../types/BulkImport'\nimport bulkImportClient from '.'\n\nconst startBulkImport = async (importId: string) => {\n const startImportResponse = await bulkImportClient.post(\n `/buyer-orgs/${importId}`\n )\n\n return startImportResponse.data as ImportDetails\n}\n\nexport default startBulkImport\n\n```"
}
] |
code_b2b-organizations_371ebda7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/typings/vtex.my-account-commons/Router.d.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.my-account-commons/Router' {\n export const Link\n export const withRouter\n export const Route\n export const Switch\n export const Redirect\n export const HashRouter\n}\n\n```"
}
] |
code_b2b-organizations_c46b49f6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/typings/vtex.my-account-commons/index.d.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.my-account-commons' {\n export const BaseLoading\n export const SkeletonPiece\n export const SkeletonBox\n export const ContentWrapper\n export const GenericError\n}\n\n```"
}
] |
code_b2b-organizations_f17e430e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationSettings/index.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n/* eslint-disable vtex/prefer-early-return */\nimport type { FunctionComponent } from 'react'\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { FormattedMessage, useIntl } from 'react-intl'\nimport { useQuery, useMutation } from 'react-apollo'\nimport { PageBlock, Table, IconCheck, Button, Checkbox } from 'vtex.styleguide'\nimport { Spinner, useToast } from '@vtex/admin-ui'\n\nimport { organizationSettingsMessages as messages } from '../utils/messages'\nimport { organizationBulkAction } from '../utils/organizationBulkAction'\nimport GET_SALES_CHANNELS from '../../graphql/getSalesChannels.graphql'\nimport SELECTED_SALES_CHANNELS from '../../graphql/getSelectedChannels.graphql'\nimport UPDATE_SALES_CHANNELS from '../../graphql/updateSalesChannels.graphql'\nimport UPDATE_B2B_SETTINGS from '../../graphql/updateB2BSettings.graphql'\nimport GET_B2B_SETTINGS from '../../graphql/getB2BSettings.graphql'\nimport { TopbarCustom } from './TopbarCustom'\nimport { useOrgPermission } from '../../hooks/useOrgPermission'\nimport { ORGANIZATION_EDIT } from '../../utils/constants'\n\ninterface SalesChannel {\n channelId: string\n name: string\n tableName: string\n}\n\ninterface CellRendererProps<RowType> {\n rowData: RowType\n updateCellMeasurements: () => void\n}\n\nconst OrganizationSettings: FunctionComponent = () => {\n const defaultSchema = {\n properties: {\n tableName: {\n title: 'Sales Channels',\n },\n },\n }\n\n const showToast = useToast()\n const { formatMessage } = useIntl()\n const [salesChannels, setSalesChannels] = useState([] as SalesChannel[])\n const [selectedChannels, setSelectedChannel] = useState([] as SalesChannel[])\n const [loading, setLoading] = useState(false)\n const [settings, setSettings] = useState({\n autoApprove: false,\n businessReadOnly: false,\n stateReadOnly: false,\n uiSettings: {\n clearCart: false,\n showModal: false,\n fullImpersonation: false,\n },\n })\n\n const [warningTopbarColor, setWarningTopbarColor] = useState({\n color: { hex: '#141E7A' },\n history: [],\n })\n\n const [warningTopbarMessage, setWarningTopbarMessage] = useState('')\n\n const { data } = useQuery(GET_SALES_CHANNELS, {\n ssr: false,\n })\n\n const { data: selectedData, refetch } = useQuery(SELECTED_SALES_CHANNELS, {\n ssr: false,\n })\n\n const {\n data: dataSettings,\n loading: loadingSettings,\n refetch: refetchSettings,\n } = useQuery(GET_B2B_SETTINGS, {\n ssr: false,\n })\n\n const [updateSalesChannels] = useMutation(UPDATE_SALES_CHANNELS)\n const [updateB2BSettings] = useMutation(UPDATE_B2B_SETTINGS)\n\n const { data: canEditBuyerOrg } = useOrgPermission({\n resourceCode: ORGANIZATION_EDIT,\n })\n\n useEffect(() => {\n if (!data) return\n\n const options: SalesChannel[] = []\n\n data.salesChannels.forEach((item: { id: string; name: string }) => {\n options.push({\n channelId: item.id,\n name: item.name,\n tableName: `${item.name} (${item.id})`,\n })\n })\n setSalesChannels(options)\n }, [data])\n\n useEffect(() => {\n if (!selectedData) return\n\n const selectedOptions: any[] = []\n\n selectedData.getSalesChannels.forEach(\n (item: { id: string; name: string }) => {\n selectedOptions.push({\n channelId: item.id,\n name: item.name,\n tableName: `${item.name} (${item.id})`,\n })\n }\n )\n setSelectedChannel(selectedOptions)\n }, [selectedData])\n\n useEffect(() => {\n if (!dataSettings) {\n return\n }\n\n const { getB2BSettings } = dataSettings\n\n setSettings({\n autoApprove: getB2BSettings?.autoApprove,\n businessReadOnly: getB2BSettings?.businessReadOnly,\n stateReadOnly: getB2BSettings?.stateReadOnly,\n uiSettings: {\n clearCart: getB2BSettings?.uiSettings?.clearCart,\n showModal: getB2BSettings?.uiSettings?.showModal,\n fullImpersonation: getB2BSettings?.uiSettings?.fullImpersonation,\n },\n })\n\n setWarningTopbarColor({\n color: {\n hex: getB2BSettings?.uiSettings?.topBar?.hexColor ?? '#656896',\n },\n history: [],\n })\n setWarningTopbarMessage(getB2BSettings?.uiSettings?.topBar?.name ?? '')\n }, [dataSettings])\n\n const getSchema = () => {\n const cellRenderer = ({\n rowData: { channelId, name, tableName },\n }: CellRendererProps<SalesChannel>) => {\n const assigned = selectedChannels.some(\n channel => channel.channelId === channelId\n )\n\n return (\n <span className={assigned ? 'c-disabled' : ''}>\n {tableName ?? name}\n {assigned && <IconCheck />}\n </span>\n )\n }\n\n return {\n properties: {\n name: {\n title: 'Sales Channels',\n ...{ cellRenderer },\n },\n },\n }\n }\n\n const handleUpdateRequest = () => {\n const channels = selectedChannels.map((item: any) => {\n return {\n id: item.channelId,\n name: item.name,\n }\n })\n\n setLoading(true)\n\n const promises = []\n\n promises.push(\n updateSalesChannels({\n variables: {\n channels,\n },\n }).catch(error => {\n console.error(error)\n showToast({\n variant: 'critical',\n message: formatMessage(messages.toastUpdateFailure),\n })\n })\n )\n promises.push(\n updateB2BSettings({\n variables: {\n input: {\n ...settings,\n uiSettings: {\n ...settings.uiSettings,\n topBar: {\n name: warningTopbarMessage,\n hexColor: warningTopbarColor.color.hex,\n },\n },\n },\n },\n })\n )\n\n Promise.all(promises)\n .then(() => {\n showToast({\n variant: 'positive',\n message: formatMessage(messages.toastUpdateSuccess),\n })\n refetch()\n refetchSettings()\n setLoading(false)\n })\n .catch(error => {\n console.error(error)\n showToast({\n variant: 'critical',\n message: formatMessage(messages.toastUpdateFailure),\n })\n })\n }\n\n const handleAddBinding = (rowParams: any) => {\n const { selectedRows = [] } = rowParams\n const newBindings = [] as SalesChannel[]\n\n selectedRows.forEach((row: any) => {\n if (\n !selectedChannels.some(channel => channel.channelId === row.channelId)\n ) {\n newBindings.push({\n channelId: row.channelId,\n name: row.name,\n tableName: `${row.name} (${row.channelId})`,\n })\n }\n })\n\n setSelectedChannel([...selectedChannels, ...newBindings])\n }\n\n const handleRemoveBinding = (rowParams: any) => {\n const { selectedRows = [] } = rowParams\n const bindingToRemove = [] as string[]\n\n selectedRows.forEach((row: any) => {\n bindingToRemove.push(row.channelId)\n })\n\n const newBindingList = selectedChannels.filter(\n channel => !bindingToRemove.includes(channel.channelId)\n )\n\n setSelectedChannel(newBindingList)\n }\n\n const handleChangeWarningTopbarColor = useCallback(\n (color: { hex: string }) => {\n setWarningTopbarColor(prevState => ({\n ...prevState,\n color,\n }))\n },\n []\n )\n\n const handleChangeWarningTopbarMessage = useCallback((text: string) => {\n setWarningTopbarMessage(text)\n }, [])\n\n return (\n <PageBlock\n title={formatMessage(messages.tablePageTitle)}\n titleAside={\n <span className=\"mt4 flex justify-end mb4\">\n <Button\n isLoading={loading}\n variation=\"primary\"\n onClick={() => handleUpdateRequest()}\n disabled={!canEditBuyerOrg}\n >\n <FormattedMessage id=\"admin/b2b-organizations.costCenter-details.button.save\" />\n </Button>\n </span>\n }\n >\n <div>\n <h3 className=\"t-heading-3\">\n {formatMessage(messages.generalSettings)}\n </h3>\n <div className=\"pa6\">\n <div className=\"mb4\">\n <Checkbox\n checked={settings.autoApprove}\n id=\"autoApprove\"\n name=\"autoApprove\"\n onChange={() => {\n setSettings({ ...settings, autoApprove: !settings.autoApprove })\n }}\n label={formatMessage(messages.autoApprove)}\n />\n </div>\n {loadingSettings ? (\n <Spinner />\n ) : (\n <>\n {!settings.autoApprove && (\n <TopbarCustom\n colorState={warningTopbarColor}\n message={warningTopbarMessage}\n onChangeColor={handleChangeWarningTopbarColor}\n onChangeMessage={handleChangeWarningTopbarMessage}\n />\n )}\n </>\n )}\n\n <div className=\"mb4\">\n <Checkbox\n checked={settings.businessReadOnly}\n id=\"businessReadOnly\"\n name=\"businessReadOnly\"\n onChange={() => {\n setSettings({\n ...settings,\n businessReadOnly: !settings.businessReadOnly,\n })\n }}\n label={formatMessage(messages.businessReadOnly)}\n />\n </div>\n <div className=\"mb4\">\n <Checkbox\n checked={settings.stateReadOnly}\n id=\"stateReadOnly\"\n name=\"stateReadOnly\"\n onChange={() => {\n setSettings({\n ...settings,\n stateReadOnly: !settings.stateReadOnly,\n })\n }}\n label={formatMessage(messages.stateReadOnly)}\n />\n </div>\n <div className=\"mb4\">\n <Checkbox\n checked={settings.uiSettings.showModal}\n id=\"showModal\"\n name=\"showModal\"\n onChange={() => {\n setSettings({\n ...settings,\n uiSettings: {\n ...settings.uiSettings,\n showModal: !settings.uiSettings.showModal,\n },\n })\n }}\n label={formatMessage(messages.showModal)}\n />\n </div>\n <div className=\"mb4\">\n <Checkbox\n checked={settings.uiSettings.clearCart}\n id=\"clearCart\"\n name=\"clearCart\"\n onChange={() => {\n setSettings({\n ...settings,\n uiSettings: {\n ...settings.uiSettings,\n clearCart: !settings.uiSettings.clearCart,\n },\n })\n }}\n label={formatMessage(messages.clearCart)}\n />\n </div>\n <div className=\"mb6\">\n <Checkbox\n checked={settings.uiSettings.fullImpersonation}\n id=\"fullImpersonation\"\n name=\"fullImpersonation\"\n onChange={() => {\n setSettings({\n ...settings,\n uiSettings: {\n ...settings.uiSettings,\n fullImpersonation: !settings.uiSettings.fullImpersonation,\n },\n })\n }}\n label={formatMessage(messages.fullImpersonation)}\n />\n </div>\n </div>\n </div>\n <div className=\"w-100 mt4 mb4\">\n <h3 className=\"t-heading-3\">{formatMessage(messages.bindingTitle)}</h3>\n </div>\n <div className=\"flex\">\n <div className=\"w-50\">\n <h4 className=\"t-heading-4 mt0 mb0\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-settings-select.binding.selected\" />\n </h4>\n {selectedChannels ? (\n <Table\n fullWidth\n schema={defaultSchema}\n items={selectedChannels}\n bulkActions={organizationBulkAction(\n handleRemoveBinding,\n messages.removeFromBinding,\n formatMessage\n )}\n />\n ) : null}\n </div>\n <div className=\"w-50\">\n <h4 className=\"t-heading-4 mt0 mb0\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-settings-select.binding.available\" />\n </h4>\n <Table\n fullWidth\n schema={getSchema()}\n items={salesChannels}\n bulkActions={organizationBulkAction(\n handleAddBinding,\n messages.addToBinding,\n formatMessage\n )}\n />\n </div>\n </div>\n </PageBlock>\n )\n}\n\nexport default OrganizationSettings\n\n```"
}
] |
code_b2b-organizations_513a4069
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationSettings/TopbarCustom.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport type { ChangeEvent } from 'react'\nimport React from 'react'\nimport { useIntl, FormattedMessage } from 'react-intl'\nimport { Box, ColorPicker, Textarea } from 'vtex.styleguide'\n\nimport { organizationSettingsMessages } from '../utils/messages'\n\ntype Color = { hex: string }\n\ninterface TopbarCustomProps {\n colorState: {\n color: Color\n history: string[]\n }\n message: string\n onChangeColor: (color: Color) => void\n onChangeMessage: (text: string) => void\n}\n\nexport function TopbarCustom({\n colorState,\n message,\n onChangeColor,\n onChangeMessage,\n}: TopbarCustomProps) {\n const { formatMessage } = useIntl()\n\n return (\n <div className=\"mv4 topbar-custom\">\n <Box style={{ padding: 0 }}>\n <h3 className=\"t-heading-3\">\n <FormattedMessage id=\"admin/b2b-organizations.warning-topbar-inative-org.form.title\" />\n </h3>\n <p className=\"t-small mw9 mb5\">\n <FormattedMessage id=\"admin/b2b-organizations.warning-topbar-inative-org.form.help-text\" />\n </p>\n <ColorPicker\n label={formatMessage(\n organizationSettingsMessages.formColorPickerLabel\n )}\n color={colorState.color}\n colorHistory={colorState.history}\n onChange={onChangeColor}\n />\n <Textarea\n onChange={(event: ChangeEvent<HTMLInputElement>) =>\n onChangeMessage(event.target.value)\n }\n value={message}\n label={formatMessage(organizationSettingsMessages.formTextareaLabel)}\n name=\"message\"\n size=\"small\"\n helpText={formatMessage(\n organizationSettingsMessages.formTextareaHelpText\n )}\n />\n </Box>\n </div>\n )\n}\n\n```"
}
] |
code_b2b-organizations_acc7e324
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/utils/organizationBulkAction.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { organizationMessages as messages } from './messages'\n\nexport const organizationBulkAction = (\n handleCallback: { (rowParams: any): void; (rowParams: any): void },\n labelMessage: { id: string },\n formatMessage: { (...args: any): unknown }\n) => {\n return {\n texts: {\n rowsSelected: (qty: number) =>\n formatMessage(messages.selectedRows, {\n qty,\n }),\n },\n main: {\n label: formatMessage(labelMessage),\n handleCallback,\n },\n }\n}\n\n```"
}
] |
code_b2b-organizations_8a0e0bd5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/utils/messages.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { defineMessages } from 'react-intl'\n\nconst adminPrefix = 'admin/b2b-organizations.'\n\nexport const organizationMessages = defineMessages({\n statusActive: {\n id: `${adminPrefix}organization-details.status.active`,\n },\n statusOnHold: {\n id: `${adminPrefix}organization-details.status.on-hold`,\n },\n statusInactive: {\n id: `${adminPrefix}organization-details.status.inactive`,\n },\n toastUpdateSuccess: {\n id: `${adminPrefix}organization-details.toast.update-success`,\n },\n toastUpdateFailure: {\n id: `${adminPrefix}organization-details.toast.update-failure`,\n },\n toastAddCostCenterSuccess: {\n id: `${adminPrefix}organization-details.toast.add-costCenter-success`,\n },\n toastAddCostCenterFailure: {\n id: `${adminPrefix}organization-details.toast.add-costCenter-failure`,\n },\n detailsColumnName: {\n id: `${adminPrefix}organization-details.table.column-name.title`,\n },\n columnAddresses: {\n id: `${adminPrefix}organization-details.table.column-addresses.title`,\n },\n detailsPageTitle: {\n id: `${adminPrefix}organization-details.title`,\n },\n back: {\n id: `${adminPrefix}back`,\n },\n status: {\n id: `${adminPrefix}organization-details.status`,\n },\n costCenters: {\n id: `${adminPrefix}organization-details.costCenters`,\n },\n settings: {\n id: `${adminPrefix}organization-details.settings`,\n },\n createQuote: {\n id: `${adminPrefix}organization-details.settings.createQuote`,\n },\n showRows: {\n id: `${adminPrefix}showRows`,\n },\n of: {\n id: `${adminPrefix}of`,\n },\n checkItOut: {\n id: `${adminPrefix}check-it-out`,\n },\n invalidSchema: {\n id: `${adminPrefix}invalid-schema`,\n },\n autocompleteSearching: {\n id: `${adminPrefix}autocomplete-searching`,\n },\n new: {\n id: `${adminPrefix}organization-details.button.new`,\n },\n collections: {\n id: `${adminPrefix}organization-details.collections`,\n },\n paymentTerms: {\n id: `${adminPrefix}organization-details.paymentTerms`,\n },\n priceTables: {\n id: `${adminPrefix}organization-details.price-tables`,\n },\n sellers: {\n id: `${adminPrefix}organization-details.sellers`,\n },\n salesChannelNone: {\n id: `${adminPrefix}organization-details.none`,\n },\n salesChannel: {\n id: `${adminPrefix}organization-details.sales-channel`,\n },\n users: {\n id: `${adminPrefix}organization-details.users`,\n },\n selectedRows: {\n id: `${adminPrefix}selected-rows`,\n },\n removeFromOrg: {\n id: `${adminPrefix}organization-details.remove-from-org`,\n },\n addToOrg: {\n id: `${adminPrefix}organization-details.add-to-org`,\n },\n add: {\n id: `${adminPrefix}organization-details.button.add`,\n },\n cancel: {\n id: `${adminPrefix}organization-details.button.cancel`,\n },\n costCenterName: {\n id: `${adminPrefix}costCenter-details.costCenter-name`,\n },\n stateRegistration: {\n id: `${adminPrefix}costCenter-details.stateRegistration`,\n },\n stateRegistrationHelp: {\n id: `${adminPrefix}costCenter-details.stateRegistration.helpText`,\n },\n businessDocument: {\n id: `${adminPrefix}costCenter-details.businessDocument`,\n },\n businessDocumentHelp: {\n id: `${adminPrefix}costCenter-details.businessDocument.helpText`,\n },\n phoneNumber: {\n id: `${adminPrefix}costCenter-details.phoneNumber`,\n },\n phoneNumberHelp: {\n id: `${adminPrefix}costCenter-details.phoneNumber.helpText`,\n },\n editUser: {\n id: `${adminPrefix}organization-details.edit-user`,\n },\n save: {\n id: `${adminPrefix}organization-details.button.save`,\n },\n removeUser: {\n id: `${adminPrefix}organization-details.button.remove-user`,\n },\n default: {\n id: `${adminPrefix}organization-details.default`,\n },\n organizationNameRequired: {\n id: `${adminPrefix}organization-details.organization-name-required`,\n },\n tradeName: {\n id: `${adminPrefix}organization-details.tradeName`,\n },\n tradeNameHelp: {\n id: `${adminPrefix}organization-details.tradeName.helpText`,\n },\n email: {\n id: `${adminPrefix}user-details.email`,\n },\n costCenter: {\n id: `${adminPrefix}user-details.placeholder-costCenter`,\n },\n role: {\n id: `${adminPrefix}user-details.placeholder-role`,\n },\n userCostCenter: {\n id: `${adminPrefix}user-details.costCenter`,\n },\n userOrganization: {\n id: `${adminPrefix}user-details.organization`,\n },\n userRole: {\n id: `${adminPrefix}user-details.role`,\n },\n addUser: {\n id: `${adminPrefix}organization-details.add-user`,\n },\n addUserHelp: {\n id: `${adminPrefix}organization-details.add-user.helpText`,\n },\n name: {\n id: `${adminPrefix}user-details.name`,\n },\n columnEmail: {\n id: `${adminPrefix}organization-users.column.email`,\n },\n columnRole: {\n id: `${adminPrefix}organization-users.column.role`,\n },\n columnCostCenter: {\n id: `${adminPrefix}organization-users.column.costCenter`,\n },\n usersEmptyState: {\n id: `${adminPrefix}organization-users.emptyState`,\n },\n toastAddUserSuccess: {\n id: `${adminPrefix}organization-users.toast.add-success`,\n },\n toastUserDuplicatedOrganization: {\n id: `${adminPrefix}organization-users.toast.duplicated-organization`,\n },\n toastUserDuplicated: {\n id: `${adminPrefix}organization-users.toast.duplicated`,\n },\n toastAddUserFailure: {\n id: `${adminPrefix}organization-users.toast.add-failure`,\n },\n toastUpdateUserSuccess: {\n id: `${adminPrefix}organization-users.toast.update-success`,\n },\n toastUpdateUserFailure: {\n id: `${adminPrefix}organization-users.toast.update-failure`,\n },\n toastRemoveUserSuccess: {\n id: `${adminPrefix}organization-users.toast.remove-success`,\n },\n toastRemoveUserFailure: {\n id: `${adminPrefix}organization-users.toast.remove-failure`,\n },\n removeUserConfirm: {\n id: `${adminPrefix}organization-details.button.remove-user-confirm`,\n },\n removeUserHelp: {\n id: `${adminPrefix}organization-details.remove-user.helpText`,\n },\n addSingle: {\n id: `${adminPrefix}organizations-admin.add-single`,\n },\n addBulk: {\n id: `${adminPrefix}organizations-admin.add-bulk`,\n },\n toastAddOrgSuccess: {\n id: `${adminPrefix}organizations-admin.toast.add-organization-success`,\n },\n toastAddOrgFailure: {\n id: `${adminPrefix}organizations-admin.toast.add-organization-failure`,\n },\n tableColumnName: {\n id: `${adminPrefix}organizations-admin.table.column-name.title`,\n },\n columnStatus: {\n id: `${adminPrefix}organizations-admin.table.column-status.title`,\n },\n view: {\n id: `${adminPrefix}organizations-admin.table.view.label`,\n },\n tablePageTitle: {\n id: `${adminPrefix}organizations-admin.title`,\n },\n organizationsEmptyState: {\n id: `${adminPrefix}organizations-admin.table.empty-state`,\n },\n searchPlaceholder: {\n id: `${adminPrefix}organizations-admin.table.search.placeholder`,\n },\n clearFilters: {\n id: `${adminPrefix}organizations-admin.table.clearFilters.label`,\n },\n filterStatus: {\n id: `${adminPrefix}organizations-admin.table.statusFilter.label`,\n },\n filtersAll: {\n id: `${adminPrefix}organizations-admin.table.filters.all`,\n },\n filtersNone: {\n id: `${adminPrefix}organizations-admin.table.filters.none`,\n },\n filtersIncludes: {\n id: `${adminPrefix}organizations-admin.table.filters.includes`,\n },\n organizationName: {\n id: `${adminPrefix}organizations-admin.add-organization.organization-name`,\n },\n defaultCostCenterName: {\n id: `${adminPrefix}organizations-admin.add-organization.default-costCenter-name`,\n },\n organizationsTitle: {\n id: `${adminPrefix}organizations.navigation.label`,\n },\n notAllowViewMessage: {\n id: `${adminPrefix}organizations.not-allow-view-message`,\n },\n permissionSettings: {\n id: `${adminPrefix}organization-details.permission-settings`,\n },\n})\n\nexport const costCenterMessages = defineMessages({\n toastUpdateSuccess: {\n id: `${adminPrefix}costCenter-details.toast.update-success`,\n },\n toastUpdateFailure: {\n id: `${adminPrefix}costCenter-details.toast.update-failure`,\n },\n toastDeleteFailure: {\n id: `${adminPrefix}costCenter-details.toast.delete-failure`,\n },\n addressEdit: {\n id: `${adminPrefix}costCenter-details.address.edit`,\n },\n addressDelete: {\n id: `${adminPrefix}costCenter-details.address.delete`,\n },\n pageTitle: {\n id: `${adminPrefix}costCenter-details.title`,\n },\n back: {\n id: `${adminPrefix}back`,\n },\n costCenterName: {\n id: `${adminPrefix}costCenter-details.costCenter-name`,\n },\n phoneNumber: {\n id: `${adminPrefix}costCenter-details.phoneNumber`,\n },\n phoneNumberHelp: {\n id: `${adminPrefix}costCenter-details.phoneNumber.helpText`,\n },\n stateRegistration: {\n id: `${adminPrefix}costCenter-details.stateRegistration`,\n },\n stateRegistrationHelp: {\n id: `${adminPrefix}costCenter-details.stateRegistration.helpText`,\n },\n businessDocument: {\n id: `${adminPrefix}costCenter-details.businessDocument`,\n },\n businessDocumentHelp: {\n id: `${adminPrefix}costCenter-details.businessDocument.helpText`,\n },\n addresses: {\n id: `${adminPrefix}costCenter-details.addresses`,\n },\n add: {\n id: `${adminPrefix}costCenter-details.button.add`,\n },\n cancel: {\n id: `${adminPrefix}costCenter-details.button.cancel`,\n },\n update: {\n id: `${adminPrefix}costCenter-details.button.update`,\n },\n deleteConfirm: {\n id: `${adminPrefix}costCenter-details.button.delete-confirm`,\n },\n defaultAddress: {\n id: `${adminPrefix}costCenter-details.default-address`,\n },\n duplicateAddress: {\n id: `${adminPrefix}costCenter-details.duplicate-address`,\n },\n marketingTags: {\n id: `${adminPrefix}costCenter-details.marketing-tags`,\n },\n nothingToShow: {\n id: `${adminPrefix}costCenter-details.addresses.nothing-to-show`,\n },\n searchAddress: {\n id: `${adminPrefix}costCenter-details.addresses.search-address`,\n },\n showRows: {\n id: `${adminPrefix}costCenter-details.addresses.show-rows`,\n },\n of: {\n id: `${adminPrefix}costCenter-details.addresses.pagination.of`,\n },\n address: {\n id: `${adminPrefix}costCenter-details.table.column-address.title`,\n },\n receiverName: {\n id: `${adminPrefix}costCenter-details.table.column-address.receiverName`,\n },\n})\n\nexport const organizationRequestMessages = defineMessages({\n toastCreatedSuccess: {\n id: `${adminPrefix}organization-request-details.toast.created-success`,\n },\n toastUpdateSuccess: {\n id: `${adminPrefix}organization-request-details.toast.update-success`,\n },\n toastUpdateFailure: {\n id: `${adminPrefix}organization-request-details.toast.update-failure`,\n },\n toastUpdateFailureNoEmail: {\n id: `${adminPrefix}organization-request-details.toast.update-failure-missing-email`,\n },\n detailsPageTitle: {\n id: `${adminPrefix}organization-request-details.title`,\n },\n back: {\n id: `${adminPrefix}back`,\n },\n addNote: {\n id: `${adminPrefix}organization-request-details.add-note.label`,\n },\n columnName: {\n id: `${adminPrefix}organization-requests-admin.table.column-name.title`,\n },\n columnAdmin: {\n id: `${adminPrefix}organization-requests-admin.table.column-admin.title`,\n },\n columnStatus: {\n id: `${adminPrefix}organization-requests-admin.table.column-status.title`,\n },\n columnCreated: {\n id: `${adminPrefix}organization-requests-admin.table.column-created.title`,\n },\n view: {\n id: `${adminPrefix}organization-requests-admin.table.view.label`,\n },\n tablePageTitle: {\n id: `${adminPrefix}organization-requests-admin.title`,\n },\n emptyState: {\n id: `${adminPrefix}organization-requests-admin.table.empty-state`,\n },\n showRows: {\n id: `${adminPrefix}showRows`,\n },\n of: {\n id: `${adminPrefix}of`,\n },\n searchPlaceholder: {\n id: `${adminPrefix}organization-requests-admin.table.search.placeholder`,\n },\n clearFilters: {\n id: `${adminPrefix}organization-requests-admin.table.clearFilters.label`,\n },\n statusFilter: {\n id: `${adminPrefix}organization-requests-admin.table.statusFilter.label`,\n },\n filtersAll: {\n id: `${adminPrefix}organization-requests-admin.table.filters.all`,\n },\n filtersNone: {\n id: `${adminPrefix}organization-requests-admin.table.filters.none`,\n },\n filtersIncludes: {\n id: `${adminPrefix}organization-requests-admin.table.filters.includes`,\n },\n})\n\nexport const organizationSettingsMessages = defineMessages({\n toastUpdateSuccess: {\n id: `${adminPrefix}organization-settings-admin.toast.update-success`,\n },\n toastUpdateFailure: {\n id: `${adminPrefix}organization-settings-admin.toast.update-failure`,\n },\n tablePageTitle: {\n id: `${adminPrefix}organization-settings-admin.title`,\n },\n customFieldsTitle: {\n id: `${adminPrefix}organization-settings-admin.customFieldsTitle`,\n },\n emptyState: {\n id: `${adminPrefix}organization-requests-admin.table.empty-state`,\n },\n autoApprove: {\n id: `${adminPrefix}organization-settings-admin.autoApprove`,\n },\n businessReadOnly: {\n id: `${adminPrefix}organization-settings-admin.businessReadOnly`,\n },\n stateReadOnly: {\n id: `${adminPrefix}organization-settings-admin.stateReadOnly`,\n },\n saveSettings: {\n id: `${adminPrefix}organization-settings-admin.saveSettings`,\n },\n selectedPaymentsTableTitle: {\n id: `${adminPrefix}organization-settings-admin.selectedPaymentsTableTitle`,\n },\n availablePaymentsTableTitle: {\n id: `${adminPrefix}organization-settings-admin.availablePaymentsTableTitle`,\n },\n selectedPriceTablesTitle: {\n id: `${adminPrefix}organization-settings-admin.selectedPriceTablesTitle`,\n },\n availablePriceTablesTitle: {\n id: `${adminPrefix}organization-settings-admin.availablePriceTablesTitle`,\n },\n bindingTitle: {\n id: `${adminPrefix}organization-settings-select.binding.title`,\n },\n bindingAvailable: {\n id: `${adminPrefix}organization-settings-select.binding.available`,\n },\n bindingSelected: {\n id: `${adminPrefix}organization-settings-select.binding.selected`,\n },\n selectedRows: {\n id: `${adminPrefix}selected-rows`,\n },\n removeFromBinding: {\n id: `${adminPrefix}organization-settings-select.remove-from-binding`,\n },\n addToBinding: {\n id: `${adminPrefix}organization-settings-select.add-to-binding`,\n },\n showModal: {\n id: `${adminPrefix}organization-settings-showModal`,\n },\n clearCart: {\n id: `${adminPrefix}organization-settings-clearCart`,\n },\n fullImpersonation: {\n id: `${adminPrefix}organization-settings-fullImpersonation`,\n },\n formColorPickerLabel: {\n id: `${adminPrefix}warning-topbar-inative-org.form.color-picker-label`,\n },\n formTextareaLabel: {\n id: `${adminPrefix}warning-topbar-inative-org.form.textarea-label`,\n },\n formTextareaHelpText: {\n id: `${adminPrefix}warning-topbar-inative-org.form.textarea-help-text`,\n },\n generalSettings: {\n id: `${adminPrefix}organization-settings-admin.generalSettings`,\n },\n})\n\nexport const organizationCustomFieldsMessages = defineMessages({\n customFieldsTitle: {\n id: `${adminPrefix}custom-fields.title`,\n },\n customFieldsTitleSingular: {\n id: `${adminPrefix}custom-fields.name-singular`,\n },\n customFieldsExplanation: {\n id: `${adminPrefix}custom-fields.explanation`,\n },\n customFieldsTableFieldName: {\n id: `${adminPrefix}custom-fields.table.field-name`,\n },\n customFieldsTableFieldType: {\n id: `${adminPrefix}custom-fields.table.field-type`,\n },\n customFieldsTableDropdownPreview: {\n id: `${adminPrefix}custom-fields.table.dropdown-preview`,\n },\n customFieldsTableUseOnRegistration: {\n id: `${adminPrefix}custom-fields.table.use-on-registration`,\n },\n customFieldsAddField: {\n id: `${adminPrefix}custom-fields.add-field`,\n },\n customFieldsRemoveField: {\n id: `${adminPrefix}custom-fields.remove-field`,\n },\n customFieldsAddDropdownLine: {\n id: `${adminPrefix}custom-fields.table.add-dropdown-line`,\n },\n customFieldsRemoveDropdownLine: {\n id: `${adminPrefix}custom-fields.table.remove-dropdown-line`,\n },\n customFieldsDropdownLineValue: {\n id: `${adminPrefix}custom-fields.table.dropdown-line-value`,\n },\n customFieldsDropdownLineLabel: {\n id: `${adminPrefix}custom-fields.table.dropdown-line-label`,\n },\n customFieldsTextLabel: {\n id: `${adminPrefix}custom-fields.table.text-label`,\n },\n customFieldsDropdownLabel: {\n id: `${adminPrefix}custom-fields.table.dropdown-label`,\n },\n})\n\n```"
}
] |
code_b2b-organizations_231370ad
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationDetails/OrganizationDetailsPayTerms.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { FormattedMessage, useIntl } from 'react-intl'\nimport { PageBlock, Table } from 'vtex.styleguide'\nimport React, { Fragment, useEffect, useState } from 'react'\nimport { useQuery } from 'react-apollo'\n\nimport { organizationMessages as messages } from '../utils/messages'\nimport { organizationBulkAction } from '../utils/organizationBulkAction'\nimport GET_PAYMENT_TERMS from '../../graphql/getPaymentTerms.graphql'\n\nexport interface PaymentTerm {\n paymentTermId: number\n name: string\n id?: number\n}\n\nconst OrganizationDetailsPayTerms = ({\n getSchema,\n paymentTermsState,\n setPaymentTermsState,\n}: {\n getSchema: (argument?: any) => any\n paymentTermsState: PaymentTerm[]\n setPaymentTermsState: (value: any) => void\n}) => {\n /**\n * Hooks\n */\n const { formatMessage } = useIntl()\n /**\n * States\n */\n\n const [paymentTermsOptions, setPaymentTermsOptions] = useState(\n [] as PaymentTerm[]\n )\n\n /**\n * Queries\n */\n\n const { data: paymentTermsData, loading } = useQuery<{\n getPaymentTerms: PaymentTerm[]\n }>(GET_PAYMENT_TERMS, { ssr: false })\n\n /**\n * Effects\n */\n\n useEffect(() => {\n if (!paymentTermsData?.getPaymentTerms?.length) {\n return\n }\n\n const paymentTerms =\n paymentTermsData.getPaymentTerms.map((paymentTerm: any) => {\n return { name: paymentTerm.name, paymentTermId: paymentTerm.id }\n }) ?? []\n\n setPaymentTermsOptions(paymentTerms)\n }, [paymentTermsData])\n\n /**\n * Functions\n */\n\n const handleRemovePaymentTerms = (rowParams: {\n selectedRows: PaymentTerm[]\n }) => {\n const { selectedRows = [] } = rowParams\n const paymentTermsToRemove = [] as number[]\n\n selectedRows.forEach(row => {\n paymentTermsToRemove.push(row.paymentTermId)\n })\n\n const newPaymentTerms = paymentTermsState.filter(\n paymentTerm => !paymentTermsToRemove.includes(paymentTerm.paymentTermId)\n )\n\n setPaymentTermsState(newPaymentTerms)\n }\n\n const handleAddPaymentTerms = (rowParams: {\n selectedRows: PaymentTerm[]\n }) => {\n const { selectedRows = [] } = rowParams\n const newPaymentTerms = [] as PaymentTerm[]\n\n selectedRows.forEach((row: any) => {\n if (\n !paymentTermsState.some(\n paymentTerm => paymentTerm.paymentTermId === row.paymentTermId\n )\n ) {\n newPaymentTerms.push({\n name: row.name,\n paymentTermId: row.paymentTermId,\n })\n }\n })\n\n setPaymentTermsState([...paymentTermsState, ...newPaymentTerms])\n }\n\n return (\n <Fragment>\n <PageBlock variation=\"half\" title={formatMessage(messages.paymentTerms)}>\n <div>\n <h4 className=\"t-heading-4 mt0 mb0\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-details.assigned-to-org\" />\n </h4>\n <Table\n fullWidth\n schema={getSchema()}\n items={paymentTermsState}\n bulkActions={organizationBulkAction(\n handleRemovePaymentTerms,\n messages.removeFromOrg,\n formatMessage\n )}\n />\n </div>\n <div>\n <h4 className=\"t-heading-4 mt0 mb0\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-details.available\" />\n </h4>\n <Table\n fullWidth\n schema={getSchema('availablePayments')}\n items={paymentTermsOptions}\n loading={loading}\n bulkActions={organizationBulkAction(\n handleAddPaymentTerms,\n messages.addToOrg,\n formatMessage\n )}\n />\n </div>\n </PageBlock>\n </Fragment>\n )\n}\n\nexport default OrganizationDetailsPayTerms\n\n```"
}
] |
code_b2b-organizations_8100867f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationDetails/OrganizationDetailsSettings.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { PageBlock, Checkbox } from 'vtex.styleguide'\nimport React, { Fragment } from 'react'\nimport { useIntl } from 'react-intl'\n\nimport { organizationMessages as messages } from '../utils/messages'\n\nexport interface PermissionsOptions {\n value: boolean\n label: string\n}\n\ntype Permission = 'createQuote'\n\ninterface OrganizationDetailsSettingsProps {\n permissionsOptions: PermissionsOptions[]\n setPermissionsOptions: React.Dispatch<\n React.SetStateAction<PermissionsOptions[]>\n >\n}\n\nconst OrganizationDetailsSettings = ({\n permissionsOptions,\n setPermissionsOptions,\n}: OrganizationDetailsSettingsProps) => {\n const { formatMessage } = useIntl()\n\n const simulateTranslate: Record<Permission, string> = {\n createQuote: formatMessage(messages.createQuote),\n }\n\n const handleCheckboxChange = (label: string) => {\n setPermissionsOptions(prevOptions =>\n prevOptions.map(option =>\n option.label === label ? { ...option, value: !option.value } : option\n )\n )\n }\n\n return (\n <Fragment>\n <PageBlock title={formatMessage(messages.permissionSettings)}>\n {permissionsOptions.map(permissionOption => (\n <div>\n <Checkbox\n checked={permissionOption.value}\n id=\"permissionOrganization\"\n name=\"permissionOrganization\"\n onChange={() => handleCheckboxChange(permissionOption.label)}\n label={simulateTranslate[permissionOption.label as Permission]}\n />\n </div>\n ))}\n </PageBlock>\n </Fragment>\n )\n}\n\nexport default OrganizationDetailsSettings\n\n```"
}
] |
code_b2b-organizations_65dab4c8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationDetails/OrganizationDetailsSalesChannel.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment, useEffect, useState } from 'react'\nimport { useIntl } from 'react-intl'\nimport { PageBlock, RadioGroup } from 'vtex.styleguide'\nimport { useQuery } from 'react-apollo'\n\nimport { organizationMessages as messages } from '../utils/messages'\nimport GET_SALES_CHANNELS from '../../graphql/getSalesChannels.graphql'\n\ninterface SalesChannel {\n value: string\n label?: string\n}\n\nconst OrganizationDetailsSalesChannel = ({\n salesChannelState,\n setSalesChannelState,\n}: {\n salesChannelState: string\n setSalesChannelState: (value: any) => void\n}) => {\n /**\n * Hooks\n */\n const { formatMessage } = useIntl()\n\n /**\n * States\n */\n const [salesChannelOptions, setSalesChannelOptions] = useState(\n [] as SalesChannel[]\n )\n\n /**\n * Queries\n */\n const { data: salesChannelsData } = useQuery(GET_SALES_CHANNELS, {\n ssr: false,\n })\n\n /**\n * Effects\n */\n useEffect(() => {\n if (!salesChannelsData?.salesChannels?.length) {\n return\n }\n\n const options = [\n {\n value: '',\n label: formatMessage(messages.salesChannelNone),\n },\n ] as SalesChannel[]\n\n salesChannelsData.salesChannels.forEach(\n (channel: { id: string; name: string }) => {\n options.push({\n value: channel.id,\n label: `${channel.name} (${channel.id})`,\n })\n }\n )\n\n setSalesChannelOptions(options)\n }, [salesChannelsData])\n\n return (\n <Fragment>\n <PageBlock title={formatMessage(messages.salesChannel)}>\n <div>\n <RadioGroup\n name=\"salesChannels\"\n options={salesChannelOptions}\n value={salesChannelState}\n onChange={(e: any) => setSalesChannelState(e.currentTarget.value)}\n />\n </div>\n </PageBlock>\n </Fragment>\n )\n}\n\nexport default OrganizationDetailsSalesChannel\n\n```"
}
] |
code_b2b-organizations_f7766ed1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationDetails/OrganizationDetailsDefault.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { Dropdown, Input, PageBlock } from 'vtex.styleguide'\nimport { FormattedMessage, useIntl } from 'react-intl'\nimport React, { Fragment } from 'react'\nimport type { FunctionComponent } from 'react'\n\nimport { organizationMessages as messages } from '../utils/messages'\nimport CustomFieldInput from '../OrganizationDetailsCustomField'\n\ninterface Props {\n organizationNameState: string\n setOrganizationNameState: (value: string) => void\n organizationTradeNameState: string\n setOrganizationTradeNameState: (value: string) => void\n statusState: string\n setStatusState: (value: string) => void\n data: any\n customFieldsState: CustomField[]\n setCustomFieldsState: (value: CustomField[]) => void\n}\n\nconst OrganizationDetailsDefault: FunctionComponent<Props> = ({\n organizationNameState,\n setOrganizationNameState,\n organizationTradeNameState,\n setOrganizationTradeNameState,\n statusState,\n setStatusState,\n data,\n customFieldsState,\n setCustomFieldsState,\n}) => {\n /**\n * Hooks\n */\n const { formatMessage, formatDate } = useIntl()\n\n /**\n * States\n */\n const statusOptions = [\n {\n value: 'active',\n label: formatMessage(messages.statusActive),\n },\n {\n value: 'on-hold',\n label: formatMessage(messages.statusOnHold),\n },\n {\n value: 'inactive',\n label: formatMessage(messages.statusInactive),\n },\n ]\n\n const handleCustomFieldsUpdate = (\n index: number,\n customField: CustomField\n ) => {\n const newCustomFields = [...customFieldsState]\n\n newCustomFields[index] = customField\n setCustomFieldsState(newCustomFields)\n }\n\n return (\n <Fragment>\n <PageBlock>\n <Input\n autocomplete=\"off\"\n size=\"large\"\n label={\n <h4 className=\"t-heading-5 mb0 pt3\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-details.organization-name\" />\n </h4>\n }\n value={organizationNameState}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setOrganizationNameState(e.target.value)\n }}\n required\n />\n <div className=\"pv3\">\n <Input\n autocomplete=\"off\"\n size=\"large\"\n label={\n <h4 className=\"t-heading-5 mb0 pt3\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-details.tradeName\" />\n </h4>\n }\n helpText={\n <FormattedMessage id=\"admin/b2b-organizations.organization-details.tradeName.helpText\" />\n }\n value={organizationTradeNameState}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setOrganizationTradeNameState(e.target.value)\n }}\n />\n </div>\n <div className=\"pv3\">\n <Dropdown\n label={\n <h4 className=\"t-heading-5 mb0 pt3\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-details.status\" />\n </h4>\n }\n placeholder={formatMessage(messages.status)}\n options={statusOptions}\n value={statusState}\n onChange={(_: void, v: string) => setStatusState(v)}\n />\n </div>\n <h4 className=\"t-heading-5 mb0 pt3\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-details.created\" />\n </h4>\n <div className=\"mv3\">\n {formatDate(data.getOrganizationById.created, {\n day: 'numeric',\n month: 'numeric',\n year: 'numeric',\n })}\n </div>\n </PageBlock>\n {customFieldsState?.length ? (\n <PageBlock>\n <h4 className=\"t-heading-5 mb0 pt3\">\n <FormattedMessage id=\"admin/b2b-organizations.custom-fields.title\" />\n </h4>\n {customFieldsState?.map((customField: CustomField, index: number) => (\n <CustomFieldInput\n key={`${customField.name}`}\n index={index}\n handleUpdate={handleCustomFieldsUpdate}\n customField={customField}\n />\n ))}\n </PageBlock>\n ) : null}\n </Fragment>\n )\n}\n\nexport default OrganizationDetailsDefault\n\n```"
}
] |
code_b2b-organizations_bf5d12ca
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationDetails/OrganizationDetailsCollections.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport type { ChangeEvent } from 'react'\nimport React, { Fragment, useEffect, useState } from 'react'\nimport { FormattedMessage, useIntl } from 'react-intl'\nimport { PageBlock, Table } from 'vtex.styleguide'\nimport { useQuery } from 'react-apollo'\n\nimport { organizationMessages as messages } from '../utils/messages'\nimport { organizationBulkAction } from '../utils/organizationBulkAction'\nimport GET_COLLECTIONS from '../../graphql/getCollections.graphql'\n\nexport interface Collection {\n collectionId: string\n name: string\n}\n\nconst OrganizationDetailsCollections = ({\n getSchema,\n collectionsState,\n setCollectionsState,\n}: {\n getSchema: (argument?: any) => any\n collectionsState: Collection[]\n setCollectionsState: (value: any) => void\n}) => {\n /**\n * Hooks\n */\n const { formatMessage } = useIntl()\n /**\n * States\n */\n\n const [collectionOptions, setCollectionOptions] = useState([] as Collection[])\n const [collectionPaginationState, setCollectionPaginationState] = useState({\n page: 1,\n pageSize: 25,\n })\n\n /**\n * Queries\n */\n const {\n data: collectionsData,\n refetch: refetchCollections,\n loading,\n } = useQuery(GET_COLLECTIONS, {\n variables: collectionPaginationState,\n notifyOnNetworkStatusChange: true,\n ssr: false,\n })\n\n /**\n * Effects\n */\n\n useEffect(() => {\n if (!collectionsData?.collections?.items?.length) {\n return\n }\n\n const collections =\n collectionsData.collections.items.map((collection: any) => {\n return { name: collection.name, collectionId: collection.id }\n }) ?? []\n\n setCollectionOptions(collections)\n }, [collectionsData])\n\n /**\n * Functions\n */\n const handleRemoveCollections = (rowParams: any) => {\n const { selectedRows = [] } = rowParams\n const collectionsToRemove = [] as string[]\n\n selectedRows.forEach((row: any) => {\n collectionsToRemove.push(row.collectionId)\n })\n\n const newCollectionList = collectionsState.filter(\n collection => !collectionsToRemove.includes(collection.collectionId)\n )\n\n setCollectionsState(newCollectionList)\n }\n\n const handleCollectionsPrevClick = () => {\n if (collectionPaginationState.page === 1) return\n\n const newPage = collectionPaginationState.page - 1\n\n setCollectionPaginationState({\n ...collectionPaginationState,\n page: newPage,\n })\n\n refetchCollections({\n ...collectionPaginationState,\n page: newPage,\n })\n }\n\n const handleCollectionsNextClick = () => {\n const newPage = collectionPaginationState.page + 1\n\n setCollectionPaginationState({\n ...collectionPaginationState,\n page: newPage,\n })\n\n refetchCollections({\n ...collectionPaginationState,\n page: newPage,\n })\n }\n\n const handleRowsChange = (e: ChangeEvent<HTMLInputElement>) => {\n const {\n target: { value },\n } = e\n\n setCollectionPaginationState({\n page: 1,\n pageSize: +value,\n })\n\n refetchCollections({\n page: 1,\n pageSize: +value,\n })\n }\n\n const handleAddCollections = (rowParams: any) => {\n const { selectedRows = [] } = rowParams\n const newCollections = [] as Collection[]\n\n selectedRows.forEach((row: any) => {\n if (\n !collectionsState.some(\n collection => collection.collectionId === row.collectionId\n )\n ) {\n newCollections.push({ name: row.name, collectionId: row.collectionId })\n }\n })\n\n setCollectionsState([...collectionsState, ...newCollections])\n }\n\n return (\n <Fragment>\n <PageBlock variation=\"half\" title={formatMessage(messages.collections)}>\n <div>\n <h4 className=\"t-heading-4 mt0 mb0\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-details.assigned-to-org\" />\n </h4>\n <Table\n fullWidth\n schema={getSchema()}\n items={collectionsState}\n bulkActions={organizationBulkAction(\n handleRemoveCollections,\n messages.removeFromOrg,\n formatMessage\n )}\n />\n </div>\n <div>\n <h4 className=\"t-heading-4 mt0 mb0\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-details.available\" />\n </h4>\n <Table\n fullWidth\n schema={getSchema('availableCollections')}\n items={collectionOptions}\n loading={loading}\n pagination={{\n onNextClick: handleCollectionsNextClick,\n onPrevClick: handleCollectionsPrevClick,\n onRowsChange: handleRowsChange,\n selectedOption: collectionPaginationState.pageSize,\n currentItemFrom:\n (collectionPaginationState.page - 1) *\n collectionPaginationState.pageSize +\n 1,\n currentItemTo:\n collectionsData?.collections?.paging?.total <\n collectionPaginationState.page *\n collectionPaginationState.pageSize\n ? collectionsData?.collections?.paging?.total\n : collectionPaginationState.page *\n collectionPaginationState.pageSize,\n textShowRows: formatMessage(messages.showRows),\n textOf: formatMessage(messages.of),\n totalItems: collectionsData?.collections?.paging?.total ?? 0,\n rowsOptions: [25, 50],\n }}\n bulkActions={organizationBulkAction(\n handleAddCollections,\n messages.addToOrg,\n formatMessage\n )}\n />\n </div>\n </PageBlock>\n </Fragment>\n )\n}\n\nexport default OrganizationDetailsCollections\n\n```"
}
] |
code_b2b-organizations_72198966
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationDetails/useHashRouter.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport React, { useEffect, useRef, useState } from 'react'\n\nconst useHashRouter = ({\n sessionKey,\n defaultPath,\n routes,\n}: {\n sessionKey: string\n defaultPath: string\n routes: string[]\n}) => {\n const [tab, setTab] = React.useState('')\n const [location, setLocation] = useState(null as any)\n const routerRef = useRef(null as any)\n\n const setupTab = (_tab: string) => {\n sessionStorage.setItem(sessionKey, _tab)\n setTab(_tab)\n }\n\n const handleTabChange = (_tab: string) => {\n if (!routerRef?.current) {\n return\n }\n\n routerRef.current?.history?.push(`/${_tab}`)\n setupTab(_tab)\n }\n\n const onHashChange = () => {\n const hash = window.location.hash.replace('#/', '')\n\n if (routes.includes(hash)) {\n setupTab(hash)\n }\n }\n\n useEffect(() => {\n if (!location) return\n setupTab(location.pathname.replace('/', ''))\n }, [location?.pathname])\n\n useEffect(() => {\n let lastHash = window.location.hash\n const handleHashChange = () => {\n if (lastHash !== window.location.hash) {\n lastHash = window.location.hash\n onHashChange()\n }\n }\n\n const interval = setInterval(handleHashChange, 400)\n\n return () => {\n clearInterval(interval)\n }\n }, [])\n\n useEffect(() => {\n if (!routerRef?.current) return\n const { pathname } = routerRef.current?.history?.location\n\n if (pathname === '/' || !routes.includes(pathname.replace('/', ''))) {\n const sessionTab = sessionStorage.getItem(sessionKey)\n\n routerRef.current?.history?.push(\n sessionTab ? `/${sessionTab}` : `/${defaultPath}`\n )\n }\n\n setLocation(routerRef.current?.history?.location)\n }, [routerRef.current])\n\n return {\n tab,\n handleTabChange,\n routerRef,\n }\n}\n\nexport default useHashRouter\n\n```"
}
] |
code_b2b-organizations_8df6e163
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationDetails/OrganizationDetailsPriceTables.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment, useEffect, useState } from 'react'\nimport { FormattedMessage, useIntl } from 'react-intl'\nimport { PageBlock, Table } from 'vtex.styleguide'\nimport { useQuery } from 'react-apollo'\n\nimport { organizationMessages as messages } from '../utils/messages'\nimport { organizationBulkAction } from '../utils/organizationBulkAction'\nimport GET_PRICE_TABLES from '../../graphql/getPriceTables.graphql'\n\nexport interface PriceTable {\n tableId: string\n name?: string\n}\n\nconst OrganizationDetailsPriceTables = ({\n getSchema,\n priceTablesState,\n setPriceTablesState,\n}: {\n getSchema: (argument?: any) => any\n priceTablesState: string[]\n setPriceTablesState: (value: any) => void\n}) => {\n /**\n * Hooks\n */\n const { formatMessage } = useIntl()\n\n /**\n * States\n */\n const [priceTableOptions, setPriceTableOptions] = useState([] as PriceTable[])\n\n /**\n * Queries\n */\n const { data: priceTablesData, loading } = useQuery(GET_PRICE_TABLES, {\n ssr: false,\n })\n\n /**\n * Effects\n */\n useEffect(() => {\n if (!priceTablesData?.priceTables?.length) {\n return\n }\n\n const options = [] as PriceTable[]\n\n priceTablesData.priceTables.forEach((priceTable: string) => {\n if (!options.find(option => option.tableId === priceTable)) {\n options.push({ tableId: priceTable })\n }\n })\n\n setPriceTableOptions(options)\n }, [priceTablesData])\n\n /**\n * Functions\n */\n const handleRemovePriceTables = (rowParams: any) => {\n const { selectedRows = [] } = rowParams\n const priceTablesToRemove = [] as string[]\n\n selectedRows.forEach((row: PriceTable) => {\n priceTablesToRemove.push(row.tableId)\n })\n\n const newPriceTablesList = priceTablesState.filter(\n priceTable => !priceTablesToRemove.includes(priceTable)\n )\n\n setPriceTablesState(newPriceTablesList)\n }\n\n const handleAddPriceTables = (rowParams: any) => {\n const { selectedRows = [] } = rowParams\n const newPriceTables = [] as string[]\n\n selectedRows.forEach((row: PriceTable) => {\n if (!priceTablesState.includes(row.tableId)) {\n newPriceTables.push(row.tableId)\n }\n })\n\n setPriceTablesState((prevState: any) => [...prevState, ...newPriceTables])\n }\n\n return (\n <Fragment>\n <PageBlock variation=\"half\" title={formatMessage(messages.priceTables)}>\n <div>\n <h4 className=\"t-heading-4 mt0 mb0\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-details.assigned-to-org\" />\n </h4>\n <Table\n fullWidth\n schema={getSchema()}\n items={priceTablesState.map(priceTable => {\n return {\n tableId: priceTable,\n name:\n priceTableOptions.find(\n option => option.tableId === priceTable\n )?.name ?? priceTable,\n }\n })}\n bulkActions={organizationBulkAction(\n handleRemovePriceTables,\n messages.removeFromOrg,\n formatMessage\n )}\n />\n </div>\n <div>\n <h4 className=\"t-heading-4 mt0 mb0\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-details.available\" />\n </h4>\n <Table\n fullWidth\n schema={getSchema('availablePriceTables')}\n items={priceTableOptions}\n loading={loading}\n bulkActions={organizationBulkAction(\n handleAddPriceTables,\n messages.addToOrg,\n formatMessage\n )}\n />\n </div>\n </PageBlock>\n </Fragment>\n )\n}\n\nexport default OrganizationDetailsPriceTables\n\n```"
}
] |
code_b2b-organizations_6a4eb819
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationDetails/OrganizationDetailsSellers.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment, useEffect, useState } from 'react'\nimport { useQuery } from 'react-apollo'\nimport { useToast } from '@vtex/admin-ui'\nimport { PageBlock, Table } from 'vtex.styleguide'\nimport { FormattedMessage, useIntl } from 'react-intl'\n\nimport type { AvailabilityTypes } from '../OrganizationDetails'\nimport GET_ACCOUNT from '../../graphql/getAccount.graphql'\nimport { organizationMessages as messages } from '../utils/messages'\nimport { organizationBulkAction } from '../utils/organizationBulkAction'\nimport GET_SELLERS_PAGINATED from '../../graphql/getSellersPaginated.graphql'\n\nexport interface Seller {\n sellerId: string\n name?: string\n}\n\nexport interface SellerItem {\n id: string\n name: string\n}\n\ninterface RowParams {\n selectedRows: Seller[]\n}\n\ninterface GetAccountResponse {\n getAccount: {\n id: string\n name: string\n }\n}\n\ninterface GetSellersPaginatedQueryResponse {\n getSellersPaginated: {\n items: SellerItem[]\n pagination: {\n page: number\n pageSize: number\n total: number\n }\n }\n}\n\nconst OrganizationDetailsSellers = ({\n getSchema,\n sellersState,\n setSellersState,\n}: {\n getSchema: (type?: AvailabilityTypes) => unknown\n sellersState: Seller[]\n setSellersState: React.Dispatch<React.SetStateAction<Seller[]>>\n}) => {\n /**\n * Hooks\n */\n const toast = useToast()\n const { formatMessage } = useIntl()\n\n /**\n * States\n */\n const [variables, setVariables] = useState({ page: 1, pageSize: 25 })\n const [sellerOptions, setSellerOptions] = useState<Seller[]>([])\n\n /**\n * Queries\n */\n const { data: accountData, loading: loadingAccountData } = useQuery<\n GetAccountResponse\n >(GET_ACCOUNT, {\n onError: error => {\n toast({ variant: 'critical', message: error.message })\n },\n })\n\n const {\n data: sellersData,\n loading: loadingSellersData,\n refetch: refetchSellersData,\n } = useQuery<GetSellersPaginatedQueryResponse>(GET_SELLERS_PAGINATED, {\n variables,\n skip: !accountData,\n onCompleted: data => {\n if (!data?.getSellersPaginated?.items) {\n return\n }\n\n const options = data.getSellersPaginated.items.map(({ name, id }) => {\n // This is a workaround to show the account name in the seller list only for the first seller.\n // This is because the first seller is created with the account name,\n // and in turn the trade name is indexed to the product catalogs.\n if (id === '1' && accountData) {\n return {\n name: accountData.getAccount.name,\n sellerId: id,\n }\n }\n\n return {\n name,\n sellerId: id,\n }\n })\n\n setSellerOptions(options)\n },\n onError: error => {\n toast({ variant: 'critical', message: error.message })\n },\n })\n\n /**\n * Constants\n */\n const totalItems = sellersData?.getSellersPaginated?.pagination?.total ?? 0\n\n /**\n * Functions\n */\n const handleRemoveSellers = (rowParams: RowParams) => {\n const { selectedRows = [] } = rowParams\n const sellersToRemove: Seller[] = []\n\n selectedRows.forEach((row: Seller) => {\n sellersToRemove.push(row)\n })\n\n const newSellersList = sellersState.filter(\n seller =>\n !sellersToRemove.some(\n removeSeller => removeSeller.sellerId === seller.sellerId\n )\n )\n\n setSellersState(newSellersList)\n }\n\n const handleAddSellers = (rowParams: RowParams) => {\n const { selectedRows = [] } = rowParams\n const newSellers: Seller[] = []\n\n selectedRows.forEach((row: Seller) => {\n if (!sellersState.some(seller => seller.sellerId === row.sellerId)) {\n newSellers.push(row)\n }\n })\n\n setSellersState(prevState => [...prevState, ...newSellers])\n }\n\n const handleNext = () => {\n if (variables.page * variables.pageSize >= totalItems) return\n\n setVariables(prev => ({ ...prev, page: prev.page + 1 }))\n\n refetchSellersData({\n page: variables.page + 1,\n pageSize: variables.pageSize,\n })\n }\n\n const handlePrev = () => {\n if (variables.page === 1) return\n\n setVariables(prev => ({ ...prev, page: prev.page - 1 }))\n\n refetchSellersData({\n page: variables.page - 1,\n pageSize: variables.pageSize,\n })\n }\n\n const handleRowsChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const {\n target: { value },\n } = e\n\n setVariables({ page: 1, pageSize: +value })\n\n refetchSellersData({\n page: 1,\n pageSize: +value,\n })\n }\n\n useEffect(() => {\n if (accountData) {\n refetchSellersData()\n }\n }, [accountData, refetchSellersData])\n\n return (\n <Fragment>\n <PageBlock variation=\"half\" title={formatMessage(messages.sellers)}>\n <div>\n <h4 className=\"t-heading-4 mt0 mb0\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-details.assigned-to-org\" />\n </h4>\n <Table\n fullWidth\n schema={getSchema()}\n items={sellersState}\n bulkActions={organizationBulkAction(\n handleRemoveSellers,\n messages.removeFromOrg,\n formatMessage\n )}\n />\n </div>\n\n <div>\n <h4 className=\"t-heading-4 mt0 mb0\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-details.available\" />\n </h4>\n <Table\n fullWidth\n loading={loadingAccountData || loadingSellersData}\n schema={getSchema('availableSellers')}\n bulkActions={organizationBulkAction(\n handleAddSellers,\n messages.addToOrg,\n formatMessage\n )}\n items={sellerOptions}\n pagination={{\n onNextClick: handleNext,\n onPrevClick: handlePrev,\n onRowsChange: handleRowsChange,\n selectedOption: variables.pageSize,\n currentItemFrom: (variables.page - 1) * variables.pageSize + 1,\n currentItemTo: Math.min(\n variables.page * variables.pageSize,\n totalItems\n ),\n textShowRows: formatMessage(messages.showRows),\n textOf: formatMessage(messages.of),\n rowsOptions: [25, 50, 100],\n totalItems,\n }}\n />\n </div>\n </PageBlock>\n </Fragment>\n )\n}\n\nexport default OrganizationDetailsSellers\n\n```"
}
] |
code_b2b-organizations_646145a9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationDetails/OrganizationDetailsCostCenters.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport type { ChangeEvent } from 'react'\nimport React, { Fragment, useState, useEffect } from 'react'\nimport {\n Button,\n Input,\n Modal,\n PageBlock,\n Table,\n Spinner,\n} from 'vtex.styleguide'\nimport { FormattedMessage, useIntl } from 'react-intl'\nimport { useMutation, useQuery } from 'react-apollo'\nimport { useRuntime } from 'vtex.render-runtime'\nimport { addValidation } from 'vtex.address-form/helpers'\nimport {\n AddressContainer,\n AddressForm,\n AddressRules,\n CountrySelector,\n PostalCodeGetter,\n} from 'vtex.address-form'\nimport { StyleguideInput } from 'vtex.address-form/inputs'\nimport type { ToastProps } from '@vtex/admin-ui'\n\nimport GET_COST_CENTERS from '../../graphql/getCostCentersByOrganizationId.graphql'\nimport type { CellRendererProps } from '../OrganizationDetails'\nimport { organizationMessages as messages } from '../utils/messages'\nimport { getEmptyAddress, isValidAddress } from '../../utils/addresses'\nimport CREATE_COST_CENTER from '../../graphql/createCostCenter.graphql'\nimport GET_LOGISTICS from '../../graphql/getLogistics.graphql'\nimport { validatePhoneNumber } from '../../modules/formValidators'\nimport GET_B2B_CUSTOM_FIELDS from '../../graphql/getB2BCustomFields.graphql'\nimport CustomFieldInput from '../OrganizationDetailsCustomField'\nimport { useOrgPermission } from '../../hooks/useOrgPermission'\nimport { ORGANIZATION_EDIT } from '../../utils/constants'\n\ninterface CostCenterSimple {\n id: string\n name: string\n addresses: Address[]\n}\n\nconst OrganizationDetailsCostCenters = ({\n setLoadingState,\n showToast,\n loadingState,\n}: {\n setLoadingState: (state: boolean) => void\n showToast: (toast: ToastProps) => void\n loadingState: boolean\n}) => {\n /**\n * Hooks\n */\n const {\n culture: { country },\n route: { params },\n navigate,\n } = useRuntime()\n\n const { formatMessage } = useIntl()\n\n /**\n * States\n */\n const [costCenterPaginationState, setCostCenterPaginationState] = useState({\n page: 1,\n pageSize: 25,\n })\n\n const [newCostCenterModalState, setNewCostCenterModalState] = useState(false)\n const [newCostCenterName, setNewCostCenterName] = useState('')\n const [newCostCenterPhoneNumber, setNewCostCenterPhoneNumber] = useState('')\n const [\n newCostCenterBusinessDocument,\n setNewCostCenterBusinessDocument,\n ] = useState('')\n\n const [\n newCostCenterStateRegistration,\n setNewCostCenterStateRegistration,\n ] = useState('')\n\n const [newCostCenterAddressState, setNewCostCenterAddressState] = useState(\n addValidation(getEmptyAddress(country))\n )\n\n /**\n * Mutations\n */\n const [createCostCenter] = useMutation(CREATE_COST_CENTER)\n const {\n data: costCentersData,\n refetch: refetchCostCenters,\n loading,\n } = useQuery(GET_COST_CENTERS, {\n variables: { ...costCenterPaginationState, id: params?.id },\n fetchPolicy: 'network-only',\n notifyOnNetworkStatusChange: true,\n skip: !params?.id,\n ssr: false,\n })\n\n //! CUSTOM FIELDS\n const {\n data: defaultCustomFieldsData,\n loading: defaultCustomFieldsDataLoading,\n } = useQuery(GET_B2B_CUSTOM_FIELDS, {\n ssr: false,\n })\n\n const { data: canEditBuyerOrg } = useOrgPermission({\n resourceCode: ORGANIZATION_EDIT,\n })\n\n const [\n costCenterCustomFieldsState,\n setCostCenterCustomFieldsState,\n ] = useState<CustomField[]>([])\n\n useEffect(() => {\n if (defaultCustomFieldsDataLoading) return\n\n const costCenterFieldsToDisplay = defaultCustomFieldsData?.getB2BSettings.costCenterCustomFields.filter(\n (item: CustomField) => item.useOnRegistration\n )\n\n setCostCenterCustomFieldsState(costCenterFieldsToDisplay)\n }, [defaultCustomFieldsData])\n\n const handleCostCenterCustomFieldsUpdate = (\n index: number,\n customField: CustomField\n ) => {\n const newCustomFields = [...costCenterCustomFieldsState]\n\n newCustomFields[index] = customField\n setCostCenterCustomFieldsState(newCustomFields)\n }\n //! CUSTOM FIELDS\n\n /**\n * Functions\n */\n const handleCostCentersRowsChange = (e: ChangeEvent<HTMLInputElement>) => {\n const {\n target: { value },\n } = e\n\n setCostCenterPaginationState({\n page: 1,\n pageSize: +value,\n })\n\n refetchCostCenters({\n id: params?.id,\n page: 1,\n pageSize: +value,\n })\n }\n\n const handleAddNewCostCenter = () => {\n setLoadingState(true)\n const newAddress = {\n addressId: newCostCenterAddressState.addressId.value,\n addressType: newCostCenterAddressState.addressType.value,\n city: newCostCenterAddressState.city.value,\n complement: newCostCenterAddressState.complement.value,\n country: newCostCenterAddressState.country.value,\n receiverName: newCostCenterAddressState.receiverName.value,\n geoCoordinates: newCostCenterAddressState.geoCoordinates.value,\n neighborhood: newCostCenterAddressState.neighborhood.value,\n number: newCostCenterAddressState.number.value,\n postalCode: newCostCenterAddressState.postalCode.value,\n reference: newCostCenterAddressState.reference.value,\n state: newCostCenterAddressState.state.value,\n street: newCostCenterAddressState.street.value,\n addressQuery: newCostCenterAddressState.addressQuery.value,\n }\n\n const variables = {\n organizationId: params.id,\n input: {\n name: newCostCenterName,\n addresses: [newAddress],\n businessDocument: newCostCenterBusinessDocument,\n customFields: costCenterCustomFieldsState,\n stateRegistration: newCostCenterStateRegistration,\n },\n }\n\n createCostCenter({ variables })\n .then(() => {\n setNewCostCenterModalState(false)\n setLoadingState(false)\n showToast({\n variant: 'positive',\n message: formatMessage(messages.toastAddCostCenterSuccess),\n })\n refetchCostCenters({ ...costCenterPaginationState, id: params?.id })\n })\n .catch(error => {\n setNewCostCenterModalState(false)\n setLoadingState(false)\n console.error(error)\n showToast({\n variant: 'critical',\n message: formatMessage(messages.toastAddCostCenterFailure),\n })\n })\n }\n\n const handleCostCentersPrevClick = () => {\n if (costCenterPaginationState.page === 1) return\n\n const newPage = costCenterPaginationState.page - 1\n\n setCostCenterPaginationState({\n ...costCenterPaginationState,\n page: newPage,\n })\n\n refetchCostCenters({\n ...costCenterPaginationState,\n id: params?.id,\n page: newPage,\n })\n }\n\n const handleCostCentersNextClick = () => {\n const newPage = costCenterPaginationState.page + 1\n\n setCostCenterPaginationState({\n ...costCenterPaginationState,\n page: newPage,\n })\n\n refetchCostCenters({\n ...costCenterPaginationState,\n id: params?.id,\n page: newPage,\n })\n }\n\n const getCostCenterSchema = () => ({\n properties: {\n name: {\n title: formatMessage(messages.detailsColumnName),\n },\n addresses: {\n title: formatMessage(messages.columnAddresses),\n cellRenderer: ({\n rowData: { addresses },\n }: CellRendererProps<CostCenterSimple>) => (\n <span>{addresses.length}</span>\n ),\n },\n },\n })\n\n const handleNewCostCenterAddressChange = (\n changedAddress: AddressFormFields\n ) => {\n const curAddress = newCostCenterAddressState\n\n const newAddress = { ...curAddress, ...changedAddress }\n\n setNewCostCenterAddressState(newAddress)\n }\n\n const handleCloseModal = () => {\n setNewCostCenterModalState(false)\n setNewCostCenterName('')\n setNewCostCenterAddressState(addValidation(getEmptyAddress(country)))\n }\n\n const { data: logisticsData } = useQuery(GET_LOGISTICS, { ssr: false })\n\n const translateCountries = () => {\n const { shipsTo = [] } = logisticsData?.logistics ?? {}\n\n return shipsTo.map((code: string) => ({\n label: formatMessage({ id: `country.${code}` }),\n value: code,\n }))\n }\n\n /**\n * View\n */\n return (\n <Fragment>\n <PageBlock title={formatMessage(messages.costCenters)}>\n <Table\n fullWidth\n schema={getCostCenterSchema()}\n loading={loading}\n items={costCentersData?.getCostCentersByOrganizationId?.data}\n onRowClick={({\n rowData: { id },\n }: CellRendererProps<CostCenterSimple>) => {\n if (!id) return\n\n navigate({\n page: 'admin.app.b2b-organizations.costCenter-details',\n params: { id },\n })\n }}\n pagination={{\n onNextClick: handleCostCentersNextClick,\n onPrevClick: handleCostCentersPrevClick,\n onRowsChange: handleCostCentersRowsChange,\n selectedOption: costCenterPaginationState.pageSize,\n currentItemFrom:\n (costCenterPaginationState.page - 1) *\n costCenterPaginationState.pageSize +\n 1,\n currentItemTo:\n costCentersData?.getCostCentersByOrganizationId?.pagination\n ?.total <\n costCenterPaginationState.page *\n costCenterPaginationState.pageSize\n ? costCentersData?.getCostCentersByOrganizationId?.pagination\n ?.total\n : costCenterPaginationState.page *\n costCenterPaginationState.pageSize,\n textShowRows: formatMessage(messages.showRows),\n textOf: formatMessage(messages.of),\n totalItems:\n costCentersData?.getCostCentersByOrganizationId?.pagination\n ?.total ?? 0,\n rowsOptions: [25, 50, 100],\n }}\n toolbar={{\n newLine: {\n label: formatMessage(messages.new),\n handleCallback: () => setNewCostCenterModalState(true),\n disabled: !canEditBuyerOrg,\n },\n }}\n />\n </PageBlock>\n <Modal\n centered\n bottomBar={\n <div className=\"nowrap\">\n <span className=\"mr4\">\n <Button\n variation=\"tertiary\"\n onClick={() => handleCloseModal()}\n disabled={loadingState}\n >\n {formatMessage(messages.cancel)}\n </Button>\n </span>\n <span>\n <Button\n variation=\"primary\"\n onClick={() => handleAddNewCostCenter()}\n isLoading={loadingState}\n disabled={\n !newCostCenterName ||\n !isValidAddress(newCostCenterAddressState) ||\n (newCostCenterPhoneNumber &&\n !validatePhoneNumber(newCostCenterPhoneNumber))\n }\n >\n {formatMessage(messages.add)}\n </Button>\n </span>\n </div>\n }\n isOpen={newCostCenterModalState}\n onClose={() => handleCloseModal()}\n closeOnOverlayClick={false}\n >\n <p className=\"f3 f1-ns fw3 gray\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-details.add-costCenter\" />\n </p>\n <div className=\"w-100 mv6\">\n <Input\n autocomplete=\"off\"\n size=\"large\"\n label={formatMessage(messages.costCenterName)}\n value={newCostCenterName}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setNewCostCenterName(e.target.value)\n }}\n required\n />\n </div>\n <div className=\"w-100 mv6\">\n <Input\n autocomplete=\"off\"\n size=\"large\"\n label={formatMessage(messages.phoneNumber)}\n helpText={formatMessage(messages.phoneNumberHelp)}\n value={newCostCenterPhoneNumber}\n error={\n newCostCenterPhoneNumber &&\n !validatePhoneNumber(newCostCenterPhoneNumber)\n }\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setNewCostCenterPhoneNumber(e.target.value)\n }}\n />\n </div>\n <div className=\"w-100 mv6\">\n <Input\n autocomplete=\"off\"\n size=\"large\"\n label={formatMessage(messages.businessDocument)}\n helpText={formatMessage(messages.businessDocumentHelp)}\n value={newCostCenterBusinessDocument}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setNewCostCenterBusinessDocument(e.target.value)\n }}\n />\n </div>\n {/* //! Custom fields */}\n {defaultCustomFieldsDataLoading ? (\n <div className=\"mb5 flex flex-column\">\n <Spinner />\n </div>\n ) : (\n <>\n {costCenterCustomFieldsState?.map(\n (customField: CustomField, index: number) => {\n return (\n <CustomFieldInput\n key={`${customField.name}`}\n index={index}\n handleUpdate={handleCostCenterCustomFieldsUpdate}\n customField={customField}\n />\n )\n }\n )}\n </>\n )}\n {/* //! Custom fields */}\n <div className=\"w-100 mv6\">\n <Input\n autocomplete=\"off\"\n size=\"large\"\n label={formatMessage(messages.stateRegistration)}\n helpText={formatMessage(messages.stateRegistrationHelp)}\n value={newCostCenterStateRegistration}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setNewCostCenterStateRegistration(e.target.value)\n }}\n />\n </div>\n <div className=\"w-100 mv6\">\n <FormattedMessage id=\"admin/b2b-organizations.organization-details.add-costCenter.helpText\" />\n </div>\n <AddressRules\n country={newCostCenterAddressState?.country?.value}\n shouldUseIOFetching\n useGeolocation={false}\n >\n <AddressContainer\n address={newCostCenterAddressState}\n Input={StyleguideInput}\n onChangeAddress={handleNewCostCenterAddressChange}\n autoCompletePostalCode\n >\n <CountrySelector shipsTo={translateCountries()} />\n\n <PostalCodeGetter />\n\n <AddressForm\n Input={StyleguideInput}\n omitAutoCompletedFields={false}\n omitPostalCodeFields\n />\n </AddressContainer>\n </AddressRules>\n </Modal>\n </Fragment>\n )\n}\n\nexport default OrganizationDetailsCostCenters\n\n```"
}
] |
code_b2b-organizations_62bb5d88
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationDetails/OrganizationDetailsUsers.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { PageBlock } from 'vtex.styleguide'\nimport React, { Fragment } from 'react'\nimport { useIntl } from 'react-intl'\n\nimport OrganizationUsersTable from '../../components/OrganizationUsersTable'\nimport { organizationMessages as messages } from '../utils/messages'\n\nconst OrganizationDetailsUsers = ({\n params,\n loadingState,\n}: {\n params: any\n loadingState: any\n}) => {\n /**\n * Hooks\n */\n const { formatMessage } = useIntl()\n\n return (\n <Fragment>\n <PageBlock title={formatMessage(messages.users)}>\n <OrganizationUsersTable\n organizationId={params?.id}\n permissions={[]}\n refetchCostCenters={loadingState}\n isAdmin={true}\n />\n </PageBlock>\n </Fragment>\n )\n}\n\nexport default OrganizationDetailsUsers\n\n```"
}
] |
code_b2b-organizations_50028199
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationsList/OrganizationsListSearch/index.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nexport { default } from './OrganizationsListSearch'\n\n```"
}
] |
code_b2b-organizations_92b4085e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationsList/OrganizationsListSearch/OrganizationsListSearch.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { Search, csx, useSearchState } from '@vtex/admin-ui'\nimport type { TagProps } from '@vtex/admin-ui'\n\nimport type { FetchListOptions } from '../../../organizations/hooks'\n\nexport const TagVariantByStatus: Record<string, TagProps['variant']> = {\n active: 'green',\n inactive: 'red',\n 'on-hold': 'orange',\n}\n\ninterface Props {\n onSearch: (options: Partial<FetchListOptions>) => void\n}\n\nconst OrganizationsListSearch: React.FC<Props> = ({ onSearch }) => {\n const search = useSearchState()\n\n const handleSearchKeyDown: React.KeyboardEventHandler<HTMLFormElement> = event => {\n if (event.key !== 'Enter') return\n\n onSearch({\n search: search.value,\n page: 1,\n })\n }\n\n const { onClear, ...inputProps } = search.getInputProps()\n\n const handleSearchClear = () => {\n onClear()\n\n onSearch({\n search: '',\n page: 1,\n })\n }\n\n return (\n <Search\n rel=\"\"\n {...inputProps}\n onClear={handleSearchClear}\n onKeyDown={handleSearchKeyDown}\n className={csx({ marginRight: '$space-5' })}\n />\n )\n}\n\nexport default OrganizationsListSearch\n\n```"
}
] |
code_b2b-organizations_10d5e63d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationsList/OrganizationsListStatusFilter/index.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nexport { default } from './OrganizationsListStatusFilter'\n\n```"
}
] |
code_b2b-organizations_5f4162a4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/admin/OrganizationsList/OrganizationsListStatusFilter/OrganizationsListStatusFilter.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useEffect } from 'react'\nimport {\n FilterDisclosure,\n FilterFooter,\n FilterListbox,\n FilterOptionCheckbox,\n FilterPopover,\n useFilterMultipleState,\n} from '@vtex/admin-ui'\nimport { useIntl } from 'react-intl'\n\nimport { organizationMessages as messages } from '../../utils/messages'\n\nconst AllStatus = ['active', 'on-hold', 'inactive']\n\ninterface Props {\n onChange: (value: string[]) => void\n}\n\nconst OrganizationsListStatusFilter: React.FC<Props> = ({ onChange }) => {\n const { formatMessage } = useIntl()\n const state = useFilterMultipleState()\n const { appliedItems } = state\n\n useEffect(() => {\n let statuses = appliedItems.map(({ id }) => id)\n\n if (statuses.length === 0) {\n statuses = AllStatus\n }\n\n onChange(statuses)\n }, [appliedItems])\n\n return (\n <>\n <FilterDisclosure state={state}>\n {formatMessage(messages.filterStatus)}\n </FilterDisclosure>\n\n <FilterPopover state={state}>\n <FilterListbox>\n {AllStatus.map(item => (\n <FilterOptionCheckbox key={item} label={item} id={item} />\n ))}\n </FilterListbox>\n <FilterFooter />\n </FilterPopover>\n </>\n )\n}\n\nexport default OrganizationsListStatusFilter\n\n```"
}
] |
code_b2b-organizations_6e22c37f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/utils/metrics/changeTeam.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { Session } from '../../modules/session'\nimport type { Metric } from './metrics'\nimport { sendMetric } from './metrics'\n\ntype ChangeTeamFieldsMetric = {\n date: string\n user_role: string\n user_email?: string\n org_id: string\n cost_center_id: string\n}\n\ntype ChangeTeamMetric = Metric & { fields: ChangeTeamFieldsMetric }\n\nexport type StopImpersonateMetricParams = {\n sessionResponse: Session\n currentCostCenter: string\n costCenterInput: string\n currentOrganization: string\n organizationInput: string\n email: string\n}\n\nexport type ChangeTeamParams = {\n sessionResponse: Session\n currentRoleName: string\n currentOrganization: string\n currentCostCenter: string\n}\n\nconst buildMetric = (metricParams: ChangeTeamParams): ChangeTeamMetric => {\n return {\n name: 'b2b-suite-buyerorg-data' as const,\n account:\n metricParams.sessionResponse?.namespaces?.account?.accountName?.value,\n kind: 'change-team-ui-event',\n description: 'User change team/organization - UI',\n fields: {\n date: new Date().toISOString(),\n user_role: metricParams.currentRoleName,\n user_email:\n metricParams.sessionResponse?.namespaces?.profile?.email?.value,\n org_id: metricParams.currentOrganization,\n cost_center_id: metricParams.currentCostCenter,\n },\n }\n}\n\nexport const sendChangeTeamMetric = async (metricParams: ChangeTeamParams) => {\n try {\n const metric: ChangeTeamMetric = buildMetric(metricParams)\n\n await sendMetric(metric)\n } catch (error) {\n console.warn('Unable to log metrics', error)\n }\n}\n\n```"
}
] |
code_b2b-organizations_5a1f52f3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/utils/metrics/impersonate.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { B2BUserSimple } from '../../components/OrganizationUsersTable'\nimport type { Session } from '../../modules/session'\nimport { getSession } from '../../modules/session'\nimport type { Metric } from './metrics'\nimport { sendMetric } from './metrics'\n\ntype ImpersonatePerson = {\n email: string\n buyer_org_id: string\n cost_center_id: string\n cost_center_name: string\n}\n\ntype ImpersonateTarget = ImpersonatePerson & { buyer_org_name: string }\n\ntype ImpersonateFieldsMetric = {\n user: ImpersonatePerson\n target: ImpersonateTarget\n date: string\n}\n\ntype ImpersonateMetric = Metric & { fields: ImpersonateFieldsMetric }\n\nexport type ImpersonateMetricParams = {\n costCenterData: {\n getCostCenterByIdStorefront: {\n id: string\n name: string\n organization: string\n }\n }\n target: B2BUserSimple\n}\n\nexport type StopImpersonateMetricParams = {\n sessionResponse: Session\n currentCostCenter: string\n costCenterInput: string\n currentOrganization: string\n organizationInput: string\n email: string\n}\n\nconst buildImpersonateMetric = async (\n metricParams: ImpersonateMetricParams\n) => {\n const { target, costCenterData } = metricParams\n\n const session = await getSession()\n const sessionResponse = session?.response\n let namespace\n\n if (sessionResponse && 'namespaces' in sessionResponse) {\n namespace = sessionResponse?.namespaces\n }\n\n return {\n name: 'b2b-suite-buyerorg-data' as const,\n kind: 'impersonate-ui-event',\n description: 'Impersonate User Action - UI',\n account: namespace?.account?.accountName?.value,\n fields: {\n user: {\n email: namespace?.profile?.email?.value,\n buyer_org_id: costCenterData?.getCostCenterByIdStorefront.organization,\n cost_center_id: costCenterData?.getCostCenterByIdStorefront.id,\n cost_center_name: costCenterData?.getCostCenterByIdStorefront.name,\n },\n target: {\n email: target.email,\n buyer_org_id: target.orgId,\n buyer_org_name: target.organizationName,\n cost_center_id: target.costId,\n cost_center_name: target.costCenterName,\n },\n date: new Date().toISOString(),\n },\n } as ImpersonateMetric\n}\n\nconst buildStopImpersonateMetric = (\n metricParams: StopImpersonateMetricParams\n) => {\n return {\n name: 'b2b-suite-buyerorg-data' as const,\n kind: 'stop-impersonate-ui-event',\n description: 'Stop Impersonate User Action - UI',\n account:\n metricParams.sessionResponse?.namespaces?.account?.accountName?.value,\n fields: {\n user: {\n email:\n metricParams.sessionResponse?.namespaces?.authentication\n ?.storeUserEmail?.value,\n },\n target: {\n email: metricParams.email,\n buyer_org_id: metricParams.currentOrganization,\n buyer_org_name: metricParams.organizationInput,\n cost_center_id: metricParams.currentCostCenter,\n cost_center_name: metricParams.costCenterInput,\n },\n date: new Date().toISOString(),\n },\n } as ImpersonateMetric\n}\n\nexport const sendImpersonateMetric = async (\n metricParams: ImpersonateMetricParams\n) => {\n try {\n const metric = await buildImpersonateMetric(metricParams)\n\n await sendMetric(metric)\n } catch (error) {\n console.warn('Unable to log metrics', error)\n }\n}\n\nexport const sendStopImpersonateMetric = async (\n metricParams: StopImpersonateMetricParams\n) => {\n try {\n const metric = buildStopImpersonateMetric(metricParams)\n\n await sendMetric(metric)\n } catch (error) {\n console.warn('Unable to log metrics', error)\n }\n}\n\n```"
}
] |
code_b2b-organizations_ce9cb0e7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/utils/metrics/metrics.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport axios from 'axios'\n\nconst ANALYTICS_URL = 'https://rc.vtex.com/api/analytics/schemaless-events'\n\ntype ImpersonateMetric = {\n kind: 'impersonate-ui-event'\n description: 'Impersonate User Action - UI'\n}\n\ntype StopImpersonateMetric = {\n kind: 'stop-impersonate-ui-event'\n description: 'Stop Impersonate User Action - UI'\n}\n\nexport type ChangeTeamMetric = {\n kind: 'change-team-ui-event'\n description: 'User change team/organization - UI'\n}\n\nexport type Metric = {\n name: 'b2b-suite-buyerorg-data'\n account: string\n} & (ImpersonateMetric | StopImpersonateMetric | ChangeTeamMetric)\n\nexport const sendMetric = async (metric: Metric) => {\n try {\n await axios.post(ANALYTICS_URL, metric)\n } catch (error) {\n console.warn('Unable to log metrics', error)\n }\n}\n\n```"
}
] |
code_b2b-organizations_0fbf423a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/CustomFieldInputList/CustomFieldInputList.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { Spinner } from 'vtex.styleguide'\n\nimport CustomFieldInput from '../../admin/OrganizationDetailsCustomField'\n\ninterface Props {\n customFields: CustomField[] | null\n onChange: (customFields: CustomField[]) => void\n}\n\nconst CustomFieldInputList: React.FC<Props> = ({ customFields, onChange }) => {\n const isLoading = !customFields\n\n const handleUpdate = (index: number, customField: CustomField) => {\n if (!customFields) return\n\n const newCustomFields = [...customFields]\n\n newCustomFields[index] = customField\n onChange(newCustomFields)\n }\n\n return (\n <>\n {isLoading ? (\n <div className=\"mb5\">\n <Spinner />\n </div>\n ) : (\n customFields?.map((customField: CustomField, index: number) => {\n return (\n <CustomFieldInput\n key={`${customField.name}`}\n index={index}\n handleUpdate={handleUpdate}\n customField={customField}\n />\n )\n })\n )}\n </>\n )\n}\n\nexport default CustomFieldInputList\n\n```"
}
] |
code_b2b-organizations_af586da5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/CreateOrganizationButton/index.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nexport { default } from './CreateOrganizationButton'\n\n```"
}
] |
code_b2b-organizations_1a679de2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/CreateOrganizationButton/CreateOrganizationButton.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useState } from 'react'\nimport {\n IconPencil,\n IconCloudArrowUp,\n Menu,\n MenuItem,\n PageHeaderMenuButton,\n Text,\n useMenuState,\n} from '@vtex/admin-ui'\nimport { UploadModal } from '@vtex/bulk-import-ui'\nimport { useSWRConfig } from 'swr'\n\nimport CreateOrganizationModal from '../CreateOrganizationModal'\nimport { organizationMessages as messages } from '../../admin/utils/messages'\nimport { useBulkImportsQuery, useTranslate } from '../../hooks'\nimport ReportErrorScreen from '../UploadModal/ReportErrorScreen'\nimport ReportScreen from '../UploadModal/ReportScreen'\nimport ReportSuccessScreen from '../UploadModal/ReportSuccessScreen'\nimport { uploadBulkImportFile } from '../../services'\nimport type {\n BulkImportUploadError,\n FieldValidationError,\n UploadFileData,\n UploadFileResult,\n} from '../../types/BulkImport'\nimport useStartBulkImport from '../../hooks/useStartBulkImport'\nimport ReportDownloadLink from '../ReportDownloadLink/ReportDownloadLink'\nimport { UploadingScreen } from '../UploadingScreen'\nimport { ImportInBulkTooltip } from '../ImportInBulkTooltip'\nimport {\n B2B_BULK_IMPORT_TEMPLATE_LINK,\n B2B_BULK_IMPORT_BEST_PRACTICES_LINK,\n ORGANIZATION_EDIT,\n} from '../../utils/constants'\nimport { useOrgPermission } from '../../hooks/useOrgPermission'\n\nconst CreateOrganizationButton = () => {\n const { formatMessage, translate: t } = useTranslate()\n const menuState = useMenuState()\n const [open, setOpen] = useState(false)\n const [uploadModalOpen, setUploadModalOpen] = useState(false)\n const { mutate } = useSWRConfig()\n const { startBulkImport } = useStartBulkImport()\n\n const { data } = useBulkImportsQuery()\n const { data: canEditBuyerOrg } = useOrgPermission({\n resourceCode: ORGANIZATION_EDIT,\n })\n\n const handleUploadFinish = async (result: UploadFileData) => {\n if (result.status === 'success' && result.data?.fileData?.importId) {\n await startBulkImport({ importId: result.data.fileData.importId })\n mutate('/buyer-orgs')\n }\n }\n\n return (\n <>\n <PageHeaderMenuButton\n state={menuState}\n label={formatMessage(messages.new)}\n labelHidden={false}\n variant=\"primary\"\n disabled={!canEditBuyerOrg}\n />\n <Menu state={menuState} aria-label=\"actions\">\n <MenuItem\n label={formatMessage(messages.addSingle)}\n icon={<IconPencil />}\n onClick={() => setOpen(true)}\n />\n <ImportInBulkTooltip visible={!data}>\n <MenuItem\n label={formatMessage(messages.addBulk)}\n icon={<IconCloudArrowUp />}\n onClick={() => setUploadModalOpen(true)}\n disabled={!data}\n />\n </ImportInBulkTooltip>\n </Menu>\n <CreateOrganizationModal open={open} onOpenChange={setOpen} />\n <UploadModal\n helpContent={\n <Text variant=\"body\">\n {t('helpLinks', {\n 'template-link': (content: string) => (\n <a href={B2B_BULK_IMPORT_TEMPLATE_LINK}>{content}</a>\n ),\n 'best-practices-link': (content: string) => (\n <a href={B2B_BULK_IMPORT_BEST_PRACTICES_LINK}>{content}</a>\n ),\n })}\n </Text>\n }\n open={uploadModalOpen}\n onOpenChange={setUploadModalOpen}\n uploadFile={uploadBulkImportFile}\n onUploadFinish={handleUploadFinish}\n uploadingScreen={props => <UploadingScreen {...props} />}\n errorScreen={props => (\n <ReportErrorScreen {...(props.data as BulkImportUploadError)} />\n )}\n reportScreen={props => (\n <ReportScreen {...(props.data as FieldValidationError)} />\n )}\n successScreen={props => (\n <ReportSuccessScreen {...(props.data as UploadFileResult)} />\n )}\n reportFooterActionButton={props => (\n <ReportDownloadLink\n downloadLink={\n (props.data as FieldValidationError)?.errorDownloadLink\n }\n />\n )}\n />\n </>\n )\n}\n\nexport default CreateOrganizationButton\n\n```"
}
] |
code_b2b-organizations_18c1a568
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/UserWidget/UserWidgetTable.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment, useEffect, useState } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { ButtonWithIcon, IconCaretDown } from 'vtex.styleguide'\n\nimport { useScroll } from '../../hooks/useScroll'\n\ntype UserWidgetTableProps = Readonly<{\n list?: Array<{\n orgId: string\n costId: string\n organizationName: string\n costCenterName: string\n }>\n radioValue: string\n setRadioValue: React.Dispatch<React.SetStateAction<string>>\n}>\n\nconst CSS_HANDLES = [\n 'userWidgetModalTotal',\n 'userWidgetModalTableContainer',\n 'userWidgetModalTable',\n 'userWidgetModalTableRow',\n 'userWidgetModalTableRowChecked',\n 'userWidgetModalTableRadio',\n 'userWidgetModalTableCell',\n] as const\n\nconst DEFAULT_OFFSET = 15\n\nexport function UserWidgetTable(props: UserWidgetTableProps) {\n const handles = useCssHandles(CSS_HANDLES)\n const [offset, setOffset] = useState(DEFAULT_OFFSET)\n const { list = [], radioValue, setRadioValue } = props\n const slicedList = list.slice(0, offset)\n const currentOffset = offset < list.length ? offset : list.length\n const onScrollEnd = () => setOffset((prev: number) => prev + DEFAULT_OFFSET)\n const scrollRef = useScroll<HTMLDivElement>({ onScrollEnd })\n\n useEffect(() => {\n scrollRef.current?.scrollTo(0, 0)\n setOffset(DEFAULT_OFFSET)\n }, [list.length])\n\n return (\n <>\n <div\n ref={scrollRef}\n className={`${handles.userWidgetModalTableContainer} mb4`}\n >\n <table className={handles.userWidgetModalTable}>\n <tbody>\n {slicedList.map((organization, index) => {\n const id = [organization.orgId, organization.costId, index].join()\n\n return (\n <Fragment key={id}>\n <tr\n className={`${handles.userWidgetModalTableRow} ${\n id === radioValue\n ? handles.userWidgetModalTableRowChecked\n : ''\n }`}\n onClick={() => setRadioValue(id)}\n >\n <td className={handles.userWidgetModalTableCell}>\n <input\n id={id}\n value={id}\n checked={id === radioValue}\n onChange={(e: any) => setRadioValue(e.target.value)}\n type=\"radio\"\n className={handles.userWidgetModalTableRadio}\n />\n </td>\n <td className={handles.userWidgetModalTableCell}>\n <label htmlFor={id}>\n {organization.organizationName}\n </label>\n </td>\n <td className={handles.userWidgetModalTableCell}>\n <label htmlFor={id}>{organization.costCenterName}</label>\n </td>\n </tr>\n {index === slicedList.length - 1 &&\n list.length > currentOffset && (\n <tr>\n <td colSpan={3} align=\"center\">\n <ButtonWithIcon\n onClick={onScrollEnd}\n icon={<IconCaretDown />}\n variation=\"tertiary\"\n />\n </td>\n </tr>\n )}\n </Fragment>\n )\n })}\n </tbody>\n </table>\n </div>\n {list.length > DEFAULT_OFFSET && (\n <div className=\"flex justify-end mb4\">\n {currentOffset}/{list.length}\n </div>\n )}\n </>\n )\n}\n\n```"
}
] |
code_b2b-organizations_1dfd1001
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/SellerWrapper/SellerWrapper.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { useEffect } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { useProduct } from 'vtex.product-context'\n\nimport { useSelectSeller } from '../../hooks/useSelectSeller'\n\ntype SellerWrapperProps = {\n children: React.ReactNode\n}\n\nconst CSS_HANDLES = ['sellerWrapper', 'sellerWrapperNoSeller']\n\nconst SellerWrapper = ({ children }: SellerWrapperProps) => {\n const handles = useCssHandles(CSS_HANDLES)\n const { currentSelectedItem, selectSeller } = useSelectSeller()\n\n const productContext = useProduct()\n const { selectedItem } = productContext ?? {}\n\n useEffect(() => {\n selectSeller({ selectedItem })\n }, [selectedItem, selectSeller])\n\n const className = currentSelectedItem\n ? `${handles.sellerWrapper}`\n : `${handles.sellerWrapper} ${handles.sellerWrapperNoSeller}`\n\n return <div className={className}>{children}</div>\n}\n\nexport default SellerWrapper\n\n```"
}
] |
code_b2b-organizations_9406ae70
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/UploadModal/ReportList.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment } from 'react'\nimport { ReportListHeader, ReportListItem } from '@vtex/bulk-import-ui'\n\nimport type { ImportReportData } from '../../types/BulkImport'\nimport { useTranslate } from '../../hooks'\n\nexport type ReportListProps = {\n data: ImportReportData[]\n}\n\nconst ReportList = ({ data }: ReportListProps) => {\n const { translate: t } = useTranslate()\n\n return (\n <>\n {data.map(report => {\n const totalImports = report.success.imports + report.error.imports\n\n return (\n <Fragment key={report.title}>\n <ReportListHeader\n label={report.title}\n percentage={report.success.percentage}\n />\n <ReportListItem\n tone=\"secondary\"\n showBullet={false}\n label={t('reportInformationListTotal')}\n locators={[totalImports]}\n />\n <ReportListItem\n type=\"success\"\n label={t('reportInformationImportSuccessFully')}\n locators={[\n `${report.success.percentage}%`,\n report.success.imports,\n ]}\n />\n <ReportListItem\n type=\"error\"\n label={t('reportInformationImportFailed')}\n locators={[`${report.error.percentage}%`, report.error.imports]}\n />\n </Fragment>\n )\n })}\n </>\n )\n}\n\nexport default ReportList\n\n```"
}
] |
code_b2b-organizations_f15767c8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/UploadModal/ReportScreen.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { ReportInformation, ReportListItem } from '@vtex/bulk-import-ui'\nimport React from 'react'\nimport { csx } from '@vtex/admin-ui'\n\nimport type { FieldValidationError } from '../../types/BulkImport'\nimport ReportInformationDetails from './ReportInformationDetails'\nimport useErrorCount from '../../hooks/useErrorCount'\nimport { useTranslate } from '../../hooks'\n\nconst ReportScreen = (data: FieldValidationError) => {\n const getErrorCount = useErrorCount()\n\n const { translate: t } = useTranslate()\n\n const { fileName, validationResult = [], errorDownloadLink } = data\n\n const errorCount = getErrorCount(validationResult)\n\n return (\n <>\n <ReportInformation\n status=\"error\"\n title={t('reportScreenTitle', {\n errorCount,\n })}\n description={t('reportScreenDescription', {\n fileName,\n 'file-name-link': (content: string) => (\n <a href={errorDownloadLink}>{content}</a>\n ),\n })}\n className={csx({ marginBottom: '$space-4' })}\n />\n <ReportInformationDetails\n variant=\"Upload\"\n validationReportDownloadLink={errorDownloadLink}\n />\n <ReportListItem\n tone=\"secondary\"\n showBullet={false}\n label={t('reportScreenLabel')}\n locators={[errorCount]}\n className={csx({ marginTop: '$space-4' })}\n />\n {validationResult.map(({ name, invalidRows }) => (\n <ReportListItem\n key={name}\n type={invalidRows > 0 ? 'error' : 'success'}\n label={name}\n locators={[invalidRows]}\n />\n ))}\n </>\n )\n}\n\nexport default ReportScreen\n\n```"
}
] |
code_b2b-organizations_f383ec06
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/UploadModal/ReportErrorScreen.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { ErrorScreen } from '@vtex/bulk-import-ui'\n\nimport type { BulkImportUploadError } from '../../types/BulkImport'\nimport useErrorCount from '../../hooks/useErrorCount'\n\ntype ReportErrorScreenProps = BulkImportUploadError | null\n\nconst ReportErrorScreen = (data: ReportErrorScreenProps) => {\n const getErrorCount = useErrorCount()\n\n if (data?.error === 'FieldValidationError') {\n const errorCount = Array.isArray(data.validationResult)\n ? getErrorCount(data.validationResult)\n : undefined\n\n return <ErrorScreen fileName={data.fileName} errorCount={errorCount} />\n }\n\n return <ErrorScreen fileName={data?.description} />\n}\n\nexport default ReportErrorScreen\n\n```"
}
] |
code_b2b-organizations_bf1681a1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/UploadModal/ReportInformationDetails.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { Anchor, Text, csx } from '@vtex/admin-ui'\nimport React from 'react'\n\nimport { useTranslate } from '../../hooks'\n\nexport type ReportInformationDetailsProps = {\n variant: 'Import' | 'Upload'\n validationReportDownloadLink?: string\n}\n\nconst ReportInformationDetails = ({\n variant,\n validationReportDownloadLink,\n}: ReportInformationDetailsProps) => {\n const { translate: t } = useTranslate()\n\n return (\n <>\n <Text\n variant=\"body\"\n className={csx({\n display: 'block',\n marginTop: '$space-3',\n marginBottom: '$space-2',\n })}\n >\n {t(`reportInformationInitial${variant}`, {\n 'file-name-link': (content: string) => (\n <a href={validationReportDownloadLink}>{content}</a>\n ),\n })}\n </Text>\n <Text variant=\"body\">\n {t('reportInformationNextSteps')}\n <ul className={csx({ marginLeft: '$space-1' })}>\n <ol>{t('reportInformationStep1')}</ol>\n <ol>{t('reportInformationStep2')}</ol>\n <ol>{t(`reportInformationStep3${variant}`)}</ol>\n <ol>\n {t('reportInformationStep4', {\n 'template-link': (content: string) => (\n <Anchor href=\"/template-link\">{content}</Anchor>\n ),\n 'best-practices-link': (content: string) => (\n <Anchor href=\"/best-practices\">{content}</Anchor>\n ),\n })}\n </ol>\n </ul>\n </Text>\n </>\n )\n}\n\nexport default ReportInformationDetails\n\n```"
}
] |
code_b2b-organizations_0a42a4f4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/UploadModal/ReportSuccessScreen.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { SuccessScreen } from '@vtex/bulk-import-ui'\n\nimport type { UploadFileResult } from '../../types/BulkImport'\nimport { useTranslate } from '../../hooks'\n\nconst ReportSuccessScreen = ({ successCount, fileData }: UploadFileResult) => {\n const { translate: t } = useTranslate()\n\n const successCountMessage =\n typeof successCount === 'number'\n ? t('reportScreenSuccessCount', { successCount })\n : undefined\n\n return (\n <SuccessScreen fileName={fileData?.fileName} extra={successCountMessage} />\n )\n}\n\nexport default ReportSuccessScreen\n\n```"
}
] |
code_b2b-organizations_3d4c60e8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/ReportDownloadLink/ReportDownloadLink.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { Button, IconArrowLineDown } from '@vtex/admin-ui'\nimport React from 'react'\n\nimport { useTranslate } from '../../hooks'\n\ntype ReportDownloadLinkProps = {\n downloadLink?: string\n}\n\nconst ReportDownloadLink = ({ downloadLink }: ReportDownloadLinkProps) => {\n const { translate: t } = useTranslate()\n\n if (!downloadLink) return null\n\n return (\n <Button\n variant=\"tertiary\"\n iconPosition=\"end\"\n icon={<IconArrowLineDown />}\n onClick={() => window?.location.assign?.(downloadLink)}\n >\n {t('downloadReviewedLink')}\n </Button>\n )\n}\n\nexport default ReportDownloadLink\n\n```"
}
] |
code_b2b-organizations_3ed3276e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/utils/bytesToSize.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const bytesToSize = (bytes: number) => {\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']\n\n if (bytes === 0) return '0 Bytes'\n const i = Math.floor(Math.log(bytes) / Math.log(1024))\n\n if (i === 0) return `${bytes} ${sizes[i]}`\n\n return `${Math.round(bytes / 1024 ** i)}${sizes[i]}`\n}\n\n```"
}
] |
code_b2b-organizations_9f6cd56b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/utils/messages.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { defineMessages } from 'react-intl'\n\nconst storePrefix = 'store/b2b-organizations.'\n\nexport const costCenterMessages = defineMessages({\n toastUpdateSuccess: {\n id: `${storePrefix}costCenter-details.toast.update-success`,\n },\n toastUpdateFailure: {\n id: `${storePrefix}costCenter-details.toast.update-failure`,\n },\n toastDeleteFailure: {\n id: `${storePrefix}costCenter-details.toast.delete-failure`,\n },\n addressEdit: {\n id: `${storePrefix}costCenter-details.address.edit`,\n },\n addressDelete: {\n id: `${storePrefix}costCenter-details.address.delete`,\n },\n pageTitle: {\n id: `${storePrefix}costCenter-details.title`,\n },\n back: {\n id: `${storePrefix}back`,\n },\n costCenterName: {\n id: `${storePrefix}costCenter-details.costCenter-name`,\n },\n addresses: {\n id: `${storePrefix}costCenter-details.addresses`,\n },\n paymentTerms: {\n id: `${storePrefix}costCenter-details.payment-terms`,\n },\n addressesSubtitle: {\n id: `${storePrefix}costCenter-details.addresses.helpText`,\n },\n paymentTermsSubtitle: {\n id: `${storePrefix}costCenter-details.payment-terms.helpText`,\n },\n defaultAddress: {\n id: `${storePrefix}costCenter-details.default-address`,\n },\n duplicateAddress: {\n id: `${storePrefix}costCenter-details.duplicate-address`,\n },\n phoneNumber: {\n id: `${storePrefix}costCenter-details.phoneNumber`,\n },\n phoneNumberHelp: {\n id: `${storePrefix}costCenter-details.phoneNumber.helpText`,\n },\n stateRegistration: {\n id: `${storePrefix}costCenter-details.stateRegistration`,\n },\n stateRegistrationHelp: {\n id: `${storePrefix}costCenter-details.stateRegistration.helpText`,\n },\n businessDocument: {\n id: `${storePrefix}costCenter-details.businessDocument`,\n },\n businessDocumentHelp: {\n id: `${storePrefix}costCenter-details.businessDocument.helpText`,\n },\n deleteConfirm: {\n id: `${storePrefix}costCenter-details.button.delete-confirm`,\n },\n update: {\n id: `${storePrefix}costCenter-details.button.update`,\n },\n add: {\n id: `${storePrefix}costCenter-details.button.add`,\n },\n cancel: {\n id: `${storePrefix}costCenter-details.button.cancel`,\n },\n})\n\nexport const organizationMessages = defineMessages({\n editUser: {\n id: `${storePrefix}organization-details.edit-user`,\n },\n save: {\n id: `${storePrefix}organization-details.button.save`,\n },\n cancel: {\n id: `${storePrefix}organization-details.button.cancel`,\n },\n removeUser: {\n id: `${storePrefix}organization-details.button.remove-user`,\n },\n email: {\n id: `${storePrefix}user-details.email`,\n },\n costCenter: {\n id: `${storePrefix}user-details.placeholder-costCenter`,\n },\n role: {\n id: `${storePrefix}user-details.placeholder-role`,\n },\n userCostCenter: {\n id: `${storePrefix}user-details.costCenter`,\n },\n userOrganization: {\n id: `${storePrefix}user-details.organization`,\n },\n userRole: {\n id: `${storePrefix}user-details.role`,\n },\n addUser: {\n id: `${storePrefix}organization-details.add-user`,\n },\n addUserHelp: {\n id: `${storePrefix}organization-details.add-user.helpText`,\n },\n add: {\n id: `${storePrefix}organization-details.button.add`,\n },\n name: {\n id: `${storePrefix}user-details.name`,\n },\n toastAddCostCenterSuccess: {\n id: `${storePrefix}organization-details.toast.add-costCenter-success`,\n },\n toastAddCostCenterFailure: {\n id: `${storePrefix}organization-details.toast.add-costCenter-failure`,\n },\n columnName: {\n id: `${storePrefix}organization-details.table.column-name.title`,\n },\n columnAddresses: {\n id: `${storePrefix}organization-details.table.column-addresses.title`,\n },\n pageTitle: {\n id: `${storePrefix}organization-details.title`,\n },\n back: {\n id: `${storePrefix}back`,\n },\n costCenters: {\n id: `${storePrefix}organization-details.costCenters`,\n },\n users: {\n id: `${storePrefix}organization-details.users`,\n },\n showRows: {\n id: `${storePrefix}showRows`,\n },\n checkItOut: {\n id: `${storePrefix}check-it-out`,\n },\n of: {\n id: `${storePrefix}of`,\n },\n invalidSchema: {\n id: `${storePrefix}invalid-schema`,\n },\n autocompleteSearching: {\n id: `${storePrefix}autocomplete-searching`,\n },\n autocompleteSearchingCostCenter: {\n id: `${storePrefix}autocomplete-searching.cost-center`,\n },\n new: {\n id: `${storePrefix}organization-details.button.new`,\n },\n columnEmail: {\n id: `${storePrefix}organization-users.column.email`,\n },\n columnRole: {\n id: `${storePrefix}organization-users.column.role`,\n },\n columnCostCenter: {\n id: `${storePrefix}organization-users.column.costCenter`,\n },\n columnOrganizationName: {\n id: `${storePrefix}organization-users.column.organizationName`,\n },\n searchPlaceholder: {\n id: `${storePrefix}organization-users.table.search.placeholder`,\n },\n emptyState: {\n id: `${storePrefix}organization-users.emptyState`,\n },\n toastAddUserSuccess: {\n id: `${storePrefix}organization-users.toast.add-success`,\n },\n toastUserDuplicated: {\n id: `${storePrefix}organization-users.toast.duplicated`,\n },\n toastUserDuplicatedOrganization: {\n id: `${storePrefix}organization-users.toast.duplicated-organization`,\n },\n toastAddUserFailure: {\n id: `${storePrefix}organization-users.toast.add-failure`,\n },\n toastUpdateUserSuccess: {\n id: `${storePrefix}organization-users.toast.update-success`,\n },\n toastUpdateUserFailure: {\n id: `${storePrefix}organization-users.toast.update-failure`,\n },\n toastRemoveUserSuccess: {\n id: `${storePrefix}organization-users.toast.remove-success`,\n },\n toastRemoveUserFailure: {\n id: `${storePrefix}organization-users.toast.remove-failure`,\n },\n toastImpersonateStarting: {\n id: `${storePrefix}organization-users.toast.impersonate-starting`,\n },\n toastImpersonateSuccess: {\n id: `${storePrefix}organization-users.toast.impersonate-success`,\n },\n toastImpersonateFailure: {\n id: `${storePrefix}organization-users.toast.impersonate-failure`,\n },\n toastImpersonateForbidden: {\n id: `${storePrefix}organization-users.toast.impersonate-forbidden`,\n },\n toastImpersonateIdMissing: {\n id: `${storePrefix}organization-users.toast.impersonate-id-missing`,\n },\n impersonate: {\n id: `${storePrefix}organization-users.impersonate`,\n },\n removeUserConfirm: {\n id: `${storePrefix}organization-details.button.remove-user-confirm`,\n },\n removeUserHelp: {\n id: `${storePrefix}organization-details.remove-user.helpText`,\n },\n salesAdminTitle: {\n id: `${storePrefix}organization-details.sales-admin-title`,\n },\n organizationsWithoutSalesManager: {\n id: `${storePrefix}organization-details.organizations-without-sales-manager-title`,\n },\n organizationsWithoutSalesManagerOK: {\n id: `${storePrefix}organization-details.organizations-without-sales-manager-ok`,\n },\n organizationsWithoutSalesManagerWarning: {\n id: `${storePrefix}organization-details.organizations-without-sales-manager-warning`,\n },\n tradeName: {\n id: `${storePrefix}organizations-details.tradeName`,\n },\n tradeNameHelp: {\n id: `${storePrefix}organizations-details.tradeName.helpText`,\n },\n})\n\nexport const organizationRequestMessages = defineMessages({\n toastSuccess: {\n id: `${storePrefix}request-new-organization.submit.toast-success`,\n },\n toastFailure: {\n id: `${storePrefix}request-new-organization.submit.toast-failure`,\n },\n toastPending: {\n id: `${storePrefix}request-new-organization.submit.toast-duplicate-pending`,\n },\n toastApproved: {\n id: `${storePrefix}request-new-organization.submit.toast-duplicate-approved`,\n },\n pageTitle: {\n id: `${storePrefix}request-new-organization.title`,\n },\n helpText: {\n id: `${storePrefix}request-new-organization.helpText`,\n },\n organizationName: {\n id: `${storePrefix}request-new-organization.organization-name.label`,\n },\n tradeName: {\n id: `${storePrefix}request-new-organization.tradeName`,\n },\n tradeNameHelp: {\n id: `${storePrefix}request-new-organization.tradeName.helpText`,\n },\n b2bCustomerAdmin: {\n id: `${storePrefix}request-new-organization.b2b-customer-admin.title`,\n },\n b2bCustomerAdminHelpText: {\n id: `${storePrefix}request-new-organization.b2b-customer-admin.helpText`,\n },\n firstName: {\n id: `${storePrefix}request-new-organization.first-name.label`,\n },\n lastName: {\n id: `${storePrefix}request-new-organization.last-name.label`,\n },\n email: {\n id: `${storePrefix}request-new-organization.email.label`,\n },\n defaultCostCenter: {\n id: `${storePrefix}request-new-organization.default-cost-center.title`,\n },\n defaultCostCenterHelpText: {\n id: `${storePrefix}request-new-organization.default-cost-center.helpText`,\n },\n defaultCostCenterName: {\n id: `${storePrefix}request-new-organization.default-cost-center-name.label`,\n },\n phoneNumber: {\n id: `${storePrefix}request-new-organization.phoneNumber`,\n },\n phoneNumberHelp: {\n id: `${storePrefix}request-new-organization.phoneNumber.helpText`,\n },\n businessDocument: {\n id: `${storePrefix}request-new-organization.businessDocument`,\n },\n businessDocumentHelp: {\n id: `${storePrefix}request-new-organization.businessDocument.helpText`,\n },\n stateRegistration: {\n id: `${storePrefix}request-new-organization.stateRegistration`,\n },\n stateRegistrationHelp: {\n id: `${storePrefix}request-new-organization.stateRegistration.helpText`,\n },\n})\n\nexport const userWidgetMessages = defineMessages({\n role: {\n id: `${storePrefix}user-widget.role`,\n },\n organization: {\n id: `${storePrefix}user-widget.organization`,\n },\n costCenter: {\n id: `${storePrefix}user-widget.costCenter`,\n },\n status: {\n id: `${storePrefix}user-widget.status`,\n },\n active: {\n id: `${storePrefix}user-widget.status.active`,\n },\n onHold: {\n id: `${storePrefix}user-widget.status.on-hold`,\n },\n inactive: {\n id: `${storePrefix}user-widget.status.inactive`,\n },\n manageOrganization: {\n id: `${storePrefix}user-widget.manage-organization`,\n },\n impersonating: {\n id: `${storePrefix}user-widget.impersonating`,\n },\n stopImpersonation: {\n id: `${storePrefix}stop-impersonation`,\n },\n setCurrentOrganization: {\n id: `${storePrefix}set-current-organization`,\n },\n selectCompany: {\n id: `${storePrefix}modal.select-company`,\n },\n search: {\n id: `${storePrefix}modal.search`,\n },\n join: {\n id: `${storePrefix}modal.join`,\n },\n changeOrganization: {\n id: `${storePrefix}change-organization`,\n },\n currentOrganization: {\n id: `${storePrefix}current-organization`,\n },\n organizationsFound: {\n id: `${storePrefix}organizations-found`,\n },\n})\n\n```"
}
] |
code_b2b-organizations_07223240
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/ImportInBulkTooltip/ImportInBulkTooltip.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { Tooltip } from '@vtex/admin-ui'\nimport type { ReactNode } from 'react'\n\nimport { useTranslate } from '../../hooks'\n\nexport type ImportInBulkTooltipProps = {\n visible?: boolean\n children: ReactNode\n}\n\nconst ImportInBulkTooltip = ({\n visible,\n children,\n}: ImportInBulkTooltipProps) => {\n const { translate: t } = useTranslate()\n\n return visible ? (\n <Tooltip text={t('permissionAlertTooltip') as string} placement=\"left\">\n <div>{children}</div>\n </Tooltip>\n ) : (\n <>{children}</>\n )\n}\n\nexport default ImportInBulkTooltip\n\n```"
}
] |
code_b2b-organizations_7bd93542
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/ImportInBulkTooltip/index.ts from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport { default as ImportInBulkTooltip } from './ImportInBulkTooltip'\nexport type { ImportInBulkTooltipProps } from './ImportInBulkTooltip'\n\n```"
}
] |
code_b2b-organizations_74986dfd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/ImportAlertList/ImportAlertList.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { Stack } from '@vtex/admin-ui'\nimport type { ImportStatus } from '@vtex/bulk-import-ui'\nimport { ImportAlert } from '@vtex/bulk-import-ui'\n\nimport ImportReportModal from '../ImportReportModal/ImportReportModal'\nimport useClosedAlerts from '../../hooks/useClosedAlerts'\n\ntype ImportAlertData = ImportStatus & {\n importId: string\n}\n\ninterface ImportAlertListProps {\n /** A list of object with data about the status of this import. */\n data: ImportAlertData[]\n}\n\nconst ImportAlertList = ({ data }: ImportAlertListProps) => {\n const { closedAlerts, addClosedAlert } = useClosedAlerts()\n\n const filteredAlert = data.filter(\n itemData => !closedAlerts.find(alertId => alertId === itemData.importId)\n )\n\n return (\n <Stack>\n {filteredAlert.map(itemData => (\n <ImportAlert\n key={itemData.importId}\n data={itemData}\n onDismiss={() => addClosedAlert(itemData.importId)}\n detailsModal={(open, setOpen) => (\n <ImportReportModal\n onOpenChange={setOpen}\n open={open}\n importId={itemData.importId}\n />\n )}\n />\n ))}\n </Stack>\n )\n}\n\nexport default ImportAlertList\n\n```"
}
] |
code_b2b-organizations_67cfd042
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/BulkImportList/BulkImportList.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport { useBulkImportsQuery } from '../../hooks'\nimport ImportAlertList from '../ImportAlertList/ImportAlertList'\n\nconst BulkImportList = () => {\n const { data, error } = useBulkImportsQuery({\n shouldPoll: true,\n })\n\n if (error?.message) {\n console.error(error)\n }\n\n if (data) return <ImportAlertList data={data} />\n\n return null\n}\n\nexport default BulkImportList\n\n```"
}
] |
code_b2b-organizations_cd4d6f82
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/UploadingScreen/index.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nexport { default as UploadingScreen } from './UploadingScreen'\nexport type { UploadingScreenProps } from './UploadingScreen'\n\n```"
}
] |
code_b2b-organizations_8345cbc0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of b2b-organizations/react/components/UploadingScreen/ValidatingScreen.tsx from the b2b-organizations VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { Flex, Spinner, Text, csx } from '@vtex/admin-ui'\n\nimport { useTranslate } from '../../hooks'\nimport { bytesToSize } from '../utils/bytesToSize'\nimport type { UploadFileData } from '../../types/BulkImport'\nimport useBulkImportDetailsQuery from '../../hooks/useBulkImportDetailsQuery'\n\nexport type ValidatingScreenProps = {\n importId?: string\n name: string\n size: number\n onUploadFinished: (data: UploadFileData) => void\n}\n\nconst ValidatingScreen = ({\n name,\n size,\n importId,\n onUploadFinished,\n}: ValidatingScreenProps) => {\n const { translate: t } = useTranslate()\n\n useBulkImportDetailsQuery({\n importId,\n refreshInterval: 5 * 1000,\n onSuccess: data => {\n if (['InValidation', 'InProgress'].includes(data.importState)) return\n\n if (['ReadyToImport', 'Completed'].includes(data.importState)) {\n onUploadFinished({\n status: 'success',\n data: {\n fileData: {\n ...data,\n percentage: data.percentage.toString(),\n },\n },\n })\n\n return\n }\n\n if (\n ['ValidationFailed', 'CompletedWithError', 'Failed'].includes(\n data.importState\n )\n ) {\n onUploadFinished({\n status: 'error',\n showReport: data?.importState === 'ValidationFailed',\n data: {\n error: 'FieldValidationError',\n errorDownloadLink: data?.validationResult?.reportDownloadLink ?? '',\n validationResult: data?.validationResult?.validationResult ?? [],\n fileName: data.fileName,\n },\n })\n }\n },\n })\n\n return (\n <Flex\n className={csx({ backgroundColor: '$gray05', height: '100%' })}\n align=\"center\"\n direction=\"column\"\n justify=\"center\"\n >\n <Spinner className={csx({ color: '$blue40' })} size={120} />\n <Text\n className={csx({ marginBottom: '$space-3', marginTop: '$space-10' })}\n variant=\"pageTitle\"\n >\n {t('uploading')}\n </Text>\n <div>\n <Text>{name}</Text>\n <Text tone=\"secondary\">\n {' · '}\n {bytesToSize(size)}\n </Text>\n </div>\n </Flex>\n )\n}\n\nexport default ValidatingScreen\n\n```"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.