-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
854 additions
and
718 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import ico1 from './beer.png'; | ||
import ico2 from './cder.png'; | ||
import ico3 from './champage.png'; | ||
import ico4 from './coffee.png'; | ||
import ico5 from './cola.png'; | ||
import ico6 from './mineral-water.png'; | ||
|
||
export const imageIcons = [ico3, ico4, ico5, ico1, ico2, ico6]; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { TFilter } from '@/store/product/product.types'; | ||
import { IProduct } from '@/types/product.interface'; | ||
|
||
type TData = IProduct & TFilter & { strength: string[]; capacity: string[] }; | ||
|
||
export default function filterByValue(data: TData[], filter: TFilter) { | ||
if ( | ||
JSON.stringify(filter) !== | ||
'{"brand":[],"capacities":[],"kind":[],"manufacturer":[],"packing":[],"strengths":[]}' | ||
) { | ||
const products = data.filter((product) => { | ||
const isBrand = filter.brand.some( | ||
(brand: string) => product.brand[0] === brand | ||
); | ||
const isKind = filter.kind.some( | ||
(kind: string) => product.kind[0] === kind | ||
); | ||
const isManufacturer = filter.manufacturer.some( | ||
(manufacturer: string) => product.manufacturer[0] === manufacturer | ||
); | ||
const isStrength = filter.strengths.some( | ||
(strength: string) => product.strength[0] === strength | ||
); | ||
const isCapacity = filter.capacities.some( | ||
(capacity: string) => product.capacity[0] === capacity | ||
); | ||
const isPacking = filter.packing.some( | ||
(packing: string) => product.packing[0] === packing | ||
); | ||
return ( | ||
isBrand || | ||
isKind || | ||
isManufacturer || | ||
isStrength || | ||
isCapacity || | ||
isPacking | ||
); | ||
}); | ||
return products; | ||
} else return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
export default function sortByValue(data: any, value: string) { | ||
switch (value) { | ||
case 'by_title_a': | ||
return data.sort((a, b) => { | ||
if (a.title > b.title) return 1; | ||
if (a.title < b.title) return -1; | ||
return 0; | ||
}); | ||
case 'by_title_z': | ||
return data.sort((a, b) => { | ||
if (a.title > b.title) return -1; | ||
if (a.title < b.title) return 1; | ||
return 0; | ||
}); | ||
case 'by_cost_l': | ||
return data.sort((a, b) => { | ||
const costA = a.discount ? a.cost - a.discount * a.cost : a.cost; | ||
const costB = b.discount ? b.cost - b.discount * b.cost : b.cost; | ||
|
||
if (costA > costB) return -1; | ||
if (costA < costB) return 1; | ||
return 0; | ||
}); | ||
case 'by_cost_h': | ||
return data.sort((a, b) => { | ||
const costA = a.discount ? a.cost - a.discount * a.cost : a.cost; | ||
const costB = b.discount ? b.cost - b.discount * b.cost : b.cost; | ||
|
||
if (costA > costB) return 1; | ||
if (costA < costB) return -1; | ||
return 0; | ||
}); | ||
case 'by_discount': | ||
return data.sort((a, b) => { | ||
if (a.discount > b.discount) return -1; | ||
if (a.discount < b.discount) return 1; | ||
return 0; | ||
}); | ||
case 'by_new': | ||
return data.sort((a, b) => { | ||
if (a.isNew) return -1; | ||
if (!a.isNew) return 1; | ||
return 0; | ||
}); | ||
|
||
default: | ||
return -1; | ||
} | ||
} |
Oops, something went wrong.