added notification
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import Clipboard from '@react-native-clipboard/clipboard';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { authApi } from 'api/auth';
|
||||
import warhouses_api from 'api/warhouses';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
@@ -53,9 +54,8 @@ const TabsAutoWarehouses = () => {
|
||||
];
|
||||
|
||||
const handleCopy = (info: string[]) => {
|
||||
if (getMe?.status === 'active') {
|
||||
const textToCopy = info.join('\n');
|
||||
Clipboard.setString(textToCopy);
|
||||
if (getMe?.status === 'ACTIVE') {
|
||||
Clipboard.setString(info.join('\n'));
|
||||
Toast.show({
|
||||
type: 'success',
|
||||
text1: t('Nusxa olingan'),
|
||||
@@ -74,39 +74,50 @@ const TabsAutoWarehouses = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const { data } = useQuery({
|
||||
queryKey: ['warhouses'],
|
||||
queryFn: () => warhouses_api.getWarhouses({ cargoType: 'AUTO' }),
|
||||
});
|
||||
|
||||
const formattedData =
|
||||
data?.map((item: string | null) => {
|
||||
if (!item) return '';
|
||||
|
||||
const withAutoCargo = item.replace('%s', getMe?.autoCargoId || '');
|
||||
|
||||
const withAviaCargo = withAutoCargo.replace(
|
||||
'%s',
|
||||
getMe?.aviaCargoId || '',
|
||||
);
|
||||
|
||||
return withAviaCargo;
|
||||
}) || [];
|
||||
|
||||
return (
|
||||
<FlatList
|
||||
data={addressInfo}
|
||||
data={formattedData}
|
||||
horizontal
|
||||
keyExtractor={item => item.id.toString()}
|
||||
keyExtractor={(_, index) => index.toString()}
|
||||
pagingEnabled
|
||||
showsHorizontalScrollIndicator={false}
|
||||
snapToInterval={cardWidth + 10}
|
||||
decelerationRate="fast"
|
||||
renderItem={({ item, index }) => {
|
||||
const isLast = index === addressInfo.length - 1;
|
||||
const isLast = index === formattedData.length - 1;
|
||||
return (
|
||||
<View style={[styles.card, { marginRight: isLast ? 0 : 10 }]}>
|
||||
<View style={styles.titleCard}>
|
||||
<Kitay width={24 * scale} height={24 * scale} />
|
||||
<Text style={styles.title}>{item.title}</Text>
|
||||
<Text style={styles.title}>China (Auto)</Text>
|
||||
</View>
|
||||
<View style={styles.infoId}>
|
||||
<View style={{ gap: 4 * scale, width: '90%' }}>
|
||||
{item.addressInfo.map((line, idx) => (
|
||||
<Text key={idx} style={styles.infoText}>
|
||||
{line}
|
||||
</Text>
|
||||
))}
|
||||
<Text style={styles.infoText}>{item}</Text>
|
||||
</View>
|
||||
<TouchableOpacity onPress={() => handleCopy(item.addressInfo)}>
|
||||
<Copy color="#28A7E8" width={24 * scale} height={24 * scale} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
<View style={styles.postCodeWrapper}>
|
||||
<Text style={styles.postCodeText}>{t('Auto post kodi')}: </Text>
|
||||
<Text style={styles.postCode}>{item.postCode}</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}}
|
||||
@@ -117,7 +128,6 @@ const TabsAutoWarehouses = () => {
|
||||
const makeStyles = (scale: number, cardWidth: number, screenWidth: number) =>
|
||||
StyleSheet.create({
|
||||
card: {
|
||||
height: '100%',
|
||||
width: cardWidth,
|
||||
backgroundColor: '#28a8e82c',
|
||||
borderRadius: 12 * scale,
|
||||
|
||||
Reference in New Issue
Block a user